Skip to content

Commit

Permalink
8317299: safepoint scalarization doesn't keep track of the depth of t…
Browse files Browse the repository at this point in the history
…he JVM state

Reviewed-by: phh
Backport-of: 6d911f68a3244c40a62ab2570dfec68b8d0ed5d8
  • Loading branch information
TheRealMDoerr committed Jun 14, 2024
1 parent 9a392ea commit d2f857a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/hotspot/share/opto/callnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1465,9 +1465,11 @@ SafePointScalarObjectNode::SafePointScalarObjectNode(const TypeOopPtr* tp,
Node* alloc,
#endif
uint first_index,
uint depth,
uint n_fields) :
TypeNode(tp, 1), // 1 control input -- seems required. Get from root.
_first_index(first_index),
_depth(depth),
_n_fields(n_fields)
#ifdef ASSERT
, _alloc(alloc)
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/opto/callnode.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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 @@ -509,7 +509,7 @@ class SafePointNode : public MultiNode {
class SafePointScalarObjectNode: public TypeNode {
uint _first_index; // First input edge relative index of a SafePoint node where
// states of the scalarized object fields are collected.
// It is relative to the last (youngest) jvms->_scloff.
uint _depth; // Depth of the JVM state the _first_index field refers to
uint _n_fields; // Number of non-static fields of the scalarized object.
DEBUG_ONLY(Node* _alloc;)

Expand All @@ -523,7 +523,7 @@ class SafePointScalarObjectNode: public TypeNode {
#ifdef ASSERT
Node* alloc,
#endif
uint first_index, uint n_fields);
uint first_index, uint depth, uint n_fields);
virtual int Opcode() const;
virtual uint ideal_reg() const;
virtual const RegMask &in_RegMask(uint) const;
Expand All @@ -532,7 +532,7 @@ class SafePointScalarObjectNode: public TypeNode {

uint first_index(JVMState* jvms) const {
assert(jvms != nullptr, "missed JVMS");
return jvms->scloff() + _first_index;
return jvms->of_depth(_depth)->scloff() + _first_index;
}
uint n_fields() const { return _n_fields; }

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/macro.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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 @@ -725,7 +725,7 @@ bool PhaseMacroExpand::scalar_replacement(AllocateNode *alloc, GrowableArray <Sa
#ifdef ASSERT
alloc,
#endif
first_ind, nfields);
first_ind, sfpt->jvms()->depth(), nfields);
sobj->init_req(0, C->root());
transform_later(sobj);

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/vector.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 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 @@ -280,7 +280,7 @@ void PhaseVector::scalarize_vbox_node(VectorBoxNode* vec_box) {
#ifdef ASSERT
vec_box,
#endif // ASSERT
first_ind, n_fields);
first_ind, sfpt->jvms()->depth(), n_fields);
sobj->init_req(0, C->root());
sfpt->add_req(vec_value);

Expand Down
13 changes: 13 additions & 0 deletions test/hotspot/jtreg/compiler/vectorapi/TestIntrinsicBailOut.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2021, 2022, THL A29 Limited, a Tencent company. All rights reserved.
* 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
Expand Down Expand Up @@ -37,6 +38,18 @@
* -XX:-TieredCompilation compiler.vectorapi.TestIntrinsicBailOut
*/

/*
* @test
* @enablePreview
* @bug 8317299
* @summary Vector API intrinsincs should handle JVM state correctly whith late inlining when compiling with -InlineUnsafeOps
* @modules jdk.incubator.vector
* @requires vm.cpu.features ~= ".*avx512.*"
* @run main/othervm -Xcomp -XX:+UnlockDiagnosticVMOptions -XX:-InlineUnsafeOps -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=3
* -XX:CompileCommand=compileonly,compiler.vectorapi.TestIntrinsicBailOut::test -XX:CompileCommand=quiet
* -XX:-TieredCompilation compiler.vectorapi.TestIntrinsicBailOut
*/


public class TestIntrinsicBailOut {
static final VectorSpecies<Double> SPECIES256 = DoubleVector.SPECIES_256;
Expand Down

1 comment on commit d2f857a

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.