Issues creating instance of SmallInteger

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

Re: Issues creating instance of SmallInteger

johnmci

On 12-May-06, at 10:41 AM, Michael Haupt wrote:

> John,
>
> On 5/12/06, John M McIntosh <[hidden email]> 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 <[hidden email]> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
========================================================================
===


Reply | Threaded
Open this post in threaded view
|

re: Issues creating instance of SmallInteger

ccrraaiigg

Hi Michael--

        John writes:

 > The Smaltalk code for the mark/trace is easy to read...

        Yeah, for example see SmallIntegers get skipped in
ObjectMemory>>startField from the VMMaker package.


-C

--
Craig Latta
improvisational musical informaticist
www.netjam.org
Smalltalkers do: [:it | All with: Class, (And love: it)]



Reply | Threaded
Open this post in threaded view
|

Re: Issues creating instance of SmallInteger

Michael Haupt-3
In reply to this post by johnmci
John,

On 5/15/06, John M McIntosh <[hidden email]> wrote:
> > 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.

thank you very much for clarifying this. I was worried about probably
not having the students told the whole truth. :-)

Best,

Michael

Reply | Threaded
Open this post in threaded view
|

Re: Issues creating instance of SmallInteger

Chris Muller-2
In reply to this post by Colin Putney
On May 12, 2006, at 11:32 AM, Michel Calonne wrote:

> Hello,
> I've got a problem creating objects via this sample of code:
> (Smalltalk at: #AClassName) new
> The problem is that, when trying to create an instance of
> SmallInteger, it raises an error :
> "SmallIntegers can only be created by performing arithmetic"...
> If somebody can tell me why it isn't possible to create a
> SmallInteger like this, and give me a way to do it, I'd appreciate...
> And are there other classes behaving the same way? So that I can
> take them in account in my code.

 You will not want to try generalizing your serialization/materialization quite so much.  There are "immediate" types and globals that you will not want to create new instances of.  Other examples are true, false and nil, Smalltalk, Processor, Transcript and others.
 
 I've been through a ton of this kind of stuff in having written Magma.  You might find looking at my serialization/materialization code helpful in this respect.
 
 Regards,
   Chris




Reply | Threaded
Open this post in threaded view
|

The Whole Truth (was RE: Issues creating instance of SmallInteger)

SmallSqueak
In reply to this post by Michael Haupt-3

Michael Haupt wrote:

>
> John,
>
> On 5/15/06, John M McIntosh <[hidden email]> wrote:
> > > 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.
>
> thank you very much for clarifying this. I was worried about probably
> not having the students told the whole truth. :-)
>

Dear Squeaking Educators and Educating Squeakers,
       
        What "whole truth" would you tell your students
        about Squeak when you teach Squeak to them.


        Best regards,

        PhiHo



Reply | Threaded
Open this post in threaded view
|

Re: The Whole Truth (was RE: Issues creating instance of SmallInteger)

Michael Haupt-3
Hi,

On 5/16/06, SmallSqueak <[hidden email]> wrote:
> > thank you very much for clarifying this. I was worried about probably
> > not having the students told the whole truth. :-)
>
> Dear Squeaking Educators and Educating Squeakers,
>
>         What "whole truth" would you tell your students
>         about Squeak when you teach Squeak to them.

I was not expecting this to go philosophical instantly. :-) By the way
it's a course on VMs where Squeak is used as a case study, not a
course on Squeak.

Best,

Michael

Reply | Threaded
Open this post in threaded view
|

RE: The Whole Truth (was RE: Issues creating instance ofSmallInteger)

SmallSqueak
Hi,

> -----Original Message-----
> From: [hidden email] [mailto:squeak-dev-
> [hidden email]] On Behalf Of Michael Haupt
> Sent: Tuesday, May 16, 2006 5:11 AM
> To: The general-purpose Squeak developers list
> Subject: Re: The Whole Truth (was RE: Issues creating instance
> ofSmallInteger)
>
> Hi,
>
> On 5/16/06, SmallSqueak <[hidden email]> wrote:
> > > thank you very much for clarifying this. I was worried about probably
> > > not having the students told the whole truth. :-)
> >
> > Dear Squeaking Educators and Educating Squeakers,
> >
> >         What "whole truth" would you tell your students
> >         about Squeak when you teach Squeak to them.
>
> I was not expecting this to go philosophical instantly. :-)

        I hope it's Ok with you ;-)

> By the way it's a course on VMs where Squeak is used
> as a case study, not a course on Squeak.
>

        I wish if someone would teach modularization using
        Squeak image as a case study.

       
        Cheers,

        PhiHo





Reply | Threaded
Open this post in threaded view
|

Re: Re: Issues creating instance of SmallInteger

Michel Calonne
In reply to this post by Michel Calonne
For now I managed the problem by checking a classname field in the xml, and then sending a SmallInteger with Number readFrom:'42'.
I would be quite interested in looking at your code. Where can I find this Magma you're talking about (if it is open source)?

Michel

>  You will not want to try generalizing your serialization/materialization quite so much.  There are "immediate" types and globals that you will not want to create new instances of.  Other examples are true, false and nil, Smalltalk, Processor, Transcript and others.
>  
>  I've been through a ton of this kind of stuff in having written Magma.  You might find looking at my serialization/materialization code helpful in this respect.
>  
>  Regards,
>    Chris
>
>
>
>
>
> ------------------------------
>

Reply | Threaded
Open this post in threaded view
|

Re: Re: Issues creating instance of SmallInteger

Diego Fernández
On 5/16/06, Michel Calonne <[hidden email]> wrote:
> I would be quite interested in looking at your code. Where can I find this Magma you're talking about (if it is open source)?

Yes is opensource, you can get more information here:
http://minnow.cc.gatech.edu/squeak/2665

Reply | Threaded
Open this post in threaded view
|

Re: Re: Issues creating instance of SmallInteger

Chris Muller
In reply to this post by Michel Calonne
Hi Michel, you can install Magma from SqueakSource.  In Monticello, add an HTTP repository to:
 
 MCHttpRepository
     location: 'http://www.squeaksource.com/MagmaTester'
    user: ''
    password: ''

and then load "MagmaClientLoader".

Now, you are probably just interested in the serialization, you can step through a debugger:

  MaObjectSerializer halt testMaterialize: anyObject

where anyObject is any object.  This will serialize anyObject and then rematerialize it.

The reason this might be helpful is, if you are doing "generic" persistence to XML, kinds of objects that may require "special handling" during serializatino or materialization.  Projects, Morphs, fonts, flap-tabs and so forth.

But probably you do not need this much genericity..

Regards,
  Chris
 
 
 

----- Original Message ----
From: Michel Calonne <[hidden email]>
To: [hidden email]
Sent: Tuesday, May 16, 2006 5:27:42 AM
Subject: Re: Re: Issues creating instance of SmallInteger

For now I managed the problem by checking a classname field in the xml, and then sending a SmallInteger with Number readFrom:'42'.
I would be quite interested in looking at your code. Where can I find this Magma you're talking about (if it is open source)?

Michel

>  You will not want to try generalizing your serialization/materialization quite so much.  There are "immediate" types and globals that you will not want to create new instances of.  Other examples are true, false and nil, Smalltalk, Processor, Transcript and others.
>  
>  I've been through a ton of this kind of stuff in having written Magma.  You might find looking at my serialization/materialization code helpful in this respect.
>  
>  Regards,
>    Chris
>
>
>
>
>
> ------------------------------
>






12