From 8c4b6634569801cddaa9f64b8307c7d0ebb01373 Mon Sep 17 00:00:00 2001 From: Andrea Bergia Date: Sat, 24 Aug 2024 00:58:37 +0200 Subject: [PATCH] Fixed a bug with interpreter peeling introduced in #1510 (#1578) Lack of support for all the varieties of lambda function in Rhino in the new "interpreter peeling" code introduced to make continuations work better was holding back additional conversions to lambda functions. --- rhino/src/main/java/org/mozilla/javascript/Interpreter.java | 2 ++ .../java/org/mozilla/javascript/tests/LambdaFunctionTest.java | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/rhino/src/main/java/org/mozilla/javascript/Interpreter.java b/rhino/src/main/java/org/mozilla/javascript/Interpreter.java index 004893b7cd..7e0f6f74c0 100644 --- a/rhino/src/main/java/org/mozilla/javascript/Interpreter.java +++ b/rhino/src/main/java/org/mozilla/javascript/Interpreter.java @@ -1784,6 +1784,8 @@ private static Object interpretLoop(Context cx, CallFrame frame, Object throwabl ArrowFunction afun = (ArrowFunction) fun; fun = afun.getTargetFunction(); funThisObj = afun.getCallThis(cx); + } else if (fun instanceof LambdaConstructor) { + break; } else if (fun instanceof LambdaFunction) { fun = ((LambdaFunction) fun).getTarget(); } else if (fun instanceof BoundFunction) { diff --git a/tests/src/test/java/org/mozilla/javascript/tests/LambdaFunctionTest.java b/tests/src/test/java/org/mozilla/javascript/tests/LambdaFunctionTest.java index d12c1a3be6..a7fc14b329 100644 --- a/tests/src/test/java/org/mozilla/javascript/tests/LambdaFunctionTest.java +++ b/tests/src/test/java/org/mozilla/javascript/tests/LambdaFunctionTest.java @@ -37,7 +37,8 @@ public void cleanup() { } private void eval(String source) { - cx.evaluateString(root, source, "test.js", 1, null); + Utils.runWithAllOptimizationLevels( + ignored -> cx.evaluateString(root, source, "test.js", 1, null)); } @Test