Class WasmStructuredControlflowCodeGenerator
java.lang.Object
de.mirkosertic.bytecoder.core.backend.wasm.WasmStructuredControlflowCodeGenerator
- All Implemented Interfaces:
StructuredControlflowCodeGenerator
public class WasmStructuredControlflowCodeGenerator
extends Object
implements StructuredControlflowCodeGenerator
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
(package private) static class
(package private) static class
(package private) static class
(package private) static class
(package private) static class
(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int
(package private) int
private final CompileUnit
private final ExportableFunction
private final Function
<ResolvedMethod, FunctionType> (package private) int
private final GeneratedMethodsRegistry
private final Graph
(package private) int
(package private) static int
(package private) int
private final MethodToIDMapper
private final Module
private final Map
<ResolvedClass, StructType> private final List
<ResolvedClass> private final Map
<ResolvedClass, StructType> (package private) int
private final Map
<AbstractVar, Local> private final VTableResolver
-
Constructor Summary
ConstructorsConstructorDescriptionWasmStructuredControlflowCodeGenerator
(CompileUnit compileUnit, Module module, Map<ResolvedClass, StructType> rtMappings, Map<ResolvedClass, StructType> objectTypeMappings, ExportableFunction exportableFunction, Function<org.objectweb.asm.Type, WasmType> typeConverter, Function<ResolvedMethod, FunctionType> functionTypeConverter, MethodToIDMapper methodToIDMapper, Graph graph, List<ResolvedClass> resolvedClasses, VTableResolver vTableResolver, GeneratedMethodsRegistry generatedMethodsRegistry) -
Method Summary
Modifier and TypeMethodDescriptionprivate WasmValue
convertToType
(Value incoming, org.objectweb.asm.Type targetType) createLambdaInstance
(org.objectweb.asm.Type type, ExportableFunction implFunction, List<StructType.Field> closureFields, List<WasmValue> closureArguments) static WasmValue
createNewInstanceOf
(org.objectweb.asm.Type instanceType, Module module, CompileUnit compileUnit, Map<ResolvedClass, StructType> objectTypeMappings, Map<ResolvedClass, StructType> rtMappings, WasmValue externRef) void
finishBlock
(Sequencer.Block node, boolean stackEmpty) void
void
void
void
void
void
void
void
private WasmValue
generateInvokeDynamicLambdaMetaFactoryInvocation
(InvokeDynamicExpression node, ResolveCallsite resolveCallsite) private WasmValue
generateInvokeDynamicObjectMethodsEquals
(InvokeDynamicExpression node, ResolveCallsite resolveCallsite) private WasmValue
generateInvokeDynamicObjectMethodsToString
(InvokeDynamicExpression node, ResolveCallsite resolveCallsite) private WasmValue
generateInvokeDynamicStringMakeConcatWithConstants
(InvokeDynamicExpression node, ResolveCallsite resolveCallsite) void
registerVariables
(List<AbstractVar> variables) void
startBlock
(Sequencer.Block node) void
void
startCatchHandler
(org.objectweb.asm.Type type) void
startIfElseBlock
(If node) void
startIfWithTrueBlock
(If node) void
void
startTableSwitch
(TableSwitch node) void
void
startTryCatch
(String label) private WasmValue
toInstanceOfCheck
(WasmValue value, org.objectweb.asm.Type typeToCheck) private WasmValue
toType
(org.objectweb.asm.Type type) private WasmValue
toWasmValue
(AbstractVar value) private WasmValue
toWasmValue
(Add value) private WasmValue
toWasmValue
(And value) private WasmValue
toWasmValue
(ArrayLength value) private WasmValue
toWasmValue
(ArrayLoad value) private WasmValue
toWasmValue
(Cast value) private WasmValue
toWasmValue
(CaughtException value) private WasmValue
toWasmValue
(CMP value) private WasmValue
toWasmValue
(Div value) private WasmValue
toWasmValue
(EnumValuesOf value) private WasmValue
toWasmValue
(InstanceOf value) private WasmValue
private WasmValue
toWasmValue
(MethodArgument value) private WasmValue
private WasmValue
toWasmValue
(Mul value) private WasmValue
toWasmValue
(Neg value) private WasmValue
toWasmValue
(New value) private WasmValue
toWasmValue
(NewArray value) private WasmValue
toWasmValue
(NullReference value) private WasmValue
toWasmValue
(NullTest value) private WasmValue
toWasmValue
(NumericalTest value) private WasmValue
toWasmValue
(ObjectString value) private WasmValue
toWasmValue
(Or value) private WasmValue
toWasmValue
(PrimitiveClassReference reference) private WasmValue
toWasmValue
(PrimitiveDouble value) private WasmValue
toWasmValue
(PrimitiveFloat value) private WasmValue
toWasmValue
(PrimitiveInt value) private WasmValue
toWasmValue
(PrimitiveLong value) private WasmValue
toWasmValue
(PrimitiveShort value) private WasmValue
toWasmValue
(ReadClassField value) private WasmValue
toWasmValue
(ReadInstanceField value) private WasmValue
toWasmValue
(ReferenceTest value) private WasmValue
toWasmValue
(Reinterpret value) private WasmValue
toWasmValue
(Rem value) private WasmValue
toWasmValue
(RuntimeClass value) private WasmValue
toWasmValue
(RuntimeClassOf value) private WasmValue
toWasmValue
(SHL value) private WasmValue
toWasmValue
(SHR value) private WasmValue
toWasmValue
(Sub value) private WasmValue
toWasmValue
(This value) private WasmValue
toWasmValue
(TypeConversion value) private WasmValue
toWasmValue
(TypeReference value) private WasmValue
toWasmValue
(USHR value) private WasmValue
toWasmValue
(Value value) private WasmValue
toWasmValue
(XOr value) private WasmValue
private WasmValue
private WasmValue
private WasmValue
void
write
(ArrayStore node) void
write
(ClassInitialization node) void
void
write
(FrameDebugInfo node) void
void
write
(LineNumberDebugInfo node) void
write
(MethodInvocation invocation) void
write
(MonitorEnter node) void
write
(MonitorExit node) void
void
write
(ReturnValue node) void
write
(SetClassField node) void
write
(SetInstanceField node) void
void
writeBreakTo
(String label) void
writeContinueTo
(String label) private void
writeDirect
(MethodInvocation node) private void
void
private void
writeStatic
(MethodInvocation node) void
writeSwitchCase
(int index) void
private void
writeVirtual
(MethodInvocation node)
-
Field Details
-
compileUnit
-
module
-
objectTypeMappings
-
rtMappings
-
exportableFunction
-
typeConverter
-
functionTypeConverter
-
methodToIDMapper
-
varLocalMap
-
activeLevel
-
graph
-
resolvedClasses
-
vTableResolver
-
generatedMethodsRegistry
-
lambdaCounter
static int lambdaCounter -
generatedEquals
int generatedEquals -
ifcounter
int ifcounter -
catchcheckcount
int catchcheckcount -
tableSwitchCount
int tableSwitchCount -
lookupSwitchCount
int lookupSwitchCount -
checkcounter
int checkcounter
-
-
Constructor Details
-
WasmStructuredControlflowCodeGenerator
public WasmStructuredControlflowCodeGenerator(CompileUnit compileUnit, Module module, Map<ResolvedClass, StructType> rtMappings, Map<ResolvedClass, StructType> objectTypeMappings, ExportableFunction exportableFunction, Function<org.objectweb.asm.Type, WasmType> typeConverter, Function<ResolvedMethod, FunctionType> functionTypeConverter, MethodToIDMapper methodToIDMapper, Graph graph, List<ResolvedClass> resolvedClasses, VTableResolver vTableResolver, GeneratedMethodsRegistry generatedMethodsRegistry)
-
-
Method Details
-
registerVariables
- Specified by:
registerVariables
in interfaceStructuredControlflowCodeGenerator
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
writeDirect
-
writeVirtual
-
writeStatic
-
writeInterface
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
createNewInstanceOf
public static WasmValue createNewInstanceOf(org.objectweb.asm.Type instanceType, Module module, CompileUnit compileUnit, Map<ResolvedClass, StructType> objectTypeMappings, Map<ResolvedClass, StructType> rtMappings, WasmValue externRef) -
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValueStatic
-
toWasmValueDirect
-
toWasmValueVirtual
-
toWasmValueInterface
-
createLambdaInstance
private WasmStructuredControlflowCodeGenerator.LambdaInstance createLambdaInstance(org.objectweb.asm.Type type, ExportableFunction implFunction, List<StructType.Field> closureFields, List<WasmValue> closureArguments) -
generateInvokeDynamicLambdaMetaFactoryInvocation
private WasmValue generateInvokeDynamicLambdaMetaFactoryInvocation(InvokeDynamicExpression node, ResolveCallsite resolveCallsite) -
generateInvokeDynamicStringMakeConcatWithConstants
private WasmValue generateInvokeDynamicStringMakeConcatWithConstants(InvokeDynamicExpression node, ResolveCallsite resolveCallsite) -
generateInvokeDynamicObjectMethodsToString
private WasmValue generateInvokeDynamicObjectMethodsToString(InvokeDynamicExpression node, ResolveCallsite resolveCallsite) -
generateInvokeDynamicObjectMethodsEquals
private WasmValue generateInvokeDynamicObjectMethodsEquals(InvokeDynamicExpression node, ResolveCallsite resolveCallsite) -
toWasmValue
-
toType
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
convertToType
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toInstanceOfCheck
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
toWasmValue
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
startIfWithTrueBlock
- Specified by:
startIfWithTrueBlock
in interfaceStructuredControlflowCodeGenerator
-
startIfElseBlock
- Specified by:
startIfElseBlock
in interfaceStructuredControlflowCodeGenerator
-
finishIfBlock
public void finishIfBlock()- Specified by:
finishIfBlock
in interfaceStructuredControlflowCodeGenerator
-
startBlock
- Specified by:
startBlock
in interfaceStructuredControlflowCodeGenerator
-
finishBlock
- Specified by:
finishBlock
in interfaceStructuredControlflowCodeGenerator
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
writeBreakTo
- Specified by:
writeBreakTo
in interfaceStructuredControlflowCodeGenerator
-
writeContinueTo
- Specified by:
writeContinueTo
in interfaceStructuredControlflowCodeGenerator
-
startTryCatch
- Specified by:
startTryCatch
in interfaceStructuredControlflowCodeGenerator
-
startCatchBlock
public void startCatchBlock()- Specified by:
startCatchBlock
in interfaceStructuredControlflowCodeGenerator
-
startCatchHandler
public void startCatchHandler(org.objectweb.asm.Type type) - Specified by:
startCatchHandler
in interfaceStructuredControlflowCodeGenerator
-
finishCatchHandler
public void finishCatchHandler()- Specified by:
finishCatchHandler
in interfaceStructuredControlflowCodeGenerator
-
writeRethrowException
public void writeRethrowException()- Specified by:
writeRethrowException
in interfaceStructuredControlflowCodeGenerator
-
finishTryCatch
public void finishTryCatch()- Specified by:
finishTryCatch
in interfaceStructuredControlflowCodeGenerator
-
startTableSwitch
- Specified by:
startTableSwitch
in interfaceStructuredControlflowCodeGenerator
-
finishTableSwitch
public void finishTableSwitch()- Specified by:
finishTableSwitch
in interfaceStructuredControlflowCodeGenerator
-
startTableSwitchDefaultBlock
public void startTableSwitchDefaultBlock()- Specified by:
startTableSwitchDefaultBlock
in interfaceStructuredControlflowCodeGenerator
-
finishTableSwitchDefaultBlock
public void finishTableSwitchDefaultBlock()- Specified by:
finishTableSwitchDefaultBlock
in interfaceStructuredControlflowCodeGenerator
-
startLookupSwitch
- Specified by:
startLookupSwitch
in interfaceStructuredControlflowCodeGenerator
-
finishLookupSwitch
public void finishLookupSwitch()- Specified by:
finishLookupSwitch
in interfaceStructuredControlflowCodeGenerator
-
writeSwitchCase
public void writeSwitchCase(int index) - Specified by:
writeSwitchCase
in interfaceStructuredControlflowCodeGenerator
-
writeSwitchDefaultCase
public void writeSwitchDefaultCase()- Specified by:
writeSwitchDefaultCase
in interfaceStructuredControlflowCodeGenerator
-
finishSwitchDefault
public void finishSwitchDefault()- Specified by:
finishSwitchDefault
in interfaceStructuredControlflowCodeGenerator
-
finishSwitchCase
public void finishSwitchCase()- Specified by:
finishSwitchCase
in interfaceStructuredControlflowCodeGenerator
-