Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 1.79 KB

native-backend.md

File metadata and controls

36 lines (28 loc) · 1.79 KB

Native backend

Parent: compilation. Language portability: JS vs native. Config: [native]. Source anchors: compile_program_to_c_configured in src/compiler.rs and emit_native_c_with_options in src/codegen_native.rs.

JavaScript and native share parsing, semantics, linking, typed control-flow IR, and the core optimizer. --target all clones the lowered IR before JavaScript search (compile_program_all_configured). Native then runs optimizer_options() plus [native] storage; it does not inherit the JS candidate-search winner. JavaScript priority/search never changes C policy.

The native backend emits C and, for native, invokes the configured system C toolchain. Scalar primitives use C representations; arrays, strings, records, collections, unions, closures, and generic boundaries use the checked LilScript runtime representations documented in the language contract.

[native] controls conservative storage placement:

  • fixed small local arrays and eligible nonescaping aggregates/closures may use the function frame;
  • larger bounded locals may use a function region;
  • returned, global, unknown-call, unsafe-capture, phi-merged, or resized values stay heap allocated;
  • every region is released on every generated return path.

This changes allocation placement, not source ownership or identity.

JavaScript-only boundaries/features—JsValue, Regex, tasks/async, generators, dynamic/foreign imports, host objects, and currently inheritance—produce diagnostics. Native must reject them rather than silently approximate browser semantics.

Portable conformance requires generated JS, generated C compiled independently, and native execution to match the same oracle. C compilation success alone is not a semantic result.