@@ -1077,6 +1077,7 @@ object HelperFunctions {
1077
1077
val typeDataLocal = fctx.addLocal(" typeData" , typeDataType)
1078
1078
val doubleValueLocal = fctx.addLocal(" doubleValue" , WasmFloat64 )
1079
1079
val intValueLocal = fctx.addLocal(" intValue" , WasmInt32 )
1080
+ val ourObjectLocal = fctx.addLocal(" ourObject" , WasmRefType (WasmHeapType .ObjectType ))
1080
1081
1081
1082
def getHijackedClassTypeDataInstr (className : IRNames .ClassName ): WasmInstr =
1082
1083
GLOBAL_GET (WasmGlobalName .forVTable(className))
@@ -1192,7 +1193,28 @@ object HelperFunctions {
1192
1193
instrs += BR (gotTypeDataLabel)
1193
1194
}
1194
1195
1195
- instrs += STRUCT_GET (WasmStructTypeName .forClass(IRNames .ObjectClass ), WasmFieldIdx .vtable)
1196
+ /* Now we have one of our objects. Normally we only have to get the
1197
+ * vtable, but there are two exceptions. If the value is an instance of
1198
+ * `jl.CharacterBox` or `jl.LongBox`, we must use the typeData of
1199
+ * `jl.Character` or `jl.Long`, respectively.
1200
+ */
1201
+ instrs += LOCAL_TEE (ourObjectLocal)
1202
+ instrs += REF_TEST (WasmRefType (WasmStructTypeName .forClass(SpecialNames .CharBoxClass )))
1203
+ fctx.ifThenElse(typeDataType) {
1204
+ instrs += getHijackedClassTypeDataInstr(IRNames .BoxedCharacterClass )
1205
+ } {
1206
+ instrs += LOCAL_GET (ourObjectLocal)
1207
+ instrs += REF_TEST (WasmRefType (WasmStructTypeName .forClass(SpecialNames .LongBoxClass )))
1208
+ fctx.ifThenElse(typeDataType) {
1209
+ instrs += getHijackedClassTypeDataInstr(IRNames .BoxedLongClass )
1210
+ } {
1211
+ instrs += LOCAL_GET (ourObjectLocal)
1212
+ instrs += STRUCT_GET (
1213
+ WasmStructTypeName .forClass(IRNames .ObjectClass ),
1214
+ WasmFieldIdx .vtable
1215
+ )
1216
+ }
1217
+ }
1196
1218
}
1197
1219
1198
1220
instrs += CALL (WasmFunctionName .getClassOf)
0 commit comments