Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does mterp mean?

There is a folder named mterp in the dalvik source code. Its path is /vm/mterp.
I want to know what does the word mterp mean?

like image 991
YKG Avatar asked Mar 05 '14 03:03

YKG


1 Answers

The 'm' stands for "modular" -- mterp is the modular interpreter.

It was an evolution of the previous implementation, which was effectively a monster switch statement. As noted in the mterp README:

This is the source code for the Dalvik interpreter. The core of the original version was implemented as a single C function, but to improve performance we rewrote it in assembly. To make this and future assembly ports easier and less error-prone, we used a modular approach that allows development of platform-specific code one opcode at a time.

The ability to switch implementations at opcode granularity was extremely valuable, because it allowed us to swap between C and assembly implementations with a quick change to a config file -- very handy if you suspected that something in the assembly version wasn't working quite right. When we wanted to add floating point support, we just wrote new opcode pieces and created a new config file that replaced the float-dependent instructions.

The structure also makes porting the interpreter to entirely new platforms much easier, because you can evolve from the "portable" interpreter to a "fast" interpreter in bite-sized pieces.

like image 109
fadden Avatar answered Oct 13 '22 07:10

fadden