towards a flexible pharo compiler
play

Towards a flexible Pharo Compiler Clement Bera and Marcus Denker - PowerPoint PPT Presentation

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


  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 Smalltalk source code • RB AST RBParser Refactoring browser abstract OCSemanticAnnotator • Visitors syntax tree ASTTranslator + IRBuilder • Bytecode Intermediate representation level IR IRByteCodeGenerator Bytecode

  8. Reusability • AST is unchanged • Backend independent Oz/Hazelnut AST Interpreter Node navigation Smart suggestions Reflectivity Metalinks Class Builder

  9. Parametrization • Explicit Smalltalk source code compiler Refactoring browser context abstract syntax tree Compilation context • All visitors Intermediate representation are pluggable Bytecode

  10. Compiler Options • Turn off inlining of ifTrue: and friends MyClass>>foo <compilerOptions: - optionInlineIf> ^ #myNonBooleanObject ifTrue: [ 1 ] ifFalse: [ 0 ]

  11. Mapping Bytecode IRMethod RBMethodNode source code foo 76 77 B0 B0 foo ^ 1 + 2 + 3 20 B0 7C ^ 1 + 2 + 3 + 2 IRSequence IRPushLiteral RBSequenceNode RBLiteral ^ 1 + 2 + 3 ValueNode 1 • Mapping IRPushLiteral RBReturnNode RBLiteral ^ 1 + 2 + 3 ValueNode 2 uses AST IRSend RBMessageNode 1 RBMessageNode 2 + 3 directly IRPushLiteral RBLiteral RBLiteral RBMessageNode 2 ValueNode 3 ValueNode 3 + 2 3 IRSend RBMessageNode 1 RBLiteral RBLiteral ValueNode 1 ValueNode 2 IRReturn 1 2 RBReturnNode

  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?

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