Andreas Raab uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ar.323.mcz ==================== Summary ==================== Name: Kernel-ar.323 Author: ar Time: 4 December 2009, 6:32:01 am UUID: 4b183b83-103d-a046-b240-8696b955d800 Ancestors: Kernel-ar.322 Faster #ensure: handling: Instead of having the default path use thisContext>>tempAt:put: (which is very slow for the JIT) use a temp assignment and let only the termination handling actually do #tempAt:put:. Part 3 updates #ensure: to only use the fast version. =============== Diff against Kernel-ar.322 =============== Item was changed: ----- Method: BlockClosure>>ensure: (in category 'exceptions') ----- ensure: aBlock + "Evaluate a termination block after evaluating the receiver, regardless of + whether the receiver's evaluation completes. N.B. This method is *not* + implemented as a primitive. Primitive 198 always fails. The VM uses prim + 198 in a context's method as the mark for an ensure:/ifCurtailed: activation." - "Evaluate a termination block after evaluating the receiver, regardless of whether the receiver's evaluation completes." + | complete returnValue | - | complete returnValue b | <primitive: 198> returnValue := self valueNoContextSwitch. + complete ifNil:[ - "aBlock wasn't nil when execution of this method began; it is nil'd out by the unwind machinery, and that's how we know it's already been evaluated ... otherwise, obviously, it needs to be evaluated" - (aBlock == nil or:[complete == true]) ifFalse: [ - "nil out aBlock temp before evaluating aBlock so it is not executed again if aBlock remote returns" - b := aBlock. - thisContext tempAt: 1 put: nil. "Could be aBlock := nil, but arguments cannot be modified" complete := true. + aBlock value. - b value. ]. ^ returnValue! Item was changed: ----- Method: BlockContext>>ensure: (in category 'exceptions') ----- ensure: aBlock + "Evaluate a termination block after evaluating the receiver, regardless of + whether the receiver's evaluation completes. N.B. This method is *not* + implemented as a primitive. Primitive 198 always fails. The VM uses prim + 198 in a context's method as the mark for an ensure:/ifCurtailed: activation." - "Evaluate a termination block after evaluating the receiver, regardless of whether the receiver's evaluation completes." + | complete returnValue | - | complete returnValue b | <primitive: 198> returnValue := self value. + complete ifNil:[ - "aBlock wasn't nil when execution of this method began; it is nil'd out by the unwind machinery, and that's how we know it's already been evaluated ... otherwise, obviously, it needs to be evaluated" - (aBlock == nil or:[complete == true]) ifFalse: [ - "nil out aBlock temp before evaluating aBlock so it is not executed again if aBlock remote returns" - b := aBlock. - thisContext tempAt: 1 put: nil. "aBlock := nil" complete := true. + aBlock value. - b value. ]. ^ returnValue! |
Free forum by Nabble | Edit this page |