SlideShare a Scribd company logo
1 of 27
Download to read offline
Bootstrapping a Smalltalk
G. Casaccio, S. Ducasse, L. Fabresse, J-B. Arnaud, B. van Ryseghem

Presented by: M. Denker




M.Denker - Bootstrapping a Smalltalk                         November 2011
What is Bootstrapping?




                    A process that builds
          the minimal infrastructure of a language
        that is reusable to define this language itself




  M.Denker - Bootstrapping a Smalltalk                   November 2011 -
Example: Bootstrapping a language X



                                               Tools
 Language X                     Compiler

                                           Loader




  M.Denker - Bootstrapping a Smalltalk                 November 2011 -
Example: Bootstrapping a language X



                                               Tools
 Language X                     Compiler

                                           Loader




  How to create/write all of this for language X?



  M.Denker - Bootstrapping a Smalltalk                 November 2011 -
Example: Bootstrapping a language X



                                                   Tools
 Language X                     Compiler

                                           Loader




                                           Compiler
 Language Y                 description       or
                                           Loader




  M.Denker - Bootstrapping a Smalltalk                     November 2011 -
Example: Bootstrapping a language X



                                                   Tools
 Language X                     Compiler
   Resilient                               Loader


       ≠
                                           Compiler
 Language Y                 description       or
                                           Loader
      Java



  M.Denker - Bootstrapping a Smalltalk                     November 2011 -
Example: Bootstrapping a language X



                                                   Tools
 Language X                     Compiler
 Squeak/Pharo                              Loader



       ⊃
                                           Compiler
 Language Y                 description       or
                                           Loader
     Slang



  M.Denker - Bootstrapping a Smalltalk                     November 2011 -
Why Bootstrapping?


   - Agile and explicit process

   - Explicit malleability and evolution support

   - Warranty of initial state

   - Minimal self reference




   M.Denker - Bootstrapping a Smalltalk            November 2011 -
Existing approaches

                                    Bootstrap Approaches



                        Execution-based                   Static-based
                               (tracing)                   (generation)




                  OnAbsence OnPresence Dumping Recreating
                      Spoon               Chacharas   MicroSqueak     CorGen
                                                       Hazelnut      GNU ST




   M.Denker - Bootstrapping a Smalltalk                                        November 2011 -
Existing approaches

                                    Bootstrap Approaches



                        Execution-based                   Static-based
                               (tracing)                   (generation)




                  OnAbsence OnPresence Dumping Recreating
                      Spoon               Chacharas   MicroSqueak     CorGen
                                                       Hazelnut      GNU ST




   M.Denker - Bootstrapping a Smalltalk                                        November 2011 -
Spoon

- Client / Server approach
- Client side starts as minimal
- On each slot access if the target object is missing, fetch and copy it from
the server

                                                                                                  ss
                                                                                             ce
                                                                                       t   ac
                                                                                  lo
                                                                           1   .s

                                         t
                                        jec




                                                                                                     t
                                                                                                  jec
                                   ob




                                                                                             ob
                                  ing




                                                                                         g
                              py




                                                                                     tin
                             co




                                                                                   ec
                                                                                 inj
                             3.




                                                                               4.
                    Server                                        Client


                                        2. slot absent grabbing
                                              it from server


      M.Denker - Bootstrapping a Smalltalk                                                               November 2011 -
Chacharas

 Same approach as Spoon but:

 - Analyze a server side execution

 - All reached objects are copied on the client




   M.Denker - Bootstrapping a Smalltalk           November 2011 -
MicroSqueak

1 - A kernel is loaded from              MicroSqueak             MicroSqueak
                                            Kernel                  Kernel
files into a namespace



                                                                    Fix references of
                                           Create stub objects         classes and
                                                                      metaclasses




                                         MicroSqueak             MicroSqueak
                                            Kernel                  Kernel




                                            Fix references of
                                                                          Save it
                                            compiled method




           M.Denker - Bootstrapping a Smalltalk                                         November 2011 -
Hazelnut


   Same approach as MicroSqueak but:

   - does not rely on a specific list of class that are manually edited

   - takes a list of classes as input and recursively copy classes into a new
   namespace




    M.Denker - Bootstrapping a Smalltalk                                        November 2011 -
Discussion                                                                 Bootstrap Approaches



                                                                      Execution-based         Static-based
Execution-based approaches:                                           (tracing)                 (generation)

- difficult to control which objects will be selected for the
bootstrapped image                                            OnAbsence OnPresence         Dumping Recreating
                                                                                          MicroSqueak      CorGen
- reflection breaks tracing                                     Spoon         Chacharas
                                                                                            Hazelnut      GNU ST

- not suitable for interactive programs
+ suitable to compute the minimal runtime required by a program

Static-based approaches:
+ easier to control the result of a static generation
+ suitable for deep changes in a system (new object format, ...)
- hard to specify / write / maintain



          M.Denker - Bootstrapping a Smalltalk                                                November 2011 -
Our approach

                                    Bootstrap Approaches



                        Execution-based               Static-based
                              (tracing)                (generation)




                 OnAbsence OnPresence Dumping Recreating
                      Spoon           Chacharas   MicroSqueak     CorGen
                                                   Hazelnut      GNU ST




   M.Denker - Bootstrapping a Smalltalk                                    November 2011 -
CorGen
                                                 Bootstrap>>bootstrap [

1. Creation of the stub objects for literal          self
                                                            instantiateSmalltalkObjects;
objects: nil, true, false, characters
2. Definition of classes and metaclasses                    importClassesFromSources;
3. Method compilation                                       processClasses;
4. Creation of process and special object array             setupSmalltalkObjects;
                                                            saveImage]
5. Image serialization.




          M.Denker - Bootstrapping a Smalltalk                                November 2011 -
Stubs Creation

  Bootstrap>>instantiateSmalltalkObjects [
   self
        instantiateNilGst;
        instantiateTrueGst;
        instantiateFalseGst;
        instantiateCharactersTable; "build all the characters"
        instantiateEnvironment "create System Dictionary"]




    M.Denker - Bootstrapping a Smalltalk                         November 2011 -
Classes/Metaclasses creation

 Bootstrap>>processClasses [
   "fill the class stubs with real classes"
   self
          "create classes and add them to System Dictionary"
          createClasses;

          "compile and install CompileMethods"
          compileMethods ]




    M.Denker - Bootstrapping a Smalltalk                       November 2011 -
Compile Methods


- Methods either taken from the model or the source files

- Use a compiler parametrized by an environment and a symbol table

- Deep changes may be applied (change bytecode set, other optimization, ...)




     M.Denker - Bootstrapping a Smalltalk                            November 2011 -
Initializing the System

 Bootstrap>>setupSmalltalkObjects [
    self setupCharacter; "insert references to the Character table"
         setupSymbol; "insert references to the Symbol table"
         setupProcessor "create Processor and install it" ]

 Bootstrap>>setupProcessor [ | processorGst |
    processGst := self createProcess.
    processorGst := GstProcessorScheduler new.
    processorGst scheduler: nilGst;
    processes: self buildProcessList;
    activeProcess: processGst;
    idleTasks: nilGst. ]

    M.Denker - Bootstrapping a Smalltalk                              November 2011 -
Initializing the System


    Bootstrap>>createProcess [
        | processGst |
        (processGst := GstProcess new)
             nextLink: nilGst;
             suspendedContext: self createInitContext;
             priority: 4;
             myList: nilGst;
             name: GstString new;
             interrupts: nilGst;
             interruptLock: nilGst ]



    M.Denker - Bootstrapping a Smalltalk                 November 2011 -
Saving the Image

- Comply with image file format:
   - Image header
   - Special object array

- Serialize objects according to their shape (CompiledMethods, ...)

- Avoid object duplication during serializing




     M.Denker - Bootstrapping a Smalltalk                             November 2011 -
The Result

A 54 classes Smalltalk Kernel:

   Kernel (15 classes): Behavior, BlockClosure, BlockContext, Boolean, Class,
   ClassDescription, ContextPart, False, Metaclass, MethodContext, MethodInfo, Object,
   ProcessorScheduler, True, UndefinedObject.

   Collection (27 classes): Array, ArrayedCollection, Bag, BindingDictionary, ByteArray,
   CharacterArray, Collection, CompiledBlock, CompiledCode, CompiledMethod, Dictionary,
   HashedCollection, IdentityDictionary, Iterable, Link, LinkedList, LookupTable,
   MethodDictionary, OrderedCollection, Process, Semaphore, SequenceableCollection, Set,
   String, Symbol, SystemDictionary, WeakSet.

   Magnitude (12 classes): Association, Character, Float, Fraction, Integer, LookupKey,
   Magnitude, MethodInfo, Number, SmallInteger, VariableBinding, HomedAssociation.


       M.Denker - Bootstrapping a Smalltalk                                    November 2011 -
Related Work
- Lisp : using image such Smalltalk, the bootstrap is done by migrate the
current image, using a cross-compiler include in the host image.

- Ruby : the kernel is load and initialize by the VM some low level initialization
is done in C, all the other is done by ruby processing. After all the module is
load separately by the Virtual Machine.

- Python : the Python virtual machine is initialized. Some classes stubs are
created and initialized in the virtual machine. (close of the ruby bootstrap)




       M.Denker - Bootstrapping a Smalltalk                                November 2011 -
Conclusion and Future Work

Pros and Cons:
   - Execution-based bootstrapping (tracing) such as Hazelnut
   - Static-based bootstrapping (declarative) such as CoreGen

Future work: Boostrapping Pharo
   - use an execution-based approach as an intermediate solution
   - reach a static-based bootstrap that can easily be maintained and co-
evolve with the system




    M.Denker - Bootstrapping a Smalltalk                             November 2011 -
THANKS

Bootstrapping a Smalltalk
G. Casaccio, S. Ducasse, L. Fabresse, J-B. Arnaud, B. van Ryseghem

Presented by: M. Denker




M.Denker - Bootstrapping a Smalltalk                         November 2011

More Related Content

More from Marcus Denker

ConstantBlocks in Pharo11
ConstantBlocks in Pharo11ConstantBlocks in Pharo11
ConstantBlocks in Pharo11Marcus Denker
 
First Class Variables as AST Annotations
First Class Variables as AST AnnotationsFirst Class Variables as AST Annotations
First Class Variables as AST AnnotationsMarcus Denker
 
Supporting Pharo / Getting Pharo Support
Supporting Pharo / Getting Pharo SupportSupporting Pharo / Getting Pharo Support
Supporting Pharo / Getting Pharo SupportMarcus Denker
 
Lecture: "Advanced Reflection: MetaLinks"
Lecture: "Advanced Reflection: MetaLinks"Lecture: "Advanced Reflection: MetaLinks"
Lecture: "Advanced Reflection: MetaLinks"Marcus Denker
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the DebuggerMarcus Denker
 
Lecture. Advanced Reflection: MetaLinks
Lecture. Advanced Reflection: MetaLinksLecture. Advanced Reflection: MetaLinks
Lecture. Advanced Reflection: MetaLinksMarcus Denker
 
Improving code completion for Pharo
Improving code completion for PharoImproving code completion for Pharo
Improving code completion for PharoMarcus Denker
 
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinksVUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinksMarcus Denker
 
Lecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinksLecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinksMarcus Denker
 
Open-Source: An Infinite Game
Open-Source: An Infinite GameOpen-Source: An Infinite Game
Open-Source: An Infinite GameMarcus Denker
 
PharoTechTalk: Contributing to Pharo
PharoTechTalk: Contributing to PharoPharoTechTalk: Contributing to Pharo
PharoTechTalk: Contributing to PharoMarcus Denker
 
Feedback Loops in Practice
Feedback Loops in PracticeFeedback Loops in Practice
Feedback Loops in PracticeMarcus Denker
 

More from Marcus Denker (20)

Soil And Pharo
Soil And PharoSoil And Pharo
Soil And Pharo
 
ConstantBlocks in Pharo11
ConstantBlocks in Pharo11ConstantBlocks in Pharo11
ConstantBlocks in Pharo11
 
Demo: Improved DoIt
Demo: Improved DoItDemo: Improved DoIt
Demo: Improved DoIt
 
First Class Variables as AST Annotations
First Class Variables as AST AnnotationsFirst Class Variables as AST Annotations
First Class Variables as AST Annotations
 
Supporting Pharo / Getting Pharo Support
Supporting Pharo / Getting Pharo SupportSupporting Pharo / Getting Pharo Support
Supporting Pharo / Getting Pharo Support
 
Lecture: "Advanced Reflection: MetaLinks"
Lecture: "Advanced Reflection: MetaLinks"Lecture: "Advanced Reflection: MetaLinks"
Lecture: "Advanced Reflection: MetaLinks"
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Variables in Pharo
Variables in PharoVariables in Pharo
Variables in Pharo
 
Lecture. Advanced Reflection: MetaLinks
Lecture. Advanced Reflection: MetaLinksLecture. Advanced Reflection: MetaLinks
Lecture. Advanced Reflection: MetaLinks
 
Improving code completion for Pharo
Improving code completion for PharoImproving code completion for Pharo
Improving code completion for Pharo
 
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinksVUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
 
Slot Composition
Slot CompositionSlot Composition
Slot Composition
 
Lecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinksLecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinks
 
PHARO IOT
PHARO IOTPHARO IOT
PHARO IOT
 
Open-Source: An Infinite Game
Open-Source: An Infinite GameOpen-Source: An Infinite Game
Open-Source: An Infinite Game
 
Lecture: MetaLinks
Lecture: MetaLinksLecture: MetaLinks
Lecture: MetaLinks
 
PharoTechTalk: Contributing to Pharo
PharoTechTalk: Contributing to PharoPharoTechTalk: Contributing to Pharo
PharoTechTalk: Contributing to Pharo
 
Feedback Loops in Practice
Feedback Loops in PracticeFeedback Loops in Practice
Feedback Loops in Practice
 
Pharo6 - ESUG17
Pharo6 - ESUG17Pharo6 - ESUG17
Pharo6 - ESUG17
 
Pharo6
Pharo6Pharo6
Pharo6
 

Recently uploaded

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 

Recently uploaded (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 

Boostrapping a Smalltalk

  • 1. Bootstrapping a Smalltalk G. Casaccio, S. Ducasse, L. Fabresse, J-B. Arnaud, B. van Ryseghem Presented by: M. Denker M.Denker - Bootstrapping a Smalltalk November 2011
  • 2. What is Bootstrapping? A process that builds the minimal infrastructure of a language that is reusable to define this language itself M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 3. Example: Bootstrapping a language X Tools Language X Compiler Loader M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 4. Example: Bootstrapping a language X Tools Language X Compiler Loader How to create/write all of this for language X? M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 5. Example: Bootstrapping a language X Tools Language X Compiler Loader Compiler Language Y description or Loader M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 6. Example: Bootstrapping a language X Tools Language X Compiler Resilient Loader ≠ Compiler Language Y description or Loader Java M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 7. Example: Bootstrapping a language X Tools Language X Compiler Squeak/Pharo Loader ⊃ Compiler Language Y description or Loader Slang M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 8. Why Bootstrapping? - Agile and explicit process - Explicit malleability and evolution support - Warranty of initial state - Minimal self reference M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 9. Existing approaches Bootstrap Approaches Execution-based Static-based (tracing) (generation) OnAbsence OnPresence Dumping Recreating Spoon Chacharas MicroSqueak CorGen Hazelnut GNU ST M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 10. Existing approaches Bootstrap Approaches Execution-based Static-based (tracing) (generation) OnAbsence OnPresence Dumping Recreating Spoon Chacharas MicroSqueak CorGen Hazelnut GNU ST M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 11. Spoon - Client / Server approach - Client side starts as minimal - On each slot access if the target object is missing, fetch and copy it from the server ss ce t ac lo 1 .s t jec t jec ob ob ing g py tin co ec inj 3. 4. Server Client 2. slot absent grabbing it from server M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 12. Chacharas Same approach as Spoon but: - Analyze a server side execution - All reached objects are copied on the client M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 13. MicroSqueak 1 - A kernel is loaded from MicroSqueak MicroSqueak Kernel Kernel files into a namespace Fix references of Create stub objects classes and metaclasses MicroSqueak MicroSqueak Kernel Kernel Fix references of Save it compiled method M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 14. Hazelnut Same approach as MicroSqueak but: - does not rely on a specific list of class that are manually edited - takes a list of classes as input and recursively copy classes into a new namespace M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 15. Discussion Bootstrap Approaches Execution-based Static-based Execution-based approaches: (tracing) (generation) - difficult to control which objects will be selected for the bootstrapped image OnAbsence OnPresence Dumping Recreating MicroSqueak CorGen - reflection breaks tracing Spoon Chacharas Hazelnut GNU ST - not suitable for interactive programs + suitable to compute the minimal runtime required by a program Static-based approaches: + easier to control the result of a static generation + suitable for deep changes in a system (new object format, ...) - hard to specify / write / maintain M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 16. Our approach Bootstrap Approaches Execution-based Static-based (tracing) (generation) OnAbsence OnPresence Dumping Recreating Spoon Chacharas MicroSqueak CorGen Hazelnut GNU ST M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 17. CorGen Bootstrap>>bootstrap [ 1. Creation of the stub objects for literal self instantiateSmalltalkObjects; objects: nil, true, false, characters 2. Definition of classes and metaclasses importClassesFromSources; 3. Method compilation processClasses; 4. Creation of process and special object array setupSmalltalkObjects; saveImage] 5. Image serialization. M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 18. Stubs Creation Bootstrap>>instantiateSmalltalkObjects [ self instantiateNilGst; instantiateTrueGst; instantiateFalseGst; instantiateCharactersTable; "build all the characters" instantiateEnvironment "create System Dictionary"] M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 19. Classes/Metaclasses creation Bootstrap>>processClasses [ "fill the class stubs with real classes" self "create classes and add them to System Dictionary" createClasses; "compile and install CompileMethods" compileMethods ] M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 20. Compile Methods - Methods either taken from the model or the source files - Use a compiler parametrized by an environment and a symbol table - Deep changes may be applied (change bytecode set, other optimization, ...) M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 21. Initializing the System Bootstrap>>setupSmalltalkObjects [ self setupCharacter; "insert references to the Character table" setupSymbol; "insert references to the Symbol table" setupProcessor "create Processor and install it" ] Bootstrap>>setupProcessor [ | processorGst | processGst := self createProcess. processorGst := GstProcessorScheduler new. processorGst scheduler: nilGst; processes: self buildProcessList; activeProcess: processGst; idleTasks: nilGst. ] M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 22. Initializing the System Bootstrap>>createProcess [ | processGst | (processGst := GstProcess new) nextLink: nilGst; suspendedContext: self createInitContext; priority: 4; myList: nilGst; name: GstString new; interrupts: nilGst; interruptLock: nilGst ] M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 23. Saving the Image - Comply with image file format: - Image header - Special object array - Serialize objects according to their shape (CompiledMethods, ...) - Avoid object duplication during serializing M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 24. The Result A 54 classes Smalltalk Kernel: Kernel (15 classes): Behavior, BlockClosure, BlockContext, Boolean, Class, ClassDescription, ContextPart, False, Metaclass, MethodContext, MethodInfo, Object, ProcessorScheduler, True, UndefinedObject. Collection (27 classes): Array, ArrayedCollection, Bag, BindingDictionary, ByteArray, CharacterArray, Collection, CompiledBlock, CompiledCode, CompiledMethod, Dictionary, HashedCollection, IdentityDictionary, Iterable, Link, LinkedList, LookupTable, MethodDictionary, OrderedCollection, Process, Semaphore, SequenceableCollection, Set, String, Symbol, SystemDictionary, WeakSet. Magnitude (12 classes): Association, Character, Float, Fraction, Integer, LookupKey, Magnitude, MethodInfo, Number, SmallInteger, VariableBinding, HomedAssociation. M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 25. Related Work - Lisp : using image such Smalltalk, the bootstrap is done by migrate the current image, using a cross-compiler include in the host image. - Ruby : the kernel is load and initialize by the VM some low level initialization is done in C, all the other is done by ruby processing. After all the module is load separately by the Virtual Machine. - Python : the Python virtual machine is initialized. Some classes stubs are created and initialized in the virtual machine. (close of the ruby bootstrap) M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 26. Conclusion and Future Work Pros and Cons: - Execution-based bootstrapping (tracing) such as Hazelnut - Static-based bootstrapping (declarative) such as CoreGen Future work: Boostrapping Pharo - use an execution-based approach as an intermediate solution - reach a static-based bootstrap that can easily be maintained and co- evolve with the system M.Denker - Bootstrapping a Smalltalk November 2011 -
  • 27. THANKS Bootstrapping a Smalltalk G. Casaccio, S. Ducasse, L. Fabresse, J-B. Arnaud, B. van Ryseghem Presented by: M. Denker M.Denker - Bootstrapping a Smalltalk November 2011