Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
9f220f4
8327012
eme64 Mar 13, 2024
5f8e5bf
test4
eme64 Mar 13, 2024
5041f64
initializing store capturing: test stub
eme64 Apr 24, 2024
dfa5da2
more tests, WIP
eme64 Apr 25, 2024
125f970
fix & extra tests
rwestrel Mar 19, 2025
71fd831
whitespace
rwestrel Apr 10, 2025
a4031f3
TestIterativeEA fix
rwestrel Apr 10, 2025
c32e453
Update test/hotspot/jtreg/compiler/macronodes/TestEliminationOfAlloca…
rwestrel Apr 24, 2025
082dcb5
Update src/hotspot/share/opto/multnode.hpp
rwestrel Apr 24, 2025
7139deb
Update src/hotspot/share/opto/escape.cpp
rwestrel Apr 24, 2025
469d8a5
Update src/hotspot/share/opto/multnode.hpp
rwestrel Apr 24, 2025
1639264
Update test/hotspot/jtreg/compiler/macronodes/TestInitializingStoreCa…
rwestrel Apr 24, 2025
377a8d7
Update test/hotspot/jtreg/compiler/macronodes/TestEliminationOfAlloca…
rwestrel Apr 24, 2025
a32b1d2
Update src/hotspot/share/opto/escape.cpp
rwestrel Apr 24, 2025
7afc47e
Update src/hotspot/share/opto/escape.cpp
rwestrel Apr 24, 2025
17517ae
review
rwestrel Apr 24, 2025
f22471c
review
rwestrel Apr 24, 2025
a401bed
review
rwestrel Apr 25, 2025
624d69e
review
rwestrel Apr 25, 2025
6134c97
review
rwestrel May 5, 2025
6a01123
more
rwestrel May 9, 2025
a76430b
more
rwestrel May 9, 2025
9f3b9cf
more
rwestrel May 12, 2025
02b43b7
more
rwestrel May 12, 2025
50e9437
more
rwestrel May 12, 2025
23035e0
more
rwestrel May 13, 2025
80d562a
more
rwestrel May 13, 2025
d5a2738
more
rwestrel May 14, 2025
af8480c
typo
rwestrel May 15, 2025
080638c
Merge branch 'master' into JDK-8327963
rwestrel May 15, 2025
616678f
Merge branch 'master' into JDK-8327963
rwestrel May 21, 2025
2a451c6
new test
rwestrel May 21, 2025
a6c6c04
new test tweak
rwestrel May 21, 2025
43c6f82
review
rwestrel May 22, 2025
c0a8ad2
Update src/hotspot/share/opto/library_call.cpp
rwestrel Jun 3, 2025
4b656f2
Merge branch 'master' into JDK-8327963
rwestrel Jun 3, 2025
24ff0e2
lambda clean up
rwestrel Jun 3, 2025
c189a7a
lambda return
rwestrel Jun 3, 2025
69c6e50
more
rwestrel Jun 4, 2025
3b5b54a
more
rwestrel Jun 5, 2025
ec9f278
Merge branch 'master' into JDK-8327963
rwestrel Aug 26, 2025
f528ce8
more
rwestrel Aug 27, 2025
fc13578
more
rwestrel Aug 28, 2025
b066f3c
Merge branch 'master' into JDK-8327963
rwestrel Sep 9, 2025
b701d03
more
rwestrel Sep 9, 2025
c64d68c
Update test/hotspot/jtreg/compiler/macronodes/TestEliminationOfAlloca…
rwestrel Sep 22, 2025
0ff5c45
Update src/hotspot/share/opto/multnode.hpp
rwestrel Sep 22, 2025
46972dc
Update src/hotspot/share/opto/multnode.hpp
rwestrel Sep 22, 2025
917ea91
Update src/hotspot/share/opto/graphKit.cpp
rwestrel Sep 22, 2025
2207487
Update src/hotspot/share/opto/graphKit.cpp
rwestrel Sep 22, 2025
f871390
Update src/hotspot/share/opto/macro.cpp
rwestrel Sep 22, 2025
6ea8c81
Update src/hotspot/share/opto/macro.cpp
rwestrel Sep 22, 2025
9fd8dc1
review
rwestrel Sep 22, 2025
f12efbc
Roberto's patches
rwestrel Sep 29, 2025
48257c9
review
rwestrel Sep 29, 2025
b5ac753
Merge branch 'master' into JDK-8327963
rwestrel Oct 28, 2025
957be06
review
rwestrel Oct 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/hotspot/share/opto/escape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ class ConnectionGraph: public ArenaObj {
// MemNode - new memory input for this node
// CheckCastPP - allocation that this is a cast of
// allocation - CheckCastPP of the allocation
// NarrowMem - newly created projection (type includes instance_id) from projection created
// before EA

// manage entries in _node_map

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/idealGraphPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ void IdealGraphPrinter::visit_node(Node* n, bool edges) {
t->dump_on(&s2);
} else if( t == Type::MEMORY ) {
s2.print(" Memory:");
MemNode::dump_adr_type(node, node->adr_type(), &s2);
MemNode::dump_adr_type(node->adr_type(), &s2);
}

assert(s2.size() < sizeof(buffer), "size in range");
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/opto/macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,7 @@ void PhaseMacroExpand::expand_initialize_membar(AllocateNode* alloc, InitializeN
// No InitializeNode or no stores captured by zeroing
// elimination. Simply add the MemBarStoreStore after object
// initialization.
// See comment below in this if's other branch that explains why a raw memory MemBar is good enough.
MemBarNode* mb = MemBarNode::make(C, Op_MemBarStoreStore, Compile::AliasIdxRaw);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the same argument as below apply for relaxing the scope of this memory barrier? Please clarify in a similar comment for this case (if the same argument applies, a reference to the comment below would be enough).

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding the comment. A follow-up question: the full comment below makes the argument that re-ordering by the compiler can't happen by construction because a later Store that publishes the just allocated object reference is indirectly control dependent on the Initialize node. However, in this case, there may be no such Initialize node (init == nullptr || init->req() < InitializeNode::RawStores). I assume the memory barrier relaxation is still OK in this scenario because we cannot have later, publishing stores of the allocated object reference? That is, if there exists such a store then there must necessarily exist an Initialize node? Or is there any other reason I am missing? It would be good to clarify this point in the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the comment. Can you have a look?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the clarification and the pointer to the comment in initialize_object, that helps.

transform_later(mb);

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/memnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void MemNode::dump_spec(outputStream *st) const {
if (in(Address) != nullptr)
_adr_type = in(Address)->bottom_type()->isa_ptr();
#endif
dump_adr_type(this, _adr_type, st);
dump_adr_type(_adr_type, st);

Compile* C = Compile::current();
if (C->alias_type(_adr_type)->is_volatile()) {
Expand All @@ -108,7 +108,7 @@ void MemNode::dump_spec(outputStream *st) const {
}
}

void MemNode::dump_adr_type(const Node* mem, const TypePtr* adr_type, outputStream *st) {
void MemNode::dump_adr_type(const TypePtr* adr_type, outputStream* st) {
st->print(" @");
if (adr_type == nullptr) {
st->print("null");
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/opto/memnode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class MemNode : public Node {
bool is_unsafe_access() const { return _unsafe_access; }

#ifndef PRODUCT
static void dump_adr_type(const Node* mem, const TypePtr* adr_type, outputStream *st);
static void dump_adr_type(const TypePtr* adr_type, outputStream* st);
virtual void dump_spec(outputStream *st) const;
#endif
};
Expand Down Expand Up @@ -1380,6 +1380,8 @@ class InitializeNode: public MemBarNode {
// Does a NarrowMemProj with this adr_type and this node as input already exist?
bool already_has_narrow_mem_proj_with_adr_type(const TypePtr* adr_type) const;

// Used during matching: find the MachProj memory projection if there's one. Expectation is that there should be at
// most one.
MachProjNode* mem_mach_proj() const;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a brief comment above this function, possibly clarifying that we do not expect to find more than one Mach memory projection.


private:
Expand Down
16 changes: 2 additions & 14 deletions src/hotspot/share/opto/multnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,25 +262,13 @@ ProjNode* ProjNode::other_if_proj() const {
}

#ifndef PRODUCT
void NarrowMemProjNode::dump_adr_type(outputStream* st) const {
st->print(" @"); _adr_type->dump_on(st);
Compile* C = Compile::current();
Compile::AliasType* atp = C->alias_type(_adr_type);
ciField* field = atp->field();
if (field != nullptr) {
st->print(", name=");
field->print_name_on(st);
}
st->print(", idx=%d;", atp->index());
}

void NarrowMemProjNode::dump_spec(outputStream *st) const {
ProjNode::dump_spec(st);
dump_adr_type(st);
MemNode::dump_adr_type(_adr_type, st);
}

void NarrowMemProjNode::dump_compact_spec(outputStream *st) const {
ProjNode::dump_compact_spec(st);
dump_adr_type(st);
MemNode::dump_adr_type(_adr_type, st);
}
#endif
1 change: 0 additions & 1 deletion src/hotspot/share/opto/multnode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ class NarrowMemProjNode : public ProjNode {
virtual int Opcode() const;

#ifndef PRODUCT
void dump_adr_type(outputStream* st) const;
virtual void dump_spec(outputStream *st) const;
virtual void dump_compact_spec(outputStream *st) const;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2591,7 +2591,7 @@ void Node::dump(const char* suffix, bool mark, outputStream* st, DumpConfig* dc)
t->dump_on(st);
} else if (t == Type::MEMORY) {
st->print(" Memory:");
MemNode::dump_adr_type(this, adr_type(), st);
MemNode::dump_adr_type(adr_type(), st);
} else if (Verbose || WizardMode) {
st->print(" Type:");
if (t) {
Expand Down
16 changes: 6 additions & 10 deletions src/hotspot/share/opto/phaseX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2592,15 +2592,15 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_
}
}
}
auto enqueue_init_mem_projs = [&](ProjNode* proj) {
add_users_to_worklist0(proj, worklist);
return MultiNode::CONTINUE;
};
Comment on lines 2595 to 2597
Copy link
Contributor

Choose a reason for hiding this comment

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

for_each call below would mean we would not need to return anything.

// If changed initialization activity, check dependent Stores
if (use_op == Op_Allocate || use_op == Op_AllocateArray) {
InitializeNode* init = use->as_Allocate()->initialization();
if (init != nullptr) {
auto enqueue = [&](ProjNode* proj) {
add_users_to_worklist0(proj, worklist);
return MultiNode::CONTINUE;
};
init->apply_to_projs(enqueue, TypeFunc::Memory);
init->apply_to_projs(enqueue_init_mem_projs, TypeFunc::Memory);
}
}
// If the ValidLengthTest input changes then the fallthrough path out of the AllocateArray may have become dead.
Expand All @@ -2615,11 +2615,7 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_

if (use_op == Op_Initialize) {
InitializeNode* init = use->as_Initialize();
auto enqueue = [&](ProjNode* proj) {
add_users_to_worklist0(proj, worklist);
return MultiNode::CONTINUE;
};
init->apply_to_projs(enqueue, TypeFunc::Memory);
init->apply_to_projs(enqueue_init_mem_projs, TypeFunc::Memory);
}
// Loading the java mirror from a Klass requires two loads and the type
// of the mirror load depends on the type of 'n'. See LoadNode::Value().
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a package declaration (and make the corresponding class names fully qualified in the @run directives).

Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
* @test
* @bug 8327963
* @summary C2: fix construction of memory graph around Initialize node to prevent incorrect execution if allocation is removed
* @run main/othervm -XX:-BackgroundCompilation TestEarlyEliminationOfAllocationWithoutUse
* @run main/othervm TestEarlyEliminationOfAllocationWithoutUse
* @run main/othervm -XX:-BackgroundCompilation compiler.macronodes.TestEarlyEliminationOfAllocationWithoutUse
* @run main/othervm compiler.macronodes.TestEarlyEliminationOfAllocationWithoutUse
*/

package compiler.macronodes;
import java.util.Arrays;

public class TestEarlyEliminationOfAllocationWithoutUse {
Expand Down