Skip to content

Commit 506550e

Browse files
committed
Variant 2: Only final-field like semantics for stable inits
1 parent 0a255f7 commit 506550e

File tree

6 files changed

+12
-41
lines changed

6 files changed

+12
-41
lines changed

src/hotspot/share/c1/c1_LIRGenerator.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,18 +1677,7 @@ void LIRGenerator::do_StoreField(StoreField* x) {
16771677

16781678
DecoratorSet decorators = IN_HEAP;
16791679
if (is_volatile) {
1680-
// Volatile access, full SC.
16811680
decorators |= MO_SEQ_CST;
1682-
} else if (x->field()->is_stable() && !x->field()->is_final() &&
1683-
is_reference_type(field_type)) {
1684-
// For reference @Stable fields, make sure we publish the contents
1685-
// safely. We need this to make sure compilers see a proper value when
1686-
// constant folding the access. Final @Stable fields are already
1687-
// handled in constructors.
1688-
decorators |= MO_RELEASE;
1689-
} else {
1690-
// Everything else is unordered.
1691-
decorators |= MO_UNORDERED;
16921681
}
16931682
if (needs_patching) {
16941683
decorators |= C1_NEEDS_PATCHING;

src/hotspot/share/ci/ciInstance.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ ciConstant ciInstance::field_value_impl(BasicType field_btype, int offset) {
7878
case T_LONG: value = ciConstant(obj->long_field(offset)); break;
7979
case T_OBJECT: // fall through
8080
case T_ARRAY: {
81-
// In case we are reading the constant off a reference @Stable field,
82-
// we need to match the releasing store with this acquire. There is no easy
83-
// way to know this from the offset, but it should not hurt to ask this for
84-
// all reference fields.
85-
oop o = obj->obj_field_acquire(offset);
81+
oop o = obj->obj_field(offset);
8682

8783
// A field will be "constant" if it is known always to be
8884
// a non-null reference to an instance of a particular class,

src/hotspot/share/opto/parse3.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,21 +209,7 @@ void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
209209
Node* val = type2size[bt] == 1 ? pop() : pop_pair();
210210

211211
DecoratorSet decorators = IN_HEAP;
212-
213-
if (is_vol) {
214-
// Volatile access, full SC.
215-
decorators |= MO_SEQ_CST;
216-
} else if (field->is_stable() && !field->is_final() &&
217-
is_reference_type(field->layout_type())) {
218-
// For reference @Stable fields, make sure we publish the contents
219-
// safely. We need this to make sure compilers see a proper value when
220-
// constant folding the access. Final @Stable fields are already
221-
// handled in constructors.
222-
decorators |= MO_RELEASE;
223-
} else {
224-
// Everything else is unordered.
225-
decorators |= MO_UNORDERED;
226-
}
212+
decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
227213

228214
bool is_obj = is_reference_type(bt);
229215

test/hotspot/jtreg/compiler/c2/irTests/stable/StablePrimArrayTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,16 @@ static Carrier testConstructorFullInit() {
153153
}
154154

155155
@Test
156-
@IR(counts = { IRNode.MEMBAR_RELEASE, "1" })
156+
@IR(failOn = { IRNode.MEMBAR })
157157
static void testMethodEmptyInit() {
158-
// Reference inits have release membars.
158+
// Reference inits do not have membars.
159159
INIT_EMPTY_CARRIER.initEmpty();
160160
}
161161

162162
@Test
163-
@IR(counts = { IRNode.MEMBAR_RELEASE, "1" })
163+
@IR(failOn = { IRNode.MEMBAR })
164164
static void testMethodFullInit() {
165-
// Reference inits have release membars.
165+
// Reference inits do not have membars.
166166
INIT_FULL_CARRIER.initFull();
167167
}
168168

test/hotspot/jtreg/compiler/c2/irTests/stable/StableRefArrayTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,16 @@ static Carrier testConstructorFullInit() {
162162
}
163163

164164
@Test
165-
@IR(counts = { IRNode.MEMBAR_RELEASE, "1" })
165+
@IR(failOn = { IRNode.MEMBAR })
166166
static void testMethodEmptyInit() {
167-
// Reference inits have release membars.
167+
// Reference inits do not have membars.
168168
INIT_EMPTY_CARRIER.initEmpty();
169169
}
170170

171171
@Test
172-
@IR(counts = { IRNode.MEMBAR_RELEASE, "1" })
172+
@IR(failOn = { IRNode.MEMBAR })
173173
static void testMethodFullInit() {
174-
// Reference inits have release membars.
174+
// Reference inits do not have membars.
175175
INIT_FULL_CARRIER.initFull();
176176
}
177177

test/hotspot/jtreg/compiler/c2/irTests/stable/StableRefPlainTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ static Carrier testConstructorFullInit() {
108108
}
109109

110110
@Test
111-
@IR(counts = { IRNode.MEMBAR_RELEASE, "1" })
111+
@IR(failOn = { IRNode.MEMBAR })
112112
static void testMethodInit() {
113-
// Reference inits have release membars.
113+
// Reference inits do not have membars.
114114
INIT_CARRIER.init();
115115
}
116116

0 commit comments

Comments
 (0)