Fix a sign-extension bug in JValue.
The uint64_t value returned by artQuickProxyInvokeHandler is derived
from a JValue. For signed types that are less than or equal to 32 bits,
the upper 32 bits are zeros, thus lossing its sign bit. This patch
allows the 044-proxy test to pass for Mips64.
Change-Id: I3012fbd415060c859e6972242452e0089139c4c4
diff --git a/runtime/jvalue.h b/runtime/jvalue.h
index 6a6d198..7b91b0b 100644
--- a/runtime/jvalue.h
+++ b/runtime/jvalue.h
@@ -32,7 +32,7 @@
int8_t GetB() const { return b; }
void SetB(int8_t new_b) {
- i = ((static_cast<int32_t>(new_b) << 24) >> 24); // Sign-extend.
+ j = ((static_cast<int64_t>(new_b) << 56) >> 56); // Sign-extend to 64 bits.
}
uint16_t GetC() const { return c; }
@@ -45,7 +45,9 @@
void SetF(float new_f) { f = new_f; }
int32_t GetI() const { return i; }
- void SetI(int32_t new_i) { i = new_i; }
+ void SetI(int32_t new_i) {
+ j = ((static_cast<int64_t>(new_i) << 32) >> 32); // Sign-extend to 64 bits.
+ }
int64_t GetJ() const { return j; }
void SetJ(int64_t new_j) { j = new_j; }
@@ -55,7 +57,7 @@
int16_t GetS() const { return s; }
void SetS(int16_t new_s) {
- i = ((static_cast<int32_t>(new_s) << 16) >> 16); // Sign-extend.
+ j = ((static_cast<int64_t>(new_s) << 48) >> 48); // Sign-extend to 64 bits.
}
uint8_t GetZ() const { return z; }