Skip to content

Commit

Permalink
Merge upstream-jdk
Browse files Browse the repository at this point in the history
  • Loading branch information
corretto-github-robot committed Nov 25, 2024
2 parents 5aca4ef + 9576546 commit 10d674d
Show file tree
Hide file tree
Showing 15 changed files with 209 additions and 181 deletions.
4 changes: 4 additions & 0 deletions make/hotspot/lib/JvmOverrideFiles.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ ifeq ($(TOOLCHAIN_TYPE), gcc)
# Need extra inlining to collapse shared marking code into the hot marking loop
BUILD_LIBJVM_shenandoahMark.cpp_CXXFLAGS := --param inline-unit-growth=1000
endif
# disable lto in g1ParScanThreadState because of special inlining/flattening used there
ifeq ($(call check-jvm-feature, link-time-opt), true)
BUILD_LIBJVM_g1ParScanThreadState.cpp_CXXFLAGS := -fno-lto
endif
endif

LIBJVM_FDLIBM_COPY_OPT_FLAG := $(CXX_O_FLAG_NONE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ address TemplateInterpreterGenerator::generate_cont_resume_interpreter_adapter()
// Restore Java expression stack pointer
__ ldr(rscratch1, Address(rfp, frame::interpreter_frame_last_sp_offset * wordSize));
__ lea(esp, Address(rfp, rscratch1, Address::lsl(Interpreter::logStackElementSize)));
// and NULL it as marker that esp is now tos until next java call
// and null it as marker that esp is now tos until next java call
__ str(zr, Address(rfp, frame::interpreter_frame_last_sp_offset * wordSize));

// Restore machine SP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ address TemplateInterpreterGenerator::generate_cont_resume_interpreter_adapter()
// Restore Java expression stack pointer
__ ld(t0, Address(fp, frame::interpreter_frame_last_sp_offset * wordSize));
__ shadd(esp, t0, fp, t0, Interpreter::logStackElementSize);
// and NULL it as marker that esp is now tos until next java call
// and null it as marker that esp is now tos until next java call
__ sd(zr, Address(fp, frame::interpreter_frame_last_sp_offset * wordSize));

// Restore machine SP
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ address TemplateInterpreterGenerator::generate_cont_resume_interpreter_adapter()
// Restore stack bottom
__ movptr(rcx, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize));
__ lea(rsp, Address(rbp, rcx, Address::times_ptr));
// and NULL it as marker that esp is now tos until next java call
// and null it as marker that esp is now tos until next java call
__ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD);

__ jmp(rax);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/cds/archiveUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class DumpRegion {
DumpRegion(const char* name, uintx max_delta = 0)
: _name(name), _base(nullptr), _top(nullptr), _end(nullptr),
_max_delta(max_delta), _is_packed(false),
_rs(NULL), _vs(NULL) {}
_rs(nullptr), _vs(nullptr) {}

char* expand_top_to(char* newtop);
char* allocate(size_t num_bytes, size_t alignment = 0);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/cds/metaspaceShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ static GrowableArrayCHeap<OopHandle, mtClassShared>* _extra_interned_strings = n
// Extra Symbols to be added to the archive
static GrowableArrayCHeap<Symbol*, mtClassShared>* _extra_symbols = nullptr;
// Methods managed by SystemDictionary::find_method_handle_intrinsic() to be added to the archive
static GrowableArray<Method*>* _pending_method_handle_intrinsics = NULL;
static GrowableArray<Method*>* _pending_method_handle_intrinsics = nullptr;

void MetaspaceShared::read_extra_data(JavaThread* current, const char* filename) {
_extra_interned_strings = new GrowableArrayCHeap<OopHandle, mtClassShared>(10000);
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/shared/locationPrinter.inline.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -54,7 +54,7 @@ bool BlockLocationPrinter<CollectedHeapT>::print_location(outputStream* st, void
// Check if addr points into Java heap.
bool in_heap = CollectedHeapT::heap()->is_in(addr);
if (in_heap) {
// base_oop_or_null() might be unimplemented and return NULL for some GCs/generations
// base_oop_or_null() might be unimplemented and return null for some GCs/generations
oop o = base_oop_or_null(addr);
if (o != nullptr) {
if ((void*)o == addr) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/oops/constantPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void ConstantPool::restore_unshareable_info(TRAPS) {
assert(is_shared(), "should always be set for shared constant pools");
if (is_for_method_handle_intrinsic()) {
// See the same check in remove_unshareable_info() below.
assert(cache() == NULL, "must not have cpCache");
assert(cache() == nullptr, "must not have cpCache");
return;
}
assert(_cache != nullptr, "constant pool _cache should not be null");
Expand Down Expand Up @@ -474,7 +474,7 @@ void ConstantPool::remove_unshareable_info() {
// This CP was created by Method::make_method_handle_intrinsic() and has nothing
// that need to be removed/restored. It has no cpCache since the intrinsic methods
// don't have any bytecodes.
assert(cache() == NULL, "must not have cpCache");
assert(cache() == nullptr, "must not have cpCache");
return;
}

Expand Down
56 changes: 23 additions & 33 deletions src/java.base/share/classes/java/lang/foreign/Linker.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,50 +241,40 @@
* </tbody>
* </table></blockquote>
* <p>
* All native linker implementations support a well-defined subset of layouts. More formally,
* a layout {@code L} is supported by a native linker {@code NL} if:
* A native linker only supports function descriptors whose argument/return layouts are
* <em>well-formed</em> layouts. More formally, a layout `L` is well-formed if:
* <ul>
* <li>{@code L} is a value layout {@code V} and {@code V.withoutName()} is a canonical layout</li>
* <li>{@code L} is a value layout and {@code L} is derived from a canonical layout
* {@code C} such that {@code L.byteAlignment() <= C.byteAlignment()}</li>
* <li>{@code L} is a sequence layout {@code S} and all the following conditions hold:
* <ol>
* <li>the alignment constraint of {@code S} is set to its
* <a href="MemoryLayout.html#layout-align">natural alignment</a>, and</li>
* <li>{@code S.elementLayout()} is a layout supported by {@code NL}.</li>
* <li>{@code L.byteAlignment()} is equal to the sequence layout's <em>natural alignment</em>
* , and</li>
* <li>{@code S.elementLayout()} is a well-formed layout.</li>
* </ol>
* </li>
* <li>{@code L} is a group layout {@code G} and all the following conditions hold:
* <ol>
* <li>the alignment constraint of {@code G} is set to its
* <a href="MemoryLayout.html#layout-align">natural alignment</a>;</li>
* <li>the size of {@code G} is a multiple of its alignment constraint;</li>
* <li>each member layout in {@code G.memberLayouts()} is either a padding layout or
* a layout supported by {@code NL}, and</li>
* <li>{@code G} does not contain padding other than what is strictly required to align
* its non-padding layout elements, or to satisfy (2).</li>
* <li>{@code G.byteAlignment()} is equal to the group layout's <em>natural alignment</em></li>
* <li>{@code G.byteSize()} is a multiple of {@code G.byteAlignment()}</li>
* <li>Each member layout in {@code G.memberLayouts()} is either a padding layout or a
* well-formed layout</li>
* <li>Each non-padding member layout {@code E} in {@code G.memberLayouts()} follows an
* optional padding member layout, whose size is the minimum size required to
* align {@code E}</li>
* <li>{@code G} contains an optional trailing padding member layout, whose size is the
* minimum size that satisfies (2)</li>
* </ol>
* </li>
* </ul>
*
* Linker implementations may optionally support additional layouts, such as
* <em>packed</em> struct layouts. A packed struct is a struct in which there is
* at least one member layout {@code L} that has an alignment constraint less strict
* than its natural alignment. This allows to avoid padding between member layouts,
* as well as avoiding padding at the end of the struct layout. For example:
* {@snippet lang = java:
* // No padding between the 2 element layouts:
* MemoryLayout noFieldPadding = MemoryLayout.structLayout(
* ValueLayout.JAVA_INT,
* ValueLayout.JAVA_DOUBLE.withByteAlignment(4));
*
* // No padding at the end of the struct:
* MemoryLayout noTrailingPadding = MemoryLayout.structLayout(
* ValueLayout.JAVA_DOUBLE.withByteAlignment(4),
* ValueLayout.JAVA_INT);
* }
* <p>
* A native linker only supports function descriptors whose argument/return layouts are
* layouts supported by that linker and are not sequence layouts.
* A function descriptor is well-formed if its argument and return layouts are
* well-formed and are not sequence layouts. A native linker is guaranteed to reject
* function descriptors that are not well-formed. However, a native linker can still
* reject well-formed function descriptors, according to platform-specific rules.
* For example, some native linkers may reject <em>packed</em> struct layouts -- struct
* layouts whose member layouts feature relaxed alignment constraints, to avoid
* the insertion of additional padding.
*
* <h3 id="function-pointers">Function pointers</h3>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import java.lang.invoke.MethodType;
import java.util.HashSet;
import java.util.List;
import java.nio.ByteOrder;
import java.util.Objects;
import java.util.Set;

Expand Down Expand Up @@ -189,54 +188,102 @@ private void checkLayoutRecursive(MemoryLayout layout) {
checkHasNaturalAlignment(layout);
long offset = 0;
long lastUnpaddedOffset = 0;
PaddingLayout preceedingPadding = null;
for (MemoryLayout member : sl.memberLayouts()) {
// check element offset before recursing so that an error points at the
// outermost layout first
checkMemberOffset(sl, member, lastUnpaddedOffset, offset);
checkStructMember(member, offset);

offset += member.byteSize();
if (!(member instanceof PaddingLayout)) {
if (!(member instanceof PaddingLayout pl)) {
lastUnpaddedOffset = offset;
if (preceedingPadding != null) {
preceedingPadding = null;
}
} else {
if (preceedingPadding != null) {
throw new IllegalArgumentException("The padding layout " + pl +
" was preceded by another padding layout " + preceedingPadding +
inMessage(sl));
}
preceedingPadding = pl;
}
}
checkGroupSize(sl, lastUnpaddedOffset);
checkNotAllPadding(sl);
checkGroup(sl, lastUnpaddedOffset);
} else if (layout instanceof UnionLayout ul) {
checkHasNaturalAlignment(layout);
long maxUnpaddedLayout = 0;
// We need to know this up front
long maxUnpaddedLayout = ul.memberLayouts().stream()
.filter(l -> !(l instanceof PaddingLayout))
.mapToLong(MemoryLayout::byteSize)
.max()
.orElse(0);

boolean hasPadding = false;

for (MemoryLayout member : ul.memberLayouts()) {
checkLayoutRecursive(member);
if (!(member instanceof PaddingLayout)) {
maxUnpaddedLayout = Long.max(maxUnpaddedLayout, member.byteSize());
if (member instanceof PaddingLayout pl) {
if (hasPadding) {
throw new IllegalArgumentException("More than one padding" + inMessage(ul));
}
hasPadding = true;
if (pl.byteSize() <= maxUnpaddedLayout) {
throw new IllegalArgumentException("Superfluous padding " + pl + inMessage(ul));
}
}
}
checkGroupSize(ul, maxUnpaddedLayout);
checkGroup(ul, maxUnpaddedLayout);
} else if (layout instanceof SequenceLayout sl) {
checkHasNaturalAlignment(layout);
if (sl.elementLayout() instanceof PaddingLayout pl) {
throw memberException(sl, pl,
"not supported because a sequence of a padding layout is not allowed");
}
checkLayoutRecursive(sl.elementLayout());
}
}

// check for trailing padding
private void checkGroupSize(GroupLayout gl, long maxUnpaddedOffset) {
// check elements are not all padding layouts
private static void checkNotAllPadding(StructLayout sl) {
if (!sl.memberLayouts().isEmpty() && sl.memberLayouts().stream().allMatch(e -> e instanceof PaddingLayout)) {
throw new IllegalArgumentException("Layout '" + sl + "' is non-empty and only has padding layouts");
}
}

// check trailing padding
private static void checkGroup(GroupLayout gl, long maxUnpaddedOffset) {
long expectedSize = Utils.alignUp(maxUnpaddedOffset, gl.byteAlignment());
if (gl.byteSize() != expectedSize) {
throw new IllegalArgumentException("Layout '" + gl + "' has unexpected size: "
+ gl.byteSize() + " != " + expectedSize);
}
}

private static String inMessage(GroupLayout gl) {
return " in " + gl;
}

// checks both that there is no excess padding between 'memberLayout' and
// the previous layout
private void checkMemberOffset(StructLayout parent, MemoryLayout memberLayout,
private static void checkMemberOffset(StructLayout parent, MemoryLayout memberLayout,
long lastUnpaddedOffset, long offset) {
long expectedOffset = Utils.alignUp(lastUnpaddedOffset, memberLayout.byteAlignment());
if (expectedOffset != offset) {
throw new IllegalArgumentException("Member layout '" + memberLayout + "', of '" + parent + "'" +
" found at unexpected offset: " + offset + " != " + expectedOffset);
throw memberException(parent, memberLayout,
"found at unexpected offset: " + offset + " != " + expectedOffset);
}
}

private static IllegalArgumentException memberException(MemoryLayout parent,
MemoryLayout member,
String info) {
return new IllegalArgumentException(
"Member layout '" + member + "', of '" + parent + "' " + info);
}

private void checkSupported(ValueLayout valueLayout) {
valueLayout = valueLayout.withoutName();
if (valueLayout instanceof AddressLayout addressLayout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.KeyboardFocusManager;
import java.awt.LayoutManager;
import java.awt.Point;
import java.awt.Rectangle;
Expand Down Expand Up @@ -123,8 +122,6 @@ public class BasicScrollBarUI
protected ArrowButtonListener buttonListener;
/** Model listener */
protected ModelListener modelListener;
/** KeyboardFocusListener */
protected KeyboardFocusListener keyboardFocusListener;

/** Thumb rectangle */
protected Rectangle thumbRect;
Expand Down Expand Up @@ -359,15 +356,12 @@ protected void installListeners(){
buttonListener = createArrowButtonListener();
modelListener = createModelListener();
propertyChangeListener = createPropertyChangeListener();
keyboardFocusListener = createKeyboardFocusListener();

scrollbar.addMouseListener(trackListener);
scrollbar.addMouseMotionListener(trackListener);
scrollbar.getModel().addChangeListener(modelListener);
scrollbar.addPropertyChangeListener(propertyChangeListener);
scrollbar.addFocusListener(getHandler());
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addPropertyChangeListener(keyboardFocusListener);

if (incrButton != null) {
incrButton.addMouseListener(buttonListener);
Expand Down Expand Up @@ -449,8 +443,6 @@ protected void uninstallListeners() {
incrButton.removeMouseListener(buttonListener);
}

KeyboardFocusManager.getCurrentKeyboardFocusManager()
.removePropertyChangeListener(keyboardFocusListener);
scrollbar.getModel().removeChangeListener(modelListener);
scrollbar.removeMouseListener(trackListener);
scrollbar.removeMouseMotionListener(trackListener);
Expand Down Expand Up @@ -517,14 +509,6 @@ protected PropertyChangeListener createPropertyChangeListener() {
return getHandler();
}

/**
* Creates a keyboard focus listener.
* @return a keyboard focus listener
*/
protected KeyboardFocusListener createKeyboardFocusListener() {
return new KeyboardFocusListener();
}

private void updateThumbState(int x, int y) {
Rectangle rect = getThumbBounds();

Expand Down Expand Up @@ -1218,35 +1202,6 @@ public boolean getSupportsAbsolutePositioning() {
return supportsAbsolutePositioning;
}

/**
* A listener to listen for keyboard focus changes.
*/
protected class KeyboardFocusListener implements PropertyChangeListener {
/**
* Constructs a {@code KeyboardFocusListener}.
*/
protected KeyboardFocusListener() {}

@Override
public void propertyChange(PropertyChangeEvent e) {
String propertyName = e.getPropertyName();

if ("focusOwner" == propertyName) {
// Stop scrolling if no longer focus owner
if (e.getNewValue() == null && scrollTimer.isRunning()) {
scrollTimer.stop();
buttonListener.handledEvent = false;
scrollbar.setValueIsAdjusting(false);
if (incrButton.getModel().isPressed()) {
incrButton.getModel().setPressed(false);
} else if (decrButton.getModel().isPressed()) {
decrButton.getModel().setPressed(false);
}
}
}
}
}

/**
* A listener to listen for model changes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ public static void main(String[] args) throws Exception {
}
throw new RuntimeException("Not able to find lock");
} finally {
theApp.getProcess().destroyForcibly();
if (theApp.getProcess() != null) {
theApp.deleteLock();
theApp.getProcess().destroyForcibly();
}
}
}
}
1 change: 1 addition & 0 deletions test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ java/awt/Window/MainKeyWindowTest/TestMainKeyWindow.java 8265985 macosx-all
java/awt/Robot/Delay/InterruptOfDelay.java 8265986 macosx-all
java/awt/Robot/InfiniteLoopException.java 8342638 windows-all,linux-all
java/awt/MenuBar/TestNoScreenMenuBar.java 8265987 macosx-all
java/awt/Robot/ScreenCaptureRobotTest.java 8344581 macosx-all

java/awt/Graphics2D/DrawString/DrawRotatedStringUsingRotatedFont.java 8266283 generic-all
java/awt/Graphics2D/DrawString/RotTransText.java 8316878 linux-all
Expand Down
Loading

0 comments on commit 10d674d

Please sign in to comment.