Issues creating instance of SmallInteger
John M McIntosh
johnmci at smalltalkconsulting.com
Mon May 15 06:31:29 UTC 2006
On 12-May-06, at 10:41 AM, Michael Haupt wrote:
> John,
>
> On 5/12/06, John M McIntosh <johnmci at smalltalkconsulting.com> wrote:
>> In Squeak we use 2 bits of the 32 in 32bit Squeak, 1 bit
>> for a tag for the GC logic, and the other bit to signify if this
>> object is a SmallInteger.
>>
>> xxxxxxxx00 -> object reference (tag bit not set; divisible by four)
>> xxxxxxxx10 -> Unused (tag bit not set; but not a valid pointer)
>> xxxxxxxx01 -> SmallInteger (tag bit set)
>> xxxxxxxx11 -> SmallInteger (tag bit set)
>
> I was not aware of that GC flag bit, but I had actually been wondering
> why one bit was "wasted" when pointers/references are word-aligned...
> Can you point me to a place in the image where that is made clear?
Ah, well this is wrong, let me dig further, this came from some
discussions we were having about 64 bit
squeak and I wonder if some of that creep into the conversation,
since mmm 30 bits of data, and 1 bit for sign.
Lets see, back to code, versus my faulty memory, I apologies for
confusing the issue.
isIntegerObject: objectPointer
^ (objectPointer bitAnd: 1) > 0
Interestingly enough in Slang and header files we optimize the
isIntegerObject: and it turns into
(oop & 1)
Also see
isNonIntegerObject: objectPointer
^ (objectPointer bitAnd: 1) = 0
As for the GC tag bit 32bit Squeak uses a bit in the Object header
MarkBit := 16r80000000.
to note if an object has been traced when running the marker logic.
immediate objects (aka integers) don't need tracing and are skipped.
The Smaltalk code for the mark/trace is easy to read, the slang
generated C code is not, since the slang logic folds multiple routines
together to avoid calls outside of the logic, plus performs
localizing usage of global variables, turning some into local
variables.
However as noted since words are aligned we technically have a spare
state where we could have 30 bits of data with bit 2 set to 1,
and bit 1 set to 0
xxxxxxxx00 oop reference, divisible by 4.
xxxxxxxx10 invalid oop reference, but could be something other than
an oops reference
xxxxxxxxx1 smallinteger
--
========================================================================
===
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
========================================================================
===
More information about the Squeak-dev
mailing list
|