[Vm-dev] VM Maker: VMMaker.oscog-eem.253.mcz

Ryan Macnak rmacnak at gmail.com
Sat Jan 12 21:40:24 UTC 2013


In Smalltalk, one knows at compile-time at which class to begin lookup for
super sends. In Newspeak, we do not know this as all methods are defined by
mixins, and the superclass of a mixin application is not known until
runtime. Hence /dynamic/ super send.

In Newspeak's as-yet-unimplemented access control, super sends can activate
protected members, but normal sends cannot. An /absent receiver/ send means
that the receiver of the message is not on stack beneath the arguments like
a normal send. This will allow the VM to implement access control without
having to check whether the receiver is allowed for types of sends that
access protected or private members, because the VM will provide the
receiver during the send itself.

On Sat, Jan 12, 2013 at 3:35 AM, stephane ducasse <
stephane.ducasse at gmail.com> wrote:

>
> Hi eliot
>
> I'm curious: what is a absent receiver dynamic super send?
>
> Stef
> On Jan 10, 2013, at 11:27 PM, commits at source.squeak.org wrote:
>
> >
> > Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
> > http://source.squeak.org/VMMaker/VMMaker.oscog-eem.253.mcz
> >
> > ==================== Summary ====================
> >
> > Name: VMMaker.oscog-eem.253
> > Author: eem
> > Time: 10 January 2013, 3:26:03.577 pm
> > UUID: 4a3ac3fb-d367-478b-ad95-ad3bb8b6216f
> > Ancestors: VMMaker.oscog-eem.252
> >
> > Implement absent receiver dynamic super send bytecode in the JIT.
> > This was an oversight from implementing absent receiver send.
> > Refactor the dynamic super send code to accomodate the new send.
> >
> > =============== Diff against VMMaker.oscog-eem.252 ===============
> >
> > Item was changed:
> >  ----- Method: SimpleStackBasedCogit>>genDynamicSuperSendBytecode (in
> category 'bytecode generators') -----
> >  genDynamicSuperSendBytecode
> > +     ^self genSendDynamicSuper: (coInterpreter literal: byte2 ofMethod:
> methodObj) numArgs: byte1!
> > -     | numArgs selector |
> > -     numArgs := byte1.
> > -     selector := coInterpreter literal: byte2 ofMethod: methodObj.
> > -     (objectMemory isYoung: selector) ifTrue:
> > -             [hasYoungReferent := true].
> > -     self assert: needsFrame.
> > -     self MoveMw: numArgs * BytesPerWord r: SPReg R: ReceiverResultReg.
> > -     numArgs > 2 ifTrue:
> > -             [self MoveCq: numArgs R: SendNumArgsReg].
> > -     self MoveCw: selector R: ClassReg.
> > -     self CallNewspeakSend: (dynamicSuperSendTrampolines at: (numArgs
> min: NumSendTrampolines - 1)).
> > -     self flag: 'currently caller pushes result'.
> > -     self PushR: ReceiverResultReg.
> > -     ^0!
> >
> > Item was changed:
> >  ----- Method:
> SimpleStackBasedCogit>>genExtSendAbsentDynamicSuperBytecode (in category
> 'bytecode generators') -----
> >  genExtSendAbsentDynamicSuperBytecode
> >       "241            11110001        i i i i i j j j Send To Absent
> Dynamic Superclass Literal Selector #iiiii (+ Extend A * 32) with jjj (+
> Extend B * 8) Arguments"
> > +     | litIndex nArgs |
> > +     litIndex := (byte1 >> 3) + (extA << 5).
> > +     extA := 0.
> > +     nArgs := (byte1 bitAnd: 7) + (extB << 3).
> > +     extB := 0.
> > +     ^self genSendAbsentDynamicSuper: (coInterpreter literal: litIndex
> ofMethod: methodObj) numArgs: nArgs!
> > -     self shouldBeImplemented.
> > -     ^EncounteredUnknownBytecode!
> >
> > Item was added:
> > + ----- Method:
> SimpleStackBasedCogit>>genSendAbsentDynamicSuper:numArgs: (in category
> 'bytecode generators') -----
> > + genSendAbsentDynamicSuper: selector numArgs: numArgs
> > +     "Shuffle arguments if necessary and push receiver.
> > +      Then send."
> > +     <inline: false>
> > +     numArgs = 0
> > +             ifTrue:
> > +                     [self PushR: ReceiverResultReg]
> > +             ifFalse:
> > +                     [self MoveMw: 0 r: SPReg R: TempReg.
> > +                     self PushR: TempReg.
> > +                     2 to: numArgs do:
> > +                             [:index|
> > +                             self MoveMw: index * BytesPerWord r: SPReg
> R: TempReg.
> > +                             self MoveR: TempReg Mw: index - 1 *
> BytesPerWord r: SPReg].
> > +                     "if we copied the code in genSendDynamicSuper: we
> could save an instruction.
> > +                     But we care not; the smarts are in
> StackToRegisterMappingCogit et al"
> > +                     self MoveR: ReceiverResultReg Mw: numArgs *
> BytesPerWord r: SPReg].
> > +     ^self genSendDynamicSuper: selector numArgs: numArgs!
> >
> > Item was added:
> > + ----- Method: SimpleStackBasedCogit>>genSendDynamicSuper:numArgs: (in
> category 'bytecode generators') -----
> > + genSendDynamicSuper: selector numArgs: numArgs
> > +     (objectMemory isYoung: selector) ifTrue:
> > +             [hasYoungReferent := true].
> > +     self assert: needsFrame.
> > +     self MoveMw: numArgs * BytesPerWord r: SPReg R: ReceiverResultReg.
> > +     numArgs > 2 ifTrue:
> > +             [self MoveCq: numArgs R: SendNumArgsReg].
> > +     self MoveCw: selector R: ClassReg.
> > +     self CallNewspeakSend: (dynamicSuperSendTrampolines at: (numArgs
> min: NumSendTrampolines - 1)).
> > +     self flag: 'currently caller pushes result'.
> > +     self PushR: ReceiverResultReg.
> > +     ^0!
> >
> > Item was removed:
> > - ----- Method: StackToRegisterMappingCogit>>genDynamicSuperSendBytecode
> (in category 'bytecode generators') -----
> > - genDynamicSuperSendBytecode
> > -     | numArgs selector |
> > -     numArgs := byte1.
> > -     selector := coInterpreter literal: byte2 ofMethod: methodObj.
> > -     self marshallSendArguments: numArgs.
> > -     ^self genMarshalledSendDynamicSuper: selector numArgs: numArgs!
> >
> > Item was added:
> > + ----- Method:
> StackToRegisterMappingCogit>>genSendAbsentDynamicSuper:numArgs: (in
> category 'bytecode generators') -----
> > + genSendAbsentDynamicSuper: selector numArgs: numArgs
> > +     "OK, we could do better and avoid spilling ReceiverResultReg if we
> refactored
> > +      marshallImplicitReceiverSendArguments: to take a flag saying
> whether the
> > +      receiver was in ReceiverResultReg (absent receiver send) or on
> the stack
> > +      (absent dynamic super send) and in the latter case loading
> ReceiverResultReg
> > +      from the stack after marshalling.  But this is a rare bytecode so
> for the moment
> > +      don't bother."
> > +     self ssAllocateCallReg: ReceiverResultReg.
> > +     self MoveMw: FoxMFReceiver r: FPReg R: ReceiverResultReg.
> > +     self marshallImplicitReceiverSendArguments: numArgs.
> > +     ^self genMarshalledSendDynamicSuper: selector numArgs: numArgs!
> >
> > Item was added:
> > + ----- Method:
> StackToRegisterMappingCogit>>genSendDynamicSuper:numArgs: (in category
> 'bytecode generators') -----
> > + genSendDynamicSuper: selector numArgs: numArgs
> > +     self marshallSendArguments: numArgs.
> > +     ^self genMarshalledSendDynamicSuper: selector numArgs: numArgs!
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20130112/8176ef60/attachment.htm


More information about the Vm-dev mailing list