SlideShare a Scribd company logo
1 of 61
Download to read offline
Mariano Martinez Peck
                                marianopeck@gmail.com
                          http://marianopeck.wordpress.com/



                                          1

Monday, August 22, 2011
What is a proxy?

                           A proxy object is a surrogate or
                          placeholder that controls access to
                                another target object.




                                           2
Monday, August 22, 2011
Glossary

                          Target: object to proxify.

                          Client: user of the proxy.

                           Interceptor: object that intercepts message
                          sending.

                           Handler: object that performs a desired
                          action as a consequence of an interception.

                                               3
Monday, August 22, 2011
Forwarder and
                          Logging example




                                 4
Monday, August 22, 2011
With or without
                  Object replacement?

                           In proxies with object replacement
                          (#become:), the target object is replaced by a
                          proxy.

                          Proxies without object replacement are a
                          kind of factory.



                                               5
Monday, August 22, 2011
With or without
                  Object replacement?

                           In proxies with object replacement
                          (#become:), the target object is replaced by a
                          proxy.

                          Proxies without object replacement are a
                          kind of factory.



                                               5
Monday, August 22, 2011
Traditional proxy
                           implementations
 Usage of a minimal object together with an implementation of a
                 custom #doesNotUnderstand
                     ProtoObject
                 identityHash
                 pointersTo
                 nextObject
                 ...



                          Proxy
            target
            doesNotUnderstand:
            executeBeforeHandling
            executeAfterHandling
                                    6
Monday, August 22, 2011
We are going to play
                    a little game...




                           7
Monday, August 22, 2011
Are both prints in Transcript the same or not?




                                                8
Monday, August 22, 2011
Are both prints in Transcript the same or not?



          Conclusion: methods understood are NOT intercepted.
                              Is that bad?




                                                8
Monday, August 22, 2011
Are both prints in Transcript the same or not?



          Conclusion: methods understood are NOT intercepted.
                              Is that bad?




        Different execution paths               8
                                                          Errors difficult to find
Monday, August 22, 2011
Do we want the regular #doesNotUnderstand
                                 or to intercept the message?
                                              9
Monday, August 22, 2011
Do we want the regular #doesNotUnderstand
                                 or to intercept the message?
                                              10
Monday, August 22, 2011
I wanted the normal #doesNotUnderstand!!!
                            11
Monday, August 22, 2011
I wanted the normal #doesNotUnderstand!!!
                             12
Monday, August 22, 2011
Problems
                   #doesNotUnderstand: cannot be trapped like a
                  regular message.

                   Mix of handling procedure and proxy
                  interception.

                   Only methods that are not understood are
                  intercepted.

                    No separation between proxies and handlers

                                    This approach is not stratified
                                         13
Monday, August 22, 2011
Subclassing from nil does not solve
                the problem.



                          14
Monday, August 22, 2011
VM CRASH




                          This solution is not uniform
                                        15
Monday, August 22, 2011
A Uniform, Light-weight and Stratified Proxy
           Model and Implementation.
                          16
Monday, August 22, 2011
Used hooks

                          Object replacement (#become:)

                          Change an object’s class (#adoptInstance:)

                          Objects as methods (#run:with:in:)

                           Classes with no method dictionary
                          (#cannotInterpret:)


                                              17
Monday, August 22, 2011
Object replacement

                          B                             B
       A                                        A
                                  c become: d
                              D                             D
                  C                                 C




                                      18
Monday, August 22, 2011
Objects as methods



         The VM sends #run: aSelector with: anArray in: aReceiver




                                   19
Monday, August 22, 2011
Objects as methods



         The VM sends #run: aSelector with: anArray in: aReceiver
         So.....We can implement in Proxy:




                                   19
Monday, August 22, 2011
CLasses with no
                           method dictionary
                           References                                        Object
                            instance of
                            message send
                            lookup
                            subclass                                         Proxy
                                                                  cannotInterpret: aMessage


                     aProxy username           4: #cannotInterpret: lookup

                          1: #username send
                                                                        ProxyTrap
                                                                       methodDict := nil
                                  aProxy

                                                 2: #aProxy lookup



                     3: Since the method dictionary was nil,
                        the VM sends #cannotInterpret to
              the receiver but starting the lookup in the superclass
                                                      20
Monday, August 22, 2011
Ghost model
                                                        Interception
                                Object               message
                                                     proxy
                                                     proxyState



                                                        ProxyHandler
                                 Proxy
                                             handleInterception: anInterception
                          handler
                          target
                          cannotInterpret:
                          proxyFor:             SimpleForwarderHandler
                                             handleInterception: anInterception

                                ProxyTrap
                          initialize
                          nilMethodDict

                                                21
Monday, August 22, 2011
How it works?         Object




                                                 Proxy
                                          handler
                                          target
                                          cannotInterpret:
                                          proxyFor:



                                                ProxyTrap
                                          initialize
                                          nilMethodDict




                                22
Monday, August 22, 2011
How it works?         Object




                                                 Proxy
                                          handler
                                          target
                                          cannotInterpret:
    Proxy class >>                        proxyFor:



                                                ProxyTrap
                                          initialize
                                          nilMethodDict




                                22
Monday, August 22, 2011
How it works?                                 Object




                                                          Of
                                                                         Proxy

                                                       ce
                                                                  handler

                                                 ns tan           target

    Proxy class >>                              i                 cannotInterpret:
                                                                  proxyFor:
                                aProxy
                                                                        ProxyTrap
                                                                  initialize
                                                                  nilMethodDict




                                     aHandler         ‘Mariano’




                                22
Monday, August 22, 2011
How it works?                                 Object




                                                          Of
                                                                         Proxy

                                                       ce
                                                                  handler

                                                 ns tan           target

    Proxy class >>                              i                 cannotInterpret:
                                                                  proxyFor:
                                aProxy
                                                                        ProxyTrap
                                                                  initialize
                                                                  nilMethodDict




                                     aHandler         ‘Mariano’


    ProxyTrap class >>



                                22
Monday, August 22, 2011
How it works?                           Object




                                                                   Proxy
                                                            handler
                                                            target
                                                            cannotInterpret:
    Proxy class >>
                                aProxy ins                  proxyFor:
                                           tan
                                               ce
                                                  Of              ProxyTrap
                                                            initialize
                                                            nilMethodDict




                                     aHandler   ‘Mariano’


    ProxyTrap class >>



                                22
Monday, August 22, 2011
How it works?                           Object




                                                                   Proxy
                                                            handler
                                                            target
                                                            cannotInterpret:
    Proxy class >>
                                aProxy ins                  proxyFor:
                                           tan
                                               ce
                                                  Of              ProxyTrap
                                                            initialize
                                                            nilMethodDict




                                     aHandler   ‘Mariano’




                                22
Monday, August 22, 2011
How it works?
                                References
                                instance of                                     Object
                                message send
                                lookup
                                subclass
                                                                                Proxy
                                                                     cannotInterpret: aMessage



                               aProxy username
                                                           4: #cannotInterpret: lookup
                                1: #username send
                                                                             ProxyTrap
                                                                          methodDict := nil
                                         aProxy
                                                               2: #aProxy lookup




                                                      3: Since the method dictionary was nil,
                                                         the VM sends #cannotInterpret to
                                               the receiver but starting the lookup in the superclass




                                  23
Monday, August 22, 2011
How it works?
                                References
                                instance of                                     Object
                                message send
                                lookup
                                subclass
                                                                                Proxy
                                                                     cannotInterpret: aMessage



                               aProxy username
                                                           4: #cannotInterpret: lookup
                                1: #username send
                                                                             ProxyTrap
                                                                          methodDict := nil
                                         aProxy
                                                               2: #aProxy lookup




                                                      3: Since the method dictionary was nil,
                                                         the VM sends #cannotInterpret to
                                               the receiver but starting the lookup in the superclass




                                  23
Monday, August 22, 2011
How it works?
                                References
                                instance of                                     Object
                                message send
                                lookup
                                subclass
                                                                                Proxy
                                                                     cannotInterpret: aMessage



                               aProxy username
                                                           4: #cannotInterpret: lookup
                                1: #username send
                                                                             ProxyTrap
                                                                          methodDict := nil
                                         aProxy
                                                               2: #aProxy lookup




                                                      3: Since the method dictionary was nil,
                                                         the VM sends #cannotInterpret to
                                               the receiver but starting the lookup in the superclass




                                  23
Monday, August 22, 2011
How it works?
                                References
                                instance of                                     Object
                                message send
                                lookup
                                subclass
                                                                                Proxy
                                                                     cannotInterpret: aMessage



                               aProxy username
                                                           4: #cannotInterpret: lookup
                                1: #username send
                                                                             ProxyTrap
                                                                          methodDict := nil
                                         aProxy
                                                               2: #aProxy lookup




                                                      3: Since the method dictionary was nil,
                                                         the VM sends #cannotInterpret to
                                               the receiver but starting the lookup in the superclass




                                  23
Monday, August 22, 2011
How it works?
                                References
                                instance of                                     Object
                                message send
                                lookup
                                subclass
                                                                                Proxy
                                                                     cannotInterpret: aMessage



                               aProxy username
                                                           4: #cannotInterpret: lookup
                                1: #username send
                                                                             ProxyTrap
                                                                          methodDict := nil
                                         aProxy
                                                               2: #aProxy lookup




                                                      3: Since the method dictionary was nil,
                                                         the VM sends #cannotInterpret to
                                               the receiver but starting the lookup in the superclass




                                  23
Monday, August 22, 2011
How it works?
                                References
                                instance of                                     Object
                                message send
                                lookup
                                subclass

       Proxy >>                                                                 Proxy
                                                                     cannotInterpret: aMessage



                               aProxy username
                                                           4: #cannotInterpret: lookup
                                1: #username send
                                                                             ProxyTrap
                                                                          methodDict := nil
                                         aProxy
                                                               2: #aProxy lookup




                                                      3: Since the method dictionary was nil,
                                                         the VM sends #cannotInterpret to
                                               the receiver but starting the lookup in the superclass




                                  23
Monday, August 22, 2011
How it works?
                                   References
                                   instance of                                     Object
                                   message send
                                   lookup
                                   subclass

       Proxy >>                                                                    Proxy
                                                                        cannotInterpret: aMessage



                                  aProxy username
                                                              4: #cannotInterpret: lookup
                                   1: #username send
                                                                                ProxyTrap
                                                                             methodDict := nil
                                            aProxy
                                                                  2: #aProxy lookup


      SimpleForwarderHandler >>
                                                         3: Since the method dictionary was nil,
                                                            the VM sends #cannotInterpret to
                                                  the receiver but starting the lookup in the superclass




                                     23
Monday, August 22, 2011
Traditional                    Ghost
         #doesNotUnderstand:             #cannotInterpret: is
         cannot be trapped like a        trapped like a regular
         regular message.                message.
         Mix of handling                 No mix of handling
         procedure and proxy             procedure and proxy
         interception.                   interception.
         Only methods that are
                                         “All” methods are
         not understood are
                                         intercepted.
         intercepted.
         No separation between           Clear separation between
         proxies and handlers.           proxies and handlers.
                                    24
Monday, August 22, 2011
is stratified




                          25
Monday, August 22, 2011
Methods not intercepted
  1) Optimizations done by the Compiler




    2) Special shortcut bytecodes between Compiler and VM



        2.1) Methods NEVER sent: #== and #class
        2.2) Methods that may or may not be executed depending
           on the receiver and arguments: e.g. in ‘1+1’ #+ is not
                executed. But with ‘1+$C’ #+ is executed.
        2.3)Always executed, they are just little optimizations.
             Examples #new, #next, 26
                                    #nextPut:, #size, etc.
Monday, August 22, 2011
Methods not intercepted
  1) Optimizations done by the Compiler




    2) Special shortcut bytecodes between Compiler and VM



        2.1) Methods NEVER sent: #== and #class
        2.2) Methods that may or may not be executed depending
           on the receiver and arguments: e.g. in ‘1+1’ #+ is not
                executed. But with ‘1+$C’ #+ is executed.
        2.3)Always executed, they are just little optimizations.
             Examples #new, #next, 26
                                    #nextPut:, #size, etc.
Monday, August 22, 2011
Methods not intercepted
  1) Optimizations done by the Compiler




    2) Special shortcut bytecodes between Compiler and VM



        2.1) Methods NEVER sent: #== and #class
        2.2) Methods that may or may not be executed depending
           on the receiver and arguments: e.g. in ‘1+1’ #+ is not
                executed. But with ‘1+$C’ #+ is executed.
        2.3)Always executed, they are just little optimizations.
             Examples #new, #next, 26
                                    #nextPut:, #size, etc.
Monday, August 22, 2011
Proxy for classes
                                                          Object




                                           ClassProxy                     Proxy
                                       superclass                  handler
                                       methodDict                  target
                                       format                      cannotInterpret:
                                       handler                     proxyFor:
                                       target
                                       cannotInterpret:
                                       proxyFor:
                                                                         ProxyTrap
                                                                   initialize
                                                                   nilMethodDict
                                         ClassProxyTrap
                                       initialize
                                       nilMethodDict
                                                                            User
                                                                    username
                                                                    age
                                                                    logIn:
                                                                    validate:




                                  27
Monday, August 22, 2011
Proxy for classes
                                                          Object




                                           ClassProxy                     Proxy
                                       superclass                  handler
                                       methodDict                  target
                                       format                      cannotInterpret:
                                       handler                     proxyFor:
                                       target
                                       cannotInterpret:
                                       proxyFor:
                                                                         ProxyTrap
                                                                   initialize
                                                                   nilMethodDict
                                         ClassProxyTrap
                                       initialize
                                       nilMethodDict
                                                                            User
                                                                    username
                                                                    age
                                                                    logIn:
                                                                    validate:




                                  27
Monday, August 22, 2011
Proxy for classes
                                                          Object




                                           ClassProxy                     Proxy
                                       superclass                  handler
                                       methodDict                  target
                                       format                      cannotInterpret:
                                       handler                     proxyFor:
                                       target
                                       cannotInterpret:
                                       proxyFor:
                                                                         ProxyTrap
                                                                   initialize
                                                                   nilMethodDict
                                         ClassProxyTrap
                                       initialize
                                       nilMethodDict
                                                                            User
                                                                    username
                                                                    age
                                                                    logIn:
                                                                    validate:




                                  27
Monday, August 22, 2011
Proxy for classes
                                                          Object




                                           ClassProxy                     Proxy
                                       superclass                  handler
                                       methodDict                  target
                                       format                      cannotInterpret:
                                       handler                     proxyFor:
                                       target
                                       cannotInterpret:
                                       proxyFor:
                                                                         ProxyTrap
                                                                   initialize
                                                                   nilMethodDict
                                         ClassProxyTrap
                                       initialize
                                       nilMethodDict
                                                                            User
                                                                    username
                                                                    age
                                                                    logIn:
                                                                    validate:




                                  27
Monday, August 22, 2011
Proxy for classes
                                                                    Object




                                             ClassProxy                             Proxy
                                         superclass                          handler
                                         methodDict                          target
                                         format                              cannotInterpret:
                                         handler                             proxyFor:
                                         target
                                         cannotInterpret:
                                         proxyFor:
                                                                                   ProxyTrap
                                                                             initialize
                                                                             nilMethodDict
                                           ClassProxyTrap
                                         initialize
                                         nilMethodDict
                                                                                      User
                                                                              username
                                                                              age
                                                                              logIn:
                                                 ins
                                                       tan                    validate:
                                                             ce
                                       aUser                    of
                                                                      aClassProxy
                                                                   methodDict = nil
                                                                superclass = ClassProxy
                                  27
Monday, August 22, 2011
Proxy for classes
                                                                       Object




                                                ClassProxy                             Proxy
                                            superclass                          handler
                                            methodDict                          target
                                            format                              cannotInterpret:
                                            handler                             proxyFor:
                                            target
                                            cannotInterpret:
                                            proxyFor:
                                                                                      ProxyTrap
                                                                                initialize
                                                                                nilMethodDict
                                              ClassProxyTrap
                                            initialize
                                            nilMethodDict
                                                                                         User
                                                                                 username
                                                                                 age
                                                                                 logIn:
                                                    ins
                                                          tan                    validate:
                                                                ce
                                        aUser                      of
                                                                         aClassProxy
                                                                      methodDict = nil
                                                                   superclass = ClassProxy
                                  27
                                       User name
Monday, August 22, 2011
Proxy for classes
                                                                                    Object




                                                             ClassProxy                             Proxy
                                                         superclass                          handler
                                                         methodDict                          target
                                                         format                              cannotInterpret:
                                                         handler                             proxyFor:
                                                         target
                                                         cannotInterpret:
                                                         proxyFor:
                                                                                                   ProxyTrap
                                                                                             initialize
                                                                                             nilMethodDict
                                                           ClassProxyTrap
                                                         initialize
                                                         nilMethodDict
                                                                                                      User
                                                                                              username
                                                                                              age
                                                                                              logIn:
                                                                 ins
                                                                       tan                    validate:
                                                                             ce
                                                     aUser                      of
                                                                                      aClassProxy
                                                                                   methodDict = nil
                              aUser username                                    superclass = ClassProxy
                                               27
                                                    User name
Monday, August 22, 2011
Proxy for methods




                                  28
Monday, August 22, 2011
Proxy for methods

                                       Regular message




                                  28
Monday, August 22, 2011
Proxy for methods

                                       Regular message
                                       Method execution




                                  28
Monday, August 22, 2011
Proxy for methods

                                                      Regular message
                                                      Method execution



                Just handling #run:with:in correctly is enough to also
                            intercept method execution.



                                         28
Monday, August 22, 2011
is Uniform




                             29
Monday, August 22, 2011
is more Uniform




                              29
Monday, August 22, 2011
More features

                          Low memory footprint.

                           Compact classes.

                           Store the minimal needed state.

                          Easy debugging.

                           Custom list of messages.

                                              30
Monday, August 22, 2011
Conclusion

                      With a little bit of special support from
                       the VM (#cannotInterpret hook), we
                      can have an image-side proxy solution
                           much better than the classic
                              #doesNotUnderstand:



                                         31
Monday, August 22, 2011
Future work


                           Experiment with immediate proxies
                          (memory address tag) in VM side.

                           Think how to correctly intercept non-
                          executed methods.




                                              32
Monday, August 22, 2011
Links


                          http://rmod.lille.inria.fr/web/pier/software/
                          Marea/GhostProxies

                          http://www.squeaksource.com/Marea.html




                                               33
Monday, August 22, 2011
A Uniform, Light-weight and Stratified Proxy Model and
                          Implementation


                                Mariano Martinez Peck
                                marianopeck@gmail.com
                          http://marianopeck.wordpress.com/



Monday, August 22, 2011

More Related Content

Similar to Ghost

Android 1.5 to 3.0: a compatibility journey
Android 1.5 to 3.0: a compatibility journeyAndroid 1.5 to 3.0: a compatibility journey
Android 1.5 to 3.0: a compatibility journeyEmanuele Di Saverio
 
Mozilla: Continuous Deploment on SUMO
Mozilla: Continuous Deploment on SUMOMozilla: Continuous Deploment on SUMO
Mozilla: Continuous Deploment on SUMOMatt Brandt
 
2011 JavaOne EJB with Meta Annotations
2011 JavaOne EJB with Meta Annotations2011 JavaOne EJB with Meta Annotations
2011 JavaOne EJB with Meta AnnotationsDavid Blevins
 
Infusion for the birds
Infusion for the birdsInfusion for the birds
Infusion for the birdscolinbdclark
 
Agile Business Analysis - The Key to Effective Requirements on Agile Projects
Agile Business Analysis - The Key to Effective Requirements on Agile ProjectsAgile Business Analysis - The Key to Effective Requirements on Agile Projects
Agile Business Analysis - The Key to Effective Requirements on Agile ProjectsLilian De Munno
 
LISA 2011 Keynote: The DevOps Transformation
LISA 2011 Keynote: The DevOps TransformationLISA 2011 Keynote: The DevOps Transformation
LISA 2011 Keynote: The DevOps Transformationbenrockwood
 
Form project why is the sky blue and other questions
Form project  why is the sky blue and other questionsForm project  why is the sky blue and other questions
Form project why is the sky blue and other questionsaakashm
 
ExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias Sociais
ExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias SociaisExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias Sociais
ExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias SociaisDOGSCAMP Summit
 
Sistemas de Recomendação e Mobilidade
Sistemas de Recomendação e MobilidadeSistemas de Recomendação e Mobilidade
Sistemas de Recomendação e MobilidadeMarcel Caraciolo
 
Cliff Moon - Building Polyglot Distributed Systems with Scalang, Boundary Tec...
Cliff Moon - Building Polyglot Distributed Systems with Scalang, Boundary Tec...Cliff Moon - Building Polyglot Distributed Systems with Scalang, Boundary Tec...
Cliff Moon - Building Polyglot Distributed Systems with Scalang, Boundary Tec...boundary_slides
 
NeOn Tool Support for Building Ontologies By Reuse - ICBO 09
NeOn Tool Support for Building Ontologies By Reuse - ICBO 09NeOn Tool Support for Building Ontologies By Reuse - ICBO 09
NeOn Tool Support for Building Ontologies By Reuse - ICBO 09Mathieu d'Aquin
 

Similar to Ghost (14)

Efficient Proxies in Smalltalk
Efficient Proxies in SmalltalkEfficient Proxies in Smalltalk
Efficient Proxies in Smalltalk
 
Android 1.5 to 3.0: a compatibility journey
Android 1.5 to 3.0: a compatibility journeyAndroid 1.5 to 3.0: a compatibility journey
Android 1.5 to 3.0: a compatibility journey
 
Anarchist guide to titanium ui
Anarchist guide to titanium uiAnarchist guide to titanium ui
Anarchist guide to titanium ui
 
SDOW (ISWC2011)
SDOW (ISWC2011)SDOW (ISWC2011)
SDOW (ISWC2011)
 
Mozilla: Continuous Deploment on SUMO
Mozilla: Continuous Deploment on SUMOMozilla: Continuous Deploment on SUMO
Mozilla: Continuous Deploment on SUMO
 
2011 JavaOne EJB with Meta Annotations
2011 JavaOne EJB with Meta Annotations2011 JavaOne EJB with Meta Annotations
2011 JavaOne EJB with Meta Annotations
 
Infusion for the birds
Infusion for the birdsInfusion for the birds
Infusion for the birds
 
Agile Business Analysis - The Key to Effective Requirements on Agile Projects
Agile Business Analysis - The Key to Effective Requirements on Agile ProjectsAgile Business Analysis - The Key to Effective Requirements on Agile Projects
Agile Business Analysis - The Key to Effective Requirements on Agile Projects
 
LISA 2011 Keynote: The DevOps Transformation
LISA 2011 Keynote: The DevOps TransformationLISA 2011 Keynote: The DevOps Transformation
LISA 2011 Keynote: The DevOps Transformation
 
Form project why is the sky blue and other questions
Form project  why is the sky blue and other questionsForm project  why is the sky blue and other questions
Form project why is the sky blue and other questions
 
ExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias Sociais
ExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias SociaisExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias Sociais
ExpOn 2011 - Diego Monteiro - Níveis de Maturidade nas Mídias Sociais
 
Sistemas de Recomendação e Mobilidade
Sistemas de Recomendação e MobilidadeSistemas de Recomendação e Mobilidade
Sistemas de Recomendação e Mobilidade
 
Cliff Moon - Building Polyglot Distributed Systems with Scalang, Boundary Tec...
Cliff Moon - Building Polyglot Distributed Systems with Scalang, Boundary Tec...Cliff Moon - Building Polyglot Distributed Systems with Scalang, Boundary Tec...
Cliff Moon - Building Polyglot Distributed Systems with Scalang, Boundary Tec...
 
NeOn Tool Support for Building Ontologies By Reuse - ICBO 09
NeOn Tool Support for Building Ontologies By Reuse - ICBO 09NeOn Tool Support for Building Ontologies By Reuse - ICBO 09
NeOn Tool Support for Building Ontologies By Reuse - ICBO 09
 

More from ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingESUG
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in PharoESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapESUG
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoESUG
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...ESUG
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsESUG
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6ESUG
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsESUG
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector TuningESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FutureESUG
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the DebuggerESUG
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing ScoreESUG
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptESUG
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsESUG
 

More from ESUG (20)

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
 

Recently uploaded

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Recently uploaded (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Ghost

  • 1. Mariano Martinez Peck marianopeck@gmail.com http://marianopeck.wordpress.com/ 1 Monday, August 22, 2011
  • 2. What is a proxy? A proxy object is a surrogate or placeholder that controls access to another target object. 2 Monday, August 22, 2011
  • 3. Glossary Target: object to proxify. Client: user of the proxy. Interceptor: object that intercepts message sending. Handler: object that performs a desired action as a consequence of an interception. 3 Monday, August 22, 2011
  • 4. Forwarder and Logging example 4 Monday, August 22, 2011
  • 5. With or without Object replacement? In proxies with object replacement (#become:), the target object is replaced by a proxy. Proxies without object replacement are a kind of factory. 5 Monday, August 22, 2011
  • 6. With or without Object replacement? In proxies with object replacement (#become:), the target object is replaced by a proxy. Proxies without object replacement are a kind of factory. 5 Monday, August 22, 2011
  • 7. Traditional proxy implementations Usage of a minimal object together with an implementation of a custom #doesNotUnderstand ProtoObject identityHash pointersTo nextObject ... Proxy target doesNotUnderstand: executeBeforeHandling executeAfterHandling 6 Monday, August 22, 2011
  • 8. We are going to play a little game... 7 Monday, August 22, 2011
  • 9. Are both prints in Transcript the same or not? 8 Monday, August 22, 2011
  • 10. Are both prints in Transcript the same or not? Conclusion: methods understood are NOT intercepted. Is that bad? 8 Monday, August 22, 2011
  • 11. Are both prints in Transcript the same or not? Conclusion: methods understood are NOT intercepted. Is that bad? Different execution paths 8 Errors difficult to find Monday, August 22, 2011
  • 12. Do we want the regular #doesNotUnderstand or to intercept the message? 9 Monday, August 22, 2011
  • 13. Do we want the regular #doesNotUnderstand or to intercept the message? 10 Monday, August 22, 2011
  • 14. I wanted the normal #doesNotUnderstand!!! 11 Monday, August 22, 2011
  • 15. I wanted the normal #doesNotUnderstand!!! 12 Monday, August 22, 2011
  • 16. Problems #doesNotUnderstand: cannot be trapped like a regular message. Mix of handling procedure and proxy interception. Only methods that are not understood are intercepted. No separation between proxies and handlers This approach is not stratified 13 Monday, August 22, 2011
  • 17. Subclassing from nil does not solve the problem. 14 Monday, August 22, 2011
  • 18. VM CRASH This solution is not uniform 15 Monday, August 22, 2011
  • 19. A Uniform, Light-weight and Stratified Proxy Model and Implementation. 16 Monday, August 22, 2011
  • 20. Used hooks Object replacement (#become:) Change an object’s class (#adoptInstance:) Objects as methods (#run:with:in:) Classes with no method dictionary (#cannotInterpret:) 17 Monday, August 22, 2011
  • 21. Object replacement B B A A c become: d D D C C 18 Monday, August 22, 2011
  • 22. Objects as methods The VM sends #run: aSelector with: anArray in: aReceiver 19 Monday, August 22, 2011
  • 23. Objects as methods The VM sends #run: aSelector with: anArray in: aReceiver So.....We can implement in Proxy: 19 Monday, August 22, 2011
  • 24. CLasses with no method dictionary References Object instance of message send lookup subclass Proxy cannotInterpret: aMessage aProxy username 4: #cannotInterpret: lookup 1: #username send ProxyTrap methodDict := nil aProxy 2: #aProxy lookup 3: Since the method dictionary was nil, the VM sends #cannotInterpret to the receiver but starting the lookup in the superclass 20 Monday, August 22, 2011
  • 25. Ghost model Interception Object message proxy proxyState ProxyHandler Proxy handleInterception: anInterception handler target cannotInterpret: proxyFor: SimpleForwarderHandler handleInterception: anInterception ProxyTrap initialize nilMethodDict 21 Monday, August 22, 2011
  • 26. How it works? Object Proxy handler target cannotInterpret: proxyFor: ProxyTrap initialize nilMethodDict 22 Monday, August 22, 2011
  • 27. How it works? Object Proxy handler target cannotInterpret: Proxy class >> proxyFor: ProxyTrap initialize nilMethodDict 22 Monday, August 22, 2011
  • 28. How it works? Object Of Proxy ce handler ns tan target Proxy class >> i cannotInterpret: proxyFor: aProxy ProxyTrap initialize nilMethodDict aHandler ‘Mariano’ 22 Monday, August 22, 2011
  • 29. How it works? Object Of Proxy ce handler ns tan target Proxy class >> i cannotInterpret: proxyFor: aProxy ProxyTrap initialize nilMethodDict aHandler ‘Mariano’ ProxyTrap class >> 22 Monday, August 22, 2011
  • 30. How it works? Object Proxy handler target cannotInterpret: Proxy class >> aProxy ins proxyFor: tan ce Of ProxyTrap initialize nilMethodDict aHandler ‘Mariano’ ProxyTrap class >> 22 Monday, August 22, 2011
  • 31. How it works? Object Proxy handler target cannotInterpret: Proxy class >> aProxy ins proxyFor: tan ce Of ProxyTrap initialize nilMethodDict aHandler ‘Mariano’ 22 Monday, August 22, 2011
  • 32. How it works? References instance of Object message send lookup subclass Proxy cannotInterpret: aMessage aProxy username 4: #cannotInterpret: lookup 1: #username send ProxyTrap methodDict := nil aProxy 2: #aProxy lookup 3: Since the method dictionary was nil, the VM sends #cannotInterpret to the receiver but starting the lookup in the superclass 23 Monday, August 22, 2011
  • 33. How it works? References instance of Object message send lookup subclass Proxy cannotInterpret: aMessage aProxy username 4: #cannotInterpret: lookup 1: #username send ProxyTrap methodDict := nil aProxy 2: #aProxy lookup 3: Since the method dictionary was nil, the VM sends #cannotInterpret to the receiver but starting the lookup in the superclass 23 Monday, August 22, 2011
  • 34. How it works? References instance of Object message send lookup subclass Proxy cannotInterpret: aMessage aProxy username 4: #cannotInterpret: lookup 1: #username send ProxyTrap methodDict := nil aProxy 2: #aProxy lookup 3: Since the method dictionary was nil, the VM sends #cannotInterpret to the receiver but starting the lookup in the superclass 23 Monday, August 22, 2011
  • 35. How it works? References instance of Object message send lookup subclass Proxy cannotInterpret: aMessage aProxy username 4: #cannotInterpret: lookup 1: #username send ProxyTrap methodDict := nil aProxy 2: #aProxy lookup 3: Since the method dictionary was nil, the VM sends #cannotInterpret to the receiver but starting the lookup in the superclass 23 Monday, August 22, 2011
  • 36. How it works? References instance of Object message send lookup subclass Proxy cannotInterpret: aMessage aProxy username 4: #cannotInterpret: lookup 1: #username send ProxyTrap methodDict := nil aProxy 2: #aProxy lookup 3: Since the method dictionary was nil, the VM sends #cannotInterpret to the receiver but starting the lookup in the superclass 23 Monday, August 22, 2011
  • 37. How it works? References instance of Object message send lookup subclass Proxy >> Proxy cannotInterpret: aMessage aProxy username 4: #cannotInterpret: lookup 1: #username send ProxyTrap methodDict := nil aProxy 2: #aProxy lookup 3: Since the method dictionary was nil, the VM sends #cannotInterpret to the receiver but starting the lookup in the superclass 23 Monday, August 22, 2011
  • 38. How it works? References instance of Object message send lookup subclass Proxy >> Proxy cannotInterpret: aMessage aProxy username 4: #cannotInterpret: lookup 1: #username send ProxyTrap methodDict := nil aProxy 2: #aProxy lookup SimpleForwarderHandler >> 3: Since the method dictionary was nil, the VM sends #cannotInterpret to the receiver but starting the lookup in the superclass 23 Monday, August 22, 2011
  • 39. Traditional Ghost #doesNotUnderstand: #cannotInterpret: is cannot be trapped like a trapped like a regular regular message. message. Mix of handling No mix of handling procedure and proxy procedure and proxy interception. interception. Only methods that are “All” methods are not understood are intercepted. intercepted. No separation between Clear separation between proxies and handlers. proxies and handlers. 24 Monday, August 22, 2011
  • 40. is stratified 25 Monday, August 22, 2011
  • 41. Methods not intercepted 1) Optimizations done by the Compiler 2) Special shortcut bytecodes between Compiler and VM 2.1) Methods NEVER sent: #== and #class 2.2) Methods that may or may not be executed depending on the receiver and arguments: e.g. in ‘1+1’ #+ is not executed. But with ‘1+$C’ #+ is executed. 2.3)Always executed, they are just little optimizations. Examples #new, #next, 26 #nextPut:, #size, etc. Monday, August 22, 2011
  • 42. Methods not intercepted 1) Optimizations done by the Compiler 2) Special shortcut bytecodes between Compiler and VM 2.1) Methods NEVER sent: #== and #class 2.2) Methods that may or may not be executed depending on the receiver and arguments: e.g. in ‘1+1’ #+ is not executed. But with ‘1+$C’ #+ is executed. 2.3)Always executed, they are just little optimizations. Examples #new, #next, 26 #nextPut:, #size, etc. Monday, August 22, 2011
  • 43. Methods not intercepted 1) Optimizations done by the Compiler 2) Special shortcut bytecodes between Compiler and VM 2.1) Methods NEVER sent: #== and #class 2.2) Methods that may or may not be executed depending on the receiver and arguments: e.g. in ‘1+1’ #+ is not executed. But with ‘1+$C’ #+ is executed. 2.3)Always executed, they are just little optimizations. Examples #new, #next, 26 #nextPut:, #size, etc. Monday, August 22, 2011
  • 44. Proxy for classes Object ClassProxy Proxy superclass handler methodDict target format cannotInterpret: handler proxyFor: target cannotInterpret: proxyFor: ProxyTrap initialize nilMethodDict ClassProxyTrap initialize nilMethodDict User username age logIn: validate: 27 Monday, August 22, 2011
  • 45. Proxy for classes Object ClassProxy Proxy superclass handler methodDict target format cannotInterpret: handler proxyFor: target cannotInterpret: proxyFor: ProxyTrap initialize nilMethodDict ClassProxyTrap initialize nilMethodDict User username age logIn: validate: 27 Monday, August 22, 2011
  • 46. Proxy for classes Object ClassProxy Proxy superclass handler methodDict target format cannotInterpret: handler proxyFor: target cannotInterpret: proxyFor: ProxyTrap initialize nilMethodDict ClassProxyTrap initialize nilMethodDict User username age logIn: validate: 27 Monday, August 22, 2011
  • 47. Proxy for classes Object ClassProxy Proxy superclass handler methodDict target format cannotInterpret: handler proxyFor: target cannotInterpret: proxyFor: ProxyTrap initialize nilMethodDict ClassProxyTrap initialize nilMethodDict User username age logIn: validate: 27 Monday, August 22, 2011
  • 48. Proxy for classes Object ClassProxy Proxy superclass handler methodDict target format cannotInterpret: handler proxyFor: target cannotInterpret: proxyFor: ProxyTrap initialize nilMethodDict ClassProxyTrap initialize nilMethodDict User username age logIn: ins tan validate: ce aUser of aClassProxy methodDict = nil superclass = ClassProxy 27 Monday, August 22, 2011
  • 49. Proxy for classes Object ClassProxy Proxy superclass handler methodDict target format cannotInterpret: handler proxyFor: target cannotInterpret: proxyFor: ProxyTrap initialize nilMethodDict ClassProxyTrap initialize nilMethodDict User username age logIn: ins tan validate: ce aUser of aClassProxy methodDict = nil superclass = ClassProxy 27 User name Monday, August 22, 2011
  • 50. Proxy for classes Object ClassProxy Proxy superclass handler methodDict target format cannotInterpret: handler proxyFor: target cannotInterpret: proxyFor: ProxyTrap initialize nilMethodDict ClassProxyTrap initialize nilMethodDict User username age logIn: ins tan validate: ce aUser of aClassProxy methodDict = nil aUser username superclass = ClassProxy 27 User name Monday, August 22, 2011
  • 51. Proxy for methods 28 Monday, August 22, 2011
  • 52. Proxy for methods Regular message 28 Monday, August 22, 2011
  • 53. Proxy for methods Regular message Method execution 28 Monday, August 22, 2011
  • 54. Proxy for methods Regular message Method execution Just handling #run:with:in correctly is enough to also intercept method execution. 28 Monday, August 22, 2011
  • 55. is Uniform 29 Monday, August 22, 2011
  • 56. is more Uniform 29 Monday, August 22, 2011
  • 57. More features Low memory footprint. Compact classes. Store the minimal needed state. Easy debugging. Custom list of messages. 30 Monday, August 22, 2011
  • 58. Conclusion With a little bit of special support from the VM (#cannotInterpret hook), we can have an image-side proxy solution much better than the classic #doesNotUnderstand: 31 Monday, August 22, 2011
  • 59. Future work Experiment with immediate proxies (memory address tag) in VM side. Think how to correctly intercept non- executed methods. 32 Monday, August 22, 2011
  • 60. Links http://rmod.lille.inria.fr/web/pier/software/ Marea/GhostProxies http://www.squeaksource.com/Marea.html 33 Monday, August 22, 2011
  • 61. A Uniform, Light-weight and Stratified Proxy Model and Implementation Mariano Martinez Peck marianopeck@gmail.com http://marianopeck.wordpress.com/ Monday, August 22, 2011