pydgin:(genera-ng(fast(instruc-on(set(simulators( from...

87
Cornell University Computer Systems Laboratory Pydgin: Genera-ng Fast Instruc-on Set Simulators from Simple Architecture Descrip-ons with Meta?Tracing JIT Compilers Derek Lockhart, Berkin Ilbeyi, and Christopher Ba=en

Upload: others

Post on 07-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Cornell'University'Computer'Systems'Laboratory'

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(

from(Simple(Architecture(Descrip-ons((

with(Meta?Tracing(JIT(Compilers(

Derek'Lockhart,'Berkin'Ilbeyi,'and'Christopher'Ba=en'

Page 2: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Motivation(

'

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 1(/(20(

Instruc>on?Set'Simulator'

Instruc>on'set'simulators'perform'func-onal(simula>on'of'a'target'architecture.'

armv5_binary'

Page 3: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Motivation(

'

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 1(/(20(

armv5_binary'

Instruc>on'set'simulators'perform'func-onal(simula>on'of'a'target'architecture.'

Instruc>on?Set'Simulator'

SoEware'Development'

Hardware'Design'

Page 4: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Motivation(

'

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 1(/(20(

Instruc>on?Set'Simulator'

SoEware'Development'

Hardware'Design'

Instruc>on'set'simulators'perform'func-onal(simula>on'of'a'target'architecture.''Instruc>on?Set'Simulator'Goals:''• Accuracy'• Observability'•  Performance''

Page 5: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Motivation(

'

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 1(/(20(

Instruc>on'set'simulators'perform'func-onal(simula>on'of'a'target'architecture.''Instruc>on?Set'Simulator'Goals:''• Accuracy'• Observability'•  Performance'•  Produc>vity''

Instruc>on?Set'Simulator'

SoEware'Development'

Hardware'Design'

Page 6: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Motivation(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 1(/(20(

SoEware'Development'

Hardware'Design'

Instruc>on?Set'Simulator'

Hardware'Design'

' Instruc>on'set'simulators'perform'func-onal(simula>on'of'a'target'architecture.''Instruc>on?Set'Simulator'Goals:''• Accuracy'• Observability'•  Performance'•  Produc>vity''

Page 7: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Motivation(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 1(/(20(

SoEware'Development'

ISA'

Hardware'Design'Hardware'Design'

Instruc>on'set'simulators'perform'func-onal(simula>on'of'a'target'architecture.''Instruc>on?Set'Simulator'Goals:''• Accuracy'• Observability'•  Performance'•  Produc>vity''

Page 8: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 2(/(20(

Performance'Produc>vity'

Page 9: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 2(/(20(

Performance'Produc>vity'

Architectural'Descrip>on'Language'

Instruc>on'Set'Interpreter'in'C'

with'DBT'

Page 10: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 2(/(20(

Performance'Produc>vity'

Architectural'Descrip>on'Language'

Instruc>on'Set'Interpreter'in'C'

with'DBT'

Page 11: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 2(/(20(

Performance'Produc>vity'

Architectural'Descrip>on'Language'

Instruc>on'Set'Interpreter'in'C'

with'DBT'

[SimIt?ARM2006]'[Wagstaff2013]'

[Simit?ARM2006]'''J.D’Errico'and'W.Qin.'Construc>ng'Portable'Compiled'Instruc>on?Set'Simulators'—'An'ADL?Driven'Approach.'DATE’06.'[Wagstaff2013]''''''H.'Wagstaff,'M.'Gould,'B.'Franke,'and'N.Topham.'Early'Par>al'Evalua>on'in'a'JIT?Compiled,'Retargetable'Instruc>on''

' ''''''''Set'Simulator'Generated'from'a'High?Level'Architecture'Descrip>on.''DAC’13.'''

Page 12: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 2(/(20(

Performance'Produc>vity'

Instruc>on'Set'Interpreter'in'C'

with'DBT'

[SimIt?ARM2006]'[Wagstaff2013]'

[Simit?ARM2006]((+'Page?based'JIT'?'Ad?hoc'ADL'with'custom'parser'?'Unmaintained'

[Wagstaff2013]((+'Region?based'JIT'+'Industry?supported'ADL'(ArchC)'?'C++?based'ADL'is'verbose'?'Not'Public'

Architectural'Descrip>on'Language'

[Simit?ARM2006]'''J.D’Errico'and'W.Qin.'Construc>ng'Portable'Compiled'Instruc>on?Set'Simulators'—'An'ADL?Driven'Approach.'DATE’06.'[Wagstaff2013]''''''H.'Wagstaff,'M.'Gould,'B.'Franke,'and'N.Topham.'Early'Par>al'Evalua>on'in'a'JIT?Compiled,'Retargetable'Instruc>on''

' ''''''''Set'Simulator'Generated'from'a'High?Level'Architecture'Descrip>on.''DAC’13.'''

Page 13: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 3(/(20(

Performance'Produc>vity'

Instruc>on'Set'Interpreter'in'C'

with'DBT'

Dynamic'Language'Interpreter'in'C'with'JIT'Compiler'

[SimIt?ARM2006]'[Wagstaff2013]'

Architectural'Descrip>on'Language'

Page 14: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 3(/(20(

Performance'Produc>vity'

Instruc>on'Set'Interpreter'in'C'

with'DBT'

Dynamic'Language'Interpreter'in'C'with'JIT'Compiler'

[SimIt?ARM2006]'[Wagstaff2013]'

Architectural'Descrip>on'Language'

Key(Insight:((

Similar'produc>vity?performance'challenges'for'building'high?performance'interpreters'of'

dynamic'languages.'(e.g.'JavaScript,'Python)(

Page 15: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 3(/(20(

Performance'Produc>vity'

Instruc>on'Set'Interpreter'in'C'

with'DBT'

Dynamic'Language'Interpreter'in'C'with'JIT'Compiler'

[SimIt?ARM2006]'[Wagstaff2013]'

Architectural'Descrip>on'Language'

Key(Insight:((

Similar'produc>vity?performance'challenges'for'building'high?performance'interpreters'of'

dynamic'languages.'(e.g.'JavaScript,'Python)(

Page 16: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 3(/(20(

Performance'Produc>vity'

RPython'Transla>on'Toolchain'

[SimIt?ARM2006]'[Wagstaff2013]'

Instruc>on'Set'Interpreter'in'C'

with'DBT'

Dynamic?Language'Interpreter'in'RPython'

Dynamic'Language'Interpreter'in'C'with'JIT'Compiler'

Architectural'Descrip>on'Language'

Page 17: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 3(/(20(

Performance'Produc>vity'

RPython'Transla>on'Toolchain'

[SimIt?ARM2006]'[Wagstaff2013]'

Instruc>on'Set'Interpreter'in'C'

with'DBT'

Dynamic?Language'Interpreter'in'RPython'

Dynamic'Language'Interpreter'in'C'with'JIT'Compiler'

Architectural'Descrip>on'Language'

Meta?Tracing(JIT:(makes(JIT(genera-on(generic(across(languages((

Page 18: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 4(/(20(

Performance'Produc>vity'

RPython'Transla>on'Toolchain'

Instruc>on'Set'Interpreter'in'C'

with'DBT'

Architectural'Descrip>on'Language'

Pydgin

Page 19: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

RPython'Transla>on'Toolchain'

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 4(/(20(

Performance'Produc>vity'

Instruc>on'Set'Interpreter'in'C'

with'DBT'

Architectural'Descrip>on'Language'

Pydgin

•  Flexible,'produc>ve,'pseudocode?like'ADL'syntax'•  ADL'embedded'in'a'popular,'general?purpose'language'•  Tracing?JIT'generator'applies'across'many'different'ISAs'•  Leverages'advancements'from'dynamic?language'JIT'research''

Page 20: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(Framework(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 5(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Page 21: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(Framework(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 6(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Page 22: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL:(ARMv5(Architectural(State(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 6(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

!!!!class!State(!object!):!!!!!!!!!def!__init__(!self,!memory,!reset_addr=0x400!):!!!!!!!!!self.pc!!=!reset_addr!!!!!!!!!self.rf!!=!ArmRegisterFile(!self,!num_regs=16!)!!!!!!!!!self.mem!=!memory!!!!!!!!!!!self.rf[!15!]!=!reset_addr!!!!!!!!!!!#!current!program!status!register!(CPSR)!!!!!!!!!self.N!!!!=!0b0!!!!!!#!Negative!condition!!!!!!!!!self.Z!!!!=!0b0!!!!!!#!Zero!condition!!!!!!!!!self.C!!!!=!0b0!!!!!!#!Carry!condition!!!!!!!!!self.V!!!!=!0b0!!!!!!#!Overflow!condition!!!!!!!!!def!fetch_pc(!self!):!!!!!!!!!return!self.pc'

Page 23: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL:(ARMv5(Architectural(State(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 6(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

!!!!class!State(!object!):!!!!!!!!!def!__init__(!self,!memory,!reset_addr=0x400!):!!!!!!!!!self.pc!!=!reset_addr!!!!!!!!!self.rf!!=!ArmRegisterFile(!self,!num_regs=16!)!!!!!!!!!self.mem!=!memory!!!!!!!!!!!self.rf[!15!]!=!reset_addr!!!!!!!!!!!#!current!program!status!register!(CPSR)!!!!!!!!!self.N!!!!=!0b0!!!!!!#!Negative!condition!!!!!!!!!self.Z!!!!=!0b0!!!!!!#!Zero!condition!!!!!!!!!self.C!!!!=!0b0!!!!!!#!Carry!condition!!!!!!!!!self.V!!!!=!0b0!!!!!!#!Overflow!condition!!!!!!!!!def!fetch_pc(!self!):!!!!!!!!!return!self.pc'

Page 24: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL:(ARMv5(Architectural(State(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 6(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

!!!!class!State(!object!):!!!!!!!!!def!__init__(!self,!memory,!reset_addr=0x400!):!!!!!!!!!self.pc!!=!reset_addr!!!!!!!!!self.rf!!=!ArmRegisterFile(!self,!num_regs=16!)!!!!!!!!!self.mem!=!memory!!!!!!!!!!!self.rf[!15!]!=!reset_addr!!!!!!!!!!!#!current!program!status!register!(CPSR)!!!!!!!!!self.N!!!!=!0b0!!!!!!#!Negative!condition!!!!!!!!!self.Z!!!!=!0b0!!!!!!#!Zero!condition!!!!!!!!!self.C!!!!=!0b0!!!!!!#!Carry!condition!!!!!!!!!self.V!!!!=!0b0!!!!!!#!Overflow!condition!!!!!!!!!def!fetch_pc(!self!):!!!!!!!!!return!self.pc'

Page 25: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL:(ARMv5(Architectural(State(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 6(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

!!!!class!State(!object!):!!!!!!!!!def!__init__(!self,!memory,!reset_addr=0x400!):!!!!!!!!!self.pc!!=!reset_addr!!!!!!!!!self.rf!!=!ArmRegisterFile(!self,!num_regs=16!)!!!!!!!!!self.mem!=!memory!!!!!!!!!!!self.rf[!15!]!=!reset_addr!!!!!!!!!!!#!current!program!status!register!(CPSR)!!!!!!!!!self.N!!!!=!0b0!!!!!!#!Negative!condition!!!!!!!!!self.Z!!!!=!0b0!!!!!!#!Zero!condition!!!!!!!!!self.C!!!!=!0b0!!!!!!#!Carry!condition!!!!!!!!!self.V!!!!=!0b0!!!!!!#!Overflow!condition!!!!!!!!!def!fetch_pc(!self!):!!!!!!!!!return!self.pc'

Page 26: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL:(ARMv5(Encodings(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 7(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

encodings!=![!!!!['nop',!!!'00000000000000000000000000000000'],!!!['mul',!!!'xxxx0000000xxxxxxxxxxxxx1001xxxx'],!!!['umull',!'xxxx0000100xxxxxxxxxxxxx1001xxxx'],!!!['adc',!!!'xxxx00x0101xxxxxxxxxxxxxxxxxxxxx'],!!!!['and',!!!'xxxx00x0000xxxxxxxxxxxxxxxxxxxxx'],!!!['b',!!!!!'xxxx1010xxxxxxxxxxxxxxxxxxxxxxxx'],!!!['bl',!!!!'xxxx1011xxxxxxxxxxxxxxxxxxxxxxxx'],!!!['bic',!!!'xxxx00x1110xxxxxxxxxxxxxxxxxxxxx'],!!!['bkpt',!!'111000010010xxxxxxxxxxxx0111xxxx'],!!!!#!...!!!!['teq',!!!'xxxx00x10011xxxxxxxxxxxxxxxxxxxx'],!!!['tst',!!!'xxxx00x10001xxxxxxxxxxxxxxxxxxxx'],!!]'

Page 27: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL:(ARMv5(Encodings(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 7(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

encodings!=![!!!!['nop',!!!'00000000000000000000000000000000'],!!!['mul',!!!'xxxx0000000xxxxxxxxxxxxx1001xxxx'],!!!['umull',!'xxxx0000100xxxxxxxxxxxxx1001xxxx'],!!!['adc',!!!'xxxx00x0101xxxxxxxxxxxxxxxxxxxxx'],!!!!['and',!!!'xxxx00x0000xxxxxxxxxxxxxxxxxxxxx'],!!!['b',!!!!!'xxxx1010xxxxxxxxxxxxxxxxxxxxxxxx'],!!!['bl',!!!!'xxxx1011xxxxxxxxxxxxxxxxxxxxxxxx'],!!!['bic',!!!'xxxx00x1110xxxxxxxxxxxxxxxxxxxxx'],!!!['bkpt',!!'111000010010xxxxxxxxxxxx0111xxxx'],!!!!#!...!!!!['teq',!!!'xxxx00x10011xxxxxxxxxxxxxxxxxxxx'],!!!['tst',!!!'xxxx00x10001xxxxxxxxxxxxxxxxxxxx'],!!]'

Page 28: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL:(ARMv5(Encodings(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 7(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

encodings!=![!!!!['nop',!!!'00000000000000000000000000000000'],!!!['mul',!!!'xxxx0000000xxxxxxxxxxxxx1001xxxx'],!!!['umull',!'xxxx0000100xxxxxxxxxxxxx1001xxxx'],!!!['adc',!!!'xxxx00x0101xxxxxxxxxxxxxxxxxxxxx'],!!!!['and',!!!'xxxx00x0000xxxxxxxxxxxxxxxxxxxxx'],!!!['b',!!!!!'xxxx1010xxxxxxxxxxxxxxxxxxxxxxxx'],!!!['bl',!!!!'xxxx1011xxxxxxxxxxxxxxxxxxxxxxxx'],!!!['bic',!!!'xxxx00x1110xxxxxxxxxxxxxxxxxxxxx'],!!!['bkpt',!!'111000010010xxxxxxxxxxxx0111xxxx'],!!!!#!...!!!!['teq',!!!'xxxx00x10011xxxxxxxxxxxxxxxxxxxx'],!!!['tst',!!!'xxxx00x10001xxxxxxxxxxxxxxxxxxxx'],!!]'

Page 29: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL:(ARMv5(Encodings(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 7(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

encodings!=![!!!!['nop',!!!'00000000000000000000000000000000'],!!!['mul',!!!'xxxx0000000xxxxxxxxxxxxx1001xxxx'],!!!['umull',!'xxxx0000100xxxxxxxxxxxxx1001xxxx'],!!!['adc',!!!'xxxx00x0101xxxxxxxxxxxxxxxxxxxxx'],!!!['add',!!!'xxxx00x0100xxxxxxxxxxxxxxxxxxxxx'],!!!['and',!!!'xxxx00x0000xxxxxxxxxxxxxxxxxxxxx'],!!!['b',!!!!!'xxxx1010xxxxxxxxxxxxxxxxxxxxxxxx'],!!!['bl',!!!!'xxxx1011xxxxxxxxxxxxxxxxxxxxxxxx'],!!!['bic',!!!'xxxx00x1110xxxxxxxxxxxxxxxxxxxxx'],!!!['bkpt',!!'111000010010xxxxxxxxxxxx0111xxxx'],!!!!#!...!!!!['teq',!!!'xxxx00x10011xxxxxxxxxxxxxxxxxxxx'],!!!['tst',!!!'xxxx00x10001xxxxxxxxxxxxxxxxxxxx'],!!]'

Page 30: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL:(ARMv5(Instruction(Semantics(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 8(/(20(

def!execute_add(!s,!inst!):!!!!!if!condition_passed(!s,!inst.cond()!):!!!!!a,!!!=!s.rf[!inst.rn()!]!!!!!b,!_!=!shifter_operand(!s,!inst!)!!!!!result!=!a!+!b!!!!!s.rf[!inst.rd()!]!=!trim_32(result)!!!!!!!if!inst.S():!!!!!!!#!...!!!!!!!s.N!=!(result!>>!31)&1!!!!!!!s.Z!=!trim_32(result)!==!0!!!!!!!s.C!=!carry_from(result)!!!!!!!s.V!=!overflow_from(a,!b,!result)!!!!!!!if!inst.rd()!==!15:!!!!!!!return!!!s.rf[PC]!=!s.fetch_pc()!+!4'

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Page 31: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL:(ARMv5(Instruction(Semantics(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 8(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

def!execute_add(!s,!inst!):!!!!!if!condition_passed(!s,!inst.cond()!):!!!!!a,!!!=!s.rf[!inst.rn()!]!!!!!b,!_!=!shifter_operand(!s,!inst!)!!!!!result!=!a!+!b!!!!!s.rf[!inst.rd()!]!=!trim_32(result)!!!!!!!if!inst.S():!!!!!!!#!...!!!!!!!s.N!=!(result!>>!31)&1!!!!!!!s.Z!=!trim_32(result)!==!0!!!!!!!s.C!=!carry_from(result)!!!!!!!s.V!=!overflow_from(a,!b,!result)!!!!!!!if!inst.rd()!==!15:!!!!!!!return!!!s.rf[PC]!=!s.fetch_pc()!+!4'

Page 32: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL:(ARMv5(Instruction(Semantics(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 8(/(20(

def!execute_add(!s,!inst!):!!!!!if!condition_passed(!s,!inst.cond()!):!!!!!a,!!!=!s.rf[!inst.rn()!]!!!!!b,!_!=!shifter_operand(!s,!inst!)!!!!!result!=!a!+!b!!!!!s.rf[!inst.rd()!]!=!trim_32(result)!!!!!!!if!inst.S():!!!!!!!#!...!!!!!!!s.N!=!(result!>>!31)&1!!!!!!!s.Z!=!trim_32(result)!==!0!!!!!!!s.C!=!carry_from(result)!!!!!!!s.V!=!overflow_from(a,!b,!result)!!!!!!!if!inst.rd()!==!15:!!!!!!!return!!!s.rf[PC]!=!s.fetch_pc()!+!4'

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Page 33: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL:(ARMv5(Instruction(Semantics(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 8(/(20(

def!execute_add(!s,!inst!):!!!!!if!condition_passed(!s,!inst.cond()!):!!!!!a,!!!=!s.rf[!inst.rn()!]!!!!!b,!_!=!shifter_operand(!s,!inst!)!!!!!result!=!a!+!b!!!!!s.rf[!inst.rd()!]!=!trim_32(result)!!!!!!!if!inst.S():!!!!!!!#!...!!!!!!!s.N!=!(result!>>!31)&1!!!!!!!s.Z!=!trim_32(result)!==!0!!!!!!!s.C!=!carry_from(result)!!!!!!!s.V!=!overflow_from(a,!b,!result)!!!!!!!if!inst.rd()!==!15:!!!!!!!return!!!s.rf[PC]!=!s.fetch_pc()!+!4'

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Page 34: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Pydgin(ADL:(ARMv5(Instruction(Semantics(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 8(/(20(

def!execute_add(!s,!inst!):!!!!!if!condition_passed(!s,!inst.cond()!):!!!!!a,!!!=!s.rf[!inst.rn()!]!!!!!b,!_!=!shifter_operand(!s,!inst!)!!!!!result!=!a!+!b!!!!!s.rf[!inst.rd()!]!=!trim_32(result)!!!!!!!if!inst.S():!!!!!!!#!...!!!!!!!s.N!=!(result!>>!31)&1!!!!!!!s.Z!=!trim_32(result)!==!0!!!!!!!s.C!=!carry_from(result)!!!!!!!s.V!=!overflow_from(a,!b,!result)!!!!!!!if!inst.rd()!==!15:!!!!!!!return!!!s.rf[PC]!=!s.fetch_pc()!+!4'

if!ConditionPassed(cond)!then!!!!Rd!=!Rn!+!shifter_operand!!!!if!S!==!1!and!Rd!==!R15!then!!!!!if!CurrentModeHasSPSR()!then!!!!!!!!CPSR!=!SPSR!!!!!else!UNPREDICTABLE!!!!else!if!S!==!1!then!!!!!N!Flag!=!Rd[31]!!!!!Z!Flag!=!if!Rd!==!0!then!1!else!0!!!!!C!Flag!=!CarryFrom(Rn!+!shifter_operand)!!!!!V!Flag!=!OverflowFrom(Rn!+!shifter_operand)(

ARM(ISA(MANUAL(SPEC(

Page 35: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Pydgin(ADL:(ARMv5(Instruction(Semantics(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 8(/(20(

def!execute_add(!s,!inst!):!!!!!if!condition_passed(!s,!inst.cond()!):!!!!!a,!!!=!s.rf[!inst.rn()!]!!!!!b,!_!=!shifter_operand(!s,!inst!)!!!!!result!=!a!+!b!!!!!s.rf[!inst.rd()!]!=!trim_32(result)!!!!!!!if!inst.S():!!!!!!!#!...!!!!!!!s.N!=!(result!>>!31)&1!!!!!!!s.Z!=!trim_32(result)!==!0!!!!!!!s.C!=!carry_from(result)!!!!!!!s.V!=!overflow_from(a,!b,!result)!!!!!!!if!inst.rd()!==!15:!!!!!!!return!!!s.rf[PC]!=!s.fetch_pc()!+!4'

ARM(ISA(MANUAL(SPEC(

if!ConditionPassed(cond)!then!!!!Rd!=!Rn!+!shifter_operand!!!!if!S!==!1!and!Rd!==!R15!then!!!!!if!CurrentModeHasSPSR()!then!!!!!!!!CPSR!=!SPSR!!!!!else!UNPREDICTABLE!!!!else!if!S!==!1!then!!!!!N!Flag!=!Rd[31]!!!!!Z!Flag!=!if!Rd!==!0!then!1!else!0!!!!!C!Flag!=!CarryFrom(Rn!+!shifter_operand)!!!!!V!Flag!=!OverflowFrom(Rn!+!shifter_operand)(

Page 36: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

RPython(ISS(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 9(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Page 37: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

RPython(ISS(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 9(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

!!!!def!instruction_set_interpreter(!memory!):!!!state!=!State(!memory!)!!!!!while!True:!!!!!!!pc!!!!!!=!state.fetch_pc()!!!!!!!inst!!!!=!memory[!pc!]!!!!!!#!fetch!!!!!execute!=!decode(!inst!)!!!!#!decode!!!!!execute(!state,!inst!)!!!!!!#!execute!

Page 38: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

RPython(ISS(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 9(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

!!!!def!instruction_set_interpreter(!memory!):!!!state!=!State(!memory!)!!!!!while!True:!!!!!!!pc!!!!!!=!state.fetch_pc()!!!!!!!inst!!!!=!memory[!pc!]!!!!!!#!fetch!!!!!execute!=!decode(!inst!)!!!!#!decode!!!!!execute(!state,!inst!)!!!!!!#!execute!

Page 39: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

RPython(ISS(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 9(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

!!!!def!instruction_set_interpreter(!memory!):!!!state!=!State(!memory!)!!!!!while!True:!!!!!!!pc!!!!!!=!state.fetch_pc()!!!!!!!inst!!!!=!memory[!pc!]!!!!!!#!fetch!!!!!execute!=!decode(!inst!)!!!!#!decode!!!!!execute(!state,!inst!)!!!!!!#!execute!

Page 40: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

RPython(ISS(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 9(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

!!!!def!instruction_set_interpreter(!memory!):!!!state!=!State(!memory!)!!!!!while!True:!!!!!!!pc!!!!!!=!state.fetch_pc()!!!!!!!inst!!!!=!memory[!pc!]!!!!!!#!fetch!!!!!execute!=!decode(!inst!)!!!!#!decode!!!!!execute(!state,!inst!)!!!!!!#!execute!

Page 41: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

RPython(ISS(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 9(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

>!python!iss.py!arm_binary(

!!!!def!instruction_set_interpreter(!memory!):!!!state!=!State(!memory!)!!!!!while!True:!!!!!!!pc!!!!!!=!state.fetch_pc()!!!!!!!inst!!!!=!memory[!pc!]!!!!!!#!fetch!!!!!execute!=!decode(!inst!)!!!!#!decode!!!!!execute(!state,!inst!)!!!!!!#!execute!!!'

Page 42: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

The(RPython(Translation(Toolchain(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 10(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Page 43: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

The(RPython(Translation(Toolchain(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 10(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

RPython�Source

Type�Inference

Op�miza�on

Code�Genera�on

Compila�on

Compiled�Interpreter

Page 44: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

The(RPython(Translation(Toolchain(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 10(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

RPython�Source

Type�Inference

Op�miza�on

Code�Genera�on

Compila�on

Compiled�Interpreter

>!./pydgin[nojit!arm_binary(

Page 45: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

RPython(ISS(with(JIT(Annotations(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 11(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

!!!!def!instruction_set_interpreter(!memory!):!!!state!=!State(!memory!)!!!!!while!True:!!!!!!!pc!!!!!!=!state.fetch_pc()!!!!!!!inst!!!!=!memory[!pc!]!!!!!!#!fetch!!!!!execute!=!decode(!inst!)!!!!#!decode!!!!!execute(!state,!inst!)!!!!!!#!execute!!!'

Page 46: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

RPython(ISS(with(JIT(Annotations(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 11(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

jd!=!JitDriver(!greens!=!['pc'],!!!!!!!!!!!!!!!!!reds!!!=!['state']!)!!!def!instruction_set_interpreter(!memory!):!!!state!=!State(!memory!)!!!!!while!True:!!!!!jd.jit_merge_point(!s.fetch_pc(),!state!)!!!!!!pc!!!!!!=!state.fetch_pc()!!!!!!!inst!!!!=!memory[!pc!]!!!!!!#!fetch!!!!!execute!=!decode(!inst!)!!!!#!decode!!!!!execute(!state,!inst!)!!!!!!#!execute!!!!!!!if!state.fetch_pc()!<!pc:!!!!!!!!jd.can_enter_jit(!s.fetch_pc(),!state!)('

Page 47: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

RPython(ISS(with(JIT(Annotations(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 11(/(20(

jd!=!JitDriver(!greens!=!['pc'],!!!!!!!!!!!!!!!!!reds!!!=!['state']!)!!!def!instruction_set_interpreter(!memory!):!!!state!=!State(!memory!)!!!!!while!True:!!!!!jd.jit_merge_point(!s.fetch_pc(),!state!)!!!!!!pc!!!!!!=!state.fetch_pc()!!!!!!!inst!!!!=!memory[!pc!]!!!!!!#!fetch!!!!!execute!=!decode(!inst!)!!!!#!decode!!!!!execute(!state,!inst!)!!!!!!#!execute!!!!!!!if!state.fetch_pc()!<!pc:!!!!!!!!jd.can_enter_jit(!s.fetch_pc(),!state!)('

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Page 48: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

The(RPython(Translation(Toolchain(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 12(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

RPython�Source

Type�Inference

Op�miza�on

Code�Genera�on

Compila�on

JIT�Generator

Compiled�Interpreter�with�JIT

Page 49: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

The(RPython(Translation(Toolchain(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 12(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

RPython�Source

Type�Inference

Op�miza�on

Code�Genera�on

Compila�on

JIT�Generator

Compiled�Interpreter�with�JIT

>!./pydgin[jit!arm_binary(

Page 50: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

JIT(Annotations(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 13(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Page 51: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

JIT(Annotations(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 13(/(20(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Crea-ng(a(compe--ve(JIT(requires(addi-onal(RPython(JIT(hints:(((

Page 52: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

JIT(Annotations(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 13(/(20(

Crea-ng(a(compe--ve(JIT(requires(addi-onal(RPython(JIT(hints:(((+ 'Minimal'JIT'Annota>ons''

SPECINT2006(

Page 53: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

JIT(Annotations(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 13(/(20(

Crea-ng(a(compe--ve(JIT(requires(addi-onal(RPython(JIT(hints:(((+ 'Minimal'JIT'Annota>ons'

+ 'Elidable'Instruc>on'Fetch'(

SPECINT2006(

Page 54: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

JIT(Annotations(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 13(/(20(

Crea-ng(a(compe--ve(JIT(requires(addi-onal(RPython(JIT(hints:(((+ 'Minimal'JIT'Annota>ons'

+ 'Elidable'Instruc>on'Fetch'+ 'Elidable'Decode''

SPECINT2006(

Page 55: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

JIT(Annotations(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Crea-ng(a(compe--ve(JIT(requires(addi-onal(RPython(JIT(hints:(((+ 'Minimal'JIT'Annota>ons'

+ 'Elidable'Instruc>on'Fetch'+ 'Elidable'Decode'+ 'Constant'Promo>on'of'PC'and'Memory'

SPECINT2006(

13(/(20(

Page 56: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

JIT(Annotations(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Crea-ng(a(compe--ve(JIT(requires(addi-onal(RPython(JIT(hints:(((+ 'Minimal'JIT'Annota>ons'

+ 'Elidable'Instruc>on'Fetch'+ 'Elidable'Decode'+ 'Constant'Promo>on'of'PC'and'Memory'

+ 'Word?Based'Target'Memory'(

SPECINT2006(

13(/(20(

Page 57: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

JIT(Annotations(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Crea-ng(a(compe--ve(JIT(requires(addi-onal(RPython(JIT(hints:(((+ 'Minimal'JIT'Annota>ons'

+ 'Elidable'Instruc>on'Fetch'+ 'Elidable'Decode'+ 'Constant'Promo>on'of'PC'and'Memory'

+ 'Word?Based'Target'Memory'

+ 'Loop'Unrolling'in'Instruc>on'Seman>cs''

SPECINT2006(

13(/(20(

Page 58: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

JIT(Annotations(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Crea-ng(a(compe--ve(JIT(requires(addi-onal(RPython(JIT(hints:(((+ 'Minimal'JIT'Annota>ons'

+ 'Elidable'Instruc>on'Fetch'+ 'Elidable'Decode'+ 'Constant'Promo>on'of'PC'and'Memory'

+ 'Word?Based'Target'Memory'

+ 'Loop'Unrolling'in'Instruc>on'Seman>cs'

+ 'Virtualizable'PC'and'Sta>s>cs'''

SPECINT2006(

13(/(20(

Page 59: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ISS(Evaluation(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Two(ISSs(implemented(in(Pydgin(•  Simplified?MIPS'• ARMv5'

'

'

14(/(20(

Page 60: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ISS(Evaluation(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Two(ISSs(implemented(in(Pydgin(•  Simplified?MIPS'• ARMv5'

Simplifica-ons(• GCC'cross?compiler'using'newlib'•  emulated'system'calls'•  “bare?metal”'system'(no'OS)''

14(/(20(

Page 61: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ISS(Evaluation(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Two(ISSs(implemented(in(Pydgin(•  Simplified?MIPS:''87?761'MIPS'• ARMv5'

Simplifica-ons(• GCC'cross?compiler'using'newlib'•  emulated'system'calls'•  “bare?metal”'system'(no'OS)''

'

14(/(20(

Page 62: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ISS(Evaluation:(ARMv5(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Two(ISSs(implemented(in(Pydgin(•  Simplified?MIPS:''87?761'MIPS'• ARMv5'

Simplifica-ons(• GCC'cross?compiler'using'newlib'•  emulated'system'calls'•  “bare?metal”'system'(no'OS)''

ARMv5'ISSs:'•  Interpre-ve:'gem5?atomic,'pydgin?nojit''

'14(/(20(

Page 63: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ISS(Evaluation:(ARMv5(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Two(ISSs(implemented(in(Pydgin(•  Simplified?MIPS:''87?761'MIPS'• ARMv5'

Simplifica-ons(• GCC'cross?compiler'using'newlib'•  emulated'system'calls'•  “bare?metal”'system'(no'OS)''

ARMv5'ISSs:'•  Interpre-ve:'gem5?atomic,'pydgin?nojit'• DBT: ' 'simit?jit,'pydgin?jit,'qemu''

' 14(/(20(

Page 64: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Pydgin(ISS(Evaluation:(ARMv5(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Pydgin(ADL(State'

Encoding'Seman>cs'

Pydgin''Interpreter'

Loop'

RPython'Transla>on'Toolchain'

Python(ISS(

Script(

Pydgin(ISS(

Executable(

Pydgin(DBT?ISS(

Executable(

Pydgin'JIT'

Annota>ons'

Two(ISSs(implemented(in(Pydgin(•  Simplified?MIPS:''87?761'MIPS'• ARMv5'

Simplifica-ons(• GCC'cross?compiler'using'newlib'•  emulated'system'calls'•  “bare?metal”'system'(no'OS)''

ARMv5'ISSs:'•  Interpre-ve:'gem5?atomic,'pydgin?nojit'• DBT: ' 'simit?jit,'pydgin?jit,'qemu*(

! !(*!not!fully!observable)''

'14(/(20(

Page 65: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

ISS(Comparison:(ARMv5(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 15(/(20(

Page 66: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

ISS(Comparison:(ARMv5(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Log(Scale(

15(/(20(

Page 67: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

ISS(Comparison:(ARMv5(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 15(/(20(

Page 68: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

ISS(Comparison:(ARMv5(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

10x(

15(/(20(

Page 69: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

ISS(Comparison:(ARMv5(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 15(/(20(

Page 70: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

ISS(Comparison:(ARMv5(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

200x(

15(/(20(

Page 71: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

ISS(Comparison:(ARMv5(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 15(/(20(

Page 72: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

ISS(Comparison:(ARMv5(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 15(/(20(

Page 73: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

ISS(Comparison:(ARMv5(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 15(/(20(

Page 74: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

ISS(Comparison:(ARMv5(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

poor'pydgin?jit'performance'due'to'large'number'of'trace'aborts'

15(/(20(

Page 75: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Performance(vs.(Maximum(Trace(Length(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 16(/(20(

Page 76: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Performance(vs.(Maximum(Trace(Length(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

speedup'normalized'to''results'in'the'paper'

16(/(20(

Page 77: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Performance(vs.(Maximum(Trace(Length(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

h264ref(

bzip2(

speedup'normalized'to''results'in'the'paper'

16(/(20(

Page 78: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Performance(vs.(Maximum(Trace(Length(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

h264ref(

bzip2(

speedup'normalized'to''results'in'the'paper'

16(/(20(

Page 79: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Results:(ARM(with(Longer(Traces(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Linear(Scale(

17(/(20(

Page 80: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Results:(ARM(with(Longer(Traces(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 17(/(20(

Page 81: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Results:(ARM(with(Longer(Traces(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

700+(MIPS!(

17(/(20(

Page 82: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Improving(with(RPython(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Pydgin'ISSs'benefit'from'performance'improvements'as'newer'versions'of'the'RPython'Transla>on'Toolchain'are'released.'

18(/(20(

Page 83: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Improving(with(RPython(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Pydgin'ISSs'benefit'from'performance'improvements'as'newer'versions'of'the'RPython'Transla>on'Toolchain'are'released.'

18(/(20(

Page 84: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Improving(with(RPython(

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Pydgin'ISSs'benefit'from'performance'improvements'as'newer'versions'of'the'RPython'Transla>on'Toolchain'are'released.'

15%(improvement(in(16(months(

18(/(20(

Page 85: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Conclusions(

Pydgin'provides'a'succinct,'embedded?DSL'within'Python'for'rapid'prototyping'of'ISAs'for'next?genera>on'hardware.''Pydgin'leverages'the'RPython'transla>on'toolchain'to'convert'these'descrip>ons'into'high?performance,'JIT?enabled'ISSs.''

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 19(/(20(

Page 86: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Conclusions(

Pydgin'provides'a'succinct,'embedded?DSL'within'Python'for'rapid'prototyping'of'ISAs'for'next?genera>on'hardware.''Pydgin'leverages'the'RPython'transla>on'toolchain'to'convert'these'descrip>ons'into'high?performance,'JIT?enabled'ISSs.''Many'opportuni>es'for'future'improvements:''• more'features'and'ISA'implementa>ons'•  performance'op>miza>ons'

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers( 19(/(20(

Page 87: Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators( from ...cbatten/pdfs/lockhart-pydgin-slides-ispass2015.pdfCornell'University' Computer'Systems'Laboratory' Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons((with(Meta?Tracing(JIT(Compilers

Conclusion(

Pydgin'is'a'produc>ve,'open?source(Python'framework'for'crea>ng'fast'instruc>on'set'simulators.'

''

hdps://github.com/cornell?brg/pydgin((

Thank'you'to'our'sponsors'for'their'support:''NSF,'DARPA,'and'dona>ons'from'Intel'Corpora>on'and'Synopsys,'Inc.'

Pydgin:(Genera-ng(Fast(Instruc-on(Set(Simulators(from(Simple(Architecture(Descrip-ons(with(Meta?Tracing(JIT(Compilers(

Pydgin

20(/(20(