From 857dcd13e7b5113178ea615f57f05fac87d6466b Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 20 Dec 2010 18:08:52 -0700 Subject: [PATCH] fix 64-bit constant comparisons on 32-bit platforms --- src/compiler.cpp | 14 +++++++++++--- test/Longs.java | 5 +++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/compiler.cpp b/src/compiler.cpp index 23778520d6..1a96292b96 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -4741,9 +4741,17 @@ class BranchEvent: public Event { if (not unreachable(this)) { if (firstConstant and secondConstant) { - if (shouldJump(c, type, size, firstConstant->value->value(), - secondConstant->value->value())) - { + int64_t firstValue = firstConstant->value->value(); + int64_t secondValue = secondConstant->value->value(); + + if (size > BytesPerWord) { + firstValue |= findConstantSite + (c, first->nextWord)->value->value() << 32; + secondValue |= findConstantSite + (c, second->nextWord)->value->value() << 32; + } + + if (shouldJump(c, type, size, firstValue, secondValue)) { apply(c, Jump, BytesPerWord, address->source, address->source); } } else { diff --git a/test/Longs.java b/test/Longs.java index 8c34fddce9..9beaf8a996 100644 --- a/test/Longs.java +++ b/test/Longs.java @@ -60,6 +60,11 @@ public class Longs { } public static void main(String[] args) throws Exception { + { long a = 0x1FFFFFFFFL; + long b = -1; + expect(a != b); + } + expect(Math.abs(-123L) == 123L); expect(readLongFrom(new java.io.InputStream() {