This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Google Summer of Code
- From: Per Bothner <per at bothner dot com>
- To: kawa at sourceware dot org
- Date: Thu, 17 Apr 2014 17:31:05 -0700
- Subject: Re: Google Summer of Code
- Authentication-results: sourceware.org; auth=none
- References: <20140305094242 dot 349492d0 at debian-andrebask> <5316F956 dot 8040303 at gmail dot com> <20140305132208 dot 3081f8dc at debian-andrebask> <m2lhwo48vi dot fsf at gmail dot com> <5319088C dot 5060401 at bothner dot com> <7B118191-4144-4937-B679-89392D5463EE at theptrgroup dot com> <20140316012026 dot 4e0ebfef at debian-andrebask> <53269580 dot 8040205 at bothner dot com> <20140320204856 dot 5aa0b4d3 at debian-andrebask> <532BAA5F dot 3000606 at bothner dot com> <20140328121426 dot 74f3e92d at vaio> <5337BD0C dot 8030301 at bothner dot com> <20140403021150 dot 0dc0f6f4 at vaio> <533F0CC5 dot 1060108 at bothner dot com> <20140413180307 dot 59d3fd9c at debian-andrebask> <534F2BB0 dot 1010208 at bothner dot com> <20140418011243 dot 7fc952d6 at vaio>
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;
}