optimization: Scope access is now a Kotlin interface, compiler uses direct slot access also for closures

This commit is contained in:
sergeych committed 2026-02-05 13:55:24 +03:00
1 parent 43a6a7aaf4
commit 6220e982a0
14 files changed
+438 -165

No files matched your search

+7 -5
View File
@@ -7,12 +7,16 @@ Current focus
- Enforce compile-time name/member resolution only; no runtime scope lookup or fallback.
- Bytecode uses memberId-based ops (CALL_MEMBER_SLOT/GET_MEMBER_SLOT/SET_MEMBER_SLOT).
- Runtime lookup opcodes (CALL_VIRTUAL/GET_FIELD/SET_FIELD) and fallback callsites are removed.
- Migrate bytecode to frame-first locals with lazy scope reflection; avoid eager scope slot plans in compiled functions.
- Use FrameSlotRef for captures and only materialize Scope for Kotlin interop; use frame.ip -> pos mapping for diagnostics.
Key recent changes
- Removed method callsite PICs and fallback opcodes; bytecode now relies on compile-time member ids only.
- Operator dispatch emits memberId calls when known; falls back to Obj opcodes for allowed built-ins without name lookup.
- Object members are allowed on unknown types; other members still require a statically known receiver type.
- Renamed BytecodeFallbackException to BytecodeCompileException.
- Added frame.ip -> pos mapping; call-site ops restore pos after args to keep stack traces accurate.
- Loop var overrides now take precedence in slot resolution to keep loop locals in frame slots.
- LocalSlotRef now falls back to name lookup when slot plans are missing (closure safety).
Known failing tests
- None (jvmTest passing).
@@ -20,14 +24,12 @@ Known failing tests
Files touched recently
- notes/type_system_spec.md (spec updated)
- AGENTS.md (type inference reminders)
- lynglib/src/commonMain/kotlin/net/sergeych/lyng/VarDeclStatement.kt
- lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt
- lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeCompiler.kt
- lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjIterable.kt
- various bytecode runtime/disassembler files (memberId ops)
- lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt
Last test run
- ./gradlew :lynglib:jvmTest --tests ScriptTest.testForInIterableUnknownTypeDisasm
- ./gradlew :lynglib:jvmTest
Spec decisions (notes/type_system_spec.md)
- Nullability: Kotlin-style, T non-null, T? nullable, !! asserts non-null.