mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-15 08:34:30 +02:00
Merge
This commit is contained in:
commit
70f5693356
14 changed files with 377 additions and 52 deletions
|
@ -248,8 +248,15 @@ bool ciMethodData::load_data() {
|
||||||
|
|
||||||
// Note: Extra data are all BitData, and do not need translation.
|
// Note: Extra data are all BitData, and do not need translation.
|
||||||
_invocation_counter = mdo->invocation_count();
|
_invocation_counter = mdo->invocation_count();
|
||||||
_state = mdo->is_mature()? mature_state: immature_state;
|
if (_invocation_counter == 0 && mdo->backedge_count() > 0) {
|
||||||
|
// Avoid skewing counter data during OSR compilation.
|
||||||
|
// Sometimes, MDO is allocated during the very first invocation and OSR compilation is triggered
|
||||||
|
// solely by backedge counter while invocation counter stays zero. In such case, it's important
|
||||||
|
// to observe non-zero invocation count to properly scale profile counts (see ciMethod::scale_count()).
|
||||||
|
_invocation_counter = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_state = mdo->is_mature() ? mature_state : immature_state;
|
||||||
_eflags = mdo->eflags();
|
_eflags = mdo->eflags();
|
||||||
_arg_local = mdo->arg_local();
|
_arg_local = mdo->arg_local();
|
||||||
_arg_stack = mdo->arg_stack();
|
_arg_stack = mdo->arg_stack();
|
||||||
|
|
|
@ -314,7 +314,7 @@ static bool check_compare_clipping( bool less_than, IfNode *iff, ConNode *limit,
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------is_unreachable_region--------------------------
|
//------------------------------is_unreachable_region--------------------------
|
||||||
// Find if the Region node is reachable from the root.
|
// Check if the RegionNode is part of an unsafe loop and unreachable from root.
|
||||||
bool RegionNode::is_unreachable_region(const PhaseGVN* phase) {
|
bool RegionNode::is_unreachable_region(const PhaseGVN* phase) {
|
||||||
Node* top = phase->C->top();
|
Node* top = phase->C->top();
|
||||||
assert(req() == 2 || (req() == 3 && in(1) != NULL && in(2) == top), "sanity check arguments");
|
assert(req() == 2 || (req() == 3 && in(1) != NULL && in(2) == top), "sanity check arguments");
|
||||||
|
@ -373,7 +373,7 @@ bool RegionNode::is_unreachable_from_root(const PhaseGVN* phase) const {
|
||||||
VectorSet visited;
|
VectorSet visited;
|
||||||
|
|
||||||
// Mark all control nodes reachable from root outputs
|
// Mark all control nodes reachable from root outputs
|
||||||
Node *n = (Node*)phase->C->root();
|
Node* n = (Node*)phase->C->root();
|
||||||
nstack.push(n);
|
nstack.push(n);
|
||||||
visited.set(n->_idx);
|
visited.set(n->_idx);
|
||||||
while (nstack.size() != 0) {
|
while (nstack.size() != 0) {
|
||||||
|
@ -475,7 +475,7 @@ Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||||
|
|
||||||
// Remove TOP or NULL input paths. If only 1 input path remains, this Region
|
// Remove TOP or NULL input paths. If only 1 input path remains, this Region
|
||||||
// degrades to a copy.
|
// degrades to a copy.
|
||||||
bool add_to_worklist = false;
|
bool add_to_worklist = true;
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
int cnt = 0; // Count of values merging
|
int cnt = 0; // Count of values merging
|
||||||
DEBUG_ONLY( int cnt_orig = req(); ) // Save original inputs count
|
DEBUG_ONLY( int cnt_orig = req(); ) // Save original inputs count
|
||||||
|
@ -501,7 +501,7 @@ Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( phase->type(n) == Type::TOP ) {
|
if( phase->type(n) == Type::TOP ) {
|
||||||
set_req(i, NULL); // Ignore TOP inputs
|
set_req_X(i, NULL, phase); // Ignore TOP inputs
|
||||||
modified = true;
|
modified = true;
|
||||||
i--;
|
i--;
|
||||||
continue;
|
continue;
|
||||||
|
@ -532,7 +532,8 @@ Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_to_worklist = true;
|
add_to_worklist = false;
|
||||||
|
phase->is_IterGVN()->add_users_to_worklist(this);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -547,45 +548,51 @@ Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||||
if ((this->is_Loop() && (del_it == LoopNode::EntryControl ||
|
if ((this->is_Loop() && (del_it == LoopNode::EntryControl ||
|
||||||
(del_it == 0 && is_unreachable_region(phase)))) ||
|
(del_it == 0 && is_unreachable_region(phase)))) ||
|
||||||
(!this->is_Loop() && has_phis && is_unreachable_region(phase))) {
|
(!this->is_Loop() && has_phis && is_unreachable_region(phase))) {
|
||||||
// Yes, the region will be removed during the next step below.
|
// This region and therefore all nodes on the input control path(s) are unreachable
|
||||||
// Cut the backedge input and remove phis since no data paths left.
|
// from root. To avoid incomplete removal of unreachable subgraphs, walk up the CFG
|
||||||
// We don't cut outputs to other nodes here since we need to put them
|
// and aggressively replace all nodes by top.
|
||||||
// on the worklist.
|
PhaseIterGVN* igvn = phase->is_IterGVN();
|
||||||
PhaseIterGVN *igvn = phase->is_IterGVN();
|
Node* top = phase->C->top();
|
||||||
if (in(1)->outcnt() == 1) {
|
ResourceMark rm;
|
||||||
igvn->_worklist.push(in(1));
|
Node_List nstack;
|
||||||
}
|
VectorSet visited;
|
||||||
del_req(1);
|
nstack.push(this);
|
||||||
cnt = 0;
|
visited.set(_idx);
|
||||||
assert( req() == 1, "no more inputs expected" );
|
while (nstack.size() != 0) {
|
||||||
uint max = outcnt();
|
Node* n = nstack.pop();
|
||||||
bool progress = true;
|
for (uint i = 0; i < n->req(); ++i) {
|
||||||
Node *top = phase->C->top();
|
Node* m = n->in(i);
|
||||||
DUIterator j;
|
assert(m != (Node*)phase->C->root(), "Should be unreachable from root");
|
||||||
while(progress) {
|
if (m != NULL && m->is_CFG() && !visited.test_set(m->_idx)) {
|
||||||
progress = false;
|
nstack.push(m);
|
||||||
for (j = outs(); has_out(j); j++) {
|
}
|
||||||
Node *n = out(j);
|
}
|
||||||
if( n->is_Phi() ) {
|
if (n->is_Region()) {
|
||||||
assert(n->in(0) == this, "");
|
// Eagerly replace phis with top to avoid regionless phis.
|
||||||
assert( n->req() == 2 && n->in(1) != NULL, "Only one data input expected" );
|
n->set_req(0, NULL);
|
||||||
// Break dead loop data path.
|
bool progress = true;
|
||||||
// Eagerly replace phis with top to avoid regionless phis.
|
uint max = n->outcnt();
|
||||||
igvn->replace_node(n, top);
|
DUIterator j;
|
||||||
if( max != outcnt() ) {
|
while (progress) {
|
||||||
progress = true;
|
progress = false;
|
||||||
j = refresh_out_pos(j);
|
for (j = n->outs(); n->has_out(j); j++) {
|
||||||
max = outcnt();
|
Node* u = n->out(j);
|
||||||
|
if (u->is_Phi()) {
|
||||||
|
igvn->replace_node(u, top);
|
||||||
|
if (max != n->outcnt()) {
|
||||||
|
progress = true;
|
||||||
|
j = n->refresh_out_pos(j);
|
||||||
|
max = n->outcnt();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
igvn->replace_node(n, top);
|
||||||
}
|
}
|
||||||
add_to_worklist = true;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (add_to_worklist) {
|
|
||||||
phase->is_IterGVN()->add_users_to_worklist(this); // Revisit collapsed Phis
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cnt <= 1 ) { // Only 1 path in?
|
if( cnt <= 1 ) { // Only 1 path in?
|
||||||
set_req(0, NULL); // Null control input for region copy
|
set_req(0, NULL); // Null control input for region copy
|
||||||
|
@ -629,8 +636,9 @@ Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||||
assert(parent_ctrl != NULL, "Region is a copy of some non-null control");
|
assert(parent_ctrl != NULL, "Region is a copy of some non-null control");
|
||||||
assert(parent_ctrl != this, "Close dead loop");
|
assert(parent_ctrl != this, "Close dead loop");
|
||||||
}
|
}
|
||||||
if (!add_to_worklist)
|
if (add_to_worklist) {
|
||||||
igvn->add_users_to_worklist(this); // Check for further allowed opts
|
igvn->add_users_to_worklist(this); // Check for further allowed opts
|
||||||
|
}
|
||||||
for (DUIterator_Last imin, i = last_outs(imin); i >= imin; --i) {
|
for (DUIterator_Last imin, i = last_outs(imin); i >= imin; --i) {
|
||||||
Node* n = last_out(i);
|
Node* n = last_out(i);
|
||||||
igvn->hash_delete(n); // Remove from worklist before modifying edges
|
igvn->hash_delete(n); // Remove from worklist before modifying edges
|
||||||
|
|
|
@ -1321,12 +1321,12 @@ JvmtiEnvBase::get_threadOop_and_JavaThread(ThreadsList* t_list, jthread thread,
|
||||||
java_thread = get_JavaThread_or_null(thread_oop);
|
java_thread = get_JavaThread_or_null(thread_oop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*jt_pp = java_thread;
|
||||||
|
*thread_oop_p = thread_oop;
|
||||||
if (java_lang_VirtualThread::is_instance(thread_oop) &&
|
if (java_lang_VirtualThread::is_instance(thread_oop) &&
|
||||||
!JvmtiEnvBase::is_vthread_alive(thread_oop)) {
|
!JvmtiEnvBase::is_vthread_alive(thread_oop)) {
|
||||||
return JVMTI_ERROR_THREAD_NOT_ALIVE;
|
return JVMTI_ERROR_THREAD_NOT_ALIVE;
|
||||||
}
|
}
|
||||||
*jt_pp = java_thread;
|
|
||||||
*thread_oop_p = thread_oop;
|
|
||||||
return JVMTI_ERROR_NONE;
|
return JVMTI_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ public final class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MemorySegment toCString(byte[] bytes, SegmentAllocator allocator) {
|
public static MemorySegment toCString(byte[] bytes, SegmentAllocator allocator) {
|
||||||
MemorySegment addr = allocator.allocate(bytes.length + 1, 1L);
|
MemorySegment addr = allocator.allocate(bytes.length + 1);
|
||||||
copy(addr, bytes);
|
copy(addr, bytes);
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ formatVersion=3
|
||||||
# Version of the currency code information in this class.
|
# Version of the currency code information in this class.
|
||||||
# It is a serial number that accompanies with each amendment.
|
# It is a serial number that accompanies with each amendment.
|
||||||
|
|
||||||
dataVersion=171
|
dataVersion=172
|
||||||
|
|
||||||
# List of all valid ISO 4217 currency codes.
|
# List of all valid ISO 4217 currency codes.
|
||||||
# To ensure compatibility, do not remove codes.
|
# To ensure compatibility, do not remove codes.
|
||||||
|
|
|
@ -873,6 +873,12 @@ Calling other JNI functions in the scope of
|
||||||
Expect a performance degradation when this option is used.
|
Expect a performance degradation when this option is used.
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
|
.B \f[CB]\-Xcomp\f[R]
|
||||||
|
Testing mode to exercise JIT compilers.
|
||||||
|
This option should not be used in production environments.
|
||||||
|
.RS
|
||||||
|
.RE
|
||||||
|
.TP
|
||||||
.B \f[CB]\-Xdebug\f[R]
|
.B \f[CB]\-Xdebug\f[R]
|
||||||
Does nothing.
|
Does nothing.
|
||||||
Provided for backward compatibility.
|
Provided for backward compatibility.
|
||||||
|
|
|
@ -236,7 +236,7 @@ public final class X11GraphicsEnvironment extends SunGraphicsEnvironment {
|
||||||
throw new AWTError("no screen devices");
|
throw new AWTError("no screen devices");
|
||||||
}
|
}
|
||||||
int index = getDefaultScreenNum();
|
int index = getDefaultScreenNum();
|
||||||
mainScreen = 0 < index && index < screens.length ? index : 0;
|
mainScreen = 0 < index && index < numScreens ? index : 0;
|
||||||
|
|
||||||
for (int id = 0; id < numScreens; ++id) {
|
for (int id = 0; id < numScreens; ++id) {
|
||||||
devices.put(id, old.containsKey(id) ? old.remove(id) :
|
devices.put(id, old.containsKey(id) ? old.remove(id) :
|
||||||
|
|
239
test/hotspot/jtreg/compiler/c2/TestDeadDataLoop.java
Normal file
239
test/hotspot/jtreg/compiler/c2/TestDeadDataLoop.java
Normal file
|
@ -0,0 +1,239 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022, 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 8284358
|
||||||
|
* @summary An unreachable loop is not removed, leading to a broken graph.
|
||||||
|
* @requires vm.compiler2.enabled
|
||||||
|
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN -XX:StressSeed=1448005075
|
||||||
|
* -XX:CompileCommand=compileonly,*TestDeadDataLoop::test* -XX:CompileCommand=dontinline,*TestDeadDataLoop::notInlined
|
||||||
|
* compiler.c2.TestDeadDataLoop
|
||||||
|
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN -XX:StressSeed=1922737097
|
||||||
|
* -XX:CompileCommand=compileonly,*TestDeadDataLoop::test* -XX:CompileCommand=dontinline,*TestDeadDataLoop::notInlined
|
||||||
|
* compiler.c2.TestDeadDataLoop
|
||||||
|
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN
|
||||||
|
* -XX:CompileCommand=compileonly,*TestDeadDataLoop::test* -XX:CompileCommand=dontinline,*TestDeadDataLoop::notInlined
|
||||||
|
* compiler.c2.TestDeadDataLoop
|
||||||
|
*/
|
||||||
|
|
||||||
|
package compiler.c2;
|
||||||
|
|
||||||
|
public class TestDeadDataLoop {
|
||||||
|
|
||||||
|
static class MyValue {
|
||||||
|
final int x;
|
||||||
|
|
||||||
|
MyValue(int x) {
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean flag = false;
|
||||||
|
static MyValue escape = null;
|
||||||
|
static volatile int volInt = 0;
|
||||||
|
|
||||||
|
static boolean test1() {
|
||||||
|
Integer box;
|
||||||
|
if (flag) {
|
||||||
|
box = 0;
|
||||||
|
} else {
|
||||||
|
box = 1;
|
||||||
|
}
|
||||||
|
if (box == 2) {
|
||||||
|
// Not reachable but that's only known after Incremental Boxing Inline
|
||||||
|
for (int i = 0; i < 1000;) {
|
||||||
|
if (notInlined()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MyValue val = new MyValue(4);
|
||||||
|
|
||||||
|
escape = new MyValue(42);
|
||||||
|
|
||||||
|
// Trigger scalarization of val in safepoint debug info
|
||||||
|
notInlined();
|
||||||
|
if (val.x < 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean test2() {
|
||||||
|
MyValue box = new MyValue(1);
|
||||||
|
if (box.x == 0) {
|
||||||
|
// Not reachable but that's only known once the box.x load is folded during IGVN
|
||||||
|
for (int i = 0; i < 1000;) {
|
||||||
|
if (notInlined()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MyValue val = new MyValue(4);
|
||||||
|
|
||||||
|
escape = new MyValue(42);
|
||||||
|
|
||||||
|
// Trigger scalarization of val in safepoint debug info
|
||||||
|
notInlined();
|
||||||
|
if (val.x < 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test3() {
|
||||||
|
Integer box = 0;
|
||||||
|
if (flag) {
|
||||||
|
box = 1;
|
||||||
|
}
|
||||||
|
if (box == 2) {
|
||||||
|
for (int i = 0; i < 1000;) {
|
||||||
|
if (notInlined()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
escape = new MyValue(42);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test4() {
|
||||||
|
MyValue box = new MyValue(1);
|
||||||
|
if (box.x == 0) {
|
||||||
|
for (int i = 0; i < 1000;) {
|
||||||
|
if (notInlined()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
escape = new MyValue(42);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test5() {
|
||||||
|
MyValue box = new MyValue(1);
|
||||||
|
if (box.x == 0) {
|
||||||
|
while (true) {
|
||||||
|
if (notInlined()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
escape = new MyValue(42);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test6() {
|
||||||
|
MyValue box = new MyValue(1);
|
||||||
|
if (box.x == 0) {
|
||||||
|
while (notInlined()) { }
|
||||||
|
escape = new MyValue(42);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test7() {
|
||||||
|
MyValue box = new MyValue(1);
|
||||||
|
if (box.x == 0) {
|
||||||
|
while (true) {
|
||||||
|
escape = new MyValue(2);
|
||||||
|
if (notInlined()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
escape = new MyValue(42);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test8() {
|
||||||
|
MyValue box = new MyValue(1);
|
||||||
|
if (box.x == 0) {
|
||||||
|
for (int i = 0; i < 1000;) {
|
||||||
|
notInlined();
|
||||||
|
if (flag) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
escape = new MyValue(42);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean test9() {
|
||||||
|
Integer box;
|
||||||
|
if (flag) {
|
||||||
|
box = 0;
|
||||||
|
} else {
|
||||||
|
box = 1;
|
||||||
|
}
|
||||||
|
if (box == 2) {
|
||||||
|
for (int i = 0; i < 1000;) {
|
||||||
|
// MemBarRelease as only Phi user
|
||||||
|
volInt = 42;
|
||||||
|
if (flag) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MyValue val = new MyValue(4);
|
||||||
|
|
||||||
|
escape = new MyValue(42);
|
||||||
|
|
||||||
|
notInlined();
|
||||||
|
if (val.x < 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test10() {
|
||||||
|
MyValue box = new MyValue(1);
|
||||||
|
if (box.x == 0) {
|
||||||
|
while (true) {
|
||||||
|
// Allocate node as only Phi user
|
||||||
|
escape = new MyValue(2);
|
||||||
|
if (flag) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
escape = new MyValue(42);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean notInlined() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// Make sure classes are initialized
|
||||||
|
Integer i = 42;
|
||||||
|
new MyValue(i);
|
||||||
|
test1();
|
||||||
|
test2();
|
||||||
|
test3();
|
||||||
|
test4();
|
||||||
|
test5();
|
||||||
|
test6();
|
||||||
|
test7();
|
||||||
|
test8();
|
||||||
|
test9();
|
||||||
|
test10();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class thrstat03 {
|
||||||
throw new Error("Unexpected: " + e);
|
throw new Error("Unexpected: " + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!check(t, t.isVirtual() ? NOT_STARTED : ZOMBIE)) {
|
if (!check(t, ZOMBIE)) {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,12 +36,18 @@ public class SelfSuspendDisablerTest {
|
||||||
System.loadLibrary("SelfSuspendDisablerTest");
|
System.loadLibrary("SelfSuspendDisablerTest");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tested JVM TI thread states
|
||||||
|
static final int NEW = 0; // No bits are set
|
||||||
|
static final int TERMINATED = 2; // JVMTI_THREAD_STATE_TERMINATED
|
||||||
|
static final int RUNNABLE = 5; // JVMTI_THREAD_STATE_ALIVE & JVMTI_THREAD_STATE_RUNNABLE
|
||||||
|
static final int SUSPENDED = 0x100005; // RUNNABLE & JVMTI_THREAD_STATE_SUSPENDED
|
||||||
|
|
||||||
native static boolean isSuspended(Thread thread);
|
native static boolean isSuspended(Thread thread);
|
||||||
native static void selfSuspend();
|
native static void selfSuspend();
|
||||||
native static void resume(Thread thread);
|
native static void resume(Thread thread);
|
||||||
native static void suspendAllVirtualThreads();
|
native static void suspendAllVirtualThreads();
|
||||||
native static void resumeAllVirtualThreads();
|
native static void resumeAllVirtualThreads();
|
||||||
|
native static int getThreadState(Thread thread);
|
||||||
|
|
||||||
private static void sleep(long millis) {
|
private static void sleep(long millis) {
|
||||||
try {
|
try {
|
||||||
|
@ -51,26 +57,57 @@ public class SelfSuspendDisablerTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void testJvmtiThreadState(Thread thread, int expectedState) {
|
||||||
|
String kindStr = thread.isVirtual()? "virtual " : "platform";
|
||||||
|
int state = getThreadState(thread);
|
||||||
|
|
||||||
|
System.out.printf("Expected %s thread state: %06X got: %06X\n",
|
||||||
|
kindStr, expectedState, state);
|
||||||
|
if (state != expectedState) {
|
||||||
|
throw new RuntimeException("Test FAILED: Unexpected thread state");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String argv[]) throws Exception {
|
public static void main(String argv[]) throws Exception {
|
||||||
Thread t1 = Thread.ofPlatform().start(() -> {
|
Thread t1 = Thread.ofPlatform().factory().newThread(() -> {
|
||||||
|
testJvmtiThreadState(Thread.currentThread(), RUNNABLE);
|
||||||
selfSuspend();
|
selfSuspend();
|
||||||
});
|
});
|
||||||
Thread t2 = Thread.ofVirtual().start(() -> {
|
Thread t2 = Thread.ofVirtual().factory().newThread(() -> {
|
||||||
|
testJvmtiThreadState(Thread.currentThread(), RUNNABLE);
|
||||||
while(!isSuspended(t1)) {
|
while(!isSuspended(t1)) {
|
||||||
Thread.yield();
|
Thread.yield();
|
||||||
}
|
}
|
||||||
Thread.yield(); // provoke unmount
|
Thread.yield(); // provoke unmount
|
||||||
|
|
||||||
|
testJvmtiThreadState(t1, SUSPENDED);
|
||||||
|
|
||||||
resume(t1);
|
resume(t1);
|
||||||
|
|
||||||
|
testJvmtiThreadState(t1, RUNNABLE);
|
||||||
|
|
||||||
suspendAllVirtualThreads();
|
suspendAllVirtualThreads();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testJvmtiThreadState(t1, NEW);
|
||||||
|
testJvmtiThreadState(t2, NEW);
|
||||||
|
|
||||||
|
t1.start();
|
||||||
|
t2.start();
|
||||||
|
|
||||||
while(!isSuspended(t2)) {
|
while(!isSuspended(t2)) {
|
||||||
sleep(100);
|
sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testJvmtiThreadState(t2, SUSPENDED);
|
||||||
|
|
||||||
resumeAllVirtualThreads();
|
resumeAllVirtualThreads();
|
||||||
|
|
||||||
t2.join();
|
t2.join();
|
||||||
t1.join();
|
t1.join();
|
||||||
|
|
||||||
|
testJvmtiThreadState(t1, TERMINATED);
|
||||||
|
testJvmtiThreadState(t2, TERMINATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,15 @@ Java_SelfSuspendDisablerTest_resumeAllVirtualThreads(JNIEnv* jni, jclass cls) {
|
||||||
check_jvmti_status(jni, jvmti->ResumeAllVirtualThreads(0, NULL), "Error in ResumeAllVirtualThreads");
|
check_jvmti_status(jni, jvmti->ResumeAllVirtualThreads(0, NULL), "Error in ResumeAllVirtualThreads");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL
|
||||||
|
Java_SelfSuspendDisablerTest_getThreadState(JNIEnv* jni, jclass cls, jthread thread) {
|
||||||
|
jint state;
|
||||||
|
check_jvmti_status(jni, jvmti->GetThreadState(thread, &state), "Error in GetThreadState");
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // extern "C"
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
|
Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
|
||||||
|
|
|
@ -736,6 +736,8 @@ sun/tools/jstat/jstatLineCounts2.sh 8268211 linux-aa
|
||||||
sun/tools/jstat/jstatLineCounts3.sh 8268211 linux-aarch64
|
sun/tools/jstat/jstatLineCounts3.sh 8268211 linux-aarch64
|
||||||
sun/tools/jstat/jstatLineCounts4.sh 8268211 linux-aarch64
|
sun/tools/jstat/jstatLineCounts4.sh 8268211 linux-aarch64
|
||||||
|
|
||||||
|
sun/tools/jhsdb/JStackStressTest.java 8276210 linux-aarch64
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
# jdk_other
|
# jdk_other
|
||||||
|
|
|
@ -185,6 +185,25 @@ public class TestSegmentAllocators {
|
||||||
assertEquals(calls.get(), 7);
|
assertEquals(calls.get(), 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStringAllocateDelegation() {
|
||||||
|
AtomicInteger calls = new AtomicInteger();
|
||||||
|
SegmentAllocator allocator = new SegmentAllocator() {
|
||||||
|
@Override
|
||||||
|
public MemorySegment allocate(long bytesSize, long bytesAlignment) {
|
||||||
|
return MemorySegment.allocateNative(bytesSize, bytesAlignment, MemorySession.openImplicit());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MemorySegment allocate(long size) {
|
||||||
|
calls.incrementAndGet();
|
||||||
|
return allocate(size, 1);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
allocator.allocateUtf8String("Hello");
|
||||||
|
assertEquals(calls.get(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test(dataProvider = "arrayAllocations")
|
@Test(dataProvider = "arrayAllocations")
|
||||||
public <Z> void testArray(AllocationFactory allocationFactory, ValueLayout layout, AllocationFunction<Object, ValueLayout> allocationFunction, ToArrayHelper<Z> arrayHelper) {
|
public <Z> void testArray(AllocationFactory allocationFactory, ValueLayout layout, AllocationFunction<Object, ValueLayout> allocationFunction, ToArrayHelper<Z> arrayHelper) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Amendments up until ISO 4217 AMENDMENT NUMBER 171
|
# Amendments up until ISO 4217 AMENDMENT NUMBER 172
|
||||||
# (As of 16 Mar 2022)
|
# (As of 27 June 2022)
|
||||||
#
|
#
|
||||||
|
|
||||||
# Version
|
# Version
|
||||||
FILEVERSION=3
|
FILEVERSION=3
|
||||||
DATAVERSION=171
|
DATAVERSION=172
|
||||||
|
|
||||||
# ISO 4217 currency data
|
# ISO 4217 currency data
|
||||||
AF AFN 971 2
|
AF AFN 971 2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue