From ff4f5f8151145b24e1361370dce3aca50b197b8c Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Sun, 9 Jan 2022 20:48:28 +0100 Subject: [PATCH] temp variable are slots and not final indexes --- .../jwebassembly/module/WasmCodeBuilder.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/de/inetsoftware/jwebassembly/module/WasmCodeBuilder.java b/src/de/inetsoftware/jwebassembly/module/WasmCodeBuilder.java index ec2b786..dc8b853 100644 --- a/src/de/inetsoftware/jwebassembly/module/WasmCodeBuilder.java +++ b/src/de/inetsoftware/jwebassembly/module/WasmCodeBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 - 2021 Volker Berlin (i-net software) + * Copyright 2018 - 2022 Volker Berlin (i-net software) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -419,17 +419,17 @@ public abstract class WasmCodeBuilder { AnyType type1 = findValueTypeFromStack( 1, javaCodePos ); AnyType type2 = findValueTypeFromStack( 2, javaCodePos ); - int varIndex1 = getTempVariable( type1, javaCodePos, javaCodePos + 1 ); - int varIndex2 = getTempVariable( type2, javaCodePos, javaCodePos + 1 ); + int varSlot1 = getTempVariable( type1, javaCodePos, javaCodePos + 1 ); + int varSlot2 = getTempVariable( type2, javaCodePos, javaCodePos + 1 ); // save in temp variables - instructions.add( new WasmLocalInstruction( VariableOperator.set, varIndex1, localVariables, javaCodePos, lineNumber ) ); - instructions.add( new WasmLocalInstruction( VariableOperator.set, varIndex2, localVariables, javaCodePos, lineNumber ) ); + instructions.add( new WasmLoadStoreInstruction( VariableOperator.set, varSlot1, localVariables, javaCodePos, lineNumber ) ); + instructions.add( new WasmLoadStoreInstruction( VariableOperator.set, varSlot2, localVariables, javaCodePos, lineNumber ) ); // and restore it in new order on the stack - instructions.add( new WasmLocalInstruction( VariableOperator.get, varIndex1, localVariables, javaCodePos, lineNumber ) ); - instructions.add( new WasmLocalInstruction( VariableOperator.get, varIndex2, localVariables, javaCodePos, lineNumber ) ); - instructions.add( new WasmLocalInstruction( VariableOperator.get, varIndex1, localVariables, javaCodePos, lineNumber ) ); + instructions.add( new WasmLoadStoreInstruction( VariableOperator.get, varSlot1, localVariables, javaCodePos, lineNumber ) ); + instructions.add( new WasmLoadStoreInstruction( VariableOperator.get, varSlot2, localVariables, javaCodePos, lineNumber ) ); + instructions.add( new WasmLoadStoreInstruction( VariableOperator.get, varSlot1, localVariables, javaCodePos, lineNumber ) ); } /** @@ -447,20 +447,20 @@ public abstract class WasmCodeBuilder { AnyType type2 = findValueTypeFromStack( 2, javaCodePos ); AnyType type3 = findValueTypeFromStack( 3, javaCodePos ); - int varIndex1 = getTempVariable( type1, javaCodePos, javaCodePos + 1 ); - int varIndex2 = getTempVariable( type2, javaCodePos, javaCodePos + 1 ); - int varIndex3 = getTempVariable( type3, javaCodePos, javaCodePos + 1 ); + int varSlot1 = getTempVariable( type1, javaCodePos, javaCodePos + 1 ); + int varSlot2 = getTempVariable( type2, javaCodePos, javaCodePos + 1 ); + int varSlot3 = getTempVariable( type3, javaCodePos, javaCodePos + 1 ); // save in temp variables - instructions.add( new WasmLocalInstruction( VariableOperator.set, varIndex1, localVariables, javaCodePos, lineNumber ) ); - instructions.add( new WasmLocalInstruction( VariableOperator.set, varIndex2, localVariables, javaCodePos, lineNumber ) ); - instructions.add( new WasmLocalInstruction( VariableOperator.set, varIndex3, localVariables, javaCodePos, lineNumber ) ); + instructions.add( new WasmLoadStoreInstruction( VariableOperator.set, varSlot1, localVariables, javaCodePos, lineNumber ) ); + instructions.add( new WasmLoadStoreInstruction( VariableOperator.set, varSlot2, localVariables, javaCodePos, lineNumber ) ); + instructions.add( new WasmLoadStoreInstruction( VariableOperator.set, varSlot3, localVariables, javaCodePos, lineNumber ) ); // and restore it in new order on the stack - instructions.add( new WasmLocalInstruction( VariableOperator.get, varIndex1, localVariables, javaCodePos, lineNumber ) ); - instructions.add( new WasmLocalInstruction( VariableOperator.get, varIndex3, localVariables, javaCodePos, lineNumber ) ); - instructions.add( new WasmLocalInstruction( VariableOperator.get, varIndex2, localVariables, javaCodePos, lineNumber ) ); - instructions.add( new WasmLocalInstruction( VariableOperator.get, varIndex1, localVariables, javaCodePos, lineNumber ) ); + instructions.add( new WasmLoadStoreInstruction( VariableOperator.get, varSlot1, localVariables, javaCodePos, lineNumber ) ); + instructions.add( new WasmLoadStoreInstruction( VariableOperator.get, varSlot3, localVariables, javaCodePos, lineNumber ) ); + instructions.add( new WasmLoadStoreInstruction( VariableOperator.get, varSlot2, localVariables, javaCodePos, lineNumber ) ); + instructions.add( new WasmLoadStoreInstruction( VariableOperator.get, varSlot1, localVariables, javaCodePos, lineNumber ) ); } /**