On the effect of branch mispredictions in the Squeak VM

John M McIntosh johnmci at mac.com
Mon Jul 7 18:59:57 UTC 2003


> *] The important part of gnuification here is to replace the  
> switch/break
> statements with labeled gotos which are supported by GCC but not other
> compilers.

Ah, well here is a thought that might send you away to think because  
the PC folks who are complain about the G5 SPEC marks say the GCC  
compiler creates crummy code on intel, versus say some other  
compiler... so any usage of GCC on intel is flawed...

Although labeled gotos are a GCC feature, why we forget that one can  
take an address at runtime.

So if the code looks like below, which comes from I note I sent to  
CodeWarrior technical support back in Jan 2001 then I think you can  
calculate the label addresses at runtime, or based on a one time if  
statement for the primitive switch statement, then you get to invoke  
the goto. The reason for this note to tech support is that doing this  
in codewarrior pre 8.x causes an internal compiler failure. I've not  
got codewarrior 8.x so I've not been able to confirm the bug was fixed.

PS If anyone has codewarror 8.x on the mac and would like to attempt a  
compile, please let me know and I'll send you a 3.0.22 mac vm folder to  
fiddle with.


However you might want to try this with intel's? or Microsoft's  
compiler and see how the code compares to GCC?

> Our GNU friends have a modification to the bytecode loop which is a
> 256 case statement such that
>
> jumptable[0] = &&_0;
> ...
> jumptable[255] = &&_255;
>
> currentByteCode = byteAt(++localip);
> while (true) {
> 	switch currentByteCode
> 		0: _0:
> 		  // stuff
>   		  currentByteCode = byteAt(++localip);
> 		  goto jumptable[currentByteCode];
> 		1: _1:
> 	  ...
> 	end switch
> }
This has been logged in our database as bug number WB1-29763.

Note that the gnuified code macros
		CASE(0)
			BREAK;
hide the actual 0:_0 and goto jumptable[currentByteCode]. These are  
explicit here to be helpful to
the metrowerks staff.

--
======================================================================== 
===
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
======================================================================== 
===



More information about the Squeak-dev mailing list