Compiled call version seems to be slower
Chuck Rasbold
rasbold at google.com
Mon Nov 30 15:53:19 PST 2009
On Mon, Nov 30, 2009 at 3:32 PM, Ulf Zibis <Ulf.Zibis at gmx.de> wrote:
> Am 30.11.2009 19:10, Tom Rodriguez schrieb:
>
> Additionally I'm wondering why the finally block is copy-and-pasted
>>>>>>>> for each separate return.
>>>>>>>> Is that as disired ?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> Sorry about asking once more. Would it be so hard to avoid the
>>>> 6-times redundancy of the finally block, or are there other reasons?
>>>>
>>>>
>>> Well, I guess no, but everyone is busy with more important stuff. But
>>> hey, it's open source :-)
>>>
>>>
>>
>> The 6 copies of the finally block are there in the bytecodes.
>>
>
> Yes, you are right.
>
>
> It's not something hotspot is creating. A finally is executed on every
>> return path so a copy of that code is needed at every return. Conceivably
>> javac could merge all the return paths through a single return with a single
>> copy of the code but it doesn't do that.
>>
>
> So I should file a bug against javac ?
I think javac does this by design in order to eliminate jsr/ret bytecodes.
Others could speak with more authority about javac.
However, I'm sure the the implementors would not call it a bug.
>
>
> You could reshape your code to look like that if you wanted to avoid
>> multiple copies.
>>
>>
>
> Hm, any idea how to do that ß
>
Get rid of the try/finally. Is this semantically equivalent to your code?
private CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst)
{
byte[] sa = src.array();
int sp = src.arrayOffset() + src.position();
int sl = sp + src.remaining();
char[] da = dst.array();
int [] dp = new int[1];
dp[0] = dst.arrayOffset() + dst.position();
int dl = dp[0] + dst.remaining();
CoderResult result = CodeResult.UNDERFLOW;
while (sp < sl) {
byte byte1 = sa[sp];
if (byte1 >= 0) { // ASCII G0
if (dp[0] == dl) {
result = CoderResult.OVERFLOW;
break;
}
da[dp[0]++] = (char)(byte1 & 0xff);
sp++;
} else if (byte1 != SS2) { // Codeset 1 G1
if (sp + 1 == sl) {
break;
}
result = decode(byte1, sa[sp+1], 0, da, dp, dl);
if (result != null)
break;
sp += 2;
} else { // Codeset 2 G2
if (sp + 4 > sl)
break;
int cnsPlane = cnspToIndex[sa[sp+1] & 0xff];
if (cnsPlane < 0) {
result = CoderResult.malformedForLength(2);
break;
}
result = decode(sa[sp+2], sa[sp+3], cnsPlane, da, dp,
dl);
if (result != null)
break;
sp += 4;
}
}
src.position(sp - src.arrayOffset());
dst.position(dp[0] - dst.arrayOffset());
return result;
}
> -Ulf
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20091130/9a7339c7/attachment-0001.html
More information about the hotspot-compiler-dev
mailing list