CEK frame records: eliminate Hashtbl for all 29 frame types
Transpiler detects dict literals with a "type" string field and emits CekFrame records instead of Dict(Hashtbl). Maps frame-specific fields to generic record slots: cf_type, cf_env, cf_name, cf_body, cf_remaining, cf_f, cf_args (also evaled), cf_results (also raw-args), cf_extra (ho-type/scheme/indexed/match-val/current-item/...), cf_extra2 (emitted/effect-list/first-render) Runtime get_val handles CekFrame with direct field match — O(1) field access vs Hashtbl.find. Bootstrapper: skip stdlib.sx entirely (already OCaml primitives). Result: 29 CekFrame + 2 CekState = 31 record types, only 8 Hashtbl.create remaining (effect-annotations, empty dicts). Benchmark (200 divs): 2.94s → 1.71s (1.7x speedup from baseline). Real pages: ~same as CekState-only (frames are <20% of allocations; states dominate at 199K/page). Foundation for JIT: record-based value representation enables typed compilation — JIT can emit direct field access instead of hash table lookups. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -79,6 +79,22 @@ let get_val container key =
|
||||
| "control" -> s.cs_control | "env" -> s.cs_env
|
||||
| "kont" -> s.cs_kont | "phase" -> String s.cs_phase
|
||||
| "value" -> s.cs_value | _ -> Nil)
|
||||
| CekFrame f, String k ->
|
||||
(match k with
|
||||
| "type" -> String f.cf_type | "env" -> f.cf_env
|
||||
| "name" -> f.cf_name | "body" -> f.cf_body
|
||||
| "remaining" -> f.cf_remaining | "f" -> f.cf_f
|
||||
| "args" -> f.cf_args | "evaled" -> f.cf_args
|
||||
| "results" -> f.cf_results | "raw-args" -> f.cf_results
|
||||
| "then" -> f.cf_body | "else" -> f.cf_name
|
||||
| "ho-type" -> f.cf_extra | "scheme" -> f.cf_extra
|
||||
| "indexed" -> f.cf_extra | "value" -> f.cf_extra
|
||||
| "phase" -> f.cf_extra | "has-effects" -> f.cf_extra
|
||||
| "match-val" -> f.cf_extra | "current-item" -> f.cf_extra
|
||||
| "update-fn" -> f.cf_extra | "head-name" -> f.cf_extra
|
||||
| "emitted" -> f.cf_extra2 | "effect-list" -> f.cf_extra2
|
||||
| "first-render" -> f.cf_extra2
|
||||
| _ -> Nil)
|
||||
| Dict d, String k -> dict_get d k
|
||||
| Dict d, Keyword k -> dict_get d k
|
||||
| (List l | ListRef { contents = l }), Number n ->
|
||||
|
||||
Reference in New Issue
Block a user