CGeneratorEnhancements-ajh.cs
Anthony Hannan
ajhannan at yahoo.com
Mon Apr 8 16:17:06 UTC 2002
--- John M McIntosh <johnmci at smalltalkconsulting.com> wrote:
> I was looking at CGeneratorEnhancements-ajh.cs with an eye towards
> the statement about individual variables in each case statement
> perhaps making things abit more optimizing friendly.
>
> But there is a problem
> You see if you just apply this change set, you can't get a runnable vm.
> why? well
> self sharedCodeNamed: 'commonReturn' inCase: 120.
> in Interpreter>>returnValue:to:
>
> allows the code generator to build a common block of code within a
> case statement (label commonReturn: in case 120), then other case
> blocks can jump to the code, hint they share variables. But with
> CGeneratorEnhancements-ajh.cs each case statement gets unique
> variables like so:
>
> (ack a goto aren't those evil?)
>
> case 121:
> /* returnTrue */
> cntx1 = longAt(((((char *) localHomeContext))
> + 4) + (0 << 2));
> val1 = trueObj;
> /* begin returnValue:to: */
> goto commonReturn;
> l4: /* end returnValue:to: */;
> break;
> case 122:
> /* returnFalse */
> cntx2 = longAt(((((char *) localHomeContext))
> + 4) + (0 << 2));
> val2 = falseObj;
> /* begin returnValue:to: */
> goto commonReturn;
>
> However in commonReturn the variables used are cntx and val, and of
> course we fail to proceed.
>
> Ah but the old code used t1 and t2, and you're right if you guessed
> commonReturn: used
> t1 and t2 in the correct places. Design or accident?
>
> case 121:
> /* returnTrue */
> t2 = longAt(((((char *) localHomeContext)) +
> 4) + (0 << 2));
> t1 = trueObj;
> /* begin returnValue:to: */
> goto commonReturn;
> l4: /* end returnValue:to: */;
> break;
> case 122:
> /* returnFalse */
> t2 = longAt(((((char *) localHomeContext)) +
> 4) + (0 << 2));
> t1 = falseObj;
> /* begin returnValue:to: */
> goto commonReturn;
>
>
> Mmm now I could hack something together, but thought I should look
> for a more correct solution.
If you look at the comment in sharedCodeNamed:inCase: it says not to use this
in methods that take args. The work around is to define a new global and use
it to pass the args. You can make the global local to the interpret() function
the same way localSP and a few others are. From John's subsequent posts it
looks like he figured this out already.
Cheers,
Anthony
__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/
More information about the Squeak-dev
mailing list
|