[Vm-dev] Re: [Pharo-dev] Should literals be immutable ?

Levente Uzonyi leves at elte.hu
Mon Oct 27 20:46:52 UTC 2014

On Mon, 27 Oct 2014, Eliot Miranda wrote:

> I disagree.  It's about an incremental improvement.  A per-object 
immutability bit used to protect against direct alteration of literals 
works.  Right now there's nothing to stop one recompiling a method, and
per-object immutability doesn't change that.  So mutable compiled methods 
are tolerable (at least in VW we kept methods mutable).  But having the 
bit stop direct modification of literals is goodness, not to
be avoided because it doesn't prevent more exotic modification via become.

But if you allow mutable CompiledMethods, then Clement's example can be 
rewritten as:

MyClass >> #foo

 	^#(false) first
 		ifFalse: [
 			'first call since compilation' logCr.
 			thisContext method in: [ :method |
 				(method literalAt: (method literals indexOf: #(false)) put: { true }) ] ]
 		ifTrue: [ 'other calls' logCr ]

(#becomeForward: could also be used on the literal).

How will you avoid implementing the deoptimization of the method (the 
slow path) when this is possible?


More information about the Vm-dev mailing list