SlideShare a Scribd company logo
Towards a flexible
Pharo Compiler
Clement Bera and Marcus Denker
Three Problems
• Architecture is not reusable
• Compiler can not be parametrized
• The mapping between source code and
bytecode is overly complex.
Reusability
• AST is special for the Compiler
• Tools use own AST (RB)
• AST is destroyed when compiling
• No reusable backend/parser...
No Parametrization
• No pluggable archicture
• Parser, code generator fixed
• No infrastructure for compiler options
Mapping bc2source
• For the Debugger, we need to map
bytecode to source offsets
• With closures, we need to map temp
offsets to real temps.
Old Compiler: Encoder builds
complex table structure
Solution: OPAL
• New compiler framework for Pharo
• Default compiler in Pharo3
• Old Compiler will be a loadable package
Design
• RB AST
• Visitors
• Bytecode
level IR
Smalltalk source code
Refactoring browser abstract
syntax tree
Intermediate representation
Bytecode
RBParser
ASTTranslator + IRBuilder
IRByteCodeGenerator
OCSemanticAnnotator
Reusability
• AST is unchanged
• Backend independent
AST Interpreter
Oz/Hazelnut
Reflectivity
Metalinks
Class Builder
Smart suggestions
Node navigation
Parametrization
• Explicit
compiler
context
• All visitors
are pluggable
Smalltalk source code
Refactoring browser
abstract syntax tree
Intermediate representation
Bytecode
Compilation context
Compiler Options
• Turn off inlining of ifTrue: and friends
MyClass>>foo
<compilerOptions: - optionInlineIf>
^ #myNonBooleanObject
ifTrue: [ 1 ]
ifFalse: [ 0 ]
Mapping
• Mapping
uses AST
directly
source codeBytecode
foo
^ 1 + 2 + 3
76 77 B0
20 B0 7C
IRMethod RBMethodNode
RBSequenceNode
RBReturnNode
RBMessageNode 1
RBLiteral
ValueNode 1
IRPushLiteral
IRSequence
RBLiteral
ValueNode 1
IRPushLiteral
RBLiteral
ValueNode 2
IRReturn
RBReturnNode
IRSend
RBMessageNode 1
IRPushLiteral
RBLiteral
ValueNode 3
RBMessageNode 2 RBLiteral
ValueNode 3
IRSend
RBMessageNode 2
B0
+ 2
1 2
3
+ 2
+ 3
^ 1 + 2 + 3
^ 1 + 2 + 3
foo
^ 1 + 2 + 3
RBLiteral
ValueNode 2
Performance
• Visitors and IR do cost a bit of speed
• But not much
Conclusion
• Opal solves the problems of the old
compiler
• Important basis for many features you will
see in Pharo3 and Pharo4
Conclusion
• Opal solves the problems of the old
compiler
• Important basis for many features you will
see in Pharo3 and Pharo4
Questions?

More Related Content

PPTX
Network layer Part 5
PPT
Compilation
PDF
Introduction to spartakus and how it can help fight linux kernel ABI breakages
PPTX
Linker and loader upload
PPT
A hands-on introduction to the ELF Object file format
PDF
Dynamic pricing of Lyft rides using streaming
PDF
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
PPTX
TINA showcase: MOOSE Scalable Ethernet
Network layer Part 5
Compilation
Introduction to spartakus and how it can help fight linux kernel ABI breakages
Linker and loader upload
A hands-on introduction to the ELF Object file format
Dynamic pricing of Lyft rides using streaming
Python Streaming Pipelines on Flink - Beam Meetup at Lyft 2019
TINA showcase: MOOSE Scalable Ethernet

Viewers also liked (9)

PDF
Talk: An Instrument whose Music is Ideas
PDF
Unstuck
PDF
Lecture: Reflection
PDF
Pharo3 at Fosdem
PDF
Pharo: Syntax in a Nutshell
PDF
Pharo ESUG
PDF
Pharo Status (from PharoDays 2015)
PPT
Business Diagram V2
PDF
Practical Object-Oriented Back-in-Time Debugging
Talk: An Instrument whose Music is Ideas
Unstuck
Lecture: Reflection
Pharo3 at Fosdem
Pharo: Syntax in a Nutshell
Pharo ESUG
Pharo Status (from PharoDays 2015)
Business Diagram V2
Practical Object-Oriented Back-in-Time Debugging
Ad

Similar to Towards a flexible Pharo Compiler (20)

PPT
assem.ppt
PPTX
CSC 204 PASSES IN COMPILER CONSTURCTION.pptx
ZIP
Inside Python [OSCON 2012]
KEY
Inside Python
PPTX
Compiler Construction
PDF
Alchemist: An Apache Spark <=> MPI Interface with Michael Mahoney and Kai Rot...
PDF
C# 8 and .NET Core 3
PPTX
C Programming for ARM.pptx
PDF
The reasons why 64-bit programs require more stack memory
PPTX
ORC Deep Dive 2020
PDF
1 introduction to compiler
PPTX
Valuable Information on Lexical Analysis in Compiler Design
PDF
Design for Scalability in ADAM
PDF
Scalable up genomic analysis with ADAM
PDF
04-machine-basics great ppt ever you seen
PDF
Writing High Peformance C# 7 Code
PDF
Database in Kubernetes: Diagnostics and Monitoring
PDF
So You Want to Write a Connector?
PDF
Performance improvements in etcd 3.5 release
PPTX
Embedded computing platform design
assem.ppt
CSC 204 PASSES IN COMPILER CONSTURCTION.pptx
Inside Python [OSCON 2012]
Inside Python
Compiler Construction
Alchemist: An Apache Spark <=> MPI Interface with Michael Mahoney and Kai Rot...
C# 8 and .NET Core 3
C Programming for ARM.pptx
The reasons why 64-bit programs require more stack memory
ORC Deep Dive 2020
1 introduction to compiler
Valuable Information on Lexical Analysis in Compiler Design
Design for Scalability in ADAM
Scalable up genomic analysis with ADAM
04-machine-basics great ppt ever you seen
Writing High Peformance C# 7 Code
Database in Kubernetes: Diagnostics and Monitoring
So You Want to Write a Connector?
Performance improvements in etcd 3.5 release
Embedded computing platform design
Ad

More from Marcus Denker (20)

PDF
Soil And Pharo
PDF
ConstantBlocks in Pharo11
PDF
Demo: Improved DoIt
PDF
First Class Variables as AST Annotations
PDF
Supporting Pharo / Getting Pharo Support
PDF
Lecture: "Advanced Reflection: MetaLinks"
PDF
thisContext in the Debugger
PDF
Variables in Pharo
PDF
Lecture. Advanced Reflection: MetaLinks
PDF
Improving code completion for Pharo
PDF
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
PDF
Slot Composition
PDF
Lecture: Advanced Reflection. MetaLinks
PDF
PHARO IOT
PDF
Open-Source: An Infinite Game
PDF
Lecture: MetaLinks
PDF
PharoTechTalk: Contributing to Pharo
PDF
Feedback Loops in Practice
PDF
Pharo6 - ESUG17
PDF
Soil And Pharo
ConstantBlocks in Pharo11
Demo: Improved DoIt
First Class Variables as AST Annotations
Supporting Pharo / Getting Pharo Support
Lecture: "Advanced Reflection: MetaLinks"
thisContext in the Debugger
Variables in Pharo
Lecture. Advanced Reflection: MetaLinks
Improving code completion for Pharo
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
Slot Composition
Lecture: Advanced Reflection. MetaLinks
PHARO IOT
Open-Source: An Infinite Game
Lecture: MetaLinks
PharoTechTalk: Contributing to Pharo
Feedback Loops in Practice
Pharo6 - ESUG17

Recently uploaded (20)

PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Hybrid model detection and classification of lung cancer
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Zenith AI: Advanced Artificial Intelligence
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
1. Introduction to Computer Programming.pptx
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
August Patch Tuesday
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Assigned Numbers - 2025 - Bluetooth® Document
Web App vs Mobile App What Should You Build First.pdf
DP Operators-handbook-extract for the Mautical Institute
Hybrid model detection and classification of lung cancer
Encapsulation_ Review paper, used for researhc scholars
NewMind AI Weekly Chronicles - August'25-Week II
Zenith AI: Advanced Artificial Intelligence
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
WOOl fibre morphology and structure.pdf for textiles
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Unlocking AI with Model Context Protocol (MCP)
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
1. Introduction to Computer Programming.pptx
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
August Patch Tuesday

Towards a flexible Pharo Compiler

  • 1. Towards a flexible Pharo Compiler Clement Bera and Marcus Denker
  • 2. Three Problems • Architecture is not reusable • Compiler can not be parametrized • The mapping between source code and bytecode is overly complex.
  • 3. Reusability • AST is special for the Compiler • Tools use own AST (RB) • AST is destroyed when compiling • No reusable backend/parser...
  • 4. No Parametrization • No pluggable archicture • Parser, code generator fixed • No infrastructure for compiler options
  • 5. Mapping bc2source • For the Debugger, we need to map bytecode to source offsets • With closures, we need to map temp offsets to real temps. Old Compiler: Encoder builds complex table structure
  • 6. Solution: OPAL • New compiler framework for Pharo • Default compiler in Pharo3 • Old Compiler will be a loadable package
  • 7. Design • RB AST • Visitors • Bytecode level IR Smalltalk source code Refactoring browser abstract syntax tree Intermediate representation Bytecode RBParser ASTTranslator + IRBuilder IRByteCodeGenerator OCSemanticAnnotator
  • 8. Reusability • AST is unchanged • Backend independent AST Interpreter Oz/Hazelnut Reflectivity Metalinks Class Builder Smart suggestions Node navigation
  • 9. Parametrization • Explicit compiler context • All visitors are pluggable Smalltalk source code Refactoring browser abstract syntax tree Intermediate representation Bytecode Compilation context
  • 10. Compiler Options • Turn off inlining of ifTrue: and friends MyClass>>foo <compilerOptions: - optionInlineIf> ^ #myNonBooleanObject ifTrue: [ 1 ] ifFalse: [ 0 ]
  • 11. Mapping • Mapping uses AST directly source codeBytecode foo ^ 1 + 2 + 3 76 77 B0 20 B0 7C IRMethod RBMethodNode RBSequenceNode RBReturnNode RBMessageNode 1 RBLiteral ValueNode 1 IRPushLiteral IRSequence RBLiteral ValueNode 1 IRPushLiteral RBLiteral ValueNode 2 IRReturn RBReturnNode IRSend RBMessageNode 1 IRPushLiteral RBLiteral ValueNode 3 RBMessageNode 2 RBLiteral ValueNode 3 IRSend RBMessageNode 2 B0 + 2 1 2 3 + 2 + 3 ^ 1 + 2 + 3 ^ 1 + 2 + 3 foo ^ 1 + 2 + 3 RBLiteral ValueNode 2
  • 12. Performance • Visitors and IR do cost a bit of speed • But not much
  • 13. Conclusion • Opal solves the problems of the old compiler • Important basis for many features you will see in Pharo3 and Pharo4
  • 14. Conclusion • Opal solves the problems of the old compiler • Important basis for many features you will see in Pharo3 and Pharo4 Questions?