From 975126be58a92228e945730f9ff2337bfea41b9a Mon Sep 17 00:00:00 2001 From: Chouser Date: Fri, 20 Feb 2015 02:53:46 -0500 Subject: forth: Add call-site caching to boost perf --- forth/step2_eval.fs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'forth/step2_eval.fs') diff --git a/forth/step2_eval.fs b/forth/step2_eval.fs index 2b55ce0..10e1e77 100644 --- a/forth/step2_eval.fs +++ b/forth/step2_eval.fs @@ -6,12 +6,15 @@ require printer.fs argv i cells + @ as-native loop ; +: env-assoc ( map sym-str-addr sym-str-len xt ) + -rot MalSymbol. swap MalNativeFn. rot assoc ; + MalMap/Empty - s" +" MalSymbol. :noname args-as-native + MalInt. ; MalNativeFn. rot assoc - s" -" MalSymbol. :noname args-as-native - MalInt. ; MalNativeFn. rot assoc - s" *" MalSymbol. :noname args-as-native * MalInt. ; MalNativeFn. rot assoc - s" /" MalSymbol. :noname args-as-native / MalInt. ; MalNativeFn. rot assoc -value repl-env + s" +" :noname args-as-native + MalInt. ; env-assoc + s" -" :noname args-as-native - MalInt. ; env-assoc + s" *" :noname args-as-native * MalInt. ; env-assoc + s" /" :noname args-as-native / MalInt. ; env-assoc +constant repl-env : read read-str ; : eval ( env obj ) mal-eval ; -- cgit v1.2.3 From a631063f3fa2eaed473369b376a5499df92209bd Mon Sep 17 00:00:00 2001 From: Chouser Date: Sun, 22 Feb 2015 13:20:31 -0500 Subject: forth: Add map-hint to symbols for better perf --- forth/step2_eval.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'forth/step2_eval.fs') diff --git a/forth/step2_eval.fs b/forth/step2_eval.fs index 10e1e77..724de44 100644 --- a/forth/step2_eval.fs +++ b/forth/step2_eval.fs @@ -61,7 +61,7 @@ MalSymbol dup 0= if drop ." Symbol '" - sym as-native safe-type + sym pr-str safe-type ." ' not found." cr 1 throw endif ;; -- cgit v1.2.3