diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-02-02 23:01:09 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-02-02 23:01:33 +0000 |
| commit | 96b78561204020df21703a5fe8922bf49dc6e1f4 (patch) | |
| tree | 2a4d23304a5e3d128c5ad5128329bd57bdee9317 /src/main/java | |
| parent | 4fb0e6305743e265fec1b199210e77150b0216e1 (diff) | |
Store effect handler methods directly
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/shidtopatio/ShidToPatioEffects.java | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/src/main/java/org/shedlang/compiler/shidtopatio/ShidToPatioEffects.java b/src/main/java/org/shedlang/compiler/shidtopatio/ShidToPatioEffects.java index 8cf27d7d..648e62f1 100644 --- a/src/main/java/org/shedlang/compiler/shidtopatio/ShidToPatioEffects.java +++ b/src/main/java/org/shedlang/compiler/shidtopatio/ShidToPatioEffects.java @@ -100,7 +100,7 @@ public class ShidToPatioEffects { return ShidToPatioGc.gcObjectDataLayout(PatioDataLayouts.struct(List.of( PatioDataLayouts.fromType(EFFECT_HANDLER_TYPE), PatioDataLayouts.struct(Lists.repeat( - PatioDataLayouts.fromType(EFFECT_HANDLER_METHOD_POINTER_TYPE), + PatioDataLayouts.fromType(EFFECT_HANDLER_METHOD_TYPE), methodCount )) ))); @@ -118,6 +118,10 @@ public class ShidToPatioEffects { public int gcChildrenCount() { return methodCount; } + + public List<Integer> handlerMethodOffset(int handlerMethodIndex) { + return ShidToPatioGc.gcObjectOffset(List.of(1, handlerMethodIndex)); + } } private static final PatioFunctionDeclaration FIND_HANDLER_METHOD_DECLARATION = new PatioFunctionDeclaration( @@ -153,17 +157,6 @@ public class ShidToPatioEffects { Sources.RUNTIME ); - private static final PatioFunctionDeclaration SET_HANDLER_METHOD_DECLARATION = new PatioFunctionDeclaration( - "shed__runtime__effects_set_handler_method", - List.of( - PatioLocal.param("handler", EFFECT_HANDLER_TYPE), - PatioLocal.param("methodIndex", EFFECT_METHOD_INDEX_TYPE), - PatioLocal.param("handlerMethod", EFFECT_HANDLER_METHOD_TYPE) - ), - PatioTypes.VOID, - Sources.RUNTIME - ); - private static final PatioFunctionDeclaration POP_HANDLER_DECLARATION = new PatioFunctionDeclaration( "shed__runtime__effects_pop_handler", List.of(), @@ -347,7 +340,6 @@ public class ShidToPatioEffects { context = context .ensureCompilationUnitElement(PUSH_HANDLER_DECLARATION) - .ensureCompilationUnitElement(SET_HANDLER_METHOD_DECLARATION) .ensureCompilationUnitElement(POP_HANDLER_DECLARATION); var effectHandlerResult = context.allocateVal( @@ -376,14 +368,11 @@ public class ShidToPatioEffects { )); for (var handlerMethodInfo : effectInfo.methods()) { - context = context.addInstruction(new PatioCall( - Optional.empty(), - SET_HANDLER_METHOD_DECLARATION.name(), - List.of( - effectHandler, - PatioIntConst.of(handlerMethodInfo.fieldIndex()), - handlerMethodsByName.get(handlerMethodInfo.name()) - ), + context = context.addInstruction(new PatioMemoryStore( + effectHandler, + effectHandlerRuntimeType.layout(), + effectHandlerRuntimeType.handlerMethodOffset(handlerMethodInfo.fieldIndex()), + handlerMethodsByName.get(handlerMethodInfo.name()), source )); } |
