a bytecode set for adaptive optimizations

Post on 20-May-2015

180 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

A bytecode set for adaptive optimizations IWST 2014 at ESUG, Cambridge

TRANSCRIPT

A bytecode set for adaptive

optimizationsClément Béra & Eliot Miranda

Thursday, August 21, 14

Introduction

• The Cog VM is the standard VM for:

• Pharo

• Squeak

• Newspeak

Thursday, August 21, 14

Introduction• Working runtime bytecode to bytecode

optimizer for Cog’s JIT

• The optimizer

• depends the bytecode set quality

• needs new bytecode instructions

Thursday, August 21, 14

Introduction

• Design of a new bytecode set

Thursday, August 21, 14

Plan

• Context

• Challenges for a good bytecode set

• Current Issues

• New bytecode set

• Switching between bytecode sets

Thursday, August 21, 14

Context

• Compiled methods are objects

• Shared between the VM and the image

Thursday, August 21, 14

Object header (8 bytes)

literals (4 bytes per literal)

compiled method header (4 bytes)

bytecodes (variable)

source pointer (variable, usually 4 bytes)

Memory representation ofCompiled Method in 32 bits

with the new Memory Manager Spur

Thursday, August 21, 14

Object header (8 bytes)

literals (4 bytes per literal)

compiled method header (4 bytes)

bytecodes (variable)

source pointer (variable, usually 4 bytes)

Memory representation ofCompiled Method in 32 bits

with the new Memory Manager Spur

Thursday, August 21, 14

Bytecode set

• Stack based

• Interpreted by the StackInterpreter

• Compiled to machine code by Cogit

• Generated by the in-image compiler

Thursday, August 21, 14

Challenges

• Generic challenges

• Challenges for the bytecode optimizer

Thursday, August 21, 14

Generic challenges

• Platform-independent

• Compact

• Easy to decode

• Backward compatibility

Thursday, August 21, 14

Optimizer challenges

...

Thursday, August 21, 14

OptimizerThursday there’s a talk about it.

• Inlining

• Primitive specialization

Thursday, August 21, 14

Optimizer challenges

• Inlined primitives / unsafe operations

• Large methods

• Access to non receiver instance variable

• Extendable

Thursday, August 21, 14

Current issues• Large method unsupported

• Few available bytes

• Primitive encoding forbidding inlining

• DoubleExtendedDoAnything bytecode

• Immediate objects compaction

• Late addition of the closure bytecode

Thursday, August 21, 14

New bytecode set

• Extendable instructions (prefix)

• Inlined primitives / unsafe operations

• Extendable (available bytes)

• Maximum number of literals increased

Thursday, August 21, 14

New bytecode set• Overall bytecode size smaller

• Immediate objects compaction

• Easier decoding

• Sorted by number of bytes

• Sorted by functionalities

• Closure decoding improved

Thursday, August 21, 14

Bytecode set switch

• Offline converter: hard to debug

• VM supporting two bytecode set

• Bit in compiled method header

Thursday, August 21, 14

Conclusion

• Designed a bytecode set for runtime bytecode to bytecode optimizations

• Next step is to work on the optimizer

• Come at my talk thursday about it

Thursday, August 21, 14

Questions

Thursday, August 21, 14

top related