Permalink
Browse files

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.
  • Loading branch information...
1 parent 3f03986 commit 24f682f5b676fd4cbf25592054022d9a410fbcc5 @dicej dicej committed Sep 3, 2012
Showing with 10 additions and 6 deletions.
  1. +6 −6 src/x86.cpp
  2. +4 −0 test/Longs.java
View
@@ -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);
View
@@ -385,6 +385,10 @@ public int read() {
{ long b = 0xBEL; int x = 0; int y = 0xFF;
expect(((b >>> x) & y) == 0xBEL); }
+
+ { long b = 0xFFFFFFFFFFFFFFFFL; int s = 20;
+ expect((b >>> -s) == 0xFFFFF);
+ }
}
}

0 comments on commit 24f682f

Please sign in to comment.