Eliot Miranda uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-eem.217.mcz
==================== Summary ====================
Name: Compiler-eem.217
Author: eem
Time: 27 September 2011, 3:51:31.614 pm
UUID: 4b06bdff-bc34-4a41-b59d-8de0dc9bf16c
Ancestors: Compiler-eem.216
Add MethodNode>>ensureNotQuick to allow forcing generating
non-quick versions of quick methods (^self, ^inst var, et al).
This is used by MwbreakpointWrapper.
Yes this could arguably be a set of extensions in
MethodWrappers, but it feels too intimate for that, and
other compilers may want to implement the same API.
=============== Diff against Compiler-eem.216 ===============
Item was added:
+ ----- Method: BlockNode>>ensureNotQuick: (in category 'converting') -----
+ ensureNotQuick: encoder
+ "If the receiver is quick (can be generated as a Quick method, ^self,^inst var or ^ special constant)
+ make it not so. This is used to create break-pointable versions of quick methods. Answer if the
+ receiver was quick."
+ self isQuick ifFalse:
+ [^false].
+ "Making statements size > 1 is sufficient to cause isQuick to answer false (see BlockNode>>isQuick).
+ N.B. This is a no-op since statements generate via emitCodeForEffect: and VariableNodes have no effect."
+ statements addFirst: (encoder encodeVariable: 'self').
+ ^true!
Item was added:
+ ----- Method: MethodNode>>ensureNotQuick (in category 'converting') -----
+ ensureNotQuick
+ "If the receiver is quick (can be generated as a Quick method, ^self,^inst var or ^ special constant)
+ make it not so. This is used to create break-pointable versions of quick methods. Answer if the
+ receiver was quick."
+ ^block ensureNotQuick: encoder!
There is a reference on Wikipedia's page on Tuple Spaces to http://www.fongen.no/?docname=SmallSpaces/ but that is a dead link.
I was interested in building tuple-space for Smalltalk, but this and a 1988 paper from Matsuoka and Kawai are the only things I turned up.
If anyone knows more, please let me know. Also, I'd be interested to hear if people think this is a particularly good idea before I turn a grad student loose on it.
Thanks ../Dave
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.631.mcz
==================== Summary ====================
Name: Kernel-ul.631
Author: ul
Time: 27 September 2011, 6:47:40.645 pm
UUID: 7793f80d-42dc-2a45-afc1-67ce003aba45
Ancestors: Kernel-eem.630, Kernel-ul.630
Merged.
=============== Diff against Kernel-eem.630 ===============
Item was changed:
----- Method: MethodDictionary class>>new (in category 'instance creation') -----
new
+ "Create a new instance with 32 slots, which can hold at most 24 methods before growing is necessary."
- "Create a new instance with 32 slots. See the comment of #sizeFor: why the argument is 16."
+ ^self newForCapacity: 32!
- ^self new: 16!
Item was changed:
----- Method: MethodDictionary class>>new: (in category 'instance creation') -----
new: numberOfElements
+ "Create an instance large enough to hold numberOfElements methods without growing."
- "Create an instance large enough to hold numberOfElements without growing. Note that the basic size must be a power of 2. It is VITAL (see grow) that size gets doubled if numberOfElements is a power of 2"
+ ^self newForCapacity: (self sizeFor: numberOfElements)!
- | size |
- size := self sizeFor: numberOfElements.
- ^(self basicNew: size) initialize: size!
Item was added:
+ ----- Method: MethodDictionary class>>newForCapacity: (in category 'private') -----
+ newForCapacity: capacity
+ "Create an instance with the given capacity which must be a power of two."
+
+ ^(self basicNew: capacity) initialize: capacity!
Item was changed:
----- Method: MethodDictionary class>>sizeFor: (in category 'sizing') -----
sizeFor: numberOfElements
"Return the minimum capacity of a dictionary that can hold numberOfElements elements. At least 25% of the array must be empty and the return value must be a power of 2."
+ ^(numberOfElements * 4 // 3) asLargerPowerOfTwo!
- ^1 bitShift: (numberOfElements * 4 // 3) highBit!
Item was changed:
----- Method: MethodDictionary>>grow (in category 'private') -----
grow
| newSelf |
+ newSelf := self species newForCapacity: self basicSize * 2.
- newSelf := self species new: self basicSize. "This will double the size"
1 to: self basicSize do: [ :i |
(self basicAt: i) ifNotNil: [ :key |
newSelf at: key put: (array at: i) ] ].
self become: newSelf!
Item was changed:
----- Method: MethodDictionary>>rehash (in category 'private') -----
rehash
| newInstance |
+ newInstance := self species newForCapacity: self basicSize.
- newInstance := self species new: self basicSize - 1. "Make sure it has the same capacity"
1 to: self basicSize do: [ :index |
(self basicAt: index) ifNotNil: [ :key |
newInstance at: key put: (array at: index) ] ].
self copyFrom: newInstance!
Item was changed:
----- Method: MethodDictionary>>removeAll (in category 'removing') -----
removeAll
+ "Remove all elements from this collection. Preserve the capacity"
- "This provides a faster way than repeated become.
- a single become is still in use to prevent system crash."
| newSelf |
tally = 0 ifTrue: [^self].
+ newSelf := self species newForCapacity: self basicSize.
- newSelf := self species new: self basicSize - 1. "This will preserve the capacity"
self copyFrom: newSelf!
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.630.mcz
==================== Summary ====================
Name: Kernel-ul.630
Author: ul
Time: 27 September 2011, 6:09:18.907 pm
UUID: 87434805-2f3c-c446-b12b-3af3c0043cea
Ancestors: Kernel-nice.629
Fix for the recently introduced MethodDictionary bug reported by Mariano Martinez Peck on the Pharo list and some other things.
- added MethodDictionary class >> #newForCapacity: to reduce the complexity of the various methods which create new instances with a given capacity (#grow, #rehash, #removeAll). These changes make some comments unnecessary.
- fix: #sizeFor: should allow 75% load factor
=============== Diff against Kernel-nice.629 ===============
Item was changed:
----- Method: MethodDictionary class>>new (in category 'instance creation') -----
new
+ "Create a new instance with 32 slots, which can hold at most 24 methods before growing is necessary."
- "Create a new instance with 32 slots. See the comment of #sizeFor: why the argument is 16."
+ ^self newForCapacity: 32!
- ^self new: 16!
Item was changed:
----- Method: MethodDictionary class>>new: (in category 'instance creation') -----
new: numberOfElements
+ "Create an instance large enough to hold numberOfElements methods without growing."
- "Create an instance large enough to hold numberOfElements without growing. Note that the basic size must be a power of 2. It is VITAL (see grow) that size gets doubled if numberOfElements is a power of 2"
+ ^self newForCapacity: (self sizeFor: numberOfElements)!
- | size |
- size := self sizeFor: numberOfElements.
- ^(self basicNew: size) initialize: size!
Item was added:
+ ----- Method: MethodDictionary class>>newForCapacity: (in category 'private') -----
+ newForCapacity: capacity
+ "Create an instance with the given capacity which must be a power of two."
+
+ ^(self basicNew: capacity) initialize: capacity!
Item was changed:
----- Method: MethodDictionary class>>sizeFor: (in category 'sizing') -----
sizeFor: numberOfElements
"Return the minimum capacity of a dictionary that can hold numberOfElements elements. At least 25% of the array must be empty and the return value must be a power of 2."
+ ^(numberOfElements * 4 // 3) asLargerPowerOfTwo!
- ^1 bitShift: (numberOfElements * 4 // 3) highBit!
Item was changed:
----- Method: MethodDictionary>>grow (in category 'private') -----
grow
| newSelf |
+ newSelf := self species newForCapacity: self basicSize * 2.
- newSelf := self species new: self basicSize. "This will double the size"
1 to: self basicSize do: [ :i |
(self basicAt: i) ifNotNil: [ :key |
newSelf at: key put: (array at: i) ] ].
self become: newSelf!
Item was changed:
----- Method: MethodDictionary>>rehash (in category 'private') -----
rehash
| newInstance |
+ newInstance := self species newForCapacity: self basicSize.
- newInstance := self species new: self basicSize - 1. "Make sure it has the same capacity"
1 to: self basicSize do: [ :index |
(self basicAt: index) ifNotNil: [ :key |
newInstance at: key put: (array at: index) ] ].
self copyFrom: newInstance!
Item was changed:
----- Method: MethodDictionary>>removeAll (in category 'removing') -----
removeAll
+ "Remove all elements from this collection. Preserve the capacity"
- "This provides a faster way than repeated become.
- a single become is still in use to prevent system crash."
| newSelf |
tally = 0 ifTrue: [^self].
+ newSelf := self species newForCapacity: self basicSize.
- newSelf := self species new: self basicSize - 1. "This will preserve the capacity"
self copyFrom: newSelf!
Eliot Miranda uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-eem.216.mcz
==================== Summary ====================
Name: Compiler-eem.216
Author: eem
Time: 27 September 2011, 8:55:43.391 am
UUID: 6876b6f4-047e-4ed9-81e6-9f49c02fcd00
Ancestors: Compiler-eem.215
Use the methodForDecompile hook in decompile:in:. This
fixes infinite recursion when decompiling installed wrapper
methods. Needs Kernel-eem.630.
=============== Diff against Compiler-eem.215 ===============
Item was changed:
----- Method: Decompiler>>decompile:in: (in category 'public access') -----
decompile: aSelector in: aClass
"See Decompiler|decompile:in:method:. The method is found by looking up
the message, aSelector, in the method dictionary of the class, aClass."
^self
decompile: aSelector
in: aClass
+ method: (aClass compiledMethodAt: aSelector) methodForDecompile!
- method: (aClass compiledMethodAt: aSelector)!
Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.630.mcz
==================== Summary ====================
Name: Kernel-eem.630
Author: eem
Time: 27 September 2011, 8:45:29.372 am
UUID: 71012e54-3304-4e32-9ab0-46fa56f149c5
Ancestors: Kernel-nice.629
Provide a hook for subclasses to substitute an altered
method when deocmpiling. This aoids an infinite recursion
decompiling installed MwMethodWrapper methods.
=============== Diff against Kernel-nice.629 ===============
Item was changed:
----- Method: CompiledMethod>>decompile (in category 'decompiling') -----
decompile
"Return the decompiled parse tree that represents self"
| class selector |
class := self methodClass ifNil: [Object].
selector := self selector ifNil: [self defaultSelector].
+ ^class decompilerClass new decompile: selector in: class method: self methodForDecompile!
- ^class decompilerClass new decompile: selector in: class method: self.!
Item was changed:
----- Method: CompiledMethod>>decompileWithTemps (in category 'decompiling') -----
decompileWithTemps
"Return the decompiled parse tree that represents self, but get the temp names
by compiling the sourcecode..."
| class selector |
class := self methodClass ifNil: [Object].
selector := self selector ifNil: [self defaultSelector].
(self fileIndex > 0 and: [(SourceFiles at: self fileIndex) isNil]) ifTrue: [
"Emergency or no source file -- decompile without temp names "
^self decompile.
].
^((self decompilerClass new withTempNames: self methodNode schematicTempNamesString)
decompile: selector
in: class
+ method: self methodForDecompile)!
- method: self)!
Item was changed:
----- Method: CompiledMethod>>getSourceFor:in: (in category 'source code management') -----
getSourceFor: selector in: class
"Retrieve or reconstruct the source code for this method."
| trailer source |
+ (self properties includesKey: #source) ifTrue:
+ [^self properties at: #source].
trailer := self trailer.
trailer tempNames ifNotNil: [:namesString |
"Magic sources -- decompile with temp names"
^ ((class decompilerClass new withTempNames: namesString)
+ decompile: selector in: class method: self methodForDecompile)
- decompile: selector in: class method: self)
decompileString].
trailer sourceCode ifNotNil: [:code | ^ code ].
trailer hasSourcePointer ifFalse: [
"No source pointer -- decompile without temp names"
+ ^ (class decompilerClass new decompile: selector in: class method: self methodForDecompile)
- ^ (class decompilerClass new decompile: selector in: class method: self)
decompileString].
"Situation normal; read the sourceCode from the file"
source := [self getSourceFromFileAt: trailer sourcePointer]
on: Error
"An error can happen here if, for example, the changes file has been truncated by an aborted download. The present solution is to ignore the error and fall back on the decompiler. A more thorough solution should probably trigger a systematic invalidation of all source pointers past the end of the changes file. Consider that, as time goes on, the changes file will eventually grow large enough to cover the lost code, and then instead of falling into this error case, random source code will get returned."
do: [ :ex | ex return: nil].
^source ifNil: [
"Something really wrong -- decompile blind (no temps)"
+ (class decompilerClass new decompile: selector in: class method: self methodForDecompile)
- (class decompilerClass new decompile: selector in: class method: self)
decompileString]!
Item was added:
+ ----- Method: CompiledMethod>>methodForDecompile (in category 'decompiling') -----
+ methodForDecompile
+ "This is a hook to allow recursive methods like MwMethodWrapper to avoid infinite recursion."
+ ^self!
Changes to Trunk (http://source.squeak.org/trunk.html) in the last 24 hours:
http://lists.squeakfoundation.org/pipermail/packages/2011-September/004992.…
Name: Kernel-nice.628
Ancestors: Kernel-nice.627
Boolean subclasses know better how to behave, so if we delegate ==> , we can implement a branch-less implication.
Though I wonder if this is really an optimization in case of a JIT VM...
{
[true ==> [1 > 2]] bench.
[false ==> [1 > 2]] bench.
}
#( '6,440,000 per second.' '6,690,000 per second.') "BEFORE"
#( '6,410,000 per second.' '7,030,000 per second.') "AFTER"
=============================================
http://lists.squeakfoundation.org/pipermail/packages/2011-September/004993.…
Name: Kernel-nice.629
Ancestors: Kernel-nice.628
Define and use #highBitOfByte when we know we operate on byte boundary.
And, oups, remove ===> which crept in trunk (was solely for testing speed).
=============================================