[Pharo-project] Problem with CompiledMethodTrailer

Igor Stasenko siguctua at gmail.com
Mon May 9 17:06:45 CEST 2011

On 9 May 2011 16:01, Mariano Martinez Peck <marianopeck at gmail.com> wrote:
> Another that....all those incorrect compiled method has the same:  they miss
> the bytecode 120 (self return), and they ALL have the same last byte: 32.
> what that 32 can be?  I don't know...
This is indicating a trailer kind:

((CompiledMethod allInstances select:  [:each | each trailer kind =
#VarLengthSourcePointer] ) ) first trailer kindAsByte

32 stands for #VarLengthSourcePointer trailer.

And i have plenty of methods with #VarLengthSourcePointer in my image

((CompiledMethod allInstances select:  [:each | each trailer kind =
#VarLengthSourcePointer] ) ) size 4387

because my .changes file go over 32Mb "limit".

Now to check what is going on, we should run a following:

methods := ((CompiledMethod allInstances select:  [:each | each
trailer kind = #VarLengthSourcePointer] ) ).

methods := methods select: [:m | m isInstalled ]. "we don't care about
not-installed ones"

and for installed we should verify that after compilation it from source code,
it ends up with same bytecode as in currently installed method.

| methods |

methods := ((CompiledMethod allInstances select:  [:each | each
trailer kind = #VarLengthSourcePointer] ) ).
methods := methods select: [:m |
	| cls |
	cls := m methodClass.
	cls isObsolete not and: [ (cls compiledMethodAt: m selector) == m ] ].

methods select: [:m |
	| m2 |
	m2 := m methodNode generate.
	((m initialPC = m2 initialPC and: [m endPC = m2 endPC ]) and: [
		(m initialPC to: m endPC) allSatisfy: [:i | (m at: i) = (m2 at: i)]  	]) not

In my image the result of doit is empty array.
Note that endPC is calculating based on trailer data. So if trailer is
not correct, it would affect the comparison.
So, it could fail if source code pointer is not valid or endPC
calculation is wrong.
But for all methods it is correct.

Best regards,
Igor Stasenko AKA sig.

More information about the Pharo-project mailing list