Skip to content

Commit c45fa41

Browse files
Minor cleanups and documentation changes.
1 parent 300f96c commit c45fa41

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/ObjectHeaderImpl.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public final class ObjectHeaderImpl extends ObjectHeader {
9090
numAlignmentBits = CodeUtil.log2(ConfigurationValues.getObjectLayout().getAlignment());
9191
int numMinimumReservedBits = 3;
9292
VMError.guarantee(numMinimumReservedBits <= numAlignmentBits, "Minimum set of reserved bits must be provided by object alignment");
93-
if (isIdentityHasFieldOptional()) {
93+
if (isIdentityHashFieldOptional()) {
9494
VMError.guarantee(ReferenceAccess.singleton().haveCompressedReferences(), "Ensures hubs (at the start of the image heap) remain addressable");
9595
numReservedBits = numMinimumReservedBits + 2;
9696
VMError.guarantee(numReservedBits <= numAlignmentBits || hasShift(),
@@ -160,9 +160,9 @@ public void initializeHeaderOfNewObject(Pointer objectPointer, Word encodedHub,
160160
@Override
161161
public boolean hasOptionalIdentityHashField(Word header) {
162162
if (GraalDirectives.inIntrinsic()) {
163-
ReplacementsUtil.staticAssert(isIdentityHasFieldOptional(), "use only when hashcode fields are optional");
163+
ReplacementsUtil.staticAssert(isIdentityHashFieldOptional(), "use only when hashcode fields are optional");
164164
} else {
165-
VMError.guarantee(isIdentityHasFieldOptional(), "use only when hashcode fields are optional");
165+
VMError.guarantee(isIdentityHashFieldOptional(), "use only when hashcode fields are optional");
166166
}
167167

168168
UnsignedWord inFieldState = IDHASH_STATE_IN_FIELD.shiftLeft(IDHASH_STATE_SHIFT);
@@ -172,7 +172,7 @@ public boolean hasOptionalIdentityHashField(Word header) {
172172
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
173173
void setIdentityHashInField(Object o) {
174174
assert VMOperation.isGCInProgress();
175-
VMError.guarantee(isIdentityHasFieldOptional());
175+
VMError.guarantee(isIdentityHashFieldOptional());
176176
UnsignedWord oldHeader = readHeaderFromObject(o);
177177
UnsignedWord inFieldState = IDHASH_STATE_IN_FIELD.shiftLeft(IDHASH_STATE_SHIFT);
178178
UnsignedWord newHeader = oldHeader.and(IDHASH_STATE_BITS.not()).or(inFieldState);
@@ -198,9 +198,9 @@ void setIdentityHashInField(Object o) {
198198
@Override
199199
public void setIdentityHashFromAddress(Pointer ptr, Word currentHeader) {
200200
if (GraalDirectives.inIntrinsic()) {
201-
ReplacementsUtil.staticAssert(isIdentityHasFieldOptional(), "use only when hashcode fields are optional");
201+
ReplacementsUtil.staticAssert(isIdentityHashFieldOptional(), "use only when hashcode fields are optional");
202202
} else {
203-
assert isIdentityHasFieldOptional() : "use only when hashcode fields are optional";
203+
assert isIdentityHashFieldOptional() : "use only when hashcode fields are optional";
204204
assert !hasIdentityHashFromAddress(currentHeader) : "must not already have a hashcode";
205205
}
206206

@@ -222,9 +222,9 @@ public boolean hasIdentityHashFromAddress(Word header) {
222222
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
223223
static boolean hasIdentityHashFromAddressInline(Word header) {
224224
if (GraalDirectives.inIntrinsic()) {
225-
ReplacementsUtil.staticAssert(isIdentityHasFieldOptional(), "use only when hashcode fields are optional");
225+
ReplacementsUtil.staticAssert(isIdentityHashFieldOptional(), "use only when hashcode fields are optional");
226226
} else {
227-
assert isIdentityHasFieldOptional();
227+
assert isIdentityHashFieldOptional();
228228
}
229229

230230
UnsignedWord fromAddressState = IDHASH_STATE_FROM_ADDRESS.shiftLeft(IDHASH_STATE_SHIFT);
@@ -317,7 +317,7 @@ public long encodeAsImageHeapObjectHeader(ImageHeapObject obj, long hubOffsetFro
317317
assert obj.getPartition() instanceof FillerObjectDummyPartition;
318318
}
319319
}
320-
if (isIdentityHasFieldOptional()) {
320+
if (isIdentityHashFieldOptional()) {
321321
header |= (IDHASH_STATE_IN_FIELD.rawValue() << IDHASH_STATE_SHIFT);
322322
}
323323
return header;
@@ -435,7 +435,7 @@ static boolean hasShift() {
435435
}
436436

437437
@Fold
438-
static boolean isIdentityHasFieldOptional() {
438+
static boolean isIdentityHashFieldOptional() {
439439
return ConfigurationValues.getObjectLayout().isIdentityHashFieldOptional();
440440
}
441441
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/config/ObjectLayout.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@
4949
* {@link #isIdentityHashFieldInObjectHeader()}).</li>
5050
* <li>At a type specific offset, potentially outside the object header (see
5151
* {@link #isIdentityHashFieldAtTypeSpecificOffset()}).</li>
52-
* <li>Outside the object header, at a type and object state specific offset (see
53-
* {@link #isIdentityHashFieldOptional()}).</li>
52+
* <li>Outside the object header, at a type- or object-specific offset (see
53+
* {@link #isIdentityHashFieldOptional()}). Note that the field is not part of every object. When an
54+
* object needs the field, the object is resized during garbage collection to accommodate the
55+
* field.</li>
5456
* </ol>
5557
*/
5658
public final class ObjectLayout {
@@ -72,7 +74,6 @@ public ObjectLayout(SubstrateTargetDescription target, int referenceSize, int ob
7274
assert CodeUtil.isPowerOf2(objectAlignment) : objectAlignment;
7375
assert arrayLengthOffset % Integer.BYTES == 0;
7476
assert hubOffset < firstFieldOffset && hubOffset < arrayLengthOffset : hubOffset;
75-
assert identityHashMode == IdentityHashMode.OBJECT_HEADER || identityHashMode == IdentityHashMode.TYPE_SPECIFIC || identityHashMode == IdentityHashMode.OPTIONAL;
7677
assert (identityHashMode != IdentityHashMode.OPTIONAL && headerIdentityHashOffset > 0 && headerIdentityHashOffset < arrayLengthOffset && headerIdentityHashOffset % Integer.BYTES == 0) ||
7778
(identityHashMode == IdentityHashMode.OPTIONAL && headerIdentityHashOffset == -1);
7879

@@ -257,7 +258,7 @@ public enum IdentityHashMode {
257258
OBJECT_HEADER(0),
258259
/* At a type-specific offset (potentially outside the object header). */
259260
TYPE_SPECIFIC(1),
260-
/* At a type and object-state specific offset (outside the object header). */
261+
/* At a type- or object-specific offset (outside the object header). */
261262
OPTIONAL(2);
262263

263264
final int value;

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ public int getMonitorOffset() {
632632
/**
633633
* If possible, use {@link LayoutEncoding#getIdentityHashOffset(Object)} instead. If the hash
634634
* code field is optional, note that this method may return an offset that is outside the bounds
635-
* of a freshly the object.
635+
* of a newly allocated object.
636636
*/
637637
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
638638
public int getIdentityHashOffset() {

0 commit comments

Comments
 (0)