Skip to content

Commit

Permalink
[WIP] Try to remove builtin type caching in BuiltinObject
Browse files Browse the repository at this point in the history
Maybe this will fix the invalid polyglot layer sharing assertion errors.
  • Loading branch information
Akirathan committed Dec 16, 2024
1 parent 8feab15 commit 7510906
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Bind;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
Expand All @@ -27,8 +28,6 @@ public abstract class BuiltinObject extends EnsoObject {

private final String builtinName;

@CompilationFinal private Builtin cachedBuiltinType;

/**
* @param builtinName Simple name of the builtin that should be contained in {@link
* org.enso.interpreter.runtime.builtin.Builtins#builtinsByName}.
Expand All @@ -43,13 +42,11 @@ public final boolean hasType() {
}

@ExportMessage
@TruffleBoundary
public final Type getType(@Bind("$node") Node node) {
if (cachedBuiltinType == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
var ctx = EnsoContext.get(node);
cachedBuiltinType = ctx.getBuiltins().getBuiltinType(builtinName);
}
return cachedBuiltinType.getType();
var ctx = EnsoContext.get(node);
var builtinType = ctx.getBuiltins().getBuiltinType(builtinName);
return builtinType.getType();
}

/**
Expand All @@ -76,6 +73,7 @@ public final boolean hasMetaObject() {
}

@ExportMessage
@TruffleBoundary
public final Type getMetaObject(@Bind("$node") Node node) {
return getType(node);
}
Expand Down

0 comments on commit 7510906

Please sign in to comment.