2.2 KiB
2.2 KiB
Bytecode Migration Plan
Goal: migrate the compiler so all values live in frames/bytecode, keeping JVM tests green after each step.
Steps
- Step 1: Module/import slots seeded into module frame; bytecode module resolution works across closures.
- Step 2: Allow implicit/qualified
thismember refs to compile to bytecode.- Enable bytecode for
ImplicitThisMethodCallRef,QualifiedThisMethodSlotCallRef,QualifiedThisFieldSlotRef. - Keep unsupported cases blocked:
ClassScopeMemberRef, dynamic receivers, delegated members. - JVM tests must be green before commit.
- Enable bytecode for
- Step 3: Bytecode support for
try/catch/finally.- Implement bytecode emission for try/catch and finally blocks.
- Preserve existing error/stack semantics.
- JVM tests must be green before commit.
Remaining Migration (prioritized)
- Step 4: Allow bytecode wrapping for supported declaration statements.
- Enable
DestructuringVarDeclStatementandExtensionPropertyDeclStatementincontainsUnsupportedForBytecode. - Keep JVM tests green before commit.
- Enable
- Step 5: Enable bytecode for delegated var declarations.
- Revisit
containsDelegatedRefsguard forDelegatedVarDeclStatement. - Ensure delegate binding uses explicit
Statementobjects (no inline suspend lambdas).
- Revisit
- Step 6: Map literal spread in bytecode.
- Replace
MapLiteralEntry.Spreadbytecode exception with runtimeputAll/merge logic.
- Replace
- Step 7: Class-scope member refs in bytecode.
- Support
ClassScopeMemberRefwithout scope-map fallback.
- Support
- Step 8: ObjDynamic member access in bytecode.
- Allow dynamic receiver field/method lookup without falling back to interpreter.
- Step 9: Module-level bytecode execution.
- Compile
Scriptbodies to bytecode instead of interpreting at module scope. - Keep import/module slot seeding in frame-only flow.
- Compile
Notes
- Keep imports bound to module frame slots; no scope map writes for imports.
- Avoid inline suspend lambdas in compiler hot paths; use explicit
object : Statement(). - Do not reintroduce bytecode fallback opcodes; all symbol resolution remains compile-time only.