Skip to content

Commit 7197c2a

Browse files
committed
make isMemberReadable complaint with readMember and use the method string name as toDisplayString for the scope
1 parent 44af4ac commit 7197c2a

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/SubstitutionScope.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
*/
2323
package com.oracle.truffle.espresso.nodes;
2424

25-
import com.oracle.truffle.api.CompilerDirectives;
2625
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
2726
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
2827
import com.oracle.truffle.api.TruffleLanguage;
@@ -42,7 +41,7 @@
4241
final class SubstitutionScope implements TruffleObject {
4342
@CompilationFinal(dimensions = 1) private final Object[] args;
4443
private final Method method;
45-
@CompilationFinal(dimensions = 1) private String[] paramNames;
44+
private String[] paramNames;
4645

4746
SubstitutionScope(Object[] arguments, Method.MethodVersion method) {
4847
this.args = arguments;
@@ -88,7 +87,6 @@ Object readMember(String member) throws UnknownIdentifierException {
8887
// so this branch should rarely be taken.
8988
String[] names = paramNames;
9089
if (names == null) {
91-
CompilerDirectives.transferToInterpreterAndInvalidate();
9290
names = paramNames = fetchNames();
9391
}
9492
for (int i = 0; i < names.length; i++) {
@@ -140,19 +138,32 @@ Object getMembers(@SuppressWarnings("unused") boolean includeInternal) throws Un
140138
}
141139

142140
@ExportMessage
143-
boolean isMemberReadable(@SuppressWarnings("unused") String member) {
141+
@TruffleBoundary
142+
boolean isMemberReadable(String member) {
144143
try {
145144
int index = Integer.parseInt(member);
146145
return 0 <= index && index < args.length;
147146
} catch (NumberFormatException e) {
147+
// OK, see if we have parameter names as a fallback.
148+
// The main use case which is JDWP doesn't use anything but slots,
149+
// so this branch should rarely be taken.
150+
String[] names = paramNames;
151+
if (names == null) {
152+
names = paramNames = fetchNames();
153+
}
154+
for (String name : names) {
155+
if (name.equals(member)) {
156+
return true;
157+
}
158+
}
148159
return false;
149160
}
150161
}
151162

152163
@ExportMessage
153164
@SuppressWarnings("static-method")
154165
Object toDisplayString(@SuppressWarnings("unused") boolean allowSideEffects) {
155-
return "<intrinsified>";
166+
return method.getNameAsString();
156167
}
157168

158169
}

0 commit comments

Comments
 (0)