[Newcompiler] TODO list NewCompiler
Marcus Denker
denker at iam.unibe.ch
Fri Aug 4 07:35:15 UTC 2006
On 03.08.2006, at 18:21, Mathieu Suen wrote:
>
> Ok so if I understand it mean that if you have a method like this:
>
> zork
> | a |
> a := 2.
> ^[a + 2] value
>
> to get ''a' in the block you have to call push theEnvironement +
> pushInstVar: 1 so you get the value of 'a'. this is a field access?
>
Yes.
When compiling the code inside the block, the visitor does something
like this:
1) push environment
2) pushInstVar: 1
> I have decompile the code and I saw realy strange things.... But I
> start to understand it a bit.
>
The bytecode then generated is a bit different: there is no bytecode
for "accessing an instvar
of another object". So the code generated is
push environment
push 1
send: privGetInstVar:
One of the steps to improve the perfomance (and make everything
nicer) would be to add bytecodes
for getting/setting for the object on the stack... now with Croquet
supporting remote assignment in
the syntax directly (object instVar := 5, not that I like that too
much...), it would be nice for them, too.
> I saw a CompiledMethod witch is a constant pushed but were it come
> from? (BlockClosure I think but I cant see it)
There are two things that can happen with blocks that are compiled:
1) we can generate a BlockClosure, because there are no free variables.
2) we can't. So we just generate a method, store this in the
literalframe (this is the pushed method you saw)
and then send "createBlock: env" to it at runtime
The method to look at is ASTTranslatorForValue>>#acceptBlockNode
....
blockMethod := aBlockNode generateIR.
aBlockNode freeVars isEmpty ifTrue: [
"Create block at compile time"
methodBuilder pushBlock: blockMethod.
] ifFalse: [
"Create block at run time"
| outerScope envVar |
outerScope := aBlockNode scope outerScope.
envVar := outerScope hasEscapingEnv
ifTrue: [outerScope thisEnvVar]
ifFalse: [outerScope receiverVar].
methodBuilder pushBlockMethod: blockMethod.
envVar emitLocalValue: methodBuilder.
methodBuilder send: #createBlock:.
].
Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3938 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/newcompiler/attachments/20060804/cc4a1899/smime.bin
More information about the Newcompiler
mailing list