From 2d1d87fecd7d47ee61c0783dd97d58e70b34383c Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Sat, 26 Oct 2024 09:00:18 +0200 Subject: [PATCH] Compiler: revert 1647 --- CHANGES.md | 2 -- compiler/lib/generate.ml | 3 ++- compiler/tests-compiler/direct_calls.ml | 15 +++++++-------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index cb0a415455..0e39ba7f9e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,8 +9,6 @@ * Compiler: improved global dead code elimination (#2206) * Compiler: speedup json parsing, relying on Yojson.Raw (#1640) * Compiler: Decode sourcemap mappings only when necessary (#1664) -* Compiler: make indirect call using sequence instead of using the call method - [f.call(null, args)] becomes [(0,f)(args)] * Compiler: mark [TextEncoder] as reserved * Compiler: add support for the Wasm backend in parts of the pipeline, in prevision for the merge of wasm_of_ocaml diff --git a/compiler/lib/generate.ml b/compiler/lib/generate.ml index dbf0577505..7784206d67 100644 --- a/compiler/lib/generate.ml +++ b/compiler/lib/generate.ml @@ -898,7 +898,8 @@ let apply_fun_raw ctx f params exact trampolined loc = (* Make sure we are performing a regular call, not a (slower) method call *) match f with - | J.EAccess _ | J.EDot _ -> J.call (J.ESeq (int 0, f)) params loc + | J.EAccess _ | J.EDot _ -> + J.call (J.dot f (Utf8_string.of_string_exn "call")) (s_var "null" :: params) loc | _ -> J.call f params loc in let apply = diff --git a/compiler/tests-compiler/direct_calls.ml b/compiler/tests-compiler/direct_calls.ml index eac493b749..e458e83918 100644 --- a/compiler/tests-compiler/direct_calls.ml +++ b/compiler/tests-compiler/direct_calls.ml @@ -84,8 +84,8 @@ let%expect_test "direct calls without --enable effects" = //end function test3(x){ function F(symbol){function f(x){return x + 1 | 0;} return [0, f];} - var M1 = F([0]), M2 = F([0]), _b_ = (0, M2[1])(2); - return [0, (0, M1[1])(1), _b_]; + var M1 = F([0]), M2 = F([0]), _b_ = M2[1].call(null, 2); + return [0, M1[1].call(null, 1), _b_]; } //end function test4(x){ @@ -94,11 +94,10 @@ let%expect_test "direct calls without --enable effects" = return [0, f]; } var M1 = F([0]), M2 = F([0]); - (0, M1[1])(1); - return (0, M2[1])(2); + M1[1].call(null, 1); + return M2[1].call(null, 2); } - //end - |}] + //end |}] let%expect_test "direct calls with --enable effects" = let code = @@ -179,8 +178,8 @@ let%expect_test "direct calls with --enable effects" = //end function test3(x, cont){ function F(symbol){function f(x){return x + 1 | 0;} return [0, f];} - var M1 = F(), M2 = F(), _c_ = (0, M2[1])(2); - return cont([0, (0, M1[1])(1), _c_]); + var M1 = F(), M2 = F(), _c_ = M2[1].call(null, 2); + return cont([0, M1[1].call(null, 1), _c_]); } //end function test4(x, cont){