Annotated. Each entry says why you would open it, so you can choose the right one under time
pressure.
This chapter has an unusual property: its subject has a normative published specification, a
generated implementation and a deleted historical implementation, and all three are public.
When the specification and the runtime appear to disagree, the runtime is what executes on the device.
The NAx naming scheme decoded, with the bit layout of every format. Read it when you are decoding an instruction from raw bytes and need to know which nibble is which
The container the instructions live in. Owned by 12-DEX-Internals, listed here because the three pages are read together
Those three pages are the ground truth for the whole instruction reference. If this chapter and one of
them ever disagree, the page is right and the chapter is wrong.
You need certainty about an opcode. One macro-expanded table: opcode number, enum name, mnemonic string, format, index type, verification flags. This is what the runtime is compiled from, so it is definitionally correct. It also answers "does this opcode exist on this Android version?" in seconds — just switch branches
libdexfile/dex/dex_instruction.h, .cc
Operand extraction: how the runtime pulls vA, vB, the literal and the index out of the code units
libdexfile/dex/dex_file_structs.h
The code_item your instructions live inside
art/runtime/verifier/method_verifier.cc
Why your patch was rejected. The data-flow verification that produces VerifyError, including the register-type lattice and the move-result adjacency check
art/runtime/interpreter/
How ART executes the instructions today, for comparison with Dalvik's mterp
Repository platform/dalvik — the tooling side, still maintained¶
Path
Open it when
opcode-gen/bytecode.txt
You want the single text file the tooling's opcode tables are generated from. Elegant piece of engineering: one source, and the C headers, the tables and the published documentation all derive from it, which is why they have never drifted
These paths only exist on branches up to and including kitkat-release. Browse
android.googlesource.com/platform/dalvik and
change the branch selector; on android10-release and later the vm/ directory is gone.
The interpreter design in its authors' own words: the fixed-size handler areas, the table-start + opcode * handler-size dispatch, and the portable-versus-fast split. Short, and the best primary source on how a real production bytecode interpreter is built
vm/mterp/config-*
Per-architecture lists of which opcodes have hand-written assembly handlers
vm/mterp/out/InterpC-*.c, InterpAsm-*.S
The generated interpreter actually compiled into libdvm.so
vm/interp/Interp.cpp, Interp.h, InterpDefs.h
Interpreter entry, exception dispatch, the FINISH macro
vm/interp/Stack.cpp
Frame setup and teardown — the register array of §2.4, allocated
Profiling counters, threshold, trace selection, the translation lookup table, and trace chaining. The place to read if you want to understand what a trace JIT actually is
vm/compiler/Compiler.cpp, .h
The compiler thread's main loop and the work queue
vm/compiler/Frontend.cpp
Trace descriptor to intermediate representation
vm/compiler/Dataflow.cpp, SSATransformation.cpp
The analysis, such as it was
vm/compiler/Loop.cpp
The only loop optimisation there was
vm/compiler/Ralloc.cpp
Register allocation — trace-local, which is the design's central limitation
vm/compiler/InlineTransformation.cpp
The inliner. Read it to see how little inlining a trace JIT can do, which is the honest answer to "why was it only 2–5× faster than interpretation"
vm/compiler/codegen/arm/, vm/compiler/template/
Native code emission and the hand-written assembly templates
dalvik/docs/ survives on every branch, including current ones. These are 2008-era HTML documents
and they are still the clearest explanation of several things nothing else explains.
Document
Why
docs/dexopt.html
Why install-time optimisation is device-specific, what quickening does, and why the dependency table exists. The direct ancestor of ART's VDEX
docs/verifier.html
What the verifier checks and why, written before anyone had a reason to obscure it
Note on CVE citation. This chapter names CVE-2017-13156 (Janus) because it is precisely the
"two parsers, one file" pattern the chapter teaches, and it names CVE-2013-4787 ("Master Key")
only to correct its frequent misattribution to Dalvik — it is a ZIP-parsing bug and belongs to
10-APK-Internals. Everything else is described as a class of
issue. A misattributed CVE in a client deliverable is worse than no citation.
The reverse-engineering and tampering procedures. Cite these by name rather than by test ID — the identifiers have been renumbered between MASTG versions
Dan Bornstein, Dalvik VM Internals, Google I/O 2008
The original design rationale, from the designer: why a register machine, why one constant pool, why memory-mappable. The primary source for §1.1 and §2.2
Ben Cheng and Bill Buzbee, A JIT Compiler for Android's Dalvik VM, Google I/O 2010
The trace JIT explained by the people who built it, including the memory argument for traces over methods
Google I/O 2014, The ART runtime
The replacement, and the case made for it at the time
Android Internals: A Confectioner's Cookbook — Jonathan Levin
The deepest published treatment of the runtime and its context. Volume on the userspace runtime is the relevant one
Android Security Internals — Nikolay Elenkov
The security model this bytecode executes inside
Decompiling Android — Godfrey Nolan
Dated, and written around the format rather than around a tool, which is why it aged better than most
Engineering a Compiler — Cooper and Torczon
Not Android-specific. If §2.2's stack-versus-register argument interested you, this is where the general theory is