Skip to content

feat(vm): Android emulator foundation with const-return demo (2)#4

Open
haeter525 wants to merge 3 commits into
ev-flow:pr-a/parser-try-catchfrom
haeter525:pr-b/vm-scaffold
Open

feat(vm): Android emulator foundation with const-return demo (2)#4
haeter525 wants to merge 3 commits into
ev-flow:pr-a/parser-try-catchfrom
haeter525:pr-b/vm-scaffold

Conversation

@haeter525
Copy link
Copy Markdown
Member

@haeter525 haeter525 commented May 21, 2026

Summary

Lays down the Android emulator foundation with a const-return demo.

Depends on #5. This PR's base is the pr-a/parser-try-catch branch on this repo; once #5 merges, the base auto-updates to main.

Scope

Foundation (src/dextrace/vm/):

  • decoder, register_file, state, call_frame, signals, errors, int_ops
  • heap, class_hierarchy, trace
  • engine.py (~900 LoC interpreter loop)
  • handlers/__init__.py, handlers/move.py (only handler shipped)
  • android_stubs/__init__.py (REGISTRY/types only; stub modules deferred)

Supporting:

  • core/dex_class_iter.py — used by class_hierarchy
  • dalvik/payload.pyPackedSwitchTable / SparseSwitchTable / FillArrayDataTable decoders (consumed by engine for switch + array ops)

Tests (117 passing):

  • tests/vm/ — unit tests
  • tests/test_vm_run_const_return.py — Python-API end-to-end tests

One-line verification

pytest tests/test_vm_run_const_return.py -q

@haeter525 haeter525 force-pushed the pr-a/parser-try-catch branch from 19636e5 to ef426d6 Compare May 21, 2026 13:37
Lays down the Dalvik interpreter scaffolding (primitives + engine loop)
with the absolute minimum handler (`move` only — covers const-* opcodes)
and an empty android_stubs registry. Engine wiring for the remaining
handlers and stub modules is held back behind explicit "scaffold:
re-enable in follow-up" comments so the next PRs become pure additions.

End-to-end demo: const_return.dex (one `const/16` + one `return`) runs
through the engine and produces 42.

Primitives (src/dextrace/vm/):
- decoder, register_file, state, call_frame, signals, errors, int_ops
- heap, class_hierarchy, trace
- engine.py (~900 LoC interpreter loop)
- handlers/__init__.py, handlers/move.py (only handler shipped)
- android_stubs/__init__.py (REGISTRY/types only; stub modules deferred)

Supporting:
- core/dex_class_iter.py (used by class_hierarchy)
- dalvik/payload.py: PackedSwitchTable / SparseSwitchTable /
  FillArrayDataTable decoders (consumed by engine for switch + array ops)

Tests (117 passing):
- tests/vm/test_{register_file,int_ops,heap,class_hierarchy,
  class_hierarchy_subtype,switch_payload}.py — primitive unit tests
- tests/test_vm_run_const_return.py — Python-API end-to-end (CLI
  variants land alongside cli/cmd_run.py in the CLI PR)

Held back for follow-up PRs:
- handlers/{arithmetic,array,branch,compare,field,throw,
  type_check,type_conv}.py — engine has matching scaffold markers
  at each import + register() site
- android_stubs/{sms,text,intent,telephony,network,runtime,
  filesystem,content}.py — package __init__ has matching marker
- Integration tests that need full handlers / stubs / CLI

Verification (one-liner):
    pytest tests/test_vm_run_const_return.py -q

Full scaffold suite:
    pytest -q   # 117 passed

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@haeter525 haeter525 changed the title feat(vm): scaffold — Dalvik VM framework with const-return demo (Layer 2/N) feat(vm): scaffold — Dalvik VM framework with const-return demo May 21, 2026
@haeter525 haeter525 changed the title feat(vm): scaffold — Dalvik VM framework with const-return demo feat(vm): Android emulator foundation with const-return demo (2) May 21, 2026
Drop P1/P4/P5a-f and OV-1..OV-6 references from inline comments — the
codenames are noise without the design doc next to them. Also remove the
empty stub-bootstrap block in android_stubs since stub modules will
re-add it when they land.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@haeter525 haeter525 marked this pull request as ready for review May 21, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant