|
22 | 22 | */
|
23 | 23 | package com.oracle.truffle.espresso.nodes;
|
24 | 24 |
|
| 25 | +import java.util.ArrayList; |
| 26 | +import java.util.HashMap; |
| 27 | + |
25 | 28 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
26 | 29 | import com.oracle.truffle.api.frame.Frame;
|
27 | 30 | import com.oracle.truffle.api.frame.MaterializedFrame;
|
|
35 | 38 | import com.oracle.truffle.api.library.ExportMessage;
|
36 | 39 | import com.oracle.truffle.api.source.SourceSection;
|
37 | 40 | import com.oracle.truffle.espresso.EspressoScope;
|
| 41 | +import com.oracle.truffle.espresso.classfile.attributes.Local; |
38 | 42 | import com.oracle.truffle.espresso.classfile.descriptors.ByteSequence;
|
39 | 43 | import com.oracle.truffle.espresso.classfile.descriptors.Signatures;
|
40 | 44 | import com.oracle.truffle.espresso.classfile.descriptors.Symbol;
|
41 | 45 | import com.oracle.truffle.espresso.classfile.descriptors.Symbol.Name;
|
42 | 46 | import com.oracle.truffle.espresso.classfile.descriptors.Symbol.Type;
|
43 | 47 | import com.oracle.truffle.espresso.impl.Method;
|
44 |
| -import com.oracle.truffle.espresso.classfile.attributes.Local; |
45 | 48 | import com.oracle.truffle.espresso.vm.continuation.UnwindContinuationException;
|
46 | 49 |
|
47 |
| -import java.util.ArrayList; |
48 |
| -import java.util.HashMap; |
49 |
| - |
50 | 50 | @GenerateWrapper(yieldExceptions = UnwindContinuationException.class, resumeMethodPrefix = "resumeContinuation")
|
51 | 51 | @ExportLibrary(NodeLibrary.class)
|
52 | 52 | abstract class AbstractInstrumentableBytecodeNode extends EspressoInstrumentableNode {
|
@@ -83,14 +83,15 @@ public final boolean hasScope(@SuppressWarnings("unused") Frame frame) {
|
83 | 83 |
|
84 | 84 | @ExportMessage
|
85 | 85 | public final Object getScope(Frame frame, @SuppressWarnings("unused") boolean nodeEnter) {
|
86 |
| - return getScopeSlowPath(frame != null ? frame.materialize() : null); |
| 86 | + return getScopeSlowPath(frame != null ? frame.materialize() : null, getMethod(), getBci(frame)); |
87 | 87 | }
|
88 | 88 |
|
89 | 89 | @TruffleBoundary
|
90 |
| - private Object getScopeSlowPath(MaterializedFrame frame) { |
91 |
| - // construct the current scope with valid local variables information |
92 |
| - Method method = getMethodVersion().getMethod(); |
93 |
| - Local[] liveLocals = method.getLocalVariableTable().getLocalsAt(getBci(frame)); |
| 90 | + private static Object getScopeSlowPath(MaterializedFrame frame, Method method, int bci) { |
| 91 | + // NOTE: this might be called while the thread is not entered into the context so |
| 92 | + // don't use things like a LanguageReference |
| 93 | + // Construct the current scope with valid local variables information |
| 94 | + Local[] liveLocals = method.getLocalVariableTable().getLocalsAt(bci); |
94 | 95 | boolean allParamsIncluded = checkLocals(liveLocals, method);
|
95 | 96 | if (!allParamsIncluded) {
|
96 | 97 | ArrayList<Local> constructedLiveLocals = new ArrayList<>();
|
@@ -120,7 +121,7 @@ private Object getScopeSlowPath(MaterializedFrame frame) {
|
120 | 121 | for (int i = startslot; i < localCount; i++) {
|
121 | 122 | Symbol<Type> paramType = hasReceiver ? Signatures.parameterType(parsedSignature, i - 1) : Signatures.parameterType(parsedSignature, i);
|
122 | 123 | if (!slotToLocal.containsKey(i)) {
|
123 |
| - Symbol<Name> localName = getLanguage().getNames().getOrCreate(ByteSequence.create("arg_" + i)); |
| 124 | + Symbol<Name> localName = method.getLanguage().getNames().getOrCreate(ByteSequence.create("arg_" + i)); |
124 | 125 | constructedLiveLocals.add(new Local(localName, paramType, null, 0, 0xffff, i));
|
125 | 126 | slotToLocal.remove(i);
|
126 | 127 | }
|
|
0 commit comments