From 5cdaafebe2ee826f8df3ed350bdd6380dfd295bb Mon Sep 17 00:00:00 2001 From: Nathan Braswell Date: Sun, 17 Apr 2022 01:52:01 -0400 Subject: [PATCH] Change lapply to optionally take in an explicit env, make it optional for vapply so they match, then tweak Y such that it threads the dynamic env through, then implement eta-reduction in the compiler backend. This provides about the same speedup again from the Y elimination, as it's kinda the other half for fully getting rid of Y such that there's just static recursive calls. fib.kp went from 1.7 -> 1.1 -> 0.5, and fib_let similarly. fib.kp is now faster than fib_manual, but just by a bit. --- .gitignore | 5 ++ fact.kp | 2 +- fib.kp | 2 +- fib2.kp | 2 +- fib_let.kp | 2 +- partial_eval.scm | 184 ++++++++++++++++++++++++++++++----------------- table.md | 18 +++++ to_compile.kp | 2 +- 8 files changed, 147 insertions(+), 70 deletions(-) create mode 100644 table.md diff --git a/.gitignore b/.gitignore index da108b0..e9656d1 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,8 @@ kraken_bootstrap compiler_version.krak untracked_misc k_prime + + +# Added by cargo + +/target diff --git a/fact.kp b/fact.kp index b588465..0043d9e 100644 --- a/fact.kp +++ b/fact.kp @@ -6,7 +6,7 @@ (let1 cons (lambda (h t) (concat (array h) t)) (let1 Y (lambda (f3) ((lambda (x1) (x1 x1)) - (lambda (x2) (f3 (lambda (& y) (lapply (x2 x2) y)))))) + (lambda (x2) (f3 (wrap (vau app_env (& y) (lapply (x2 x2) y app_env))))))) (let1 vY (lambda (f) ((lambda (x3) (x3 x3)) (lambda (x4) (f (vau de1 (& y) (vapply (x4 x4) y de1)))))) diff --git a/fib.kp b/fib.kp index b67672a..a18de17 100644 --- a/fib.kp +++ b/fib.kp @@ -6,7 +6,7 @@ (let1 cons (lambda (h t) (concat (array h) t)) (let1 Y (lambda (f3) ((lambda (x1) (x1 x1)) - (lambda (x2) (f3 (lambda (& y) (lapply (x2 x2) y)))))) + (lambda (x2) (f3 (wrap (vau app_env (& y) (lapply (x2 x2) y app_env))))))) (let1 vY (lambda (f) ((lambda (x3) (x3 x3)) (lambda (x4) (f (vau de1 (& y) (vapply (x4 x4) y de1)))))) diff --git a/fib2.kp b/fib2.kp index 4b93446..63c32f9 100644 --- a/fib2.kp +++ b/fib2.kp @@ -6,7 +6,7 @@ (let1 cons (lambda (h t) (concat (array h) t)) (let1 Y (lambda (f3) ((lambda (x1) (x1 x1)) - (lambda (x2) (f3 (lambda (& y) (lapply (x2 x2) y)))))) + (lambda (x2) (f3 (wrap (vau app_env (& y) (lapply (x2 x2) y app_env))))))) (let1 vY (lambda (f) ((lambda (x3) (x3 x3)) (lambda (x4) (f (vau de1 (& y) (vapply (x4 x4) y de1)))))) diff --git a/fib_let.kp b/fib_let.kp index 25334cf..54b601d 100644 --- a/fib_let.kp +++ b/fib_let.kp @@ -6,7 +6,7 @@ (let1 cons (lambda (h t) (concat (array h) t)) (let1 Y (lambda (f3) ((lambda (x1) (x1 x1)) - (lambda (x2) (f3 (lambda (& y) (lapply (x2 x2) y)))))) + (lambda (x2) (f3 (wrap (vau app_env (& y) (lapply (x2 x2) y app_env))))))) (let1 vY (lambda (f) ((lambda (x3) (x3 x3)) (lambda (x4) (f (vau de1 (& y) (vapply (x4 x4) y de1)))))) diff --git a/partial_eval.scm b/partial_eval.scm index da78878..2b2b6d2 100644 --- a/partial_eval.scm +++ b/partial_eval.scm @@ -481,7 +481,7 @@ ((comb? x) (dlet (((wrap_level env_id de? se variadic params body rec_hash) (.comb x)) ((se_s done_envs) (recurse se done_envs)) ((body_s done_envs) (recurse body done_envs))) - (array (true_str "") done_envs))) + (array (true_str "") done_envs))) ((prim_comb? x) (array (true_str "") done_envs)) ((marked_env? x) (dlet ((e (.env_marked x)) (index (.marked_env_idx x)) @@ -608,13 +608,13 @@ (comb_takes_de? (lambda (x l) (cond ((comb? x) (!= nil (.comb_des x))) - ((prim_comb? x) (cond ( (= (.prim_comb_sym x) 'vau) true) - ((and (= (.prim_comb_sym x) 'eval) (= 1 l)) true) - ((and (= (.prim_comb_sym x) 'veval) (= 1 l)) true) - ( (= (.prim_comb_sym x) 'lapply) true) - ( (= (.prim_comb_sym x) 'vapply) true) - ( (= (.prim_comb_sym x) 'cond) true) ; but not vcond - (true false))) + ((prim_comb? x) (cond ((= (.prim_comb_sym x) 'vau) true) + ((= (.prim_comb_sym x) 'eval) (= 1 l)) + ((= (.prim_comb_sym x) 'veval) (= 1 l)) + ((= (.prim_comb_sym x) 'lapply) (= 1 l)) + ((= (.prim_comb_sym x) 'vapply) (= 1 l)) + ((= (.prim_comb_sym x) 'cond) true) ; but not vcond + (true false))) ((and (marked_array? x) (not (.marked_array_is_val x))) true) ((and (marked_symbol? x) (not (.marked_symbol_is_val x))) true) (true (error (str "illegal comb_takes_de? param " x))) @@ -889,11 +889,11 @@ ) (veval_inner only_head de env_stack pectx (if implicit_env (array unval_body) (array unval_body eval_env)) indent)))) ) 'eval 1 true)) - (array 'vapply (marked_prim_comb (dlambda (only_head de env_stack pectx (f ps ide) indent) - (veval_inner only_head de env_stack pectx (array (marked_array false false nil (cons f (.marked_array_values ps)) nil) ide) (+ 1 indent)) + (array 'vapply (marked_prim_comb (dlambda (only_head de env_stack pectx args indent) + (veval_inner only_head de env_stack pectx (array (marked_array false false nil (cons (idx args 0) (.marked_array_values (idx args 1))) nil) (mif (= 3 (len args)) (idx args 2) de)) (+ 1 indent)) ) 'vapply 1 true)) - (array 'lapply (marked_prim_comb (dlambda (only_head de env_stack pectx (f ps) indent) - (veval_inner only_head de env_stack pectx (array (marked_array false false nil (cons (with_wrap_level f (- (.any_comb_wrap_level f) 1)) (.marked_array_values ps)) nil)) (+ 1 indent)) + (array 'lapply (marked_prim_comb (dlambda (only_head de env_stack pectx args indent) + (veval_inner only_head de env_stack pectx (array (marked_array false false nil (cons (with_wrap_level (idx args 0) (- (.any_comb_wrap_level (idx args 0)) 1)) (.marked_array_values (idx args 1))) nil) (mif (= 3 (len args)) (idx args 2) de)) (+ 1 indent)) ) 'lapply 1 true)) (array 'vau (marked_prim_comb (lambda (only_head de env_stack pectx params indent) (dlet ( @@ -932,6 +932,7 @@ ) 'wrap 1 true)) (array 'unwrap (marked_prim_comb (dlambda (only_head de env_stack pectx (evaled) indent) + ; TODO should support prim comb like runtime (if (comb? evaled) (array pectx nil (with_wrap_level evaled (- (.any_comb_wrap_level evaled) 1))) (array pectx "bad passed to unwrap" nil)) ) 'unwrap 1 true)) @@ -3211,12 +3212,32 @@ ((k_lapply_loc k_lapply_length datasi) (alloc_data "k_lapply" datasi)) (k_lapply_msg_val (bor (<< k_lapply_length 32) k_lapply_loc #b011)) - ((k_lapply func_idx funcs) (array func_idx (+ 1 func_idx) (concat funcs (func '$lapply '(param $p i64) '(param $d i64) '(param $s i64) '(result i64) '(local $ptr i32) '(local $len i32) '(local $comb i64) '(local $params i64) '(local $wrap_level i64) - (ensure_not_op_n_params_set_ptr_len i32.ne 2) + ((k_lapply func_idx funcs) (array func_idx (+ 1 func_idx) (concat funcs (func '$lapply '(param $p i64) '(param $d i64) '(param $s i64) '(result i64) '(local $ptr i32) '(local $len i32) '(local $comb i64) '(local $params i64) '(local $wrap_level i64) '(local $inner_env i64) + (ensure_not_op_n_params_set_ptr_len i32.lt_u 2) (type_assert 0 type_combiner k_lapply_msg_val) (type_assert 1 type_array k_lapply_msg_val) (local.set '$comb (call '$dup (i64.load 0 (local.get '$ptr)))) (local.set '$params (call '$dup (i64.load 8 (local.get '$ptr)))) + (_if '$needs_dynamic_env + (i64.ne (i64.const #b0) (i64.and (local.get '$comb) (i64.const #b100000))) + (then + (_if '$explicit_inner + (i32.eq (i32.const 3) (local.get '$len)) + (then + (type_assert 2 type_env k_lapply_msg_val) + (call '$drop (local.get '$d)) + (local.set '$inner_env (call '$dup (i64.load 16 (local.get '$ptr)))) + ) + (else + (local.set '$inner_env (local.get '$d)) + ) + ) + ) + (else + (call '$drop (local.get '$d)) + (local.set '$inner_env (i64.const nil_val)) + ) + ) (call '$drop (local.get '$p)) (local.set '$wrap_level (i64.and (i64.shr_u (local.get '$comb) (i64.const 4)) (i64.const #b1))) (_if '$wrap_level_ne_1 @@ -3231,12 +3252,8 @@ 0 ;params (local.get '$params) - ; pass through d env - ;(local.get '$d) - (_if '$needs_dynamic_env '(result i64) - (i64.ne (i64.const #b0) (i64.and (local.get '$comb) (i64.const #b100000))) - (then (local.get '$d)) - (else (call '$drop (local.get '$d)) (i64.const nil_val))) + ; dynamic env + (local.get '$inner_env) ; static env (i64.or (i64.shl (i64.and (local.get '$comb) (i64.const #x3FFFFFFC0)) (i64.const 2)) (i64.const #b01001)) @@ -3247,15 +3264,33 @@ ((k_vapply_loc k_vapply_length datasi) (alloc_data "k_vapply" datasi)) (k_vapply_msg_val (bor (<< k_vapply_length 32) k_vapply_loc #b011)) - ((k_vapply func_idx funcs) (array func_idx (+ 1 func_idx) (concat funcs (func '$vapply '(param $p i64) '(param $d i64) '(param $s i64) '(result i64) '(local $ptr i32) '(local $len i32) '(local $comb i64) '(local $params i64) '(local $wrap_level i64) '(local $denv i64) + ((k_vapply func_idx funcs) (array func_idx (+ 1 func_idx) (concat funcs (func '$vapply '(param $p i64) '(param $d i64) '(param $s i64) '(result i64) '(local $ptr i32) '(local $len i32) '(local $comb i64) '(local $params i64) '(local $wrap_level i64) '(local $inner_env i64) (ensure_not_op_n_params_set_ptr_len i32.ne 3) (type_assert 0 type_combiner k_vapply_msg_val) (type_assert 1 type_array k_vapply_msg_val) - (type_assert 2 type_env k_vapply_msg_val) (local.set '$comb (call '$dup (i64.load 0 (local.get '$ptr)))) (local.set '$params (call '$dup (i64.load 8 (local.get '$ptr)))) - (local.set '$denv (call '$dup (i64.load 16 (local.get '$ptr)))) - drop_p_d + (_if '$needs_dynamic_env + (i64.ne (i64.const #b0) (i64.and (local.get '$comb) (i64.const #b100000))) + (then + (_if '$explicit_inner + (i32.eq (i32.const 3) (local.get '$len)) + (then + (type_assert 2 type_env k_vapply_msg_val) + (call '$drop (local.get '$d)) + (local.set '$inner_env (call '$dup (i64.load 16 (local.get '$ptr)))) + ) + (else + (local.set '$inner_env (local.get '$d)) + ) + ) + ) + (else + (call '$drop (local.get '$d)) + (local.set '$inner_env (i64.const nil_val)) + ) + ) + (call '$drop (local.get '$p)) (local.set '$wrap_level (i64.and (i64.shr_u (local.get '$comb) (i64.const 4)) (i64.const #b1))) (_if '$wrap_level_ne_0 (i64.ne (i64.const 0) (local.get '$wrap_level)) @@ -3269,12 +3304,8 @@ 0 ;params (local.get '$params) - ; passed in denv, not our $d env - ;(local.get '$denv) - (_if '$needs_dynamic_env '(result i64) - (i64.ne (i64.const #b0) (i64.and (local.get '$comb) (i64.const #b100000))) - (then (local.get '$denv)) - (else (call '$drop (local.get '$denv)) (i64.const nil_val))) + ; dynamic env + (local.get '$inner_env) ; static env (i64.or (i64.shl (i64.and (local.get '$comb) (i64.const #x3FFFFFFC0)) (i64.const 2)) (i64.const #b01001)) @@ -4417,6 +4448,8 @@ (memo (put memo (.hash c) result)) ) (array result nil nil (array datasi funcs memo env pectx)))))))) + ; This is the other half of where we notice & tie up recursion based on partial eval's noted rec-stops + ; Other half is below in comb compilation (or (and (!= nil (.marked_array_this_rec_stop c)) (get_passthrough (idx (.marked_array_this_rec_stop c) 0) ctx)) (if need_value (array nil nil (str "errr, needed value and was call " (str_strip c)) ctx) (if (= 0 (len (.marked_array_values c))) (array nil nil (str "errr, empty call array" (str_strip c)) ctx) @@ -4583,7 +4616,7 @@ (then wrap_0_param_code) (else (_if '$is_wrap_1 - (i64.eq (i64.const #x10) (i64.and (local.get '$tmp) (i64.const #x30))) + (i64.eq (i64.const #x10) (i64.and (local.get '$tmp) (i64.const #x10))) (then wrap_1_param_code) (else wrap_x_param_code) ) @@ -4715,7 +4748,58 @@ ((comb? c) (dlet ( - ((wrap_level env_id de? se variadic params body rec_hash) (.comb c)) + ((wrap_level env_id de? se variadic params body rec_hashes) (.comb c)) + (_ (mif (> wrap_level 1) (error "wrap level TOO DARN HIGH"))) + + ; Let's look and see if we can eta-reduce! + ; This is done here during code gen (when you would expect it earlier, like as part of partial eval) + ; because we currently only "tie the knot" for Y combinator based recursion here + ; at compile time (indeed, part of that happens in the block down below where we put our func value into memo before compiling), + ; and so we can only tell here weather or not it will be safe to remove the level of lazyness (because we get a func value back instead of code) + ; and perform the eta reduction. + + (attempt_reduction (and + variadic + (= 1 (len params)) + (= 4 (len (.marked_array_values body))) + (prim_comb? (idx (.marked_array_values body) 0)) + (= 'lapply (.prim_comb_sym (idx (.marked_array_values body) 0))) + (marked_symbol? (idx (.marked_array_values body) 2)) + (not (.marked_symbol_is_val (idx (.marked_array_values body) 2))) + (= (idx params 0) (.marked_symbol_value (idx (.marked_array_values body) 2))) + (marked_symbol? (idx (.marked_array_values body) 3)) + (not (.marked_symbol_is_val (idx (.marked_array_values body) 3))) + (= de? (.marked_symbol_value (idx (.marked_array_values body) 3))) + )) + + (full_params (concat params (mif de? (array de?) (array)))) + (normal_params_length (if variadic (- (len params) 1) (len params))) + (compile_body_part (lambda (ctx body_part) (dlet ( + (inner_env (make_tmp_inner_env params de? se env_id)) + ((params_vec _ _ ctx) (compile-inner ctx (marked_array true false nil (map (lambda (k) (marked_symbol nil k)) full_params) nil) true false s_env_access_code)) + (new_get_s_env_code (_if '$have_s_env '(result i64) + (i64.ne (i64.const nil_val) (local.get '$s_env)) + (then (local.get '$s_env)) + (else (local.tee '$s_env (call '$env_alloc (i64.const params_vec) (local.get '$inner_params) (local.get '$outer_s_env))) + (local.set '$inner_params (i64.const nil_val)) + (local.set '$outer_s_env (i64.const nil_val)) + ))) + ((datasi funcs memo env pectx) ctx) + ((inner_value inner_code err ctx) (compile-inner (array datasi funcs memo inner_env pectx) body_part false false new_get_s_env_code)) + ; Don't overwrite env with what was our inner env! Env is returned as part of context to our caller! + ((datasi funcs memo _was_inner_env pectx) ctx) + ) (array inner_value inner_code err (array datasi funcs memo env pectx))))) + + ((early_quit err ctx) (mif attempt_reduction + (dlet ( + ((inner_value inner_code err ctx) (compile_body_part ctx (idx (.marked_array_values body) 1))) + ; set it's wrap level to our wrap level + (inner_value (mif inner_value (bor (band inner_value (bnot (<< 1 4))) (<< wrap_level 4)))) + ) (array inner_value err ctx)) + (array nil nil ctx))) + + ) (mif (and (!= nil early_quit) (= nil err)) (array early_quit nil nil ctx) + (dlet ( ; I belive this env_code should actually re-create the actual env chain (IN THE ENV COMPILING CODE, NOT HERE) ; It might not just be s_env, because we might have been partially-evaled and returned ; from a deeper call and have some real env frames before we run into what is currently @@ -4735,7 +4819,6 @@ (maybe_func (get_passthrough (.hash c) ctx)) ((func_value _ func_err ctx) (mif maybe_func maybe_func (dlet ( - ((wrap_level env_id de? se variadic params body rec_hashes) (.comb c)) ((datasi funcs memo env pectx) ctx) (old_funcs funcs) @@ -4746,17 +4829,12 @@ (memo (mif env_val (foldl (dlambda (memo (hash wrap)) (put memo hash (calculate_combined_value env_val (calculate_func_val wrap)))) memo rec_hashes) memo)) - (_ (mif (> wrap_level 1) (error "wrap level TOO DARN HIGH"))) (ctx (array datasi funcs memo env pectx)) ;((name_msg_value _ _ ctx) (compile-inner ctx (marked_val (str "\n\ncalling function " (true_str_strip c) " with: ")) true inside_veval)) ; This can be optimized for common cases, esp with no de? and varidaic to make it much faster ; But not prematurely, I just had to redo it after doing that the first time, we'll get there when we get there - (inner_env (make_tmp_inner_env params de? se env_id)) - (full_params (concat params (mif de? (array de?) (array)))) - (normal_params_length (if variadic (- (len params) 1) (len params))) - ((params_vec _ _ ctx) (compile-inner ctx (marked_array true false nil (map (lambda (k) (marked_symbol nil k)) full_params) nil) true false s_env_access_code)) (parameter_symbols (map (lambda (k) (array 'local k 'i64)) full_params)) (env_setup_code (concat (local.set '$s_env (i64.const nil_val)) @@ -4793,24 +4871,9 @@ ; (local.set '$inner_params (i64.const nil_val)) ; (local.set '$outer_s_env (i64.const nil_val)) ; )) - (new_get_s_env_code (_if '$have_s_env '(result i64) - (i64.ne (i64.const nil_val) (local.get '$s_env)) - (then (local.get '$s_env)) - (else (local.tee '$s_env (call '$env_alloc (i64.const params_vec) (local.get '$inner_params) (local.get '$outer_s_env))) - (local.set '$inner_params (i64.const nil_val)) - (local.set '$outer_s_env (i64.const nil_val)) - ))) ;(new_get_s_env_code (local.get '$s_env)) (setup_code (concat - ;(call '$print (i64.const name_msg_value)) - ;(call '$print (local.get '$params)) - ;(call '$print (i64.const space_msg_val)) - ;(call '$print (i64.shl (i64.shr_u (local.get '$params) (i64.const 32)) (i64.const 1))) - ;(call '$print (i64.const space_msg_val)) - ;(call '$print (i64.const (<< (len params) 1))) - ;(call '$print (i64.const newline_msg_val)) - ;(call '$print (i64.const newline_msg_val)) (_if '$params_len_good (if variadic (i64.lt_u (i64.shr_u (local.get '$params) (i64.const 32)) (i64.const (- (len params) 1))) (i64.ne (i64.shr_u (local.get '$params) (i64.const 32)) (i64.const (len params)))) @@ -4821,20 +4884,10 @@ (call '$print (i64.const bad_params_number_msg_val)) (unreachable) ) - (else - ;(call '$print (i64.const call_ok_msg_val)) - ;(call '$print (i64.const newline_msg_val)) - ;(call '$print (local.get '$s_env)) - ;(call '$print (i64.const newline_msg_val)) - ) ) env_setup_code )) - ((datasi funcs memo env pectx) ctx) - ((inner_value inner_code err ctx) (compile-inner (array datasi funcs memo inner_env pectx) body false false new_get_s_env_code)) - ; Don't overwrite env with what was our inner env! Env is returned as part of context to our caller! - ((datasi funcs memo _was_inner_env pectx) ctx) - ;(_ (print_strip "inner_value for maybe const is " inner_value " inner_code is " inner_code " err is " err " this was for " body)) + ((inner_value inner_code err ctx) (compile_body_part ctx body)) (inner_code (mif inner_value (i64.const inner_value) inner_code)) (end_code (concat (call '$drop (local.get '$s_env)) (call '$drop (local.get '$outer_s_env)) @@ -4844,6 +4897,7 @@ (concat setup_code inner_code end_code) )))) ; replace our placeholder with the real one + ((datasi funcs memo env pectx) ctx) (funcs (concat old_funcs our_func (drop funcs (+ 1 (len old_funcs))))) (memo (put memo (.hash c) func_value)) @@ -4862,7 +4916,7 @@ ; x - 2 = y ) (mif env_val (array (calculate_combined_value env_val func_value) nil (mif func_err (str func_err ", from compiling comb body") (mif env_err (str env_err ", from compiling comb env") nil)) ctx) (array nil (i64.or (i64.const func_value) (i64.and (i64.const #x7FFFFFFC0) (i64.shr_u env_code (i64.const 2)))) (mif func_err (str func_err ", from compiling comb body (env as code)") (mif env_err (str env_err ", from compiling comb env (as code)") nil)) ctx)) - )) + )))) (true (error (str "Can't compile-inner impossible " c))) ))) diff --git a/table.md b/table.md new file mode 100644 index 0000000..58c04ae --- /dev/null +++ b/table.md @@ -0,0 +1,18 @@ +| Command | Mean [ms] | Min [ms] | Max [ms] | Relative | +|:---|---:|---:|---:|---:| +| `echo 30 \| wasmtime ./fib_compiled.wasm` | 500.3 ± 3.0 | 495.3 | 503.8 | 111.77 ± 14.02 | +| `echo 30 \| wasmtime ./fib_compiled_let.wasm` | 816.4 ± 3.4 | 812.8 | 821.6 | 182.39 ± 22.86 | +| `echo 30 \| wasmtime ./fib_interpreted.wasm` | 11818.0 ± 64.9 | 11751.4 | 11983.8 | 2640.24 ± 331.01 | +| `echo 30 \| wasmtime ./fib_interpreted_let.wasm` | 32808.0 ± 126.9 | 32655.0 | 33015.6 | 7329.58 ± 918.47 | +| `echo 30 \| wasmtime ./builtin_fib.wasm` | 11.4 ± 1.8 | 10.1 | 28.6 | 2.55 ± 0.52 | +| `echo 30 \| wasmtime ./fib_compiled_manual.wasm` | 562.4 ± 3.9 | 556.2 | 569.0 | 125.64 ± 15.76 | +| `echo 30 \| wasmtime ./rust_fib/target/wasm32-wasi/debug/rust_let.wasm` | 29.8 ± 2.3 | 28.5 | 47.0 | 6.66 ± 0.98 | +| `echo 30 \| wasmtime ./rust_fib/target/wasm32-wasi/release/rust_let.wasm` | 19.0 ± 2.1 | 17.6 | 36.9 | 4.25 ± 0.71 | +| `echo 30 \| ./rust_fib/target/debug/rust_let` | 8.3 ± 0.5 | 7.2 | 10.3 | 1.86 ± 0.26 | +| `echo 30 \| ./rust_fib/target/release/rust_let` | 4.5 ± 0.6 | 3.2 | 6.2 | 1.00 | +| `scheme --script ./fib.scm 30` | 53.7 ± 0.7 | 52.8 | 55.5 | 11.99 ± 1.51 | +| `scheme --script ./fib_let.scm 30` | 53.3 ± 0.5 | 52.5 | 54.5 | 11.91 ± 1.50 | +| `python3 ./fib.py 30` | 287.6 ± 3.3 | 282.1 | 292.7 | 64.26 ± 8.08 | +| `python3 ./fib_let.py 30` | 304.3 ± 3.6 | 299.4 | 310.0 | 67.99 ± 8.55 | +| `echo 30 \| java -jar ./clojure_fib/target/uberjar/clojure_fib-0.1.0-SNAPSHOT-standalone.jar` | 686.2 ± 14.6 | 676.0 | 725.2 | 153.29 ± 19.47 | +| `echo 30 \| java -jar ./clojure_hi/target/uberjar/clojure_hi-0.1.0-SNAPSHOT-standalone.jar` | 658.2 ± 13.2 | 639.2 | 679.3 | 147.05 ± 18.65 | diff --git a/to_compile.kp b/to_compile.kp index 3e2f8fb..f4101ee 100644 --- a/to_compile.kp +++ b/to_compile.kp @@ -5,7 +5,7 @@ (let1 cons (lambda (h t) (concat (array h) t)) (let1 Y (lambda (f3) ((lambda (x1) (x1 x1)) - (lambda (x2) (f3 (lambda (& y) (lapply (x2 x2) y)))))) + (lambda (x2) (f3 (wrap (vau app_env (& y) (lapply (x2 x2) y app_env))))))) (let1 vY (lambda (f) ((lambda (x3) (x3 x3)) (lambda (x4) (f (vau de1 (& y) (vapply (x4 x4) y de1))))))