SmallInteger as Methods [WAS] Re: [Pharo-project] Ideas for CompiledMethod proxies?

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

SmallInteger as Methods [WAS] Re: [Pharo-project] Ideas for CompiledMethod proxies?

Mariano Martinez Peck
 


On Sat, Nov 20, 2010 at 7:50 PM, Eliot Miranda <[hidden email]> wrote:


On Sat, Nov 20, 2010 at 10:28 AM, Mariano Martinez Peck <[hidden email]> wrote:


Thanks Levente. I like this idea. I've been doing proxies for classes,
normal objects, etc and I never thought about using SmallIntegers. This is
because I usually need to do a #become:   between the original object and
the proxy. But in this case this is not needed, since I just need a
methodDict at: put: .  And this is a good idea because I don't need an
object header per proxy instance.

I will try to implement this. Thank you very much for all the answers.

I did a quick implementation and it works. The only problem is that you can't swap-out a method that's used by the swap-in code.


It doesn't work here. It seems I cannot use SmallInteger like methods. The #run:with:in: is never call and the image crashes.

That's simply a bug and we should fix it.  What crashes, the Interpreter, Cog or both?  Prepare a reproducible test case (image, change set etc) and we can try and fix this.


To reproduce just file in the attached cs. Then evaluate the following:

TestCase methodDict at: #assert: put: 4.
TestCase new assert: 'zaraza'.

If works, you should have a debugger in SmallInteger >> #run:with:in:
otherwise, a crash.

I've tested in mac vms like:
 
Squeak 4.2.5beta1U
Squeak 5.8b4

and it crash.
In Squeak 64-32 5.7b1   it just hangs forever (I guess at some point it will crash).

And in Cog it works perfect!  The problem is that I am using my own VM and I cannot use COG. So, if Cog has fixed this, I would like to know the changes so that to apply it to my VM.

Maybe it is already fixed in latest VMMaker, but I couldn't compile it....(other story)

Thanks for any help.

Mariano



 
best
Eliot
 

Example (be carefull, it may crash your image):

TestCase methodDict at: #assert: put: 4.
TestCase new assert: 'zaraza'.

I am checking the VM side now to see if I find something.

Cheers

Mariano

 

Levente


Mariano




Levente


Thanks

Mariano









SmallIntegerAsMethod.1.cs (438 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: SmallInteger as Methods [WAS] Re: [Pharo-project] Ideas for CompiledMethod proxies?

David T. Lewis
 
On Sat, Nov 20, 2010 at 08:41:44PM +0100, Mariano Martinez Peck wrote:

>  
> On Sat, Nov 20, 2010 at 7:50 PM, Eliot Miranda <[hidden email]>wrote:
> >
> > On Sat, Nov 20, 2010 at 10:28 AM, Mariano Martinez Peck <
> > [hidden email]> wrote:
> >
> >> It doesn't work here. It seems I cannot use SmallInteger like methods. The
> >> #run:with:in: is never call and the image crashes.
> >>
> >
> > That's simply a bug and we should fix it.  What crashes, the Interpreter,
> > Cog or both?  Prepare a reproducible test case (image, change set etc) and
> > we can try and fix this.
> >
> >
> To reproduce just file in the attached cs. Then evaluate the following:
>
> TestCase methodDict at: #assert: put: 4.
> TestCase new assert: 'zaraza'.
>
> If works, you should have a debugger in SmallInteger >> #run:with:in:
> otherwise, a crash.
>
> I've tested in mac vms like:
>
> Squeak 4.2.5beta1U
> Squeak 5.8b4
>
> and it crash.
> In Squeak 64-32 5.7b1   it just hangs forever (I guess at some point it will
> crash).
>
> And in Cog it works perfect!  The problem is that I am using my own VM and I
> cannot use COG. So, if Cog has fixed this, I would like to know the changes
> so that to apply it to my VM.
>
> Maybe it is already fixed in latest VMMaker, but I couldn't compile
> it....(other story)
>

It is definitely not fixed in the latest VMMaker (interpreter).

Dave

Reply | Threaded
Open this post in threaded view
|

Re: SmallInteger as Methods [WAS] Re: [Pharo-project] Ideas for CompiledMethod proxies?

Mariano Martinez Peck
 


On Sun, Nov 21, 2010 at 8:18 PM, David T. Lewis <[hidden email]> wrote:

On Sat, Nov 20, 2010 at 08:41:44PM +0100, Mariano Martinez Peck wrote:
>
> On Sat, Nov 20, 2010 at 7:50 PM, Eliot Miranda <[hidden email]>wrote:
> >
> > On Sat, Nov 20, 2010 at 10:28 AM, Mariano Martinez Peck <
> > [hidden email]> wrote:
> >
> >> It doesn't work here. It seems I cannot use SmallInteger like methods. The
> >> #run:with:in: is never call and the image crashes.
> >>
> >
> > That's simply a bug and we should fix it.  What crashes, the Interpreter,
> > Cog or both?  Prepare a reproducible test case (image, change set etc) and
> > we can try and fix this.
> >
> >
> To reproduce just file in the attached cs. Then evaluate the following:
>
> TestCase methodDict at: #assert: put: 4.
> TestCase new assert: 'zaraza'.
>
> If works, you should have a debugger in SmallInteger >> #run:with:in:
> otherwise, a crash.
>
> I've tested in mac vms like:
>
> Squeak 4.2.5beta1U
> Squeak 5.8b4
>
> and it crash.
> In Squeak 64-32 5.7b1   it just hangs forever (I guess at some point it will
> crash).
>
> And in Cog it works perfect!  The problem is that I am using my own VM and I
> cannot use COG. So, if Cog has fixed this, I would like to know the changes
> so that to apply it to my VM.
>
> Maybe it is already fixed in latest VMMaker, but I couldn't compile
> it....(other story)
>

It is definitely not fixed in the latest VMMaker (interpreter).



Thanks Dave. Then I guess it was integrated in Cog by Eliot, or maybe just a side effect in Eliot changes that automagically fixed this?

best regards,

Mariano
Reply | Threaded
Open this post in threaded view
|

Re: SmallInteger as Methods [WAS] Re: [Pharo-project] Ideas for CompiledMethod proxies?

Eliot Miranda-2
 


On Sun, Nov 21, 2010 at 3:48 PM, Mariano Martinez Peck <[hidden email]> wrote:
 


On Sun, Nov 21, 2010 at 8:18 PM, David T. Lewis <[hidden email]> wrote:

On Sat, Nov 20, 2010 at 08:41:44PM +0100, Mariano Martinez Peck wrote:
>
> On Sat, Nov 20, 2010 at 7:50 PM, Eliot Miranda <[hidden email]>wrote:
> >
> > On Sat, Nov 20, 2010 at 10:28 AM, Mariano Martinez Peck <
> > [hidden email]> wrote:
> >
> >> It doesn't work here. It seems I cannot use SmallInteger like methods. The
> >> #run:with:in: is never call and the image crashes.
> >>
> >
> > That's simply a bug and we should fix it.  What crashes, the Interpreter,
> > Cog or both?  Prepare a reproducible test case (image, change set etc) and
> > we can try and fix this.
> >
> >
> To reproduce just file in the attached cs. Then evaluate the following:
>
> TestCase methodDict at: #assert: put: 4.
> TestCase new assert: 'zaraza'.
>
> If works, you should have a debugger in SmallInteger >> #run:with:in:
> otherwise, a crash.
>
> I've tested in mac vms like:
>
> Squeak 4.2.5beta1U
> Squeak 5.8b4
>
> and it crash.
> In Squeak 64-32 5.7b1   it just hangs forever (I guess at some point it will
> crash).
>
> And in Cog it works perfect!  The problem is that I am using my own VM and I
> cannot use COG. So, if Cog has fixed this, I would like to know the changes
> so that to apply it to my VM.
>
> Maybe it is already fixed in latest VMMaker, but I couldn't compile
> it....(other story)
>

It is definitely not fixed in the latest VMMaker (interpreter).



Thanks Dave. Then I guess it was integrated in Cog by Eliot, or maybe just a side effect in Eliot changes that automagically fixed this?

Yes.  When I did run:as:in: support for Cog I fixed this.  I introduced

isOopCompiledMethod: oop
    "Answer whether the oop is an object of compiled method format"
<api>
    ^(self isNonIntegerObject: oop) and: [(self formatOf: oop) >= 12]

and used it in the relevant places.  perhaps you could look at the usage in Cog and apply the same to the interpreter?

The existing method is

isCompiledMethod: oop
    "Answer whether the argument object is of compiled method format"
    ^(self formatOf: oop) >= 12

and may crash if given a SmallInteger (alas on x86 it won't always crash :) ).

best
Eliot
 

best regards,

Mariano


Reply | Threaded
Open this post in threaded view
|

Re: SmallInteger as Methods [WAS] Re: [Pharo-project] Ideas for CompiledMethod proxies?

David T. Lewis
 
On Sun, Nov 21, 2010 at 05:06:01PM -0800, Eliot Miranda wrote:

>  
> On Sun, Nov 21, 2010 at 3:48 PM, Mariano Martinez Peck <
> [hidden email]> wrote:
> >
> > On Sun, Nov 21, 2010 at 8:18 PM, David T. Lewis <[hidden email]>wrote:
> >>
> >> On Sat, Nov 20, 2010 at 08:41:44PM +0100, Mariano Martinez Peck wrote:
> >> >
> >> > On Sat, Nov 20, 2010 at 7:50 PM, Eliot Miranda <[hidden email]
> >> >wrote:
> >> > >
> >> > > On Sat, Nov 20, 2010 at 10:28 AM, Mariano Martinez Peck <
> >> > > [hidden email]> wrote:
> >> > >
> >> > >> It doesn't work here. It seems I cannot use SmallInteger like
> >> methods. The
> >> > >> #run:with:in: is never call and the image crashes.
> >> > >>
> >> > >
> >> > > That's simply a bug and we should fix it.  What crashes, the
> >> Interpreter,
> >> > > Cog or both?  Prepare a reproducible test case (image, change set etc)
> >> and
> >> > > we can try and fix this.
> >> > >
> >> > >
> >> > To reproduce just file in the attached cs. Then evaluate the following:
> >> >
> >> > TestCase methodDict at: #assert: put: 4.
> >> > TestCase new assert: 'zaraza'.
> >> >
> >> > If works, you should have a debugger in SmallInteger >> #run:with:in:
> >> > otherwise, a crash.
> >> >
> >> > I've tested in mac vms like:
> >> >
> >> > Squeak 4.2.5beta1U
> >> > Squeak 5.8b4
> >> >
> >> > and it crash.
> >> > In Squeak 64-32 5.7b1   it just hangs forever (I guess at some point it
> >> will
> >> > crash).
> >> >
> >> > And in Cog it works perfect!  The problem is that I am using my own VM
> >> and I
> >> > cannot use COG. So, if Cog has fixed this, I would like to know the
> >> changes
> >> > so that to apply it to my VM.
> >> >
> >> > Maybe it is already fixed in latest VMMaker, but I couldn't compile
> >> > it....(other story)
> >> >
> >>
> >> It is definitely not fixed in the latest VMMaker (interpreter).
> >>
> >>
> >
> > Thanks Dave. Then I guess it was integrated in Cog by Eliot, or maybe just
> > a side effect in Eliot changes that automagically fixed this?
> >
>
> Yes.  When I did run:as:in: support for Cog I fixed this.  I introduced
>
> isOopCompiledMethod: oop
>     "Answer whether the oop is an object of compiled method format"
> <api>
>     ^(self isNonIntegerObject: oop) and: [(self formatOf: oop) >= 12]
>
> and used it in the relevant places.  perhaps you could look at the usage in
> Cog and apply the same to the interpreter?
>
> The existing method is
>
> isCompiledMethod: oop
>     "Answer whether the argument object is of compiled method format"
>     ^(self formatOf: oop) >= 12
>
> and may crash if given a SmallInteger (alas on x86 it won't always crash :)
> ).

Thanks Eliot,

I put the check only into Interpreter>>lookupMethodInDictionary (not because
I wanted to do it differently, but because I'm behind in my email and did not
notice your message until now). This seems sufficient for the moment, and I'll
make a note to apply your more general fixes in the next update.

In any case, it was educational figuring it out on my own :)

Dave

Reply | Threaded
Open this post in threaded view
|

Re: SmallInteger as Methods [WAS] Re: [Pharo-project] Ideas for CompiledMethod proxies?

Mariano Martinez Peck
 


On Mon, Nov 22, 2010 at 7:58 PM, David T. Lewis <[hidden email]> wrote:

On Sun, Nov 21, 2010 at 05:06:01PM -0800, Eliot Miranda wrote:
>
> On Sun, Nov 21, 2010 at 3:48 PM, Mariano Martinez Peck <
> [hidden email]> wrote:
> >
> > On Sun, Nov 21, 2010 at 8:18 PM, David T. Lewis <[hidden email]>wrote:
> >>
> >> On Sat, Nov 20, 2010 at 08:41:44PM +0100, Mariano Martinez Peck wrote:
> >> >
> >> > On Sat, Nov 20, 2010 at 7:50 PM, Eliot Miranda <[hidden email]
> >> >wrote:
> >> > >
> >> > > On Sat, Nov 20, 2010 at 10:28 AM, Mariano Martinez Peck <
> >> > > [hidden email]> wrote:
> >> > >
> >> > >> It doesn't work here. It seems I cannot use SmallInteger like
> >> methods. The
> >> > >> #run:with:in: is never call and the image crashes.
> >> > >>
> >> > >
> >> > > That's simply a bug and we should fix it.  What crashes, the
> >> Interpreter,
> >> > > Cog or both?  Prepare a reproducible test case (image, change set etc)
> >> and
> >> > > we can try and fix this.
> >> > >
> >> > >
> >> > To reproduce just file in the attached cs. Then evaluate the following:
> >> >
> >> > TestCase methodDict at: #assert: put: 4.
> >> > TestCase new assert: 'zaraza'.
> >> >
> >> > If works, you should have a debugger in SmallInteger >> #run:with:in:
> >> > otherwise, a crash.
> >> >
> >> > I've tested in mac vms like:
> >> >
> >> > Squeak 4.2.5beta1U
> >> > Squeak 5.8b4
> >> >
> >> > and it crash.
> >> > In Squeak 64-32 5.7b1   it just hangs forever (I guess at some point it
> >> will
> >> > crash).
> >> >
> >> > And in Cog it works perfect!  The problem is that I am using my own VM
> >> and I
> >> > cannot use COG. So, if Cog has fixed this, I would like to know the
> >> changes
> >> > so that to apply it to my VM.
> >> >
> >> > Maybe it is already fixed in latest VMMaker, but I couldn't compile
> >> > it....(other story)
> >> >
> >>
> >> It is definitely not fixed in the latest VMMaker (interpreter).
> >>
> >>
> >
> > Thanks Dave. Then I guess it was integrated in Cog by Eliot, or maybe just
> > a side effect in Eliot changes that automagically fixed this?
> >
>
> Yes.  When I did run:as:in: support for Cog I fixed this.  I introduced
>
> isOopCompiledMethod: oop
>     "Answer whether the oop is an object of compiled method format"
> <api>
>     ^(self isNonIntegerObject: oop) and: [(self formatOf: oop) >= 12]
>
> and used it in the relevant places.  perhaps you could look at the usage in
> Cog and apply the same to the interpreter?
>
> The existing method is
>
> isCompiledMethod: oop
>     "Answer whether the argument object is of compiled method format"
>     ^(self formatOf: oop) >= 12
>
> and may crash if given a SmallInteger (alas on x86 it won't always crash :)
> ).

Thanks Eliot,

I put the check only into Interpreter>>lookupMethodInDictionary (not because
I wanted to do it differently, but because I'm behind in my email and did not
notice your message until now). This seems sufficient for the moment, and I'll
make a note to apply your more general fixes in the next update.

Yes, because with only that change there are still problems. For example, if you put a SmallInteger as method and then you send #perform:
Example:

TestCase methodDict at: #assert: put: 5.
(TestCase >> #assert:) perform: #literals.

cheers

mariano
 

In any case, it was educational figuring it out on my own :)

Dave


Reply | Threaded
Open this post in threaded view
|

Re: SmallInteger as Methods [WAS] Re: [Pharo-project] Ideas for CompiledMethod proxies?

David T. Lewis
 
On Mon, Nov 22, 2010 at 08:05:02PM +0100, Mariano Martinez Peck wrote:

>  
> On Mon, Nov 22, 2010 at 7:58 PM, David T. Lewis <[hidden email]> wrote:
>
> >
> > On Sun, Nov 21, 2010 at 05:06:01PM -0800, Eliot Miranda wrote:
> > >
> > > On Sun, Nov 21, 2010 at 3:48 PM, Mariano Martinez Peck <
> > > [hidden email]> wrote:
> > > >
> > > > On Sun, Nov 21, 2010 at 8:18 PM, David T. Lewis <[hidden email]
> > >wrote:
> > > >>
> > > >> On Sat, Nov 20, 2010 at 08:41:44PM +0100, Mariano Martinez Peck wrote:
> > > >> >
> > > >> > On Sat, Nov 20, 2010 at 7:50 PM, Eliot Miranda <
> > [hidden email]
> > > >> >wrote:
> > > >> > >
> > > >> > > On Sat, Nov 20, 2010 at 10:28 AM, Mariano Martinez Peck <
> > > >> > > [hidden email]> wrote:
> > > >> > >
> > > >> > >> It doesn't work here. It seems I cannot use SmallInteger like
> > > >> methods. The
> > > >> > >> #run:with:in: is never call and the image crashes.
> > > >> > >>
> > > >> > >
> > > >> > > That's simply a bug and we should fix it.  What crashes, the
> > > >> Interpreter,
> > > >> > > Cog or both?  Prepare a reproducible test case (image, change set
> > etc)
> > > >> and
> > > >> > > we can try and fix this.
> > > >> > >
> > > >> > >
> > > >> > To reproduce just file in the attached cs. Then evaluate the
> > following:
> > > >> >
> > > >> > TestCase methodDict at: #assert: put: 4.
> > > >> > TestCase new assert: 'zaraza'.
> > > >> >
> > > >> > If works, you should have a debugger in SmallInteger >>
> > #run:with:in:
> > > >> > otherwise, a crash.
> > > >> >
> > > >> > I've tested in mac vms like:
> > > >> >
> > > >> > Squeak 4.2.5beta1U
> > > >> > Squeak 5.8b4
> > > >> >
> > > >> > and it crash.
> > > >> > In Squeak 64-32 5.7b1   it just hangs forever (I guess at some point
> > it
> > > >> will
> > > >> > crash).
> > > >> >
> > > >> > And in Cog it works perfect!  The problem is that I am using my own
> > VM
> > > >> and I
> > > >> > cannot use COG. So, if Cog has fixed this, I would like to know the
> > > >> changes
> > > >> > so that to apply it to my VM.
> > > >> >
> > > >> > Maybe it is already fixed in latest VMMaker, but I couldn't compile
> > > >> > it....(other story)
> > > >> >
> > > >>
> > > >> It is definitely not fixed in the latest VMMaker (interpreter).
> > > >>
> > > >>
> > > >
> > > > Thanks Dave. Then I guess it was integrated in Cog by Eliot, or maybe
> > just
> > > > a side effect in Eliot changes that automagically fixed this?
> > > >
> > >
> > > Yes.  When I did run:as:in: support for Cog I fixed this.  I introduced
> > >
> > > isOopCompiledMethod: oop
> > >     "Answer whether the oop is an object of compiled method format"
> > > <api>
> > >     ^(self isNonIntegerObject: oop) and: [(self formatOf: oop) >= 12]
> > >
> > > and used it in the relevant places.  perhaps you could look at the usage
> > in
> > > Cog and apply the same to the interpreter?
> > >
> > > The existing method is
> > >
> > > isCompiledMethod: oop
> > >     "Answer whether the argument object is of compiled method format"
> > >     ^(self formatOf: oop) >= 12
> > >
> > > and may crash if given a SmallInteger (alas on x86 it won't always crash
> > :)
> > > ).
> >
> > Thanks Eliot,
> >
> > I put the check only into Interpreter>>lookupMethodInDictionary (not
> > because
> > I wanted to do it differently, but because I'm behind in my email and did
> > not
> > notice your message until now). This seems sufficient for the moment, and
> > I'll
> > make a note to apply your more general fixes in the next update.
> >
>
> Yes, because with only that change there are still problems. For example, if
> you put a SmallInteger as method and then you send #perform:
> Example:
>
> TestCase methodDict at: #assert: put: 5.
> (TestCase >> #assert:) perform: #literals.

I get MessageNotUnderstood: SmallInteger>>literals with your example.
Is that not expected?

Dave

Reply | Threaded
Open this post in threaded view
|

Re: SmallInteger as Methods [WAS] Re: [Pharo-project] Ideas for CompiledMethod proxies?

Mariano Martinez Peck
 


On Mon, Nov 22, 2010 at 8:20 PM, David T. Lewis <[hidden email]> wrote:

On Mon, Nov 22, 2010 at 08:05:02PM +0100, Mariano Martinez Peck wrote:
>
> On Mon, Nov 22, 2010 at 7:58 PM, David T. Lewis <[hidden email]> wrote:
>
> >
> > On Sun, Nov 21, 2010 at 05:06:01PM -0800, Eliot Miranda wrote:
> > >
> > > On Sun, Nov 21, 2010 at 3:48 PM, Mariano Martinez Peck <
> > > [hidden email]> wrote:
> > > >
> > > > On Sun, Nov 21, 2010 at 8:18 PM, David T. Lewis <[hidden email]
> > >wrote:
> > > >>
> > > >> On Sat, Nov 20, 2010 at 08:41:44PM +0100, Mariano Martinez Peck wrote:
> > > >> >
> > > >> > On Sat, Nov 20, 2010 at 7:50 PM, Eliot Miranda <
> > [hidden email]
> > > >> >wrote:
> > > >> > >
> > > >> > > On Sat, Nov 20, 2010 at 10:28 AM, Mariano Martinez Peck <
> > > >> > > [hidden email]> wrote:
> > > >> > >
> > > >> > >> It doesn't work here. It seems I cannot use SmallInteger like
> > > >> methods. The
> > > >> > >> #run:with:in: is never call and the image crashes.
> > > >> > >>
> > > >> > >
> > > >> > > That's simply a bug and we should fix it.  What crashes, the
> > > >> Interpreter,
> > > >> > > Cog or both?  Prepare a reproducible test case (image, change set
> > etc)
> > > >> and
> > > >> > > we can try and fix this.
> > > >> > >
> > > >> > >
> > > >> > To reproduce just file in the attached cs. Then evaluate the
> > following:
> > > >> >
> > > >> > TestCase methodDict at: #assert: put: 4.
> > > >> > TestCase new assert: 'zaraza'.
> > > >> >
> > > >> > If works, you should have a debugger in SmallInteger >>
> > #run:with:in:
> > > >> > otherwise, a crash.
> > > >> >
> > > >> > I've tested in mac vms like:
> > > >> >
> > > >> > Squeak 4.2.5beta1U
> > > >> > Squeak 5.8b4
> > > >> >
> > > >> > and it crash.
> > > >> > In Squeak 64-32 5.7b1   it just hangs forever (I guess at some point
> > it
> > > >> will
> > > >> > crash).
> > > >> >
> > > >> > And in Cog it works perfect!  The problem is that I am using my own
> > VM
> > > >> and I
> > > >> > cannot use COG. So, if Cog has fixed this, I would like to know the
> > > >> changes
> > > >> > so that to apply it to my VM.
> > > >> >
> > > >> > Maybe it is already fixed in latest VMMaker, but I couldn't compile
> > > >> > it....(other story)
> > > >> >
> > > >>
> > > >> It is definitely not fixed in the latest VMMaker (interpreter).
> > > >>
> > > >>
> > > >
> > > > Thanks Dave. Then I guess it was integrated in Cog by Eliot, or maybe
> > just
> > > > a side effect in Eliot changes that automagically fixed this?
> > > >
> > >
> > > Yes.  When I did run:as:in: support for Cog I fixed this.  I introduced
> > >
> > > isOopCompiledMethod: oop
> > >     "Answer whether the oop is an object of compiled method format"
> > > <api>
> > >     ^(self isNonIntegerObject: oop) and: [(self formatOf: oop) >= 12]
> > >
> > > and used it in the relevant places.  perhaps you could look at the usage
> > in
> > > Cog and apply the same to the interpreter?
> > >
> > > The existing method is
> > >
> > > isCompiledMethod: oop
> > >     "Answer whether the argument object is of compiled method format"
> > >     ^(self formatOf: oop) >= 12
> > >
> > > and may crash if given a SmallInteger (alas on x86 it won't always crash
> > :)
> > > ).
> >
> > Thanks Eliot,
> >
> > I put the check only into Interpreter>>lookupMethodInDictionary (not
> > because
> > I wanted to do it differently, but because I'm behind in my email and did
> > not
> > notice your message until now). This seems sufficient for the moment, and
> > I'll
> > make a note to apply your more general fixes in the next update.
> >
>
> Yes, because with only that change there are still problems. For example, if
> you put a SmallInteger as method and then you send #perform:
> Example:
>
> TestCase methodDict at: #assert: put: 5.
> (TestCase >> #assert:) perform: #literals.

I get MessageNotUnderstood: SmallInteger>>literals with your example.
Is that not expected?

Yes, that's perfect....grrrr maybe it a another thing, I cannot remember :(
maybe TestCase new perform: #assert:   ?

Anyway, if I can reproduce it again, I'll let you know.

Thanks!

mariano
 

Dave


Reply | Threaded
Open this post in threaded view
|

Re: SmallInteger as Methods [WAS] Re: [Pharo-project] Ideas for CompiledMethod proxies?

David T. Lewis
 
On Mon, Nov 22, 2010 at 08:27:53PM +0100, Mariano Martinez Peck wrote:

>  
> On Mon, Nov 22, 2010 at 8:20 PM, David T. Lewis <[hidden email]> wrote:
> >
> > On Mon, Nov 22, 2010 at 08:05:02PM +0100, Mariano Martinez Peck wrote:
> > >
> > > On Mon, Nov 22, 2010 at 7:58 PM, David T. Lewis <[hidden email]>
> > wrote:
> > > >
> > > > On Sun, Nov 21, 2010 at 05:06:01PM -0800, Eliot Miranda wrote:
> > > > >
> > > > > On Sun, Nov 21, 2010 at 3:48 PM, Mariano Martinez Peck <
> > > > > [hidden email]> wrote:
> > > > > >
> > > > > > On Sun, Nov 21, 2010 at 8:18 PM, David T. Lewis <
> > [hidden email]
> > > > >wrote:
> > > > > >>
> > > > > >> On Sat, Nov 20, 2010 at 08:41:44PM +0100, Mariano Martinez Peck
> > wrote:
> > > > > >> >
> > > > > >> > On Sat, Nov 20, 2010 at 7:50 PM, Eliot Miranda <
> > > > [hidden email]
> > > > > >> >wrote:
> > > > > >> > >
> > > > > >> > > On Sat, Nov 20, 2010 at 10:28 AM, Mariano Martinez Peck <
> > > > > >> > > [hidden email]> wrote:
> > > > > >> > >
> > > > > >> > >> It doesn't work here. It seems I cannot use SmallInteger like
> > > > > >> methods. The
> > > > > >> > >> #run:with:in: is never call and the image crashes.
> > > > > >> > >>
> > > > > >> > >
> > > > > >> > > That's simply a bug and we should fix it.  What crashes, the
> > > > > >> Interpreter,
> > > > > >> > > Cog or both?  Prepare a reproducible test case (image, change
> > set
> > > > etc)
> > > > > >> and
> > > > > >> > > we can try and fix this.
> > > > > >> > >
> > > > > >> > >
> > > > > >> > To reproduce just file in the attached cs. Then evaluate the
> > > > following:
> > > > > >> >
> > > > > >> > TestCase methodDict at: #assert: put: 4.
> > > > > >> > TestCase new assert: 'zaraza'.
> > > > > >> >
> > > > > >> > If works, you should have a debugger in SmallInteger >>
> > > > #run:with:in:
> > > > > >> > otherwise, a crash.
> > > > > >> >
> > > > > >> > I've tested in mac vms like:
> > > > > >> >
> > > > > >> > Squeak 4.2.5beta1U
> > > > > >> > Squeak 5.8b4
> > > > > >> >
> > > > > >> > and it crash.
> > > > > >> > In Squeak 64-32 5.7b1   it just hangs forever (I guess at some
> > point
> > > > it
> > > > > >> will
> > > > > >> > crash).
> > > > > >> >
> > > > > >> > And in Cog it works perfect!  The problem is that I am using my
> > own
> > > > VM
> > > > > >> and I
> > > > > >> > cannot use COG. So, if Cog has fixed this, I would like to know
> > the
> > > > > >> changes
> > > > > >> > so that to apply it to my VM.
> > > > > >> >
> > > > > >> > Maybe it is already fixed in latest VMMaker, but I couldn't
> > compile
> > > > > >> > it....(other story)
> > > > > >> >
> > > > > >>
> > > > > >> It is definitely not fixed in the latest VMMaker (interpreter).
> > > > > >>
> > > > > >>
> > > > > >
> > > > > > Thanks Dave. Then I guess it was integrated in Cog by Eliot, or
> > maybe
> > > > just
> > > > > > a side effect in Eliot changes that automagically fixed this?
> > > > > >
> > > > >
> > > > > Yes.  When I did run:as:in: support for Cog I fixed this.  I
> > introduced
> > > > >
> > > > > isOopCompiledMethod: oop
> > > > >     "Answer whether the oop is an object of compiled method format"
> > > > > <api>
> > > > >     ^(self isNonIntegerObject: oop) and: [(self formatOf: oop) >= 12]
> > > > >
> > > > > and used it in the relevant places.  perhaps you could look at the
> > usage
> > > > in
> > > > > Cog and apply the same to the interpreter?
> > > > >
> > > > > The existing method is
> > > > >
> > > > > isCompiledMethod: oop
> > > > >     "Answer whether the argument object is of compiled method format"
> > > > >     ^(self formatOf: oop) >= 12
> > > > >
> > > > > and may crash if given a SmallInteger (alas on x86 it won't always
> > crash
> > > > :)
> > > > > ).
> > > >
> > > > Thanks Eliot,
> > > >
> > > > I put the check only into Interpreter>>lookupMethodInDictionary (not
> > > > because
> > > > I wanted to do it differently, but because I'm behind in my email and
> > did
> > > > not
> > > > notice your message until now). This seems sufficient for the moment,
> > and
> > > > I'll
> > > > make a note to apply your more general fixes in the next update.
> > > >
> > >
> > > Yes, because with only that change there are still problems. For example,
> > if
> > > you put a SmallInteger as method and then you send #perform:
> > > Example:
> > >
> > > TestCase methodDict at: #assert: put: 5.
> > > (TestCase >> #assert:) perform: #literals.
> >
> > I get MessageNotUnderstood: SmallInteger>>literals with your example.
> > Is that not expected?
> >
>
> Yes, that's perfect....grrrr maybe it a another thing, I cannot remember :(
> maybe TestCase new perform: #assert:   ?
>
> Anyway, if I can reproduce it again, I'll let you know.

Mariano,

Indeed you were right, the necessary checks were still missing from
#primitivePerform and #primitivePerformAt: so the following would still
crash the VM:

  TestCase methodDict at: #assert: put: 5.
  (TestCase >> #assert:) perform: #literals.

I added the updates to VMMaker-dtl.205 (this time adopting Eliots's
changes directly) so hopefully this will now cover all cases.
The update that I did for Interpreter>>lookupMethodInDictionary:
should be added back to the oscog branch, but it does not effect
the Cog VM itself, so at this point I expect that an interpreter VM
built from VMMaker-dtl.205 will behave identically to a Cog VM with
respect to handling objects as methods.

Dave

Reply | Threaded
Open this post in threaded view
|

Re: SmallInteger as Methods [WAS] Re: [Pharo-project] Ideas for CompiledMethod proxies?

David T. Lewis
 
On Tue, Nov 23, 2010 at 12:03:01PM -0500, David T. Lewis wrote:
>
> Indeed you were right, the necessary checks were still missing from
> #primitivePerform and #primitivePerformAt: so the following would still
> crash the VM:
>
>   TestCase methodDict at: #assert: put: 5.
>   (TestCase >> #assert:) perform: #literals.
>

Sorry, the above was a cut and paste error in my email. The thing
that would still crash the interpreter VM prior to this update was:

  TestCase methodDict at: #assert: put: 4.
  TestCase new perform: #assert: with: 'zaraza'.

In any case it should be resolved now.

> I added the updates to VMMaker-dtl.205 (this time adopting Eliots's
> changes directly) so hopefully this will now cover all cases.
> The update that I did for Interpreter>>lookupMethodInDictionary:
> should be added back to the oscog branch, but it does not effect
> the Cog VM itself, so at this point I expect that an interpreter VM
> built from VMMaker-dtl.205 will behave identically to a Cog VM with
> respect to handling objects as methods.
>
> Dave
Reply | Threaded
Open this post in threaded view
|

Re: SmallInteger as Methods [WAS] Re: [Pharo-project] Ideas for CompiledMethod proxies?

Mariano Martinez Peck
 
Thanks a lot David!

On Tue, Nov 23, 2010 at 6:47 PM, David T. Lewis <[hidden email]> wrote:

On Tue, Nov 23, 2010 at 12:03:01PM -0500, David T. Lewis wrote:
>
> Indeed you were right, the necessary checks were still missing from
> #primitivePerform and #primitivePerformAt: so the following would still
> crash the VM:
>
>   TestCase methodDict at: #assert: put: 5.
>   (TestCase >> #assert:) perform: #literals.
>

Sorry, the above was a cut and paste error in my email. The thing
that would still crash the interpreter VM prior to this update was:

 TestCase methodDict at: #assert: put: 4.
 TestCase new perform: #assert: with: 'zaraza'.

In any case it should be resolved now.

> I added the updates to VMMaker-dtl.205 (this time adopting Eliots's
> changes directly) so hopefully this will now cover all cases.
> The update that I did for Interpreter>>lookupMethodInDictionary:
> should be added back to the oscog branch, but it does not effect
> the Cog VM itself, so at this point I expect that an interpreter VM
> built from VMMaker-dtl.205 will behave identically to a Cog VM with
> respect to handling objects as methods.
>
> Dave