[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re : [Help-smalltalk] About sp and thisContext->spOffset
From: |
Mathieu Suen |
Subject: |
Re : [Help-smalltalk] About sp and thisContext->spOffset |
Date: |
Fri, 27 Aug 2010 08:14:41 +0000 (GMT) |
----- Message d'origine ----
> De : Paolo Bonzini <address@hidden>
> Objet : Re: [Help-smalltalk] About sp and thisContext->spOffset
>
> On 08/26/2010 05:45 PM, Mathieu Suen wrote:
> > Hi,
> >
> > AFAIK sp in a context take in account the temporaries.
> > This mean the if you have 1 temp sp is equal to 1 at the beginning of the
> > function (minus the fact the is lazily sync but that is not my point)
> > From that there is something I don't understand:
> > In smalltalk I got the following example:
> >
> > | method |
> > method := (STInST.RBParser parseMethod: 'foo ^12') jitMethodIn: A.
> > A methodDictionary at: #foo put: method.
> > A new foo printNl
> >
> > I would expected to be FROM_INT(2) aka 5 since you have (A new) push on the
> > stack.
> > What did I miss-understood?
>
> Temporaries in the REPL are kind of special because they must survive
> multiple evaluations. So, they are treated as globals (or as instance
> variables in VisualGST).
>
> Try wrapping your test with Eval [ ... ], which will delimit the scope
> of the "method" variable, and sp will be 2 as expected.
Sorry I didn't mention it but the test above is written in a unit test:
testReturn [
| method |
method := (STInST.RBParser parseMethod: 'foo ^12') jitMethodIn: A.
A methodDictionary at: #foo put: method.
A new foo printNl
]
But from this :
/* activate_new_context */
thisContext->spOffset =
FROM_INT ((sp - thisContext->contextStack) - sendArgs);
It seems normal that spOffset is equal to FROM_INT(1).
So it mean also the the push if it were using spOffset should be:
push: object
memory storePointer: stackPointer
ofObject: activeContext
withValue: object.
stackPointer := stackPointer + 1.
Instead of:
push: object
stackPointer := stackPointer + 1.
memory storePointer: stackPointer
ofObject: activeContext
withValue: object
>
> Paolo
>