This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Google Summer of Code




On 04/17/2014 04:12 PM, Andrea Bernardini wrote:
In the numCases == 2 code, all the gotos point to a return statement,
while in the numCases == 1 the return is missing. What I wanted to
obtain was the same code with a return statement at the end. But adding
a return statement at the end with emitReturn() is not enough, because
for some reason after_label is not pointing to the correct location:

I have a hunch there could be a problem with the "fixup" machinery -
which could be a bug in my code - or that you're violating some
important assumption in the code.

The fixup logic is rather complex.  It can re-order the bytecode and
make various optimizations.  It actually makes 3 passes over the
bytecode. I suggest uncommenting disAssembleWithFixups and calling it
at the beginning of processFixups - the attached patch shows what you
need to do.  That will show you how the bytecode looks before
fixup-processing.

I assume switchValuePushed is being called by your code (probably indirectly via startSwitch) and that exitSwitch is called before
addDefault.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/
Index: gnu/bytecode/CodeAttr.java
===================================================================
--- gnu/bytecode/CodeAttr.java	(revision 7851)
+++ gnu/bytecode/CodeAttr.java	(working copy)
@@ -2538,6 +2538,10 @@
   {
     if (fixup_count <= 0)
       return;
+    System.out.println("processFixups for "+getMethod());
+    ClassTypeWriter writer = new ClassTypeWriter(getMethod().getDeclaringClass(), System.out, 0);
+disAssembleWithFixups(writer);
+writer.flush();
 
     // For each label, set it to its maximum limit, assuming all
     // fixups causes the code the be expanded.  We need a prepass
@@ -2936,7 +2940,7 @@
     dst.printAttributes(this);
   }
 
-  /* DEBUGGING:
+    ///* DEBUGGING:
   public void disAssembleWithFixups (ClassTypeWriter dst)
   {
     if (fixup_count <= 0)
@@ -3017,7 +3021,7 @@
 	i++;
       }
   }
-  */
+  //*/
 
   public void disAssemble (ClassTypeWriter dst, int start, int limit)
   {
Index: gnu/bytecode/Label.java
===================================================================
--- gnu/bytecode/Label.java	(revision 7851)
+++ gnu/bytecode/Label.java	(working copy)
@@ -241,9 +241,9 @@
     code.setReachable(true);
   }
 
-  /* DEBUG
+    ///* DEBUG
   int id = ++counter;
   static int counter;
   public String toString() { return "Label#"+id+"-pos:"+position; }
-  */
+    //*/
 }
Index: gnu/bytecode/SwitchState.java
===================================================================
--- gnu/bytecode/SwitchState.java	(revision 7851)
+++ gnu/bytecode/SwitchState.java	(working copy)
@@ -63,7 +63,7 @@
     cases_label = new Label(code);
     after_label = new Label(code);
     outerTry = code.try_stack;
-
+    System.err.println("new Switch switch_label:"+switch_label+" cases_label:"+cases_label+" after_label:"+after_label);
     numCases = 0;
   }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]