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 Oct 18, 2024
2 parents 2398439 + daa67f4 commit 02893fd
Show file tree
Hide file tree
Showing 19 changed files with 579 additions and 45 deletions.
2 changes: 2 additions & 0 deletions make/test/JtregNativeJdk.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ ifeq ($(call isTargetOs, linux), true)
# stripping during the test libraries' build.
BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libFib := -g
BUILD_JDK_JTREG_LIBRARIES_STRIP_SYMBOLS_libFib := false
# nio tests' libCreationTimeHelper native needs -ldl linker flag
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libCreationTimeHelper := -ldl
endif

ifeq ($(ASAN_ENABLED), true)
Expand Down
5 changes: 4 additions & 1 deletion src/hotspot/share/ci/ciEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,10 @@ void ciEnv::dump_replay_data_helper(outputStream* out) {
for (int i = 0; i < objects->length(); i++) {
objects->at(i)->dump_replay_data(out);
}
dump_compile_data(out);

if (this->task() != nullptr) {
dump_compile_data(out);
}
out->flush();
}

Expand Down
7 changes: 0 additions & 7 deletions src/hotspot/share/classfile/javaClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,19 +1434,12 @@ void java_lang_Class::compute_offsets() {

InstanceKlass* k = vmClasses::Class_klass();
CLASS_FIELDS_DO(FIELD_COMPUTE_OFFSET);

// Init lock is a C union with component_mirror. Only instanceKlass mirrors have
// init_lock and only ArrayKlass mirrors have component_mirror. Since both are oops
// GC treats them the same.
_init_lock_offset = _component_mirror_offset;

CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
}

#if INCLUDE_CDS
void java_lang_Class::serialize_offsets(SerializeClosure* f) {
f->do_bool(&_offsets_computed);
f->do_u4((u4*)&_init_lock_offset);

CLASS_FIELDS_DO(FIELD_SERIALIZE_OFFSET);

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/classfile/javaClasses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class java_lang_String : AllStatic {
macro(java_lang_Class, protection_domain, object_signature, false) \
macro(java_lang_Class, signers, object_signature, false) \
macro(java_lang_Class, source_file, object_signature, false) \
macro(java_lang_Class, init_lock, object_signature, false)

class java_lang_Class : AllStatic {
friend class VMStructs;
Expand Down
5 changes: 4 additions & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,8 +921,11 @@ void ShenandoahConcurrentGC::op_init_updaterefs() {
heap->set_evacuation_in_progress(false);
heap->set_concurrent_weak_root_in_progress(false);
heap->prepare_update_heap_references(true /*concurrent*/);
heap->set_update_refs_in_progress(true);
if (ShenandoahVerify) {
heap->verifier()->verify_before_updaterefs();
}

heap->set_update_refs_in_progress(true);
if (ShenandoahPacing) {
heap->pacer()->setup_for_updaterefs();
}
Expand Down
18 changes: 12 additions & 6 deletions src/hotspot/share/opto/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1483,12 +1483,18 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const {
} else {
ciInstanceKlass *canonical_holder = ik->get_canonical_holder(offset);
assert(offset < canonical_holder->layout_helper_size_in_bytes(), "");
if (!ik->equals(canonical_holder) || tj->offset() != offset) {
if( is_known_inst ) {
tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, true, nullptr, offset, to->instance_id());
} else {
tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, false, nullptr, offset);
}
assert(tj->offset() == offset, "no change to offset expected");
bool xk = to->klass_is_exact();
int instance_id = to->instance_id();

// If the input type's class is the holder: if exact, the type only includes interfaces implemented by the holder
// but if not exact, it may include extra interfaces: build new type from the holder class to make sure only
// its interfaces are included.
if (xk && ik->equals(canonical_holder)) {
assert(tj == TypeInstPtr::make(to->ptr(), canonical_holder, is_known_inst, nullptr, offset, instance_id), "exact type should be canonical type");
} else {
assert(xk || !is_known_inst, "Known instance should be exact type");
tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, is_known_inst, nullptr, offset, instance_id);
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/hotspot/share/opto/gcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,20 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) {
// The anti-dependence constraints apply only to the fringe of this tree.

Node* initial_mem = load->in(MemNode::Memory);
// We don't optimize the memory graph for pinned loads, so we may need to raise the
// root of our search tree through the corresponding slices of MergeMem nodes to
// get to the node that really creates the memory state for this slice.
if (load_alias_idx >= Compile::AliasIdxRaw) {
while (initial_mem->is_MergeMem()) {
MergeMemNode* mm = initial_mem->as_MergeMem();
Node* p = mm->memory_at(load_alias_idx);
if (p != mm->base_memory()) {
initial_mem = p;
} else {
break;
}
}
}
worklist_store.push(initial_mem);
worklist_visited.push(initial_mem);
worklist_mem.push(nullptr);
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/opto/graphKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,7 @@ Node* GraphKit::make_load(Node* ctl, Node* adr, const Type* t, BasicType bt,
bool mismatched,
bool unsafe,
uint8_t barrier_data) {
assert(adr_idx == C->get_alias_index(_gvn.type(adr)->isa_ptr()), "slice of address and input slice don't match");
assert(adr_idx != Compile::AliasIdxTop, "use other make_load factory" );
const TypePtr* adr_type = nullptr; // debug-mode-only argument
debug_only(adr_type = C->get_adr_type(adr_idx));
Expand Down Expand Up @@ -1585,6 +1586,7 @@ Node* GraphKit::store_to_memory(Node* ctl, Node* adr, Node *val, BasicType bt,
bool unsafe,
int barrier_data) {
assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" );
assert(adr_idx == C->get_alias_index(_gvn.type(adr)->isa_ptr()), "slice of address and input slice don't match");
const TypePtr* adr_type = nullptr;
debug_only(adr_type = C->get_adr_type(adr_idx));
Node *mem = memory(adr_idx);
Expand Down
14 changes: 8 additions & 6 deletions src/hotspot/share/opto/library_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2921,11 +2921,10 @@ bool LibraryCallKit::inline_native_notify_jvmti_funcs(address funcAddr, const ch
Node* thread = ideal.thread();
Node* jt_addr = basic_plus_adr(thread, in_bytes(JavaThread::is_in_VTMS_transition_offset()));
Node* vt_addr = basic_plus_adr(vt_oop, java_lang_Thread::is_in_VTMS_transition_offset());
const TypePtr *addr_type = _gvn.type(addr)->isa_ptr();

sync_kit(ideal);
access_store_at(nullptr, jt_addr, addr_type, hide, _gvn.type(hide), T_BOOLEAN, IN_NATIVE | MO_UNORDERED);
access_store_at(nullptr, vt_addr, addr_type, hide, _gvn.type(hide), T_BOOLEAN, IN_NATIVE | MO_UNORDERED);
access_store_at(nullptr, jt_addr, _gvn.type(jt_addr)->is_ptr(), hide, _gvn.type(hide), T_BOOLEAN, IN_NATIVE | MO_UNORDERED);
access_store_at(nullptr, vt_addr, _gvn.type(vt_addr)->is_ptr(), hide, _gvn.type(hide), T_BOOLEAN, IN_NATIVE | MO_UNORDERED);

ideal.sync_kit(this);
} ideal.end_if();
Expand Down Expand Up @@ -3283,7 +3282,9 @@ bool LibraryCallKit::inline_native_getEventWriter() {

// Load the raw epoch value from the threadObj.
Node* threadObj_epoch_offset = basic_plus_adr(threadObj, java_lang_Thread::jfr_epoch_offset());
Node* threadObj_epoch_raw = access_load_at(threadObj, threadObj_epoch_offset, TypeRawPtr::BOTTOM, TypeInt::CHAR, T_CHAR,
Node* threadObj_epoch_raw = access_load_at(threadObj, threadObj_epoch_offset,
_gvn.type(threadObj_epoch_offset)->isa_ptr(),
TypeInt::CHAR, T_CHAR,
IN_HEAP | MO_UNORDERED | C2_MISMATCHED | C2_CONTROL_DEPENDENT_LOAD);

// Mask off the excluded information from the epoch.
Expand All @@ -3298,7 +3299,8 @@ bool LibraryCallKit::inline_native_getEventWriter() {

// Load the raw epoch value from the vthread.
Node* vthread_epoch_offset = basic_plus_adr(vthread, java_lang_Thread::jfr_epoch_offset());
Node* vthread_epoch_raw = access_load_at(vthread, vthread_epoch_offset, TypeRawPtr::BOTTOM, TypeInt::CHAR, T_CHAR,
Node* vthread_epoch_raw = access_load_at(vthread, vthread_epoch_offset, _gvn.type(vthread_epoch_offset)->is_ptr(),
TypeInt::CHAR, T_CHAR,
IN_HEAP | MO_UNORDERED | C2_MISMATCHED | C2_CONTROL_DEPENDENT_LOAD);

// Mask off the excluded information from the epoch.
Expand Down Expand Up @@ -3534,7 +3536,7 @@ void LibraryCallKit::extend_setCurrentThread(Node* jt, Node* thread) {

// Load the raw epoch value from the vthread.
Node* epoch_offset = basic_plus_adr(thread, java_lang_Thread::jfr_epoch_offset());
Node* epoch_raw = access_load_at(thread, epoch_offset, TypeRawPtr::BOTTOM, TypeInt::CHAR, T_CHAR,
Node* epoch_raw = access_load_at(thread, epoch_offset, _gvn.type(epoch_offset)->is_ptr(), TypeInt::CHAR, T_CHAR,
IN_HEAP | MO_UNORDERED | C2_MISMATCHED | C2_CONTROL_DEPENDENT_LOAD);

// Mask off the excluded information from the epoch.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/**
* @test
* @bug 8337066
* @summary Test that MergeMem is skipped when looking for stores
* @run main/othervm -Xbatch -XX:-TieredCompilation
* -XX:CompileCommand=compileonly,java.lang.StringUTF16::reverse
* compiler.controldependency.TestAntiDependencyForPinnedLoads
*/

package compiler.controldependency;

public class TestAntiDependencyForPinnedLoads {
public static void main(String[] args) {
for(int i = 0; i < 50_000; i++) {
String str = "YYYY年MM月DD日";
StringBuffer strBuffer = new StringBuffer(str);
String revStr = strBuffer.reverse().toString();
if (!revStr.equals("日DD月MM年YYYY")) throw new InternalError("FAIL");
}
}
}
101 changes: 101 additions & 0 deletions test/hotspot/jtreg/compiler/types/TestBadMemSliceWithInterfaces.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Copyright (c) 2024, Red Hat, Inc. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/**
* @test
* @bug 8340214
* @summary C2 compilation asserts with "no node with a side effect" in PhaseIdealLoop::try_sink_out_of_loop
*
* @run main/othervm -XX:-BackgroundCompilation TestBadMemSliceWithInterfaces
*
*/

public class TestBadMemSliceWithInterfaces {
public static void main(String[] args) {
B b = new B();
C c = new C();
for (int i = 0; i < 20_000; i++) {
test1(b, c, true);
test1(b, c, false);
b.field = 0;
c.field = 0;
int res = test2(b, c, true);
if (res != 42) {
throw new RuntimeException("incorrect result " + res);
}
res = test2(b, c, false);
if (res != 42) {
throw new RuntimeException("incorrect result " + res);
}
}
}

private static void test1(B b, C c, boolean flag) {
A a;
if (flag) {
a = b;
} else {
a = c;
}
for (int i = 0; i < 1000; i++) {
a.field = 42;
}
}

private static int test2(B b, C c, boolean flag) {
A a;
if (flag) {
a = b;
} else {
a = c;
}
int v = 0;
for (int i = 0; i < 2; i++) {
v += a.field;
a.field = 42;
}
return v;
}

interface I {
void m();
}

static class A {
int field;
}

static class B extends A implements I {
@Override
public void m() {

}
}

static class C extends A implements I {
@Override
public void m() {

}
}
}
50 changes: 50 additions & 0 deletions test/hotspot/jtreg/runtime/reflect/ComponentTypeFieldTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* @bug 8337622
* @summary (reflect) java.lang.Class componentType field not found.
* @library /test/lib
* @modules java.base/java.lang:open
* @run main ComponentTypeFieldTest
*/

import java.lang.reflect.Field;
import static jdk.test.lib.Asserts.*;

public class ComponentTypeFieldTest {

public static void main(String[] args) throws Exception {
Field f = Class.class.getDeclaredField("componentType");
f.setAccessible(true);
Object val = f.get(Runnable.class);
assertTrue(val == null);
System.out.println("val is " + val);

Object arrayVal = f.get(Integer[].class);
System.out.println("val is " + arrayVal);
String arrayValString = arrayVal.toString();
assertTrue(arrayValString.equals("class java.lang.Integer"));
}
}
4 changes: 2 additions & 2 deletions test/jdk/java/io/FileInputStream/ReadXBytes.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 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 @@ -45,7 +45,7 @@ public class ReadXBytes {
private static final Random RND = RandomFactory.getRandom();

public static void main(String args[]) throws IOException {
File dir = new File(System.getProperty("test.src", "."));
File dir = new File(".");
dir.deleteOnExit();

File empty = File.createTempFile("foo", "bar", dir);
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/nio/MappedByteBuffer/ForceException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 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 @@ -40,7 +40,7 @@ public static void main(String[] args) throws IOException {
int numberOfBlocks = 200;
int fileLength = numberOfBlocks * blockSize;

File file = new File(System.getProperty("test.src", "."), "test.dat");
File file = new File(".", "test.dat");
file.deleteOnExit();
try (RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
raf.setLength(fileLength);
Expand Down
Loading

0 comments on commit 02893fd

Please sign in to comment.