This document discusses IronSmalltalk, which aims to provide a Smalltalk environment that runs on the Microsoft .NET DLR framework. It covers the history and motivation behind IronSmalltalk, provides an overview of key .NET DLR concepts like message sends, call sites, and call site binders. It also discusses how IronSmalltalk implements expression trees, the code pipeline from Smalltalk to MSIL, and techniques like polymorphic inline caching. The presentation concludes by discussing the project's goals and some future directions.
44. Expression Trees
Abstract Semantic Tree
Abstract Syntax Tree
Expression trees model code
Expressions are used to
represent the implementation
of certain code or logic
64. 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!
65. 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
68. 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
74. Object Space
No Object Space Reflection
No #allInstances
No #allReferences
No #become:
But #behaveLike: is possible!
Debugger inspection is possible.
83. Callbacks
List.AddItem(string[] keys,
dynamic stList)
{
string text = stList.
.GetItemText(key);
List.AddItem()
List.AddItems() ” …somehow add it… ”
List >> showItems: }
Workspace >> evaluate
Smalltalk >> run
84. Callbacks
List >> getItemText:
aString
^self itemTexts
List >> getItemText: at: aString.
List.AddItem()
List.AddItems()
List >> showItems:
Workspace >> evaluate
Smalltalk >> run
85. Callbacks
.Net 4.0 has the dynamic
keyword used for invoking
method on dynamic objects.
List >> getItemText: IronSmalltalk objects can
List.AddItem()
transparently be used by any
DLR aware language.
List.AddItems()
List >> showItems:
Workspace >> evaluate
Smalltalk >> run
86. Callbacks
Native Name: GetItemText
List >> getItemText:
aString
List >> getItemText:
List.AddItem()
List.AddItems() The native name is the
List >> showItems: method name (selector) that
Workspace >> evaluate
is exposed to the other DLR
languages.
Smalltalk >> run
87. Exceptions
[ Transcript show:
'Hello, Edinburgh!' ]
on: Error do: [ … ].
Workspace >> evaluate
Smalltalk >> run
88. Exceptions
BlockClosure >>
on: exception
do: handlerAction
” Some magic … ”
BlockClosure >> on:do:
^self value.
Workspace >> evaluate
Smalltalk >> run
89. Exceptions
BlockClosure >> value
< Primitive >
BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
100. Exceptions
TranscriptStream >>
nextPutAll: aString
” Transcript Window cannot
TranscriptStream >>nextPutAll: hold more text! ”
TranscriptStream >> show:
BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
101. Exceptions
TranscriptStream >>
nextPutAll: aString
” Transcript Window cannot
TranscriptStream >>nextPutAll: hold more text! ”
TranscriptStream >> show:
BlockClosure >> value
FAIL !
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
102. Exceptions
.Net Exceptions
unwind the stack
TranscriptStream >>nextPutAll: when thrown!
TranscriptStream >> show:
BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
103. Exceptions
Smalltalk expects
resumable
TranscriptStream >>nextPutAll: exceptions!
TranscriptStream >> show:
BlockClosure >> value
BlockClosure >> on:do: Stack is gone!
Workspace >> evaluate
Smalltalk >> run
104. Exceptions
Must keep stack!
Extra code here …
BlockClosure >> value
TranscriptStream >>nextPutAll: Code executes as
TranscriptStream >> show:
BlockClosure >> value
usually.
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
105. Exceptions
Unwinding is
executes as
TranscriptStream >>nextPutAll:
usually.
TranscriptStream >> show:
BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
106. Exceptions
List >> getItemText:
aString
List >> getItemText:
List.AddItem() ^self itemTexts
List.AddItems() at: aString.
List >> showItems:
BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
107. Exceptions
List >> getItemText:
aString
List >> getItemText:
List.AddItem() ^self itemTexts
List.AddItems() at: aString.
List >> showItems:
BlockClosure >> value
BlockClosure >> on:do:
KEY IS MISSING
Workspace >> evaluate
Smalltalk >> run
108. Exceptions
List >> getItemText:
aString
List >> getItemText:
List.AddItem() ^self itemTexts
List.AddItems() at: aString.
List >> showItems:
BlockClosure >> value
BlockClosure >> on:do:
KEY IS MISSING
Workspace >> evaluate
Smalltalk >> run
109. Exceptions
List >> getItemText:
aString
List >> getItemText:
List.AddItem() ^self itemTexts
List.AddItems() at: aString.
List >> showItems:
BlockClosure >> value
BlockClosure >> on:do:
KEY IS MISSING
Workspace >> evaluate
Smalltalk >> run
110. Exceptions
List >> getItemText:
Exceptions must
List.AddItem() integrate with the
try { … } catch { … }
rest of the .Net!
List.AddItems()
List >> showItems:
BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
112. Exceptions
Non-Resumable exceptions can be
mapped to native .Net exceptions
Resumable exceptions cannot be
mapped to native .Net exceptions
and will need a IronSmalltalk
special implementation.