[Vm-dev] I really don't understand why this doesn't crash
Mariano Martinez Peck
marianopeck at gmail.com
Wed May 18 08:40:41 UTC 2011
Hi guys. I would really appreciate if someone could explain me the
following. I have this class:
Object subclass: #FooClass
instanceVariableNames: 'var1 var2 var3 var4 var5'
classVariableNames: ''
poolDictionaries: ''
category: 'Prueba'
With this method:
FooClass >> foo
Transcript show: var5 asString.
And then I have this class:
Object subclass: #AnotherClass
instanceVariableNames: 'age'
classVariableNames: ''
poolDictionaries: ''
category: 'Prueba'
Now, I run this test:
| inst |
inst := AnotherClass new.
inst age: 42.
(FooClass >> #foo) valueWithReceiver: inst arguments: #()
So...I am evaluating the CompiledMethod installed on #foo on "inst". The
compiledMethod has a bytecode (04) for accessing the var5. But "inst" only
have one instVar. So....shouldn't that be a crash? because the VM is
accessing outside the object... so, the test doesn't crash and in fact, it
prints "1". I don't know what number means.
I took a look to
StackInterpreter >> pushReceiverVariable: fieldIndex
self internalPush: (objectMemory fetchPointer: fieldIndex ofObject: self
receiver).
But I guess that should crash.
Thanks for any tip,
--
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20110518/38e15fce/attachment.htm
More information about the Vm-dev
mailing list