Fix JIT compiler, CSSX browser support, double-fetch, SPA layout
JIT compiler: - Fix jit_compile_lambda: resolve `compile` via symbol lookup in env instead of embedding VmClosure in AST (CEK dispatches differently) - Register eval-defcomp/eval-defisland/eval-defmacro runtime helpers in browser kernel for bytecoded defcomp forms - Disable broken .sxbc.json path (missing arity in nested code blocks), use .sxbc text format only - Mark JIT-failed closures as sentinel to stop retrying CSSX in browser: - Add cssx.sx symlink + cssx.sxbc to browser web stack - Add flush-cssx! to orchestration.sx post-swap for SPA nav - Add cssx.sx to compile-modules.js and mcp_tree.ml bytecode lists SPA navigation: - Fix double-fetch: check e.defaultPrevented in click delegation (bind-event already handled the click) - Fix layout destruction: change nav links from outerHTML to innerHTML swap (outerHTML destroyed #main-panel when response lacked it) - Guard JS popstate handler when SX engine is booted - Rename sx-platform.js → sx-platform-2.js to bust immutable cache Playwright tests: - Add trackErrors() helper to all test specs - Add SPA DOM comparison test (SPA nav vs fresh load) - Add single-fetch + no-duplicate-elements test - Improve MCP tool output: show failure details and error messages Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,7 @@ const FILES = [
|
||||
'render.sx', 'core-signals.sx', 'signals.sx', 'deps.sx', 'router.sx',
|
||||
'page-helpers.sx', 'freeze.sx', 'bytecode.sx', 'compiler.sx', 'vm.sx',
|
||||
'dom.sx', 'browser.sx', 'adapter-html.sx', 'adapter-sx.sx', 'adapter-dom.sx',
|
||||
'cssx.sx',
|
||||
'boot-helpers.sx', 'hypersx.sx', 'harness.sx', 'harness-reactive.sx',
|
||||
'harness-web.sx', 'engine.sx', 'orchestration.sx', 'boot.sx',
|
||||
];
|
||||
|
||||
@@ -647,6 +647,17 @@ let () =
|
||||
bind "provide-push!" (fun args -> match args with [n; v] -> Sx_runtime.provide_push n v | _ -> raise (Eval_error "provide-push!"));
|
||||
bind "provide-pop!" (fun args -> match args with [n] -> Sx_runtime.provide_pop n | _ -> raise (Eval_error "provide-pop!"));
|
||||
|
||||
(* Runtime helpers for bytecoded defcomp/defisland/defmacro forms.
|
||||
The compiler emits GLOBAL_GET "eval-defcomp" + CALL — these must
|
||||
exist as callable values for bytecoded .sx files that contain
|
||||
component definitions (e.g. cssx.sx). *)
|
||||
bind "eval-defcomp" (fun args ->
|
||||
match args with [List (_ :: rest)] -> Sx_ref.sf_defcomp (List rest) (Env global_env) | _ -> Nil);
|
||||
bind "eval-defisland" (fun args ->
|
||||
match args with [List (_ :: rest)] -> Sx_ref.sf_defisland (List rest) (Env global_env) | _ -> Nil);
|
||||
bind "eval-defmacro" (fun args ->
|
||||
match args with [List (_ :: rest)] -> Sx_ref.sf_defmacro (List rest) (Env global_env) | _ -> Nil);
|
||||
|
||||
(* --- Fragment / raw HTML --- *)
|
||||
bind "<>" (fun args ->
|
||||
RawHTML (String.concat "" (List.map (fun a ->
|
||||
@@ -781,7 +792,13 @@ let () =
|
||||
(try Some (Sx_vm.call_closure cl args _vm_globals)
|
||||
with Eval_error msg ->
|
||||
let fn_name = match l.l_name with Some n -> n | None -> "?" in
|
||||
Printf.eprintf "[jit] FAIL %s: %s\n%!" fn_name msg;
|
||||
Printf.eprintf "[jit] FAIL %s: %s (bc=%d consts=%d upv=%d)\n%!"
|
||||
fn_name msg
|
||||
(Array.length cl.vm_code.vc_bytecode)
|
||||
(Array.length cl.vm_code.vc_constants)
|
||||
(Array.length cl.vm_upvalues);
|
||||
(* Mark as failed to stop retrying *)
|
||||
l.l_compiled <- Some (Sx_vm.jit_failed_sentinel);
|
||||
None)
|
||||
| Some _ -> None
|
||||
| None ->
|
||||
@@ -796,7 +813,12 @@ let () =
|
||||
(try Some (Sx_vm.call_closure cl args _vm_globals)
|
||||
with Eval_error msg ->
|
||||
let fn_name2 = match l.l_name with Some n -> n | None -> "?" in
|
||||
Printf.eprintf "[jit] FAIL %s: %s\n%!" fn_name2 msg;
|
||||
Printf.eprintf "[jit] FAIL %s: %s (bc=%d consts=%d upv=%d)\n%!"
|
||||
fn_name2 msg
|
||||
(Array.length cl.vm_code.vc_bytecode)
|
||||
(Array.length cl.vm_code.vc_constants)
|
||||
(Array.length cl.vm_upvalues);
|
||||
l.l_compiled <- Some (Sx_vm.jit_failed_sentinel);
|
||||
None)
|
||||
| None -> None)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user