Skip to content

Commit

Permalink
Improve primitive logging
Browse files Browse the repository at this point in the history
- Log missing primitives on fine level and enable during testing
- Log failed primitives on finer level
- Ignore marker primitives (19, 198, 199)
  • Loading branch information
fniephaus committed Oct 24, 2021
1 parent d6d116e commit 8fc5486
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017-2021 Software Architecture Group, Hasso Plattner Institute
* Copyright (c) 2021 Oracle and/or its affiliates
*
* Licensed under the MIT License.
*/
Expand Down Expand Up @@ -135,6 +136,8 @@ protected static SqueakImage loadImageContext(final String imagePath) {
contextBuilder.option("log." + SqueakLanguageConfig.ID + ".level", logLevel);
contextBuilder.logHandler(LogHandlerAccessor.createLogHandler(System.getProperty("log.mode", "out")));
}
contextBuilder.option(// Log missing primitives
"log." + SqueakLanguageConfig.ID + ".primitives.level", "FINE");
context = contextBuilder.build();
context.initialize(SqueakLanguageConfig.ID);
context.enter();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017-2021 Software Architecture Group, Hasso Plattner Institute
* Copyright (c) 2021 Oracle and/or its affiliates
*
* Licensed under the MIT License.
*/
Expand Down Expand Up @@ -452,11 +453,11 @@ public boolean isQuickPushPrimitive() {
}

public boolean isUnwindMarked() {
return hasPrimitive() && primitiveIndex() == 198;
return hasPrimitive() && primitiveIndex() == PrimitiveNodeFactory.PRIMITIVE_ENSURE_MARKER_INDEX;
}

public boolean isExceptionHandlerMarked() {
return hasPrimitive() && primitiveIndex() == 199;
return hasPrimitive() && primitiveIndex() == PrimitiveNodeFactory.PRIMITIVE_ON_DO_MARKER_INDEX;
}

public CompiledCodeObject shallowCopy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*/
package de.hpi.swa.trufflesqueak.nodes;

import java.util.function.Supplier;

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
Expand Down Expand Up @@ -53,13 +51,14 @@ public ExecuteBytecodeNode(final CompiledCodeObject code) {
if (code.hasPrimitive()) {
primitiveNode = PrimitiveNodeFactory.forIndex(code, false, code.primitiveIndex(), false);
if (primitiveNode == null) {
final Supplier<String> messageSupplier;
if (code.primitiveIndex() == PrimitiveNodeFactory.PRIMITIVE_EXTERNAL_CALL_INDEX) {
messageSupplier = () -> "Named primitive not found for " + code;
} else {
messageSupplier = () -> "Primitive #" + code.primitiveIndex() + " not found for " + code;
final int primitiveIndex = code.primitiveIndex();
if (primitiveIndex == PrimitiveNodeFactory.PRIMITIVE_EXTERNAL_CALL_INDEX) {
LogUtils.PRIMITIVES.fine(() -> "Named primitive not found for " + code);
} else if (primitiveIndex != PrimitiveNodeFactory.PRIMITIVE_SIMULATION_GUARD_INDEX &&
primitiveIndex != PrimitiveNodeFactory.PRIMITIVE_ENSURE_MARKER_INDEX &&
primitiveIndex != PrimitiveNodeFactory.PRIMITIVE_ON_DO_MARKER_INDEX) {
LogUtils.PRIMITIVES.fine(() -> "Primitive #" + code.primitiveIndex() + " not found for " + code);
}
LogUtils.PRIMITIVES.warning(messageSupplier);
}
}
}
Expand All @@ -74,7 +73,7 @@ public Object execute(final VirtualFrame frame, final int startPC) {
} catch (final PrimitiveFailed e) {
/* getHandlePrimitiveFailedNode() also acts as a BranchProfile. */
getHandlePrimitiveFailedNode().executeHandle(frame, e.getReasonCode());
LogUtils.PRIMITIVES.fine(() -> primitiveNode.getClass().getSimpleName() + " failed (arguments: " +
LogUtils.PRIMITIVES.finer(() -> primitiveNode.getClass().getSimpleName() + " failed (arguments: " +
ArrayUtils.toJoinedString(", ", FrameAccess.getReceiverAndArguments(frame)) + ")");
/* continue with fallback code. */
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@
import de.hpi.swa.trufflesqueak.util.OS;

public final class PrimitiveNodeFactory {
public static final int PRIMITIVE_SIMULATION_GUARD_INDEX = 19;
public static final int PRIMITIVE_EXTERNAL_CALL_INDEX = 117;
public static final int PRIMITIVE_ENSURE_MARKER_INDEX = 198;
public static final int PRIMITIVE_ON_DO_MARKER_INDEX = 199;
public static final int PRIMITIVE_LOAD_INST_VAR_LOWER_INDEX = 264;
public static final int PRIMITIVE_LOAD_INST_VAR_UPPER_INDEX = 520;
private static final int MAX_PRIMITIVE_INDEX = 575;
Expand Down

0 comments on commit 8fc5486

Please sign in to comment.