[Vm-dev] Access to arguments in the stack vm

Clément Béra bera.clement at gmail.com
Mon Oct 8 19:11:49 UTC 2018


Hi,

I think the general idea is that only the methods inlined in interpret can
use localSP/localFP which are mapped to registers but only in the interpret
method to make the interpreter quicker. In the rest of the code you need to
used framePointer/stackPointer. Getting out of inlining in the interpreter
requires a call to a method such as externalizeFPandSP which moves from the
registers the value to variables, and internalizeIPandSP does the other way
around.

So in your case you need to see if for interpreter performance you want
your code to be inlined if the main interpreter loop, if so, then use
localSP, else, use stackPointer.

Hope this helps!

Best!


On Mon, Oct 8, 2018 at 8:51 PM Hernan Wilkinson <
hernan.wilkinson at 10pines.com> wrote:

>
> Hi,
>  In the implementation of the dynamically typed vm I'm doing (to give it a
> name) I need to get the parameters when a method gets activated.
>  To do it I implemented a not-inlined method that sends the message
> #internalStackValue:
>  The problem is that the code for that method is not generated. The method
> gets removed from the methods to generate code because it access "localSP"
> although not directly but due to inlining #internalStackValue:
>
>  How should I access the arguments then? Why I can not use "localSP"?
>
>  The method source is:
> keepArgumentTypes
>
> <inline: false>
> | additionalMethodState tempVarsTypes |
> additionalMethodState := self additionalMethodStateOf: newMethod.
> additionalMethodState = objectMemory nilObject ifTrue: [ ^self ].
> tempVarsTypes := objectMemory followObjField: 2 ofObject:
> additionalMethodState.
> tempVarsTypes = objectMemory nilObject ifTrue: [ ^self ].
> 0 to: argumentCount-1 do: [ :argIndex |
> self keepTypeInformationIn: tempVarsTypes at: argIndex for: (self
> internalStackValue: argIndex) ].
>  I manage to solve the problem passing localSP as parameter and doing the
> following, but I should not be doing that:
> keepArgumentTypes: sp
>
> <inline: false>
> | additionalMethodState tempVarsTypes |
> additionalMethodState := self additionalMethodStateOf: newMethod.
> additionalMethodState = objectMemory nilObject ifTrue: [ ^self ].
> tempVarsTypes := objectMemory followObjField: 2 ofObject:
> additionalMethodState.
> tempVarsTypes = objectMemory nilObject ifTrue: [ ^self ].
> 0 to: argumentCount-1 do: [ :argIndex |
> self keepTypeInformationIn: tempVarsTypes at: argIndex for: (stackPages
> longAtPointer: sp + (argIndex * objectMemory bytesPerOop)) ].
>
> --
>
> *Hernán WilkinsonAgile Software Development, Teaching & Coaching*
> *Phone: +54-011*-4893-2057
> *Twitter: @HernanWilkinson*
> *site: http://www.10Pines.com <http://www.10pines.com/>*
> Address: Alem 896, Floor 6, Buenos Aires, Argentina
>


-- 
Clément Béra
https://clementbera.github.io/
https://clementbera.wordpress.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20181008/7334cbdb/attachment-0001.html>


More information about the Vm-dev mailing list