wasm gc: fix conversion of multidimensional arrays from JS

This commit is contained in:
Alexey Andreev 2024-10-02 20:02:58 +02:00
parent 0bd7bc6ca9
commit 2aabddc32d
3 changed files with 10 additions and 6 deletions

View File

@ -34,6 +34,7 @@ import org.teavm.model.ReferenceCache;
import org.teavm.model.TextLocation;
import org.teavm.model.ValueType;
import org.teavm.model.Variable;
import org.teavm.model.instructions.CastInstruction;
import org.teavm.model.instructions.ClassConstantInstruction;
import org.teavm.model.instructions.InvocationType;
import org.teavm.model.instructions.InvokeInstruction;
@ -472,11 +473,19 @@ class JSValueMarshaller {
insn = new InvokeInstruction();
insn.setMethod(JSMethods.UNMAP_ARRAY);
insn.setArguments(cls, var, function);
insn.setReceiver(var);
insn.setReceiver(program.createVariable());
insn.setType(InvocationType.SPECIAL);
insn.setLocation(location.getSourceLocation());
replacement.add(insn);
var cast = new CastInstruction();
cast.setTargetType(ValueType.arrayOf(ValueType.arrayOf(type)));
cast.setWeak(true);
cast.setValue(insn.getReceiver());
cast.setReceiver(var);
cast.setLocation(location.getSourceLocation());
replacement.add(cast);
return var;
}

View File

@ -65,7 +65,6 @@ public class ConversionTest {
}
@Test
@SkipPlatform(TestPlatform.WEBASSEMBLY_GC)
public void convertsPrimitiveArraysToJava() {
PrimitiveArrays arrays = getPrimitiveArrays();
@ -90,7 +89,6 @@ public class ConversionTest {
}
@Test
@SkipPlatform(TestPlatform.WEBASSEMBLY_GC)
public void convertsPrimitiveArrays2ToJava() {
PrimitiveArrays2 arrays = getPrimitiveArrays2();
@ -117,7 +115,6 @@ public class ConversionTest {
}
@Test
@SkipPlatform(TestPlatform.WEBASSEMBLY_GC)
public void convertsPrimitiveArrays4ToJava() {
PrimitiveArrays4 arrays = getPrimitiveArrays4();

View File

@ -26,7 +26,6 @@ import org.teavm.jso.JSProperty;
import org.teavm.junit.EachTestCompiledSeparately;
import org.teavm.junit.OnlyPlatform;
import org.teavm.junit.SkipJVM;
import org.teavm.junit.SkipPlatform;
import org.teavm.junit.TeaVMTestRunner;
import org.teavm.junit.TestPlatform;
@ -90,7 +89,6 @@ public class FunctorTest {
}
@Test
@SkipPlatform(TestPlatform.WEBASSEMBLY_GC)
public void castToFunctor() {
JSBiFunction f = getBiFunctionAsObject().cast();
assertEquals(23042, f.foo(23, 42));