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 ;
60
63
import com .oracle .truffle .api .nodes .ExplodeLoop ;
61
64
import com .oracle .truffle .api .source .Source ;
62
65
import com .oracle .truffle .api .source .SourceSection ;
63
- import com .oracle .truffle .espresso .EspressoLanguage ;
64
66
import com .oracle .truffle .espresso .EspressoOptions ;
65
67
import com .oracle .truffle .espresso .analysis .frame .EspressoFrameDescriptor ;
66
68
import com .oracle .truffle .espresso .analysis .frame .FrameAnalysis ;
99
101
import com .oracle .truffle .espresso .meta .ModifiersProvider ;
100
102
import com .oracle .truffle .espresso .nodes .EspressoRootNode ;
101
103
import com .oracle .truffle .espresso .nodes .interop .AbstractLookupNode ;
104
+ import com .oracle .truffle .espresso .nodes .methodhandle .MHInvokeGenericNode .MethodHandleInvoker ;
102
105
import com .oracle .truffle .espresso .nodes .methodhandle .MethodHandleIntrinsicNode ;
103
106
import com .oracle .truffle .espresso .runtime .Attribute ;
104
107
import com .oracle .truffle .espresso .runtime .EspressoContext ;
@@ -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,12 +817,23 @@ 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
- public MethodHandleIntrinsicNode spawnIntrinsicNode (EspressoLanguage language , Meta meta , ObjectKlass accessingKlass , Symbol < Name > mname , Symbol < Signature > signature ) {
834
+ public MethodHandleIntrinsicNode spawnIntrinsicNode (MethodHandleInvoker invoker ) {
820
835
assert isPolySignatureIntrinsic ();
821
- return MethodHandleIntrinsics .createIntrinsicNode (language , meta , this , accessingKlass , mname , signature );
836
+ return MethodHandleIntrinsics .createIntrinsicNode (getMeta (), this , invoker );
822
837
}
823
838
824
839
public Method forceSplit () {
@@ -1543,7 +1558,7 @@ public String getGenericSignatureAsString() {
1543
1558
1544
1559
@ Override
1545
1560
public int getModifiers () {
1546
- return linkedMethod . getFlags ();
1561
+ return getMethod (). getModifiers ();
1547
1562
}
1548
1563
1549
1564
@ Override
0 commit comments