Skip to content

Commit 24a9f45

Browse files
[GR-44212] [GR-44279] Assorted fixes for Espresso.
PullRequest: graal/13827
2 parents 792cb2a + 13b56f6 commit 24a9f45

File tree

9 files changed

+31
-9
lines changed

9 files changed

+31
-9
lines changed

espresso/mx.espresso/suite.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@
186186
"truffle:TRUFFLE_API",
187187
"truffle:TRUFFLE_NFI",
188188
],
189+
"requires": [
190+
"java.logging",
191+
],
189192
"annotationProcessors": ["truffle:TRUFFLE_DSL_PROCESSOR"],
190193
"javaCompliance" : "17+",
191194
"checkstyle": "com.oracle.truffle.espresso.jdwp",

espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/api/CallFrame.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,15 @@ public RootNode getRootNode() {
114114

115115
public Object getThisValue() {
116116
Object theScope = getScope();
117+
if (theScope == null) {
118+
return null;
119+
}
117120
try {
118-
return theScope != null ? INTEROP.readMember(theScope, "this") : null;
121+
// See com.oracle.truffle.espresso.EspressoScope.createVariables
122+
if (INTEROP.isMemberReadable(theScope, "this")) {
123+
return INTEROP.readMember(theScope, "this");
124+
}
125+
return INTEROP.readMember(theScope, "0");
119126
} catch (UnsupportedMessageException | UnknownIdentifierException e) {
120127
if (controller != null) {
121128
controller.warning(() -> "Unable to read 'this' value from method: " + getMethod() + " with currentNode: " + currentNode.getClass());

espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/DebuggerConnection.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,7 @@ private void processPacket(Packet packet) {
604604
}
605605
handleReply(packet, result);
606606
} catch (Throwable t) {
607-
// Checkstyle: stop allow error output
608-
System.out.println("[internal error]: " + t.getMessage());
609-
t.printStackTrace();
610-
// Checkstyle: resume allow error output
607+
controller.severe("Internal error while processing packet", t);
611608
PacketStream reply = new PacketStream().replyPacket().id(packet.id);
612609
reply.errorCode(ErrorCodes.INTERNAL);
613610
handleReply(packet, new CommandResult(reply));

espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/DebuggerController.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.Map;
3232
import java.util.concurrent.Callable;
3333
import java.util.function.Supplier;
34+
import java.util.logging.Level;
3435
import java.util.regex.Pattern;
3536

3637
import com.oracle.truffle.api.CallTarget;
@@ -1084,6 +1085,10 @@ public void severe(Supplier<String> supplier) {
10841085
jdwpLogger.severe(supplier);
10851086
}
10861087

1088+
public void severe(String message, Throwable error) {
1089+
jdwpLogger.log(Level.SEVERE, message, error);
1090+
}
1091+
10871092
@Override
10881093
public void onContextCreated(@SuppressWarnings("unused") TruffleContext con) {
10891094

espresso/src/com.oracle.truffle.espresso.mokapot/include/mokapot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ typedef uint64_t julong;
6969
/* Usage of the JavaVM reserved fields:
7070
* vm type | MOKA_RISTRETTO | MOKA_LATTE | MOKA_AMERICANO |
7171
* ----------+----------------+---------------------+----------------+
72-
* reserved0 | NULL | LibJavaVMIsolate* | context handle |
72+
* reserved0 | NULL | LibJavaVMIsolate* | context handle |
7373
* reserved1 | MOKA_RISTRETTO | MOKA_LATTE | MOKA_AMERICANO |
7474
* reserved2 | NULL | JavaVM* (americano) | JavaVM* (latte)|
7575
*/

espresso/src/com.oracle.truffle.espresso.mokapot/src/mokapot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,7 @@ jint DetachCurrentThread(JavaVM *vm) {
19271927

19281928
jint GetEnv(JavaVM *vm, void **penv, jint version) {
19291929
if ((*vm)->reserved1 != MOKA_LATTE) {
1930-
fprintf(stderr, "AttachCurrentThread: not a MOKA_LATTE" OS_NEWLINE_STR);
1930+
fprintf(stderr, "GetEnv: not a MOKA_LATTE" OS_NEWLINE_STR);
19311931
return JNI_ERR;
19321932
}
19331933
JavaVM *espressoJavaVM = (*vm)->reserved2;

espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/Klass.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,12 +1445,16 @@ public final int getModifiers(EspressoContext context) {
14451445
if (this instanceof ObjectKlass && context.advancedRedefinitionEnabled()) {
14461446
// getKlassVersion().getModifiers() introduces a ~10%
14471447
// perf hit on some benchmarks, so put behind a check
1448-
return this.getClassModifiers();
1448+
return getRedefinitionAwareModifiers();
14491449
} else {
14501450
return modifiers;
14511451
}
14521452
}
14531453

1454+
public int getRedefinitionAwareModifiers() {
1455+
return getModifiers();
1456+
}
1457+
14541458
/**
14551459
* Returns the modifiers for the guest Class, it takes into account inner classes which are
14561460
* public at the JVM level, but protected/private at the Java level.

espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/ObjectKlass.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,11 @@ public int getClassModifiers() {
12851285
return getKlassVersion().getClassModifiers();
12861286
}
12871287

1288+
@Override
1289+
public int getRedefinitionAwareModifiers() {
1290+
return getKlassVersion().getModifiers();
1291+
}
1292+
12881293
@Override
12891294
public Klass[] getSuperTypes() {
12901295
return getKlassVersion().getSuperTypes();
@@ -1888,6 +1893,7 @@ public int getClassModifiers() {
18881893
if (flags == -1) {
18891894
CompilerDirectives.transferToInterpreterAndInvalidate();
18901895
computedModifiers = flags = computeModifiers();
1896+
assert flags != -1;
18911897
}
18921898
// Remember to strip ACC_SUPER bit
18931899
return flags & ~ACC_SUPER & JVM_ACC_WRITTEN_FLAGS;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private Object getScopeSlowPath(MaterializedFrame frame) {
9595
localCount += method.getParameterCount();
9696

9797
Klass[] parameters = (Klass[]) method.getParameters();
98-
Utf8ConstantTable utf8Constants = getContext().getLanguage().getUtf8ConstantTable();
98+
Utf8ConstantTable utf8Constants = method.getLanguage().getUtf8ConstantTable();
9999
int startslot = 0;
100100

101101
if (hasReceiver) {

0 commit comments

Comments
 (0)