feat(vm): Android emulator foundation with const-return demo (2)#4
Open
haeter525 wants to merge 3 commits into
Open
feat(vm): Android emulator foundation with const-return demo (2)#4haeter525 wants to merge 3 commits into
haeter525 wants to merge 3 commits into
Conversation
19636e5 to
ef426d6
Compare
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>
529e99a to
06b286a
Compare
This was referenced 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lays down the Android emulator foundation with a const-return demo.
Scope
Foundation (
src/dextrace/vm/):decoder,register_file,state,call_frame,signals,errors,int_opsheap,class_hierarchy,traceengine.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 byclass_hierarchydalvik/payload.py—PackedSwitchTable/SparseSwitchTable/FillArrayDataTabledecoders (consumed by engine for switch + array ops)Tests (117 passing):
tests/vm/— unit teststests/test_vm_run_const_return.py— Python-API end-to-end testsOne-line verification