Search code examples
c++virtual-machinedalvik

Dalvik Virtual Machine source codes development approach


The source code of Dalvik can be found in here, and Virtual Machines related code is located in the folder called vm. Nearly all the codes are written in C++. However, detailed documentation of Dalvik seems missing on the Internet.

I would like to develop some new features upon original Dalvik, such as Thread Migration to and Thread Sync with remote servers. Could anyone tell me what document I can refer to and where I should start my project?


Solution

  • It's somewhat cliché to say "the source is the documentation", but for much of Dalvik it truly is.

    For example, consider the opening comment in Thread.cpp. It not only describes the thread model in some detail, it also discusses an alternative model that was considered but rejected, and the reasons for doing so.

    Another example is Exception.cpp, which discusses the ins and outs of different approaches to managing exceptions.

    Curious about how the stack is laid out? See interp/Stack.h (complete with ASCII art!).

    The internal workings of the VM are documented this way. Some larger items, like the DEX file format and the operation of the bytecode verifier, have their own stand-alone documentation in the dalvik/docs directory (which is apparently not part of that github repository). It's convenient to reference it from the dalvik docs mirror here anyway, since that gets you the CSS formatting for a couple of the larger docs.

    It would be nice if Dalvik used some standard documentation-in-code formatting convention to make it easy to pull the big pieces out.

    The VM code itself is heavily commented throughout. That goes for the ARM assembly as well.