20
A bytecode set for adaptive optimizations Clément Béra & Eliot Miranda Thursday, August 21, 14

A bytecode set for adaptive optimizations

  • Upload
    esug

  • View
    185

  • Download
    0

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: A bytecode set for adaptive optimizations

A bytecode set for adaptive

optimizationsClément Béra & Eliot Miranda

Thursday, August 21, 14

Page 2: A bytecode set for adaptive optimizations

Introduction

• The Cog VM is the standard VM for:

• Pharo

• Squeak

• Newspeak

Thursday, August 21, 14

Page 3: A bytecode set for adaptive optimizations

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

Page 4: A bytecode set for adaptive optimizations

Introduction

• Design of a new bytecode set

Thursday, August 21, 14

Page 5: A bytecode set for adaptive optimizations

Plan

• Context

• Challenges for a good bytecode set

• Current Issues

• New bytecode set

• Switching between bytecode sets

Thursday, August 21, 14

Page 6: A bytecode set for adaptive optimizations

Context

• Compiled methods are objects

• Shared between the VM and the image

Thursday, August 21, 14

Page 7: A bytecode set for adaptive optimizations

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

Page 8: A bytecode set for adaptive optimizations

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

Page 9: A bytecode set for adaptive optimizations

Bytecode set

• Stack based

• Interpreted by the StackInterpreter

• Compiled to machine code by Cogit

• Generated by the in-image compiler

Thursday, August 21, 14

Page 10: A bytecode set for adaptive optimizations

Challenges

• Generic challenges

• Challenges for the bytecode optimizer

Thursday, August 21, 14

Page 11: A bytecode set for adaptive optimizations

Generic challenges

• Platform-independent

• Compact

• Easy to decode

• Backward compatibility

Thursday, August 21, 14

Page 12: A bytecode set for adaptive optimizations

Optimizer challenges

...

Thursday, August 21, 14

Page 13: A bytecode set for adaptive optimizations

OptimizerThursday there’s a talk about it.

• Inlining

• Primitive specialization

Thursday, August 21, 14

Page 14: A bytecode set for adaptive optimizations

Optimizer challenges

• Inlined primitives / unsafe operations

• Large methods

• Access to non receiver instance variable

• Extendable

Thursday, August 21, 14

Page 15: A bytecode set for adaptive optimizations

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

Page 16: A bytecode set for adaptive optimizations

New bytecode set

• Extendable instructions (prefix)

• Inlined primitives / unsafe operations

• Extendable (available bytes)

• Maximum number of literals increased

Thursday, August 21, 14

Page 17: A bytecode set for adaptive optimizations

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

Page 18: A bytecode set for adaptive optimizations

Bytecode set switch

• Offline converter: hard to debug

• VM supporting two bytecode set

• Bit in compiled method header

Thursday, August 21, 14

Page 19: A bytecode set for adaptive optimizations

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

Page 20: A bytecode set for adaptive optimizations

Questions

Thursday, August 21, 14