From d4093f33585ad677c45085000792fc423efebb34 Mon Sep 17 00:00:00 2001 From: jjenista Date: Fri, 4 Feb 2011 01:02:49 +0000 Subject: [PATCH] improve code gen to omit empty switch cases for stall sites --- Robust/src/IR/Flat/BuildOoOJavaCode.java | 31 ++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Robust/src/IR/Flat/BuildOoOJavaCode.java b/Robust/src/IR/Flat/BuildOoOJavaCode.java index a277d40a..b0d045bc 100644 --- a/Robust/src/IR/Flat/BuildOoOJavaCode.java +++ b/Robust/src/IR/Flat/BuildOoOJavaCode.java @@ -1027,8 +1027,9 @@ public class BuildOoOJavaCode extends BuildCode { // executing, so create a switch on task ID, because waiting elements // generated by this stall site should be inserted into possibly a // different memory queue index, depending on which task type it is - output.println(" // potential stall site "); - output.println(" switch( runningSESE->classID ) {"); + // update: only generate the switch statement if there is at least + // one non-empty case that will go in it! + boolean atLeastOneCase = false; // create a case for each class of task that might be executing Iterator taskItr = oooa.getPossibleExecutingRBlocks( fn ).iterator(); @@ -1047,6 +1048,12 @@ public class BuildOoOJavaCode extends BuildCode { continue; } + if( atLeastOneCase == false ) { + atLeastOneCase = true; + output.println(" // potential stall site "); + output.println(" switch( runningSESE->classID ) {"); + } + output.println(" case "+parent.getIdentifier()+": {"); if( state.RCR ) { @@ -1094,7 +1101,10 @@ public class BuildOoOJavaCode extends BuildCode { } output.println(" } break; // end case "+parent.getIdentifier()); } - output.println(" } // end stall site switch"); + + if( atLeastOneCase ) { + output.println(" } // end stall site switch"); + } } } @@ -1395,9 +1405,7 @@ public class BuildOoOJavaCode extends BuildCode { // based on task ID, each type of task has a different index // scheme for its memory queue's, and the cases here drop the // new task instance in the right bucket - - output.println(" // add new task instance to current task's memory queues if needed "); - output.println(" switch( runningSESE->classID ) {"); + boolean atLeastOneCase = false; // create a case for each class of task that might be executing Iterator taskItr = oooa.getPossibleExecutingRBlocks( fsen ).iterator(); @@ -1418,6 +1426,12 @@ public class BuildOoOJavaCode extends BuildCode { continue; } + if( atLeastOneCase == false ) { + atLeastOneCase = true; + output.println(" // add new task instance to current task's memory queues if needed "); + output.println(" switch( runningSESE->classID ) {"); + } + output.println(" case "+parent.getIdentifier()+": {"); output.println(" REntry* rentry=NULL;"); output.println(" INTPTR* pointer=NULL;"); @@ -1502,7 +1516,10 @@ public class BuildOoOJavaCode extends BuildCode { output.println(" } break; // end case "+parent.getIdentifier()); output.println(); } - output.println(" } // end stall site switch"); + + if( atLeastOneCase ) { + output.println(" } // end stall site switch"); + } } if( state.COREPROF ) { -- 2.34.1