On Sun, Oct 3, 2010 at 1:03 PM, Bert Freudenberg <bert@freudenbergs.de> wrote:
On 03.10.2010, at 12:45, Mariano Martinez Peck wrote:

On Sun, Oct 3, 2010 at 12:42 PM, Bert Freudenberg <bert@freudenbergs.de> wrote:
What exactly are you trying to do?

hehehe sorry. I am trying to "detect unused objects".

What for?

Hi Bert. The idea is to be able to detect objects that are not used but referenced (this is why the GC don't collect them). We think there are a lots and lost of objects in this situation: they are referenced but not used for a long time, only agains certain situations, etc. The idea is to detect subgraphs of unused objects and swap them to disk, and let proxies in the image that know how to load back them when necessary.

If you are interested, you may want to see the slides of my ESUG talk:  http://www.slideshare.net/esug/swapping-esug2010
(the video is not yet available)

 When do you consider an object to be "used"? 

When it receives a message. This is why I changed #normalSend

Thanks in advance,


Neither the class nor the compiled method "receive a message". Plus there are many ways an object "appears" to receive a message but isn't really. E.g. a Float won't receive #+ because that is short-circuited in the bytecodes. A super send does not use "normalSend". Etc.

Yes, that's one of my problems. I am interested in knowing all these "anormal" situations. And yes, I think the definition "an object is usage when it receives a message" is not clear enough. Because yes, I would like to mark the CompiledMethod, Float when sending #+, and super calls.

Judging from your test cases, if an objects is just passed as an argument, you do not consider it to be used.

Good question. If you pass an object as parameter, you will probably send a message to it. In such case, then yes, it will be marked.
Now...what happens if you pass an object by argument and you don't send any message?  I guess it should be marked.

Anyway the mark has not to be THAT strict. I mean, I would like to be like that. But all these step of detecting unused objects is because I will try to swap them. Thus, the less they are usually used, the best. In the worst case, I will swap an object and will be used inmediatly -> overhead.
What if you send it the #class message? What if you identity-compare it (==)?  Should that count as "used"?

Good question. I would guess that yes. Is there a way to know all these "anormal" sends?  I know #class is in bytecode, etc. But I don't know all of them.
Maybe if you let us in on the bigger picture we could help you better.

Thanks Bert. Please let me know if there is something missing.

- Bert -

On 03.10.2010, at 12:12, Mariano Martinez Peck wrote:

Hi. I have a related question once again with this topic. I've changed Interpreter >> normalSend to something like this:

    "Send a message, starting lookup with the receiver's class."
    "Assume: messageSelector and argumentCount have been set, and that
    the receiver and arguments have been pushed onto the stack,"
    "Note: This method is inlined into the interpreter dispatch loop."
    | rcvr |
    self inline: true.
    self sharedCodeNamed: 'normalSend' inCase: 131.
    rcvr := self internalStackValue: argumentCount.
    ((self isIntegerObject: rcvr) not and: [hasToTrace])
        ifTrue: [
            self internalTurnOnUsedBit: rcvr.
    lkupClass := self fetchClassOf: rcvr.
    receiverClass := lkupClass.
    self commonSend.

So...if it is not a SmallInetger and if the flag is on, I turn on a bit.

The question is, if I send a normal message to a normal object. Example:

| anObject |
anObject := MyClass new.
anObject foo

Now...I am sure that "anObject" was marked with the bit. But what about:
a) the compiled method  MyClass >> #foo
b) MyClass

should they be marked?

In other words:

self deny: (unUsed primitiveGetUsedBit: anObject).
    self deny: (unUsed primitiveGetUsedBit: anObject class).
    self deny: (unUsed primitiveGetUsedBit: (anObject class >> #foo)).
     anObject foo.

    self assert: (unUsed primitiveGetUsedBit: anObject).
    self assert: (unUsed primitiveGetUsedBit: anObject class).
    self assert: (unUsed primitiveGetUsedBit: (anObject class >> #foo)).

should all the asserts pass?  I ask because I don't know how CompiledMethods are executed (they receive a normalSend like any other object?) nor how class are accessed.

Thanks in advance,


On Tue, May 11, 2010 at 5:43 PM, Igor Stasenko <siguctua@gmail.com> wrote:

On 11 May 2010 17:40, Mariano Martinez Peck <marianopeck@gmail.com> wrote:
>> >
>> > Thanks Igor. I could see #class does not the normal way. It was logic as it already has the pointer there ;)
>> >
>> > Now I wonder...to avoid those special cases, do you think it makes sense to intercept in commonSend rather than commonSend ?  or it would be the same ?
>> >
>> err... commonSend or commonSend? i think it would be the same :)
> hahahah sorry, I meant commonSend instead of normalSend.
>> the other point, where you can try intercept a send is cache lookup.
> internalFindNewMethod  ?

I don't know, maybe :)

> Thanks
> Mariano