[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/codegen cg_stmt.tc,1.38,1.39
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/codegen cg_stmt.tc,1.38,1.39 |
Date: |
Mon, 18 Aug 2003 03:20:03 -0400 |
Update of /cvsroot/dotgnu-pnet/pnet/codegen
In directory subversions:/tmp/cvs-serv2471/codegen
Modified Files:
cg_stmt.tc
Log Message:
Fix the code generation for C switch statements to stop values being
left on the stack during fall-through situations (bug #4822).
Index: cg_stmt.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/codegen/cg_stmt.tc,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -r1.38 -r1.39
*** cg_stmt.tc 17 Aug 2003 23:33:17 -0000 1.38
--- cg_stmt.tc 18 Aug 2003 07:20:01 -0000 1.39
***************
*** 1745,1749 ****
ILSwitchValue
*values,
unsigned long
numValues,
! ILLabel
*defaultLabel)
{
ILNode_SwitchSection *section;
--- 1745,1750 ----
ILSwitchValue
*values,
unsigned long
numValues,
! ILLabel
*defaultLabel,
! unsigned
tempVar)
{
ILNode_SwitchSection *section;
***************
*** 1757,1761 ****
while(numValues > 0)
{
! ILGenSimple(info, IL_OP_DUP);
ILGenAdjust(info, 1);
section = (ILNode_SwitchSection *)(values->section);
--- 1758,1769 ----
while(numValues > 0)
{
! if(tempVar == ~((unsigned)0))
! {
! ILGenSimple(info, IL_OP_DUP);
! }
! else
! {
! ILGenLoadLocal(info, tempVar);
! }
ILGenAdjust(info, 1);
section = (ILNode_SwitchSection *)(values->section);
***************
*** 1777,1784 ****
CompareSwitchValue(info, &(values[chopPosn].value),
IL_OP_BGE, IL_OP_BGE_UN,
&chopLabel);
! GenerateBinarySwitch(info, values, chopPosn, defaultLabel);
ILGenLabel(info, &chopLabel);
GenerateBinarySwitch(info, values + chopPosn,
! numValues - chopPosn,
defaultLabel);
}
}
--- 1785,1792 ----
CompareSwitchValue(info, &(values[chopPosn].value),
IL_OP_BGE, IL_OP_BGE_UN,
&chopLabel);
! GenerateBinarySwitch(info, values, chopPosn, defaultLabel,
tempVar);
ILGenLabel(info, &chopLabel);
GenerateBinarySwitch(info, values + chopPosn,
! numValues - chopPosn,
defaultLabel, tempVar);
}
}
***************
*** 1802,1805 ****
--- 1810,1814 ----
int savePop;
ILNode *saveSwitch;
+ unsigned tempVar = ~((unsigned)0);
/* Compute the switch expression's value */
***************
*** 1832,1839 ****
{
/* Use a simple set of "if" statements */
while(numValues > 0)
{
! ILGenSimple(info, IL_OP_DUP);
! ILGenAdjust(info, 1);
section = (ILNode_SwitchSection
*)(values->section);
CompareSwitchValue(info,
&(values->value),
--- 1841,1866 ----
{
/* Use a simple set of "if" statements */
+ if(node->body)
+ {
+ tempVar = ILGenTempVar(info,
values->value.valueType);
+ ILGenStoreLocal(info, tempVar);
+ ILGenAdjust(info, -1);
+ }
+ else
+ {
+ needPop = 1;
+ }
while(numValues > 0)
{
! if(tempVar == ~((unsigned)0))
! {
! ILGenSimple(info, IL_OP_DUP);
! ILGenAdjust(info, 1);
! }
! else
! {
! ILGenLoadLocal(info, tempVar);
! ILGenAdjust(info, 1);
! }
section = (ILNode_SwitchSection
*)(values->section);
CompareSwitchValue(info,
&(values->value),
***************
*** 1845,1849 ****
ILGenJump(info, IL_OP_BR, defaultLabel);
ILGenAdjust(info, -1);
- needPop = 1;
}
break;
--- 1872,1875 ----
***************
*** 1885,1891 ****
{
/* Use a binary tree of "if" statements */
! GenerateBinarySwitch(info, values, numValues,
defaultLabel);
ILGenAdjust(info, -1);
- needPop = 1;
}
break;
--- 1911,1927 ----
{
/* Use a binary tree of "if" statements */
! if(node->body)
! {
! tempVar = ILGenTempVar(info,
values->value.valueType);
! ILGenStoreLocal(info, tempVar);
! ILGenAdjust(info, -1);
! }
! else
! {
! needPop = 1;
! }
! GenerateBinarySwitch(info, values, numValues,
!
defaultLabel, tempVar);
ILGenAdjust(info, -1);
}
break;
***************
*** 1945,1948 ****
--- 1981,1990 ----
}
ILGenLabel(info, &breakLabel);
+
+ /* Free the temporary switch variable */
+ if(tempVar != ~((unsigned)0))
+ {
+ ILGenReleaseTempVar(info, tempVar);
+ }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/codegen cg_stmt.tc,1.38,1.39,
Rhys Weatherley <address@hidden> <=