Your SlideShare is downloading. ×
0
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
IronSmalltalk
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

IronSmalltalk

783

Published on

ESUG 2011, Edinburgh

ESUG 2011, Edinburgh

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
783
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. IronSmalltalk August 24th 2011 Todor Todorov
  • 2. IronSmalltalk Smalltalk for the Microsoft .Net DLR
  • 3. Agenda• History• Motivation and Background• Microsoft .Net DLR• Message Sends and CallSites• CallSite Binders• Expression Trees• Code Pipeline• Polymorphic Inline Caching• Conclusion• Extras / Bonus24 August 2011 Todor Todorov 3 / 111
  • 4. Smalltalk 1980
  • 5. Smalltalk 1980
  • 6. Smalltalk 1981
  • 7. Smalltalk 2011
  • 8. Smalltalk 2005
  • 9. The World Today
  • 10. The World Today
  • 11. Smalltalking since 1998 Todor Todorov
  • 12. BusinessApplications
  • 13. Microsoft.Net Platform
  • 14. Costly vs. Free?
  • 15. Commodity!
  • 16. Goal• X3J20 Compliant Smalltalk• First Class Member of the DLR Family• Easy interop. with .Net• Decent Performance
  • 17. PersonalChallenge
  • 18. .NET DLR
  • 19. .NET DLR
  • 20. .NET DLR
  • 21. Message Send
  • 22. Message SendCommunication
  • 23. Message SendTranscript show: Hello, Edinburgh!.
  • 24. Message SendTranscript show: Hello, Edinburgh!.TranscriptStream >> show: anObjectself nextPutAll: anObject asString; endEntry.
  • 25. Method LookupTranscript show: Hello, Edinburgh!.TranscriptStream >> show: anObjectself nextPutAll: anObject asString; endEntry.
  • 26. Call SiteTranscript show: Hello, Edinburgh!.call1 := Message receiver: Transcript selector: #show: arguments: #(Hello, Edinb… ).call1 evaluate.
  • 27. Call SiteTranscript show: Hello, Edinburgh!.call1 := CallSite receiver: Transcript selector: #show: arguments: #(Hello, Edinb… ).call1 evaluate.
  • 28. Call SiteTranscript show: Hello, Edinburgh!.call1 := CallSite selector: #show:.call1 evaluateWithReceiver: Transcript andArgs: #(Hello, Edinburgh).
  • 29. Call Site BindersTranscript show: Hello, Edinburgh!.call1 := CallSite onBinder: (Binder selector: #show:).call1 evaluateWithReceiver: Transcript andArgs: #(Hello, Edinburgh).
  • 30. Call Site BindersBinder >> bindFor: aReceiver arguments: anArray^BindingRule for: (aReceiver compiledMethodAt: #show).
  • 31. Dynamic Objects Reflective Objects
  • 32. Call Site BindersBinder >> bindFor: aReceiver arguments: anArray^BindingRule for: (aReceiver compiledMethodAt: #show).
  • 33. Call Site BindersBinder >> bindFor: aReceiver arguments: anArray^aReceiver bindEvaluateFor: self arguments: anArray.
  • 34. Call Site BindersObject >> bindEvaluateFor: aBinder arguments: anArray^BindingRule for: (self compiledMethodAt: aBinder selector). ” or return whatever it wants! ”
  • 35. Call Site Binders … receiver can’t help us, then …fallbackBindInvokeFor: aReceiver arguments: anArray^BindingRule for: … some compiled method …
  • 36. Expression Trees
  • 37. Expression TreesAbstract Semantic Tree
  • 38. Expression TreesAbstract Semantic TreeAbstract Syntax Tree
  • 39. Expression TreesAbstract Semantic TreeAbstract Syntax TreeExpression trees model code
  • 40. Expression TreesAbstract Semantic TreeAbstract Syntax TreeExpression trees model codeExpressions are used torepresent the implementationof certain code or logic
  • 41. Expression TreessignString ^self < 0 ifTrue: [ Negative ] ifFalse: [ Positive ].
  • 42. Expression TreessignString^Expression condition: (Expression lowerThan: self value: 0) true: Negative false: Positive.
  • 43. Expression TreessignStringselfArg := Expression parameter: self.^Expression condition: (Expression lowerThan: selfArg value: (Expression constant: 0)) true: (Expression constant: Negative) false: (Expression constant: Positive).
  • 44. Expression TreesTranscriptStream>>show: anObjectself nextPutAll: anObject.
  • 45. Expression Treesself nextPutAll: anObject.selfArg := Expression parameter: self.arg1 := Expression parameter: anObject.^Expression dynamic: (Binder selector: #nextPutAll:) receiver: selfArg arguments: (Array with: arg1).
  • 46. Expression TreesBinder >> bindFor: aReceiver arguments: anArray^BindingRule for: (aReceiver compiledMethodAt: #nextPutAll).
  • 47. Expression TreesBinder >> bindFor: aReceiver arguments: anArray^BindingRule expression: (Expression dynamic: (Binder selector: #nextPutAll:) receiver: aReceiver expression arguments: (Array with: anArray first expression).
  • 48. Code Pipeline
  • 49. Code PipelineSmalltalk Sources
  • 50. Code PipelineSmalltalk Sources Smalltalk AST Smalltalk Parser
  • 51. Code PipelineSmalltalk Sources Smalltalk Expression AST Tree Smalltalk JIT- Smalltalk Parser Compiler
  • 52. Code PipelineSmalltalk Sources Smalltalk Expression MSIL AST Tree (Bytecode) Smalltalk JIT- DLR / Linq Smalltalk Parser Compiler Compiler
  • 53. Code PipelineSmalltalk Sources Smalltalk Expression MSIL Machine Code AST Tree (Bytecode) Smalltalk JIT- DLR / Linq .NET CLR Smalltalk Parser Compiler Compiler (JIT Compiler)
  • 54. PolymorphicInline Caching
  • 55. CachingTranscript show: Hello, Edinburgh!.call1 := CallSite onBinder: (Binder selector: #show:).call1 evaluateWithReceiver: Transcript andArgs: #(Hello, Edinburgh).
  • 56. CachingBinder >> bindFor: aReceiver arguments: anArraymethod := aReceiver value compiledMethodAt: #show:.” … magic … to generate expression from method … ”^BindingRule expression: (Expression dynamic: (Binder selector: #nextPutAll:) receiver: aReceiver expression arguments: (Array with: anArray first expression).
  • 57. CachingTranscript show: Hello, Edinburgh!.call1 := CallSite onBinder: (Binder selector: #show:).call1 evaluateWithReceiver: Transcript andArgs: #(Hello, Edinburgh).
  • 58. CachingBinder >> bindFor: aReceiver arguments: anArraymethod := aReceiver value compiledMethodAt: #show:.” … magic … to generate expression from method … ”^BindingRule expression: ” … expression … ” restriction: [ :obj | obj class = TranscriptStream ].
  • 59. CachingTranscript show: Hello, Edinburgh!.call1 := CallSite onBinder: (Binder selector: #show:).call1 evaluateWithReceiver: Transcript andArgs: #(Hello, Edinburgh).
  • 60. Restrictions• Restrictions can be more complex • For example, instance specific or object version specific• Restrictions determine the polymorphism of objects• Restrictions are the key to polymorphic inline caching!
  • 61. The Cache• 3 Levels of Caching:• Level 0 : Rule for last call• Level 1 : Last 10 rules• Level 2 : 100 rules, shares across similar call sites
  • 62. .NET DLR
  • 63. Common Vocabulary• None Defined• De-Facto, the .Net class library• We aim at reusing the common classes – Example: System.Char => Character• Not everything maps easily, but most do – Example: System.String ~= String
  • 64. Demo
  • 65. Summary
  • 66. Components Hosting Interchange InstallerIC Encoder AST JIT Compiler DefinitionInstaller Runtime Compiler Core IC JitCompiler Common
  • 67. HostingWindows Process .Net AppDomain .Net AppDomain DLR Script Scope Smalltalk Runtime Smalltalk (Runtime) Smalltalk Runtime Ruby / Python Smalltalk Runtime DLR Script Scope
  • 68. SpecificsSymbolsStringsSmalltalk Process#sender#respondsTo:Events
  • 69. Object SpaceNo Object Space ReflectionNo #allInstancesNo #allReferencesNo #become:But #behaveLike: is possible!Debugger inspection is possible.
  • 70. Major Tech Companies
  • 71. Good NewsUnicodeMulti ThreadedLarge Class LibraryWeb-HostableMIT License
  • 72. Near FutureGenericsClass Library Importer (or auto-integration)Finish Version 1.0Write Tests (…)
  • 73. FutureGUI Integration (WinForms + WPF)SubSystems(Interactive) DebuggerVisual Studio IntegrationMixinsSubSystems / NamespacesInstance Specific Behavior
  • 74. Questionshttp://ironsmalltalk.codeplex.com/ mailto:todor@scientia.dk
  • 75. Callbacks List showItems: #( TT ST ).Workspace >> evaluateSmalltalk >> run
  • 76. Callbacks List >> showItems: anArray “ AddItems(anArray, self) ” <Windows API>List >> showItems:Workspace >> evaluateSmalltalk >> run
  • 77. Callbacks List.AddItems(string[] keys, dynamic stList) { for(i=0; i<…;i++) this.AddItem( keys[i],List.AddItems() stList);List >> showItems: }Workspace >> evaluateSmalltalk >> run
  • 78. Callbacks List.AddItem(string[] keys, dynamic stList) { string text = stList. .GetItemText(key);List.AddItem()List.AddItems() ” …somehow add it… ”List >> showItems: }Workspace >> evaluateSmalltalk >> run
  • 79. Callbacks List >> getItemText: aString ^self itemTextsList >> getItemText: at: aString.List.AddItem()List.AddItems()List >> showItems:Workspace >> evaluateSmalltalk >> run
  • 80. Callbacks .Net 4.0 has the dynamic keyword used for invoking method on dynamic objects.List >> getItemText: IronSmalltalk objects canList.AddItem() transparently be used by any DLR aware language.List.AddItems()List >> showItems:Workspace >> evaluateSmalltalk >> run
  • 81. Callbacks Native Name: GetItemText List >> getItemText: aStringList >> getItemText:List.AddItem()List.AddItems() The native name is theList >> showItems: method name (selector) thatWorkspace >> evaluate is exposed to the other DLR languages.Smalltalk >> run
  • 82. Exceptions [ Transcript show: Hello, Edinburgh! ] on: Error do: [ … ].Workspace >> evaluateSmalltalk >> run
  • 83. Exceptions BlockClosure >> on: exception do: handlerAction ” Some magic … ”BlockClosure >> on:do: ^self value.Workspace >> evaluateSmalltalk >> run
  • 84. Exceptions BlockClosure >> value < Primitive >BlockClosure >> valueBlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 85. Exceptions TranscriptStream >> show: anObject self nextPutAll:TranscriptStream >> show: anObject asString;BlockClosure >> value endEntry.BlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 86. Exceptions String >> asString ^self.String >> asStringTranscriptStream >> show:BlockClosure >> valueBlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 87. Exceptions TranscriptStream >> show: anObject self nextPutAll:TranscriptStream >> show: anObject asString;BlockClosure >> value endEntry.BlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 88. Exceptions TranscriptStream >> nextPutAll: aString ” … some code here … ”TranscriptStream >>nextPutAll:TranscriptStream >> show:BlockClosure >> valueBlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 89. Exceptions TranscriptStream >> show: anObject self nextPutAll:TranscriptStream >> show: anObject asString;BlockClosure >> value endEntry.BlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 90. Exceptions TranscriptStream >> endEntry ” … some code here … ”TranscriptStream >> endEntryTranscriptStream >> show:BlockClosure >> valueBlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 91. Exceptions TranscriptStream >> show: anObject self nextPutAll:TranscriptStream >> show: anObject asString;BlockClosure >> value endEntry.BlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 92. Exceptions BlockClosure >> value < Primitive >BlockClosure >> valueBlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 93. Exceptions BlockClosure >> on: exception do: handlerAction ” Some magic … ”BlockClosure >> on:do: ^self value.Workspace >> evaluateSmalltalk >> run
  • 94. Exceptions Transcript show: Hello, Edinburgh!.Workspace >> evaluateSmalltalk >> run
  • 95. Exceptions TranscriptStream >> nextPutAll: aString ” Transcript Window cannotTranscriptStream >>nextPutAll: hold more text! ”TranscriptStream >> show:BlockClosure >> valueBlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 96. Exceptions TranscriptStream >> nextPutAll: aString ” Transcript Window cannotTranscriptStream >>nextPutAll: hold more text! ”TranscriptStream >> show:BlockClosure >> value FAIL !BlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 97. Exceptions .Net Exceptions unwind the stackTranscriptStream >>nextPutAll: when thrown!TranscriptStream >> show:BlockClosure >> valueBlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 98. Exceptions Smalltalk expects resumableTranscriptStream >>nextPutAll: exceptions!TranscriptStream >> show:BlockClosure >> valueBlockClosure >> on:do: Stack is gone!Workspace >> evaluateSmalltalk >> run
  • 99. Exceptions Must keep stack!Extra code here …BlockClosure >> valueTranscriptStream >>nextPutAll: Code executes asTranscriptStream >> show:BlockClosure >> value usually.BlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 100. Exceptions Unwinding is executes asTranscriptStream >>nextPutAll: usually.TranscriptStream >> show:BlockClosure >> valueBlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 101. Exceptions List >> getItemText: aStringList >> getItemText:List.AddItem() ^self itemTextsList.AddItems() at: aString.List >> showItems:BlockClosure >> valueBlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 102. Exceptions List >> getItemText: aStringList >> getItemText:List.AddItem() ^self itemTextsList.AddItems() at: aString.List >> showItems:BlockClosure >> valueBlockClosure >> on:do: KEY IS MISSINGWorkspace >> evaluateSmalltalk >> run
  • 103. Exceptions List >> getItemText: aStringList >> getItemText:List.AddItem() ^self itemTextsList.AddItems() at: aString.List >> showItems:BlockClosure >> valueBlockClosure >> on:do: KEY IS MISSINGWorkspace >> evaluateSmalltalk >> run
  • 104. Exceptions List >> getItemText: aStringList >> getItemText:List.AddItem() ^self itemTextsList.AddItems() at: aString.List >> showItems:BlockClosure >> valueBlockClosure >> on:do: KEY IS MISSINGWorkspace >> evaluateSmalltalk >> run
  • 105. ExceptionsList >> getItemText: Exceptions mustList.AddItem() integrate with thetry { … } catch { … } rest of the .Net!List.AddItems()List >> showItems:BlockClosure >> valueBlockClosure >> on:do:Workspace >> evaluateSmalltalk >> run
  • 106. ExceptionsNon-Resumable exceptions can bemapped to native .Net exceptions
  • 107. ExceptionsNon-Resumable exceptions can bemapped to native .Net exceptionsResumable exceptions cannot bemapped to native .Net exceptionsand will need a IronSmalltalkspecial implementation.

×