Strange but when I try to implement a bytecode

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Strange but when I try to implement a bytecode

Mathieu SUEN
 
Hi,

I have been trying to implement a bytecode to create the closure  
environment needed for the NewCompiler. My first implementation looks  
like this:

createEnvironment

        | closSize |
        self fetchNextBytecode.
        closSize := currentBytecode.
        self fetchNextBytecode.
        "The following may cause GC!"
        self success: (self sufficientSpaceToInstantiate:  (self splObj:  
ClosureEnvObject) indexableSize: closSize).
        successFlag ifTrue: [
                self storePointer: 4
                        ofObject: activeContext
                        withValue:(self instantiateClass: (self splObj: ClosureEnvObject)  
indexableSize: closSize)]


This bytecode was suppose to replace the following bytecodes:

113 <20> pushConstant: ClosureEnvironment
114 <76> pushConstant: 4
115 <CD> send: new:
116 <89> pushThisContext:
117 <21> pushConstant: 5
118 <F2> send: privStoreIn:instVar:
119 <87> pop

into :

37 <7E 04> new closure: 4


But it keeps not working when a GC occurs (either in the markAnTrace  
phase or in the sweep phase).

Then I change my implementation to:

createEnvironment

        | closSize |
        self fetchNextBytecode.
        closSize := currentBytecode.
        self fetchNextBytecode.
        self push: (self splObj: ClosureEnvObject).
        self push: (self integerObjectOf: closSize).
        self primitiveNewWithArg.
        .
        successFlag ifTrue: [
                self storePointer: 4
                        ofObject: activeContext
                        withValue: self popStack]

And it works I can explain why. Could you?


        Mth