29
29
import static com .oracle .truffle .espresso .bytecode .Bytecodes .PUTSTATIC ;
30
30
import static com .oracle .truffle .espresso .bytecode .Bytecodes .RETURN ;
31
31
import static com .oracle .truffle .espresso .classfile .Constants .ACC_CALLER_SENSITIVE ;
32
+ import static com .oracle .truffle .espresso .classfile .Constants .ACC_FINAL ;
32
33
import static com .oracle .truffle .espresso .classfile .Constants .ACC_FORCE_INLINE ;
33
34
import static com .oracle .truffle .espresso .classfile .Constants .ACC_HIDDEN ;
34
35
import static com .oracle .truffle .espresso .classfile .Constants .ACC_NATIVE ;
35
36
import static com .oracle .truffle .espresso .classfile .Constants .ACC_SCOPED ;
37
+ import static com .oracle .truffle .espresso .classfile .Constants .ACC_STATIC ;
38
+ import static com .oracle .truffle .espresso .classfile .Constants .ACC_SYNTHETIC ;
36
39
import static com .oracle .truffle .espresso .classfile .Constants .ACC_VARARGS ;
37
40
import static com .oracle .truffle .espresso .classfile .Constants .REF_invokeInterface ;
38
41
import static com .oracle .truffle .espresso .classfile .Constants .REF_invokeSpecial ;
@@ -128,9 +131,8 @@ public final class Method extends Member<Signature> implements TruffleObject, Co
128
131
private final Method proxy ;
129
132
private String genericSignature ;
130
133
131
- // always null unless the raw signature exposed for this method should be
132
- // different from the one in the linkedKlass
133
134
private final Symbol <Signature > rawSignature ;
135
+ private final int rawFlags ;
134
136
135
137
// the parts of the method that can change when it's redefined
136
138
// are encapsulated within the methodVersion
@@ -148,6 +150,7 @@ public final class Method extends Member<Signature> implements TruffleObject, Co
148
150
149
151
private Method (Method method , CodeAttribute split ) {
150
152
this .rawSignature = method .rawSignature ;
153
+ this .rawFlags = method .rawFlags ;
151
154
this .declaringKlass = method .declaringKlass ;
152
155
this .methodVersion = new MethodVersion (method .getMethodVersion ().klassVersion , method .getRuntimeConstantPool (), method .getLinkedMethod (),
153
156
method .getMethodVersion ().poisonPill , split );
@@ -166,12 +169,13 @@ private Method(Method method, CodeAttribute split) {
166
169
}
167
170
168
171
Method (ObjectKlass .KlassVersion klassVersion , LinkedMethod linkedMethod , RuntimeConstantPool pool ) {
169
- this (klassVersion , linkedMethod , linkedMethod .getRawSignature (), pool );
172
+ this (klassVersion , linkedMethod , linkedMethod .getRawSignature (), pool , linkedMethod . getFlags () );
170
173
}
171
174
172
- Method (ObjectKlass .KlassVersion klassVersion , LinkedMethod linkedMethod , Symbol <Signature > rawSignature , RuntimeConstantPool pool ) {
175
+ Method (ObjectKlass .KlassVersion klassVersion , LinkedMethod linkedMethod , Symbol <Signature > rawSignature , RuntimeConstantPool pool , int rawFlags ) {
173
176
this .declaringKlass = klassVersion .getKlass ();
174
177
this .rawSignature = rawSignature ;
178
+ this .rawFlags = rawFlags ;
175
179
this .methodVersion = new MethodVersion (klassVersion , pool , linkedMethod , false , (CodeAttribute ) linkedMethod .getAttribute (CodeAttribute .NAME ));
176
180
177
181
try {
@@ -522,7 +526,7 @@ public boolean isClassInitializer() {
522
526
523
527
@ Override
524
528
public int getModifiers () {
525
- return getMethodVersion (). getModifiers () ;
529
+ return rawFlags ;
526
530
}
527
531
528
532
public boolean isCallerSensitive () {
@@ -813,7 +817,18 @@ public int getCatchLocation(int bci, StaticObject ex) {
813
817
// Spawns a placeholder method for MH intrinsics
814
818
public Method createIntrinsic (Symbol <Signature > polymorphicRawSignature ) {
815
819
assert isPolySignatureIntrinsic ();
816
- return new Method (declaringKlass .getKlassVersion (), getLinkedMethod (), polymorphicRawSignature , getRuntimeConstantPool ());
820
+ int flags ;
821
+ MethodHandleIntrinsics .PolySigIntrinsics iid = MethodHandleIntrinsics .getId (this );
822
+ if (iid == MethodHandleIntrinsics .PolySigIntrinsics .InvokeGeneric ) {
823
+ flags = getModifiers () & ~ACC_VARARGS ;
824
+ } else {
825
+ flags = ACC_NATIVE | ACC_SYNTHETIC | ACC_FINAL ;
826
+ if (iid .isStaticPolymorphicSignature ()) {
827
+ flags |= ACC_STATIC ;
828
+ }
829
+ }
830
+ assert Modifier .isNative (flags );
831
+ return new Method (declaringKlass .getKlassVersion (), getLinkedMethod (), polymorphicRawSignature , getRuntimeConstantPool (), flags );
817
832
}
818
833
819
834
public MethodHandleIntrinsicNode spawnIntrinsicNode (EspressoLanguage language , Meta meta , ObjectKlass accessingKlass , Symbol <Name > mname , Symbol <Signature > signature ) {
@@ -1547,7 +1562,7 @@ public String getGenericSignatureAsString() {
1547
1562
1548
1563
@ Override
1549
1564
public int getModifiers () {
1550
- return linkedMethod . getFlags ();
1565
+ return getMethod (). getModifiers ();
1551
1566
}
1552
1567
1553
1568
@ Override
0 commit comments