From b2b7a603b40964a6caf4709baa4fadae9b225fe8 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Fri, 19 Mar 2021 14:16:29 +0300 Subject: [PATCH] JS: fix array optimization --- .../java/org/teavm/ast/optimization/OptimizingVisitor.java | 4 +++- .../src/test/java/org/teavm/html4j/test/KnockoutTCKTest.java | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/teavm/ast/optimization/OptimizingVisitor.java b/core/src/main/java/org/teavm/ast/optimization/OptimizingVisitor.java index 5007ef45f..6171b349c 100644 --- a/core/src/main/java/org/teavm/ast/optimization/OptimizingVisitor.java +++ b/core/src/main/java/org/teavm/ast/optimization/OptimizingVisitor.java @@ -697,7 +697,9 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor { return false; } optimization.unwrappedArrayVariable = ((VariableExpr) assign.getLeftValue()).getIndex(); - if (writeFrequencies[optimization.unwrappedArrayVariable] != 1) { + if (writeFrequencies[optimization.unwrappedArrayVariable] != 1 + || preservedVars[optimization.unwrappedArrayVariable] + || readFrequencies[optimization.unwrappedArrayVariable] != optimization.arraySize) { return false; } diff --git a/html4j/src/test/java/org/teavm/html4j/test/KnockoutTCKTest.java b/html4j/src/test/java/org/teavm/html4j/test/KnockoutTCKTest.java index 9455677ae..cad0eeeec 100644 --- a/html4j/src/test/java/org/teavm/html4j/test/KnockoutTCKTest.java +++ b/html4j/src/test/java/org/teavm/html4j/test/KnockoutTCKTest.java @@ -21,7 +21,6 @@ import net.java.html.json.tests.KnockoutTest; import net.java.html.json.tests.MinesTest; import net.java.html.json.tests.OperationsTest; import net.java.html.json.tests.WebSocketTest; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.teavm.junit.SkipJVM; @@ -35,7 +34,6 @@ import org.teavm.junit.WholeClassCompilation; @RunWith(TeaVMTestRunner.class) @SkipJVM @WholeClassCompilation -@Ignore public class KnockoutTCKTest { private final ConvertTypesTest convertTypesTest = new ConvertTypesTest(); private final JSONTest jsonTest = new JSONTest();