using gcj for a different language - is it possible?
Per Bothner
per@bothner.com
Sat Jan 10 19:51:00 GMT 2004
Andrew Haley wrote:
> I think the trick used in Smalltalk was to copy and then overwrite
> both objects with a special indirection object. We could do this in
> gcj.
In the original Smalltalk implementation an "object reference" was
a 16-bit index into an object table, which pointed to the actual
objects. (Except for SmallInteger, there could be at most 32768
object instances in the system!) So becomes: was just a matter of
swapping the entries in the object table.
Later implementations used various tricks - or didn't support becomes:.
Overwriting an object to add indirection might add extra overhead
that might be unacceptable. A solution is to also create a special
indirection vtable that points to "thunk" methods that resolve the
indirection and then jump to the real methods. Then you only get
modest overhead for objects that have been objected to becomes:
without other calls having to check for indirection.
There is still an issue with accessing fields (instance variables)
of indirected objects. Luckily, in SmallTalk you can only access
fields of the current (this) object, which is never indirected.
So it is possible to implement becomes: reasonably efficiently,
as long as you stick to SmallTalk object, where you can only access
the fields of the current objects. If you care enough.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
More information about the Java
mailing list