mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-24 18:03:10 +00:00
8387940: C2: Stress allocation elimination failures
Reviewed-by: chagedorn, kvn, qamai
This commit is contained in:
parent
189dde7dfe
commit
fe430ad121
@ -601,6 +601,14 @@
|
||||
"Number of fields in instance limit for scalar replacement") \
|
||||
range(0, max_jint) \
|
||||
\
|
||||
product(bool, StressEliminateAllocations, false, DIAGNOSTIC, \
|
||||
"Randomly fail allocation elimination attempts") \
|
||||
\
|
||||
product(uint, StressEliminateAllocationsMean, 20, DIAGNOSTIC, \
|
||||
"The expected number of elimination checks made until " \
|
||||
"a random failure.") \
|
||||
range(1, max_juint) \
|
||||
\
|
||||
product(bool, OptimizePtrCompare, true, \
|
||||
"Use escape analysis to optimize pointers compare") \
|
||||
\
|
||||
|
||||
@ -748,7 +748,8 @@ Compile::Compile(ciEnv* ci_env, ciMethod* target, int osr_bci,
|
||||
if (StressLCM || StressGCM || StressIGVN || StressCCP ||
|
||||
StressIncrementalInlining || StressMacroExpansion ||
|
||||
StressMacroElimination || StressUnstableIfTraps ||
|
||||
StressBailout || StressLoopPeeling || StressCountedLoop) {
|
||||
StressBailout || StressLoopPeeling || StressCountedLoop ||
|
||||
StressEliminateAllocations) {
|
||||
initialize_stress_seed(directive);
|
||||
}
|
||||
|
||||
|
||||
@ -931,7 +931,9 @@ SafePointScalarObjectNode* PhaseMacroExpand::create_scalarized_object_descriptio
|
||||
|
||||
// We weren't able to find a value for this field,
|
||||
// give up on eliminating this allocation.
|
||||
if (field_val == nullptr) {
|
||||
bool force_scalarization_failure = StressEliminateAllocations &&
|
||||
(C->random() % StressEliminateAllocationsMean == 0);
|
||||
if (field_val == nullptr || force_scalarization_failure) {
|
||||
uint last = sfpt->req() - 1;
|
||||
for (int k = 0; k < j; k++) {
|
||||
sfpt->del_req(last--);
|
||||
@ -940,13 +942,21 @@ SafePointScalarObjectNode* PhaseMacroExpand::create_scalarized_object_descriptio
|
||||
|
||||
#ifndef PRODUCT
|
||||
if (PrintEliminateAllocations) {
|
||||
if (field != nullptr) {
|
||||
tty->print("=== At SafePoint node %d can't find value of field: ", sfpt->_idx);
|
||||
field->print();
|
||||
int field_idx = C->get_alias_index(field_addr_type);
|
||||
tty->print(" (alias_idx=%d)", field_idx);
|
||||
} else { // Array's element
|
||||
tty->print("=== At SafePoint node %d can't find value of array element [%d]", sfpt->_idx, j);
|
||||
tty->print("=== At SafePoint node %d ", sfpt->_idx);
|
||||
if (field_val == nullptr) {
|
||||
tty->print_raw("can't find value of ");
|
||||
|
||||
if (field != nullptr) {
|
||||
tty->print_raw("field: ");
|
||||
field->print();
|
||||
int field_idx = C->get_alias_index(field_addr_type);
|
||||
tty->print(" (alias_idx=%d)", field_idx);
|
||||
} else { // Array's element
|
||||
tty->print("array element [%d]", j);
|
||||
}
|
||||
} else {
|
||||
assert(force_scalarization_failure, "sanity");
|
||||
tty->print_raw("forcibly abort elimination");
|
||||
}
|
||||
tty->print(", which prevents elimination of: ");
|
||||
if (res == nullptr)
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @key stress randomness
|
||||
* @bug 8252219 8256535 8317349 8319879 8335334 8325478
|
||||
* @bug 8252219 8256535 8317349 8319879 8335334 8325478 8387940
|
||||
* @requires vm.compiler2.enabled
|
||||
* @summary Tests that different combinations of stress options and
|
||||
* -XX:StressSeed=N are accepted.
|
||||
@ -60,6 +60,10 @@
|
||||
* compiler.arguments.TestStressOptions
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressMacroElimination -XX:StressSeed=42
|
||||
* compiler.arguments.TestStressOptions
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressEliminateAllocations
|
||||
* compiler.arguments.TestStressOptions
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressEliminateAllocations -XX:StressSeed=42
|
||||
* compiler.arguments.TestStressOptions
|
||||
*/
|
||||
|
||||
package compiler.arguments;
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2026, 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 8387940
|
||||
* @requires vm.compiler2.enabled
|
||||
* @summary C2: Stress allocation elimination failures
|
||||
*
|
||||
* @library /test/lib /
|
||||
* @run driver ${test.main.class}
|
||||
*/
|
||||
|
||||
package compiler.escapeAnalysis;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
public class StressEliminateAllocationsIRTest {
|
||||
public static void main(String[] args) {
|
||||
TestFramework.runWithFlags("-XX:+UnlockDiagnosticVMOptions",
|
||||
"-XX:+StressEliminateAllocations",
|
||||
"-XX:StressEliminateAllocationsMean=1");
|
||||
}
|
||||
|
||||
static class A {
|
||||
final int i;
|
||||
A(int i) {
|
||||
this.i = i;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(counts = {IRNode.ALLOC, "1"})
|
||||
@Arguments(values = Argument.NUMBER_42)
|
||||
private static int test(int i) {
|
||||
// Even though the object is scalar replaceable,
|
||||
// allocation elimination unconditionally fails in stress mode.
|
||||
A a = new A(i);
|
||||
|
||||
dontInline();
|
||||
|
||||
return a.i;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
private static void dontInline() {}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user