Why the recycle context is search twice

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

Why the recycle context is search twice

Mathieu SUEN

Hi,

When you look at the #internalActivateNewMethod you can see the VM  
checking for freeContexts:

internalActivateNewMethod
       

        …
        (needsLarge = 0 and: [freeContexts ~= NilContext])
                ifTrue: [newContext := freeContexts.
                                freeContexts := self fetchPointer: 0 ofObject: newContext]
                ifFalse: ["Slower call for large contexts or empty free list"
                                self externalizeIPandSP.
                                newContext := self allocateOrRecycleContext: needsLarge.
                                self internalizeIPandSP].
        …

Then in the #allocateOrRecycleContext you can see another check:

allocateOrRecycleContext: needsLarge
        "Return a recycled context or a newly allocated one if none is  
available for recycling."
        | cntxt |
        needsLarge = 0
        ifTrue: [freeContexts ~= NilContext ifTrue:
                                [cntxt := freeContexts.
                                freeContexts := self fetchPointer: 0 ofObject: cntxt.
                                ^ cntxt]]
        …

        …
        needsLarge = 0
                ifTrue: [cntxt := self instantiateContext: (self splObj:  
ClassMethodContext)
                                sizeInBytes: SmallContextSize]
        …


So why there is so many check for nothings. The best would be to have  
the #allocateOrRecycleLargeContext: method?



        Mth