I think the problem is that what we did is to mark a variables as escaping when it
as *read* in an optimised block.
But what we should do is to mark only all *writes* to a variable that happens in a loop as
escaping vars even in the case when they happen in the same scope.
this means the read is simpler:
visitVariableNode: aVariableNode
| var |
var := (self lookupVariableForRead: aVariableNode) ifNil: [(self undeclaredVariable: aVariableNode)].
aVariableNode binding: var.
var isUninitialized ifTrue: [self uninitializedVariable: aVariableNode].
While in the write we need to mark:
lookupVariableForWrite: aVariableNode
| var |
var := scope lookupVar: aVariableNode name.
var ifNil: [^var].
var isSpecialVariable ifTrue: [ self storeIntoSpecialVariable: aVariableNode ].
var isWritable ifFalse: [ self storeIntoReadOnlyVariable: aVariableNode ].
var isTemp ifTrue: [
"when in a loop, all writes escape"
scope outerScope isInsideOptimizedLoop ifTrue: [ var markEscapingWrite ].
"else only escaping when they will end up in different closures"
(var scope outerNotOptimizedScope ~= scope outerNotOptimizedScope)
ifTrue: [ var markEscapingWrite]].
^var
I checked that all Opal tests that are failing are actually testing wrong, and I double checked
that all those methods are now compiled like with the old old compiler���
Now recompilng the image.
Marcus