From 24f682f5b676fd4cbf25592054022d9a410fbcc5 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 3 Sep 2012 08:44:13 -0600 Subject: [PATCH] fix 64-bit shifts on x86_32 (part 2) My earlier attempt (fa5d76b) missed an important detail, and somehow I forgot to test the 32-bit OpenJDK build which made that omission obvious. Here's the fix. --- src/x86.cpp | 12 ++++++------ test/Longs.java | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/x86.cpp b/src/x86.cpp index 06a492dcfd..acdb8f1f71 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -2186,9 +2186,9 @@ shiftLeftRR(Context* c, UNUSED unsigned aSize, Assembler::Register* a, unsigned bSize, Assembler::Register* b) { if (TargetBytesPerWord == 4 and bSize == 8) { + Assembler::Register cx(rcx); if (a->low != rcx) { c->client->save(rcx); - Assembler::Register cx(rcx); ResolvedPromise promise(0x3F); Assembler::Constant mask(&promise); moveRR(c, 4, a, 4, &cx); @@ -2204,7 +2204,7 @@ shiftLeftRR(Context* c, UNUSED unsigned aSize, Assembler::Register* a, ResolvedPromise promise(32); Assembler::Constant constant(&promise); - compareCR(c, aSize, &constant, aSize, a); + compareCR(c, aSize, &constant, aSize, &cx); opcode(c, 0x7c); //jl c->code.append(2 + 2); @@ -2232,9 +2232,9 @@ shiftRightRR(Context* c, UNUSED unsigned aSize, Assembler::Register* a, unsigned bSize, Assembler::Register* b) { if (TargetBytesPerWord == 4 and bSize == 8) { + Assembler::Register cx(rcx); if (a->low != rcx) { c->client->save(rcx); - Assembler::Register cx(rcx); ResolvedPromise promise(0x3F); Assembler::Constant mask(&promise); moveRR(c, 4, a, 4, &cx); @@ -2250,7 +2250,7 @@ shiftRightRR(Context* c, UNUSED unsigned aSize, Assembler::Register* a, ResolvedPromise promise(32); Assembler::Constant constant(&promise); - compareCR(c, aSize, &constant, aSize, a); + compareCR(c, aSize, &constant, aSize, &cx); opcode(c, 0x7c); //jl c->code.append(2 + 3); @@ -2281,9 +2281,9 @@ unsignedShiftRightRR(Context* c, UNUSED unsigned aSize, Assembler::Register* a, unsigned bSize, Assembler::Register* b) { if (TargetBytesPerWord == 4 and bSize == 8) { + Assembler::Register cx(rcx); if (a->low != rcx) { c->client->save(rcx); - Assembler::Register cx(rcx); ResolvedPromise promise(0x3F); Assembler::Constant mask(&promise); moveRR(c, 4, a, 4, &cx); @@ -2299,7 +2299,7 @@ unsignedShiftRightRR(Context* c, UNUSED unsigned aSize, Assembler::Register* a, ResolvedPromise promise(32); Assembler::Constant constant(&promise); - compareCR(c, aSize, &constant, aSize, a); + compareCR(c, aSize, &constant, aSize, &cx); opcode(c, 0x7c); //jl c->code.append(2 + 2); diff --git a/test/Longs.java b/test/Longs.java index 649ec6b2ff..4d9395f7b0 100644 --- a/test/Longs.java +++ b/test/Longs.java @@ -385,6 +385,10 @@ public class Longs { { long b = 0xBEL; int x = 0; int y = 0xFF; expect(((b >>> x) & y) == 0xBEL); } + + { long b = 0xFFFFFFFFFFFFFFFFL; int s = 20; + expect((b >>> -s) == 0xFFFFF); + } } }