2.2 KiB
2.2 KiB
Glint Runtime — Documentation
Backend for executing compiled bytecode (.glbc) of the Glint UI framework. Loads bytecode, interprets VDOM, applies CSS-like styles, executes Rhai scripts, and renders the result via Iced (native GPU-accelerated GUI).
Project Structure
src/main.rs— entry point, CLI parsingsrc/lib.rs— public API of the cratesrc/app.rs— GlintApp: Iced application, update/viewsrc/cli.rs— CLI commands compile/runsrc/renderer.rs— Iced widgets: Element → iced::Element conversionsrc/perf.rs— PerfScope: performance measurement by phasessrc/interpreter/mod.rs— Interpreter: bytecode loading, VDOM evalsrc/interpreter/types.rs— Element, VNode, FlatVDom, Value, InternedStr, Documentsrc/interpreter/style.rs— StyleSheet, StyleRule, StyleIndex, StyleCache, ComputedStylesrc/interpreter/reactive.rs— ReactiveTracker: dependency graphsrc/interpreter/rhei.rs— RheiContext: Rhai script integrationsrc/interpreter/reader.rs— Reader: .glbc bytecode readingsrc/interpreter/opcodes.rs— OP_* bytecode constants
Related Repositories
glt(compiler .gltm/.glts → .glbc)
Key Concepts
- Document — loaded .glbc file: Element tree, style sheet, variables
- Element — VDOM node: type_name, properties, children, computed_style, element_id, content_hash
- VDOM — virtual tree, result of bytecode interpretation
- StyleSheet — style sheet with indexed lookup and computed style cache
- ReactiveTracker — tracks element → variable dependencies, dirty_set
- RheiContext — compiles and executes Rhai scripts, caches AST
- ComputedStyle — result of applying CSS rules: ~40 fields (color, padding, font-size, etc.)
Optimization Phases
See ARCHITECTURE-IMPROVEMENT-PLAN.md.
Implemented: phases 3–8, 10, 9.1–9.2 (content_hash, stable Iced widget IDs).
Remaining:
| Phase | Description | Estimated Speedup |
|---|---|---|
| 0 | Profiling (bench, flamegraph) | — |
| 1 | Typed Values in styles instead of HashMap<String, String> | 2–3× |
| 2 | String interning for hot paths | 1.5–2× |
| 9.3 | Iced widget cache by content_hash | 1.5–2× (render) |