[squeak-dev] Strange primitives doing nothing

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

[squeak-dev] Strange primitives doing nothing

Igor Stasenko
I'm exploring the exception support in VM, and found two strange
primitives used by BlockClosure, which simply fail and doing nothing.

primitiveMarkUnwindMethod
        "Primitive. Mark the method for exception unwinding. The primitive
must fail after marking the context so that the regular code is run."
        self inline: false.
        ^self primitiveFail

primitiveMarkHandlerMethod
        "Primitive. Mark the method for exception handling. The primitive
must fail after marking the context so that the regular code is run."
        self inline: false.
        ^self primitiveFail

Any ideas, why they still in use? Can there be something in between,
when interpreter enters the method? Or, if nothing, then why they
still there? :)

--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Strange primitives doing nothing

stephane ducasse
I may be wrong but it seems to me that this primitives are just there  
to mark the method.
so that after the stack can is scanned for caller of 198 and 199  
(on:do:)

Have a look in the answer I got in squeak dev this summer about my  
questions about exceptions.

stef

On Nov 7, 2008, at 5:32 PM, Igor Stasenko wrote:

> I'm exploring the exception support in VM, and found two strange
> primitives used by BlockClosure, which simply fail and doing nothing.
>
> primitiveMarkUnwindMethod
> "Primitive. Mark the method for exception unwinding. The primitive
> must fail after marking the context so that the regular code is run."
> self inline: false.
> ^self primitiveFail
>
> primitiveMarkHandlerMethod
> "Primitive. Mark the method for exception handling. The primitive
> must fail after marking the context so that the regular code is run."
> self inline: false.
> ^self primitiveFail
>
> Any ideas, why they still in use? Can there be something in between,
> when interpreter enters the method? Or, if nothing, then why they
> still there? :)
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Strange primitives doing nothing

Igor Stasenko
2008/11/7 stephane ducasse <[hidden email]>:
> I may be wrong but it seems to me that this primitives are just there to
> mark the method.
> so that after the stack can is scanned for caller of 198 and 199 (on:do:)
>

Err.. what is actually happens when you 'marking a method'?
Maybe you meant a method context - which is activated when you entering method.
But to my sense this is common procedure regardless if method haves or
not haves the primitive.
I don't see a reason, why VM should do something extra when calling
primitive, because at the moment when primitive is invoked the
method's context is not created/reserved for a method - you got only
arguments on stack.
And then, since primitive fails, it should go to common procedure for
initializing & activating new context.

> Have a look in the answer I got in squeak dev this summer about my questions
> about exceptions.
>

I'll try to find it.

> stef
>
> On Nov 7, 2008, at 5:32 PM, Igor Stasenko wrote:
>
>> I'm exploring the exception support in VM, and found two strange
>> primitives used by BlockClosure, which simply fail and doing nothing.
>>
>> primitiveMarkUnwindMethod
>>        "Primitive. Mark the method for exception unwinding. The primitive
>> must fail after marking the context so that the regular code is run."
>>        self inline: false.
>>        ^self primitiveFail
>>
>> primitiveMarkHandlerMethod
>>        "Primitive. Mark the method for exception handling. The primitive
>> must fail after marking the context so that the regular code is run."
>>        self inline: false.
>>        ^self primitiveFail
>>
>> Any ideas, why they still in use? Can there be something in between,
>> when interpreter enters the method? Or, if nothing, then why they
>> still there? :)
>>
>> --
>> Best regards,
>> Igor Stasenko AKA sig.
>>
>>
>
>
>


--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Strange primitives doing nothing

Tapple Gao
On Fri, Nov 07, 2008 at 06:46:45PM +0200, Igor Stasenko wrote:
> 2008/11/7 stephane ducasse <[hidden email]>:
> > I may be wrong but it seems to me that this primitives are just there to
> > mark the method.
> > so that after the stack can is scanned for caller of 198 and 199 (on:do:)
> >
>
> Err.. what is actually happens when you 'marking a method'?

MethodContext >> #isHandlerContext
MethodContext >> #isUnwindContext

--
Matthew Fulmer -- http://mtfulmer.wordpress.com/

Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: Strange primitives doing nothing

Andreas.Raab
In reply to this post by Igor Stasenko
Igor Stasenko wrote:
> Any ideas, why they still in use? Can there be something in between,
> when interpreter enters the method? Or, if nothing, then why they
> still there? :)

As the comments say:

primitiveMarkUnwindMethod - Mark the method for exception unwinding.
primitiveMarkHandlerMethod - Mark the method for exception handling.

In other words these primitives are used to mark the frames containing
BlockContext>>on:do: and BlockContext>>ensure: so that the VM can find
these methods during unwind and exception handling. If you look at
non-local returns in the VM (returnValue:to:) you'll see this being used.

Cheers,
   - Andreas

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Strange primitives doing nothing

Igor Stasenko
2008/11/7 Andreas Raab <[hidden email]>:

> Igor Stasenko wrote:
>>
>> Any ideas, why they still in use? Can there be something in between,
>> when interpreter enters the method? Or, if nothing, then why they
>> still there? :)
>
> As the comments say:
>
> primitiveMarkUnwindMethod - Mark the method for exception unwinding.
> primitiveMarkHandlerMethod - Mark the method for exception handling.
>
> In other words these primitives are used to mark the frames containing
> BlockContext>>on:do: and BlockContext>>ensure: so that the VM can find these
> methods during unwind and exception handling. If you look at non-local
> returns in the VM (returnValue:to:) you'll see this being used.
>

Ah, now i get it. Its testing a method's primitive index to detect if
method needs special marking.
So, behavior based on primitive index, not on actual primitive
implementation... Tricky.

> Cheers,
>  - Andreas

--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: Strange primitives doing nothing

Andreas.Raab
Igor Stasenko wrote:
> Ah, now i get it. Its testing a method's primitive index to detect if
> method needs special marking.
> So, behavior based on primitive index, not on actual primitive
> implementation... Tricky.

Correct. The main reason is that otherwise you'd need additional header
bits so the  primitive index is a cheap way to avoid that need.

Cheers,
   - Andreas