[Newcompiler] Finding enough bytecodes for closures.
Klaus D. Witzel
klaus.witzel at cobss.com
Tue May 1 20:19:19 UTC 2007
On Tue, 01 May 2007 21:10:29 +0200, Marcus Denker wrote:
> On 01.05.2007, at 19:52, Klaus D. Witzel wrote:
...
>> There's one particular reason why #pushActiveContextBytecode has to
>> cancel (as noted by Bryce in the other thread) the recycling
>> possibility of contexts: any piece of code could have stored the
>> context (MethodContext and BlockContext alike) behind the VM's
>> back, say for example into a slot of a longer living object (like
>> in an iVar). From then on recycling is impossible.
>>
> yes. As soon as you access thisContext.
>
>> Can we agree that this situation (cause+effect) cannot change,
>> regardless of using MethodContext, BlockContext, BlockClosures or
>> any replacement for the latter?
>>
>
> But what we can change is that we push thisContext to access the
> environment... it did something like:
>
> pushThisContext
> pushConstant: 5
> send: privGetInstVar:
>
> So the thisContext is never referenced (and stored in a ivar, moved
> around..) but only put on the stack to
> get the 5th instVar of it. If we do that in the bytecode like this:
>
> !Interpreter methodsFor: 'stack bytecodes' stamp: 'ms 4/24/2007 15:08'!
> pushClosureEnvironment
>
> self fetchNextBytecode.
> self internalPush: (self fetchPointer: 4 ofObject: activeContext).
> ! !
>
> !Interpreter methodsFor: 'stack bytecodes' stamp: 'ms 4/28/2007 11:12'!
> storeClosureEnvironment
> "Byte code for the closure environment"
> self fetchNextBytecode.
>
> self storePointer: 4 ofObject: activeContext withValue: self
> internalStackTop! !
Yes, I already thought the code that Mathieu mentioned looks like this.
> We never need to push the thisContext at all...
*except* in ClosureEnvironment>>#return: ...
Cheers
Klaus
> Marcus
>
>
More information about the Newcompiler
mailing list