summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2015-10-15 15:53:39 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2015-10-15 15:53:39 +0000
commit7dae1918d25ea2ad6b5ba166f44472d82c53fa5e (patch)
treec064457bc684d2e43110d3df75dd0b21392d7db6
parent4f55fd25111217e37001958b7069fe03292ff1a4 (diff)
parent44f1019c14755d3d3b1e246cbbb14c3e0fa397de (diff)
Merge "Fix a sign-extension bug in JValue."
-rw-r--r--runtime/jvalue.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/jvalue.h b/runtime/jvalue.h
index 6a6d1986dc..7b91b0b2b6 100644
--- a/runtime/jvalue.h
+++ b/runtime/jvalue.h
@@ -32,7 +32,7 @@ union PACKED(4) JValue {
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 @@ union PACKED(4) JValue {
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 @@ union PACKED(4) JValue {
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; }