swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Linux to MacOSX port effort.


From: Marcus G. Daniels
Subject: Re: Linux to MacOSX port effort.
Date: 30 Apr 2002 16:31:22 -0600
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.7

SC> Does Swarm implement this phase switching by adding/removing methods 
SC> from the class; or do you switch-out the whole dispatch hash table?  I'm 
SC> guessing swapping out the whole table would be most efficient 
SC> execution-wise.  Hmm, a proxy implementation might also work.

If you look at a class implementation like src/collections/OrderedSet.m,
you'll see the markers "PHASE(Creating)" and "PHASE(Using)".  These markers
are converted into NOP methods that serve as delimiters in the list of methods.

When a class is `split' at runtime, empty classes for the different
phases are allocated and the template class, the methods in the
physical .m implementation file, are iterated over.  Methods after the
"PHASE(Creating)" marker method are copied to one class and then
methods after the "PHASE(Using)" are copied to another.  By "copied" I
mean that the array entry in a class dispatch table is assigned a new
IMP for a given selector.  (An IMP is the C function corresponding to message
implementation for a specific target object.)

Finally, an `interface class' (same notion as in Java), is created and
the class is set to the initial `creating' phase object that was just
allocated and assigned.  Switching `phase' is a matter of assigning a
new class object reference to the first slot in an object.

Anyway, that's how it works.  Methods are copied one by one into new
synthetic classees.  In practice, it's not particularly expensive
since in Swarm objects don't hop around between phases.  Once an
object is in `Using' phase it has the same dispatch performance as one
that was compiled that way.

It should be possible to implement a scheme like this
(i.e. alternative predefined groups of methods for the same physical
object) using multiple inheritance in C++ and virtual methods.  The
larger idea/agenda with this Objective C, er, well, violence was to
prototype a system for adaptive runtime code specialization.  Runtime
C++ templates, roughly speaking..

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]