[COG] primitiveIndexOf: aMethod crash in Cog when using SmallInteger

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

[COG] primitiveIndexOf: aMethod crash in Cog when using SmallInteger

Mariano Martinez Peck
 
Hi Eliot. I am not sure if you are interested in completly support SmallInteger as methods. If not, please let me know and I don't bather again.

I was trying them in Cog, and I have a crash in primitiveFlushCacheByMethod()  when it calls primitiveIndexOf:
because

primitiveIndexOf: methodPointer
    "Note: We now have 10 bits of primitive index, but they are in two places
    for temporary backward compatibility.  The time to unpack is negligible,
     since the derived primitive function pointer is stored in the method cache."
    <api>
    | primBits |
    primBits := ((self headerOf: methodPointer) >> 1) bitAnd: 16r100001FF.
    ^(primBits bitAnd: 16r1FF) + (primBits >> 19)



But....."methodPointer" can be a Smallnteger...so headerOf: fails, because rawHeaderOf: fails because it does a "objectMemory fetchPointer: HeaderIndex ofObject: methodPointer"
which send ObjectMemory >> fetchPointer: fieldIndex ofObject: oop
which does the final  "self longAt: oop + BaseHeaderSize + (fieldIndex << ShiftForWord)"

ok, you got it ;)

Now....do you consider this a bug?  how could I fix it ?

Thanks

Mariano
Reply | Threaded
Open this post in threaded view
|

Re: [COG] primitiveIndexOf: aMethod crash in Cog when using SmallInteger

Mariano Martinez Peck
 
Here I attach an screenshot of my xcode stacktrace

thanks

mariano

On Tue, Dec 14, 2010 at 10:19 AM, Mariano Martinez Peck <[hidden email]> wrote:
Hi Eliot. I am not sure if you are interested in completly support SmallInteger as methods. If not, please let me know and I don't bather again.

I was trying them in Cog, and I have a crash in primitiveFlushCacheByMethod()  when it calls primitiveIndexOf:
because

primitiveIndexOf: methodPointer
    "Note: We now have 10 bits of primitive index, but they are in two places
    for temporary backward compatibility.  The time to unpack is negligible,
     since the derived primitive function pointer is stored in the method cache."
    <api>
    | primBits |
    primBits := ((self headerOf: methodPointer) >> 1) bitAnd: 16r100001FF.
    ^(primBits bitAnd: 16r1FF) + (primBits >> 19)



But....."methodPointer" can be a Smallnteger...so headerOf: fails, because rawHeaderOf: fails because it does a "objectMemory fetchPointer: HeaderIndex ofObject: methodPointer"
which send ObjectMemory >> fetchPointer: fieldIndex ofObject: oop
which does the final  "self longAt: oop + BaseHeaderSize + (fieldIndex << ShiftForWord)"

ok, you got it ;)

Now....do you consider this a bug?  how could I fix it ?

Thanks

Mariano


Screen shot 2010-12-14 at 10.19.55 AM.png (218K) Download Attachment