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: thartmann, vlivanov
  • Loading branch information
Damon Fenacci committed Feb 6, 2024
1 parent 542b0b6 commit 6d911f6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/hotspot/share/opto/callnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,9 +1463,10 @@ void SafePointNode::disconnect_from_root(PhaseIterGVN *igvn) {

//============== SafePointScalarObjectNode ==============

SafePointScalarObjectNode::SafePointScalarObjectNode(const TypeOopPtr* tp, Node* alloc, uint first_index, uint n_fields) :
SafePointScalarObjectNode::SafePointScalarObjectNode(const TypeOopPtr* tp, Node* alloc, 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),
_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 @@ -508,7 +508,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.

Node* _alloc; // Just for debugging purposes.
Expand All @@ -519,7 +519,7 @@ class SafePointScalarObjectNode: public TypeNode {
uint first_index() const { return _first_index; }

public:
SafePointScalarObjectNode(const TypeOopPtr* tp, Node* alloc, uint first_index, uint n_fields);
SafePointScalarObjectNode(const TypeOopPtr* tp, Node* alloc, uint first_index, uint depth, uint n_fields);

virtual int Opcode() const;
virtual uint ideal_reg() const;
Expand All @@ -529,7 +529,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 @@ -766,7 +766,7 @@ SafePointScalarObjectNode* PhaseMacroExpand::create_scalarized_object_descriptio
}
}

SafePointScalarObjectNode* sobj = new SafePointScalarObjectNode(res_type, alloc, first_ind, nfields);
SafePointScalarObjectNode* sobj = new SafePointScalarObjectNode(res_type, alloc, 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 @@ -276,7 +276,7 @@ void PhaseVector::scalarize_vbox_node(VectorBoxNode* vec_box) {
SafePointNode* sfpt = safepoints.pop()->as_SafePoint();

uint first_ind = (sfpt->req() - sfpt->jvms()->scloff());
Node* sobj = new SafePointScalarObjectNode(vec_box->box_type(), vec_box, first_ind, n_fields);
Node* sobj = new SafePointScalarObjectNode(vec_box->box_type(), vec_box, first_ind, sfpt->jvms()->depth(), n_fields);
sobj->init_req(0, C->root());
sfpt->add_req(vec_value);

Expand Down
12 changes: 12 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 @@ -36,6 +37,17 @@
* -XX:-TieredCompilation compiler.vectorapi.TestIntrinsicBailOut
*/

/*
* @test
* @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 6d911f6

@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.