On Sat, 20 Nov 2010, Mariano Martinez Peck wrote:
On Sat, Nov 20, 2010 at 12:34 PM, Levente Uzonyi <[email protected]> wrote:
On Fri, 19 Nov 2010, Mariano Martinez Peck wrote:
In a 15MB image all CompiledMethods use only ~3MB, so this technique won't
save much space IMHO.
mmmmm I thought it was muuuch more. How are you measuring those 3mb ? Only
the compiled method bytearray or also the literals? Because if you take into
account all the ByteSymbol instances of literals for example, the size can
be more.
That's just the methods themselves. I did some more experiments and I
think the savings can peak at ~5MB for the 15MB image.
To minimize the space usage, use SmallIntegers as proxies. To avoid the
(Object >> #hash) literals
#literals was an example, but the same happens with all the methods
implemented in CompiledMethod.
I also used #literals as an example. :)
problem swap back the real method in MethodDictionary >> #at:ifAbsent:.
Yes, actually Luc had this idea too. I should also modify (or implement)
#at: and friends
What I was afraid is if the VM directly access to them and I cannot
interpret them. Is this possible? I think the vm access them but only when
executing them....where in such case, it will end up with a #run:with:in,
which is perfect for me.
Normally the send ends up in #run:with:in:.
A SmallInteger has 31 bits which can easily identify the file index and
position where the swapped out method is. For example you can use 7 bits for
index and 24 bits for position. That allows you to have 128 files which can
hold 16MB data each.
Or you can store a single method in a file, this way the SmallInteger
identifies the file.
Yes, exactly :)
Thanks Levente. I like this idea. I've been doing proxies for classes,
normal objects, etc and I never thought about using SmallIntegers. This is
because I usually need to do a #become: between the original object and
the proxy. But in this case this is not needed, since I just need a
methodDict at: put: . And this is a good idea because I don't need an
object header per proxy instance.
I will try to implement this. Thank you very much for all the answers.
I did a quick implementation and it works. The only problem is that you
can't swap-out a method that's used by the swap-in code.
Levente
Mariano
Levente
Thanks
Mariano