Sub-method Structural and Behavioral Reflection

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Sub-method Structural and Behavioral Reflection - Presentation Transcript

    1. Sub-method Structural and Behavioral Reflection Marcus Denker Universität Bern © Marcus Denker
    2. The Systems of the future... > ... are getting larger and more complex > ... are getting more and more dependent on each other > The demands are changing © Marcus Denker 2
    3. Examples of New Demands > Dynamic Analysis — Fine-grained selection — Install / retract at runtime — Complete system > Development Environment — Complete representation of the system — Extensible © Marcus Denker 3
    4. Reflection © Marcus Denker 4
    5. Reflection Program Description © Marcus Denker 5
    6. Reflection Program Description Query and Change © Marcus Denker 6
    7. Repeat: Demands > Dynamic Analysis — Fine-grained Selection — Install / retract at runtime — Complete System > Development Environment — Complete representation of the system — Extensible © Marcus Denker 7
    8. Reflection to the Rescue > Where? > At runtime! > Complete Structure > Everywhere! © Marcus Denker 8
    9. Reflection to the Rescue > Where? Solved (Partial Behavioral Reflection, Eric Tanter) > At runtime! > Complete structure > Everywhere! © Marcus Denker 9
    10. Three Problems of Reflection 1. Partial behavioral reflection needs to be anticipated 2. Structural reflection is limited to the granularity of a method 3. Behavioral reflection cannot be applied to the whole system © Marcus Denker 10
    11. Three Problems of Reflection 1. Anticipation 2. Structural reflection is limited to the granularity of a method 3. Behavioral reflection cannot be applied to the whole system © Marcus Denker 11
    12. Three Problems of Reflection 1. Anticipation 2. Sub-method Structure 3. Behavioral reflection cannot be applied to the whole system © Marcus Denker 12
    13. Three Problems of Reflection 1. Anticipation 2. Sub-method Structure 3. Context © Marcus Denker 13
    14. Thesis To support unanticipated behavioral reflection, reflection needs to be extended with sub-method structure and with the concept of context. © Marcus Denker 14
    15. Contributions of the Dissertation > Unanticipated partial behavioral reflection > Sub-Method Structural Reflection > Partial Behavioral Reflection using Annotations > Contextual Reflection © Marcus Denker 15
    16. Roadmap x x x x x x x x 1. Unanticipated partial behavioral reflection 2. Sub-Method Structure 3. Revisit Partial Reflection 4. Context © Marcus Denker 16
    17. Roadmap 1. Unanticipated partial behavioral reflection 2. Sub-Method Structure 3. Revisit Partial Reflection 4. Context © Marcus Denker 17
    18. Roadmap 1. Unanticipated partial behavioral reflection 2. Sub-Method Structure 3. Revisit Partial Reflection 4. Context © Marcus Denker 18
    19. meta Roadmap base 1. Unanticipated partial behavioral reflection 2. Sub-Method Structure 3. Revisit Partial Reflection 4. Context © Marcus Denker 19
    20. Roadmap x x x x x x x x 1. Unanticipated partial behavioral reflection 2. Sub-Method Structure 3. Revisit Partial Reflection 4. Context © Marcus Denker 20
    21. Reflex: Partial Behavioral Reflection x x x x x x x x > Hooksets: collection of operation occurrences > Links — Bind hooksets to meta-objects — Define protocol between base and meta metaobject > Goals — Highly selective reification links activation condition — Flexible meta-level engineering – Protocol specification hookset – Cross-cutting hooksets Tanter, OOPSLA03 © Marcus Denker 21
    22. Example: Live Analysis x x x x x x x x > Typical Web application (e.g. Wiki) > Shows performance problem under high load > Goals: — Profile and fix the problem — No restart / interruption of service © Marcus Denker 22
    23. Live Analysis x x x x x x x x — Install profiler — Analyze — Retract profiler ... while the system is running! © Marcus Denker 23
    24. Live Profiling x x x x x x x x > Operation: — Method Execution (around) > Hookset: — All execution operations in the wiki package metaobject > Metaobject: — A profiling tool links activation condition hookset © Marcus Denker 24
    25. Unanticipated Partial Behavioral x x x x x x Reflection x x > Geppetto: Unanticipated Partial Behavioral Reflection — For Squeak 3.9 with Bytecode transformation David Röthlisberger, Marcus Denker and Éric Tanter: Unanticipated Partial Behavioral Reflection: Adapting Applications at Runtime Journal of Computer Languages, Systems and Structures, vol. 34, no. 2-3, July 2008, pp. 46-65. © Marcus Denker 25
    26. Good Results x x x x x x x x > Completely dynamic > Simpler > High performance © Marcus Denker 26
    27. Benchmarks Geppetto > Slowdown for reification of message send System Slowdown Geppetto 10.85 Iguana/J 24 Metaclasstalk 20 © Marcus Denker
    28. Missing Sub-method Structure x x x x x x x x > Semantic Mismatch > Code Quality > Synthesized Code © Marcus Denker 28
    29. Roadmap 1. Dynamic partial behavioral reflection 2. Sub-Method Structure 3. Revisit Partial Reflection 4. Context © Marcus Denker 29
    30. Methods and Reflection > Method are Objects — e.g in Smalltalk > No high-level model for sub-method elements — Message sends — Assignments — Variable access > Structural reflection stops at the granularity of methods © Marcus Denker 30
    31. Sub-Method Reflection > Many tools work on sub method level — Profiler, Refactoring Tool, Debugger, Type Checker > Communication between tools needed — Example: Code coverage > All tools use different representations — Tools are harder to build — Communication not possible © Marcus Denker 31
    32. Sub-method Representation Requirements > Causal Connection > Abstraction Level > Extensibility > Persistent > Size and Performance © Marcus Denker 32
    33. Existing Method Representations > Existing representations for Methods — Text — Bytecode — AST © Marcus Denker 33
    34. Text > Low level abstraction > Not causally connected © Marcus Denker 34
    35. Bytecode 1 16 0 0 160 197 59 17 172 94 7 17 204 > Low level abstraction 122 70 17 92 94 7 17 65 112 224 135 120 88 141 0 252 > Missing extensibility > Mix of base- and meta-level code © Marcus Denker 35
    36. Abstract Syntax Tree > Not causally connected > Not extensible > Not persistent © Marcus Denker 36
    37. Solution: Reflective Methods > Annotated, persistent AST > Bytecode generated on demand and cached :ReflectiveMethod :CompiledMethod annotation compiledMethod #(12 13 45 38 98 128 annotation reflectiveMethod 84 72 42 77 22 28 59 32 7 49 51 87 64) Tools VM © Marcus Denker 37
    38. Implementation: Persephone > Implementation of Reflective Methods for Squeak > Smalltalk compiler generates Reflective Methods — Translated to bytecode on demand > Open Compiler: Plugins — Called before code generation — Transform a copy of the AST Marcus Denker, Stéphane Ducasse, Adrian Lienhard Philippe Marschall: Sub-Method Reflection Journal of Object Technology, vol. 6, no. 9, © Marcus Denker 38
    39. Requirements revisited > Abstraction Level > Causal Connection > Extensibility > Persistency > Size and Performance © Marcus Denker 39
    40. Extensible with Annotations > Source visible annotations — extended Smalltalk syntax (9 raisedTo: 10000) <:evaluateAtCompiletime:> > Source invisible annotations — Reflective API — Can reference any object > Every node can be annotated > Semantics: Compiler Plugins © Marcus Denker 40
    41. Example: Pluggable Type-System > Example for textual annotations bitFromBoolean: aBoolean <:type: Boolean :> ^ (aBoolean ifTrue: [1] ifFalse: [0]) <:type: Integer :> > Optional, pluggable type-system > Types stored as annotations in the Reflective Methods Niklaus Haldiman, Marcus Denker, Oscar Nierstrasz: “Practical, Pluggable Types,” (ICDL 2007) © Marcus Denker 41
    42. Memory Requirements number of classes memory Squeak 3.9 2040 15.7 MB Persephone 2224 20 MB no reflective methods Persephone 2224 123 MB reflective methods © Marcus Denker 42
    43. Roadmap 1. Realize partial behavioral reflection in a dynamic language 2. Sub-Method Structure 3. Revisit Partial Reflection 4. Context © Marcus Denker 43
    44. Partial Behavioral Reflection Revisited > Problems of Bytecode: — Semantic Mismatch — Code Quality — Synthesized Code > With Sub-method Reflection, we can do better! © Marcus Denker 44
    45. Sub-method Structure x x x + = x x x x x > Links can be annotations on the AST © Marcus Denker 45
    46. Performance Properties > Very fast annotations — No decompile! > On-the-fly code generation — Only code executed gets generated > Generated code is fast — Better then working on bytecode level © Marcus Denker 46
    47. Repeat: Missing Sub-method Structure x x x x x x x x > Semantic Mismatch > Code Quality > Synthesized Code © Marcus Denker 47
    48. Sub-method Structure > Semantic Mismatch > Code Quality > Synthesized Code © Marcus Denker 48
    49. Example: Feature Annotations > Features modeled instruction is meta-object as traces links > Many Problems source code — Space (AST) — Merging Traces > Solution: annotate structure Marcus Denker, Orla Greevy, Oscar Nierstrasz: Supporting Feature Analysis with Runtime Annotations (PCODA 2007) © Marcus Denker 49
    50. meta Roadmap base 1. Realize partial behavioral reflection in a dynamic language 2. Sub-Method Structure 3. Revisit Partial Reflection 4. Context © Marcus Denker 50
    51. meta Problem: Whole System base > Behavioral reflection cannot be applied to the whole system > Problem: recursion — System classes — Meta-objects © Marcus Denker 51
    52. meta The Problem of Recursion base > Call the Beeper from OrderedCollection>>#add beepLink := Link new metaObject: Beeper. beepLink selector: #beep. (OrderedCollection>>#add:) methodNode link: beepLink. © Marcus Denker 52
    53. meta Meta-object Call Recursion base Base Level Meta Object Meta Object #add: send #beep send #add: send #beep send #add: send Infinite recursion © Marcus Denker 53
    54. meta Representing Meta-level Execution base Base Level Meta Level MetaContext activation > Link enables MetaContext MetaContext deactivation © Marcus Denker 54
    55. meta Context-aware Links base Base Level Meta Level Stop meta-level call > Disable call when already on the meta-level © Marcus Denker 55
    56. meta MetaContext: Conclusion base > Recursion problem solved meta-object meta links level 0 operation base © Marcus Denker 56
    57. meta MetaContext: Conclusion base metameta- object meta-2 link level 1 meta-object > Meta-level Analysis meta links level 0 operation base Marcus Denker, Mathieu Suen,Stéphane Ducasse: The Meta in Meta-object Architectures TOOLS EUROPE 2008 © Marcus Denker 57
    58. Thesis Revisited To support unanticipated behavioral reflection, reflection needs to be extended with sub-method structure and with the concept of context. © Marcus Denker 58
    59. Future Work > Sub-method Structure — Simpler AST — AST compression — Replace text with sub-method representation > Behavioral Reflection — Composition of Links — Generalize context model: beyond the MetaContext © Marcus Denker 59
    60. Contributions of the Dissertation > Unanticipated partial behavioral reflection > Sub-Method Structural Reflection > Partial Behavioral Reflection using Annotations > Contextual Reflection © Marcus Denker 60
    61. Questions > Unanticipated partial behavioral reflection > Sub-Method Structural Reflection > Partial Behavioral Reflection using Annotations > Contextual Reflection Questions? © Marcus Denker 61
    SlideShare Zeitgeist 2009

    + Marcus DenkerMarcus Denker Nominate

    custom

    138 views, 0 favs, 0 embeds more stats

    University of Berne. PhD Defense: "Sub-method Struc more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 138
      • 138 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 0
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories