100 likes | 227 Views
Extensible virtual machines Tim Harris. Extensible virtual machines. Policy decisions can often be separated (safely) from implementation mechanisms Thread scheduling Object representation Primitive operations Run-time code generation One size does not fit all. Motivating example.
E N D
Extensible virtual machines • Policy decisions can often be separated (safely) from implementation mechanisms • Thread scheduling • Object representation • Primitive operations • Run-time code generation • One size does not fit all
Motivating example • Object placement in the heap • Safety requires the objects are stored in correctly-sized blocks of memory that are not already in use • May wish to control • Where instances of different classes are stored • Where instances allocated by different threads are stored • Which free block is chosen, if there is a choice • When the heap is expanded and when collection occurs
Prototype XVM design > > Machine A Machine B Interface Instance of code module Operations available to application < Machine C > > >
Ensuring safety • At a coarse level, the selection of implementation machines and pre-defined modules available can be limited • At a finer granularity, modules provide descriptions of their verification-time behavior in addition to their concrete implementation
Ensuring safety Start RT: [] VT: [] push arg(1) [1]’enter <Op-0x805fe38> RT: [1] VT: [] (HAS_TYPE, 1) (INT) dup add [2] ’push_key HAS_PARITY ’push_id 0 ’make_key 2 ’push_val PARITY, EVEN ’make_val 1 ’define RT: [2] VT: [] (HAS_TYPE, 1) (INT) (HAS_TYPE, 2) (INT) (HAS_PARITY, 2) (EVEN)
Contact details tim.harris@cl.cam.ac.uk http://www.cl.cam.ac.uk/~tlh20
Machine definition .define_machine extended, core, { .load_modules combine, core-wrappers; .instantiate module (combine), magnitude; .instantiate module (core-wrappers), core-wrappers; .plumb provided (instance (core-wrappers), mul_binary_op), required (instance (magnitude), to_each); .plumb provided (instance (core-wrappers), add_binary_op), required (instance (magnitude), to_results); .alias_operation instance(magnitude), binary_op, op, mag; };
Interface definition .define_interface binary_op, { .specify_operation op, in_immediate (), in_stack (x, y), out_stack (z), in_condition (precisely (key (HAS_TYPE, x), val (cpo (PRIMITIVE_TYPE, INT)), core), precisely (key (HAS_TYPE, y), val (cpo (PRIMITIVE_TYPE, INT)), core)), out_condition (precisely (key (HAS_TYPE, z), val (cpo (PRIMITIVE_TYPE, INT)), core)); };
Module definition .define_module combine, machine (core), { .present_interface interface (binary_op), binary_op; .require_interface interface (binary_op), to_each; .require_interface interface (binary_op), to_results; .alias_operation port (to_each), op, each_op; .alias_operation port (to_results), op, combine_op; .define_operation port (binary_op), op, { dup; each_op; roll int(2), int(1); dup; each_op; combine_op; }; };