Skip to content
Permalink
Browse files
[lworld] clean up VarHandle support for inline type
  • Loading branch information
Mandy Chung committed Aug 10, 2020
1 parent 59d8f6b commit 67a019a56d4770bad226e400c228181330400c02
Showing with 2 additions and 48 deletions.
  1. +2 −48 src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java
@@ -113,13 +113,11 @@ static DirectMethodHandle make(byte refKind, Class<?> refc, MemberName member, C
if (member.isStatic()) {
long offset = MethodHandleNatives.staticFieldOffset(member);
Object base = MethodHandleNatives.staticFieldBase(member);
return member.isInlineableField() ? new InlineStaticAccessor(mtype, lform, member, true, base, offset)
: new StaticAccessor(mtype, lform, member, true, base, offset);
return new StaticAccessor(mtype, lform, member, true, base, offset);
} else {
long offset = MethodHandleNatives.objectFieldOffset(member);
assert(offset == (int)offset);
return member.isInlineableField() ? new InlineAccessor(mtype, lform, member, true, (int)offset)
: new Accessor(mtype, lform, member, true, (int)offset);
return new Accessor(mtype, lform, member, true, (int)offset);
}
}
}
@@ -546,27 +544,6 @@ MethodHandle viewAsType(MethodType newType, boolean strict) {
}
}

/** This subclass handles non-static field references of inline type */
static class InlineAccessor extends Accessor {
private InlineAccessor(MethodType mtype, LambdaForm form, MemberName member,
boolean crackable, int fieldOffset) {
super(mtype, form, member, crackable, fieldOffset);
}

@Override Object checkCast(Object obj) {
return fieldType.cast(Objects.requireNonNull(obj));
}
@Override
MethodHandle copyWith(MethodType mt, LambdaForm lf) {
return new InlineAccessor(mt, lf, member, crackable, fieldOffset);
}
@Override
MethodHandle viewAsType(MethodType newType, boolean strict) {
assert(viewAsTypeChecks(newType, strict));
return new InlineAccessor(newType, form, member, false, fieldOffset);
}
}

@ForceInline
/*non-public*/
static long fieldOffset(Object accessorObj) {
@@ -615,29 +592,6 @@ MethodHandle viewAsType(MethodType newType, boolean strict) {
}
}

/** This subclass handles static field references of inline type . */
static class InlineStaticAccessor extends StaticAccessor {
private InlineStaticAccessor(MethodType mtype, LambdaForm form, MemberName member,
boolean crackable, Object staticBase, long staticOffset) {
super(mtype, form, member, crackable, staticBase, staticOffset);
}

// zero-default inline type is not-nullable
@Override Object checkCast(Object obj) {
assert fieldType.isInlineClass() : "null-default inline type not yet supported";
return fieldType.cast(Objects.requireNonNull(obj));
}
@Override
MethodHandle copyWith(MethodType mt, LambdaForm lf) {
return new InlineStaticAccessor(mt, lf, member, crackable, staticBase, staticOffset);
}
@Override
MethodHandle viewAsType(MethodType newType, boolean strict) {
assert(viewAsTypeChecks(newType, strict));
return new InlineStaticAccessor(newType, form, member, false, staticBase, staticOffset);
}
}

@ForceInline
/*non-public*/
static Object nullCheck(Object obj) {

0 comments on commit 67a019a

Please sign in to comment.