vmgen a generator of efficient virtual machine
play

vmgen - A Generator of Efficient Virtual Machine Interpreters M. - PowerPoint PPT Presentation

vmgen - A Generator of Efficient Virtual Machine Interpreters M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey May 6, 2011 M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter


  1. vmgen - A Generator of Efficient Virtual Machine Interpreters M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey May 6, 2011 M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  2. Summary vmgen generates fast interpreters from instruction descriptions also generates parts of associated tools profiler debugger disassembler code generator M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  3. Motivation writing/modifying an interpreter toolset is tedious and error-prone many parts can be automated can generated interpreters compete with those hand-written in assembly? M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  4. Motivation C compiler does most of the complicated things vmgen makes modifying an instruction set easier than rewriting anything in assembly M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  5. Process inputs: description of instruction set outputs: C code interpreter profiler debugger VM code disassembly VM code generation M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  6. Process producing a working interpreter requires a bit more work C code for interpreter skeleton C code from vmgen C compiler M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  7. Process Figure: vmgen process M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  8. Vmgen input example input format: iadd: iadd ( i1 i2 -- i ) i = i1 + i2; name stack effect, input and output types C implementation code M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  9. Output example I_iadd:{ int i1, i2, i; NEXT_P0; i1 = vm_Cell2i(sp[1]); i2 = vm_Cell2i(sp[0]); sp += 1; { i = i1 + i2; } NEXT_P1; sp[0] = vm_i2Cell(i); NEXT_P2; } M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  10. Architecture designed and optimized for stack-based VMs but register-based VMs are possible generated interpreter uses direct threading but indirect threading is possible flexible! M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  11. Optimizations vmgen interpreters are designed for optimization built-ins TOS caching, software pipelining, efficient stack usage tail duplication for branch prediction superinstructions M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  12. Existing optimizations TOS caching software pipelining/scheduled dispatch interleave instruction execution with instruction fetch superinstructions M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  13. Superinstructions not superoperators superoperators are tree operators superinstructions are DAG operators, work on stack-based interpreters arbitrary combination of previously-defined instructions M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  14. Superinstructions consequences C compiler ideally generates more efficient code VM code generator generates fewer instructions interpreter interprets fewer instructions profiler can recommend superinstructions M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  15. Novel optimizations store elimination example: dup ( i -- i i ) avoid creating a temporary variable and pushing it twice doesn’t work with superinstructions tail duplication for branch prediction M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  16. Performance two interpreters built with vmgen Gforth: Forth interpreter Cacao int: JVM interpreter, with threaded code instead of byte code M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  17. Performance Gforth is faster than Win32Forth Win32Forth is written in assembly, but uses indirect threading and PIC Gforth is slower than BigForth BigForth compiles Forth to native code M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  18. Performance Cacao int is faster than the DEC JVM native JIT compiler for some benchmarks Cacao int is slower than Cacao native, but only by a factor of two for most benchmarks Cacao int and Cacao native share synchronization and garbage collection mechanisms, and Cacao int spends 30% of its time in these routines M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  19. Performance optimizations were generally beneficial but architecture-dependent example: TOS caching improved performance on PPC by 20%, but net effect on a particular Alpha machine was 5% and benchmark-dependent M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

  20. Discussion quality of resulting interpreter depends on quality of compiler used to build interpreter authors claim GCC does a good job, but did not verify all compiled code authors manually allocated registers in Gforth because GCC inappropriately spilled important interpreter registers M. Anton Ertl, David Gregg, Andreas Krall, and Bernd Paysan Presented by Peter Bailey vmgen - A Generator of Efficient Virtual Machine Interpreters

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend