Saving morphs to file

Marcus Denker denker at iam.unibe.ch
Tue Jul 18 09:12:39 UTC 2006


On 18.07.2006, at 10:50, Marcus Denker wrote:

>
> On 18.07.2006, at 06:11, Chris Muller wrote:
>
>
> What I personally don't like is that blocks in Squeak mix the  
> static with the dynamic.
>
> For methods, we have the static (dead) description of  a method:  
> CompiledMethod.
> When it is run, a MethodContext is allocated. For blocks, we only  
> have the
> dynamic structure: BlockContext, even for the static structure of  
> "a Block".
>
> This is much nicer done in Anthony's design of blocks for the  
> ClosureCompiler.
>

As an example, have a look at a simple method accessing an iVar:

TT>>test
	^[i].

Then we execute:

TT new test explore

For the old compiler, this gets us a horribly complicated structure  
referencing
the Context of both the Block and the Method:

[] in TT>>test {[i]}
root: [] in TT>>test {[i]}
	sender: nil
	pc: 18
	stackp: 0
	nargs: 0
	startpc: 18
	home: TT>>test
		sender: nil
		pc: nil
		stackp: 0
		method: a CompiledMethod (2302)
		receiverMap: nil
		receiver: a TT


With the NewCompiler, the structure of the Closure is completely static,
it just references a method that encodes the code of the block and the
environment for the iVar access:

a BlockClosure (1599)
root: a BlockClosure (1599)
	method: a CompiledMethod (1605)
	environment: a TT
		i: nil

even with an outer temp reference, the picture does not get more  
complicated:

test
	| t |
	t := 5.
	^[t].

a BlockClosure (2739)
root: a BlockClosure (2739)
	method: a CompiledMethod (1814)
	environment: a ClosureEnvironment
		1: 5

The code of the method #test is compiled to reference the temp as the  
ivar in the Environment...
which is of course slowing down temp access for these kinds of shared  
temps.

     Marcus




More information about the Squeak-dev mailing list