Reduced memory usage of primitive fields smaller than 4-bytes
Reduced memory used by byte and boolean fields from 4 bytes down to a
single byte and shorts and chars down to two bytes. Fields are now
arranged as Reference followed by decreasing component sizes, with
fields shuffled forward as needed.
Bug: 8135266
Change-Id: I65eaf31ed27e5bd5ba0c7d4606454b720b074752
diff --git a/compiler/dex/quick/x86/utility_x86.cc b/compiler/dex/quick/x86/utility_x86.cc
index a48613f..f159beb 100644
--- a/compiler/dex/quick/x86/utility_x86.cc
+++ b/compiler/dex/quick/x86/utility_x86.cc
@@ -875,6 +875,17 @@
// StoreBaseDisp() will emit correct insn for atomic store on x86
// assuming r_dest is correctly prepared using RegClassForFieldLoadStore().
+ // x86 only allows registers EAX-EDX to be used as byte registers, if the input src is not
+ // valid, allocate a temp.
+ bool allocated_temp = false;
+ if (size == kUnsignedByte || size == kSignedByte) {
+ if (!cu_->target64 && !r_src.Low4()) {
+ RegStorage r_input = r_src;
+ r_src = AllocateByteRegister();
+ OpRegCopy(r_src, r_input);
+ allocated_temp = true;
+ }
+ }
LIR* store = StoreBaseIndexedDisp(r_base, RegStorage::InvalidReg(), 0, displacement, r_src, size);
@@ -884,6 +895,10 @@
GenMemBarrier(kAnyAny);
}
+ if (allocated_temp) {
+ FreeTemp(r_src);
+ }
+
return store;
}