With Camille we spent some minutes introducing a weak slot. A weak slot with a weak reference i.e., it is not taken into account by the garbage collector. If an object is only referenced by weak references it will be garbage collected. The nice thing about this is that now we can mix transparently weak and non-weak slots inside the same object. For example: Object subclass: #MyWeakThingy slots: { #weakLala => WeakSlot. #normalInstVar } classVariables: { } category: 'SlotTestGuille' weakLala: someLala weakLala:= someLala weakLala ^ weakLala weak := MyWeakThingy new. o:= Object new. weak weakLala. "=>Object new" o :=nil. weak weakLala. "=>nil" We also implemented with Camille the #emit* methods to make it a bit faster. A simple benchmark in my machine shows that "With no optimizations" [weak weakLala:o] bench "14,338,031 per second" "With optimizations" [weak weakLala:o] bench "27,955,761 per second" "A normal array access" someArray := Array new: 1. [someArray at: 1 put: o] bench "'39,609,322 per second'" We commited it into the inbox, the issue is the following: https://pharo.fogbugz.com/f/cases/14998/Add-WeakSlot Camille & Guille
On 26 Feb 2015, at 14:02, Guillermo Polito <guillermopolito@gmail.com> wrote:
With Camille we spent some minutes introducing a weak slot. A weak slot with a weak reference i.e., it is not taken into account by the garbage collector. If an object is only referenced by weak references it will be garbage collected.
The nice thing about this is that now we can mix transparently weak and non-weak slots inside the same object. For example: Object subclass: #MyWeakThingy slots: { #weakLala => WeakSlot. #normalInstVar } classVariables: { } category: âSlotTestGuille'
Nice! WeakSlot linesOfCode ==> â24"
We also implemented with Camille the #emit* methods to make it a bit faster. A simple benchmark in my machine shows that
We should be able to use the byte code for reading/writing the tempVector here⦠and access the inner array with no message send. (but it needs some API change in IRBuilder where we have them for now just in a version for the tempVector). Marcus
participants (2)
-
Guillermo Polito -
Marcus Denker