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/mir_to_lir.h b/compiler/dex/quick/mir_to_lir.h
index 64ef48d..d101a13 100644
--- a/compiler/dex/quick/mir_to_lir.h
+++ b/compiler/dex/quick/mir_to_lir.h
@@ -831,14 +831,14 @@
void GenNewArray(uint32_t type_idx, RegLocation rl_dest,
RegLocation rl_src);
void GenFilledNewArray(CallInfo* info);
- void GenSput(MIR* mir, RegLocation rl_src,
- bool is_long_or_double, bool is_object);
- void GenSget(MIR* mir, RegLocation rl_dest,
- bool is_long_or_double, bool is_object);
- void GenIGet(MIR* mir, int opt_flags, OpSize size,
- RegLocation rl_dest, RegLocation rl_obj, bool is_long_or_double, bool is_object);
+ void GenSput(MIR* mir, RegLocation rl_src, OpSize size);
+ // Get entrypoints are specific for types, size alone is not sufficient to safely infer
+ // entrypoint.
+ void GenSget(MIR* mir, RegLocation rl_dest, OpSize size, Primitive::Type type);
+ void GenIGet(MIR* mir, int opt_flags, OpSize size, Primitive::Type type,
+ RegLocation rl_dest, RegLocation rl_obj);
void GenIPut(MIR* mir, int opt_flags, OpSize size,
- RegLocation rl_src, RegLocation rl_obj, bool is_long_or_double, bool is_object);
+ RegLocation rl_src, RegLocation rl_obj);
void GenArrayObjPut(int opt_flags, RegLocation rl_array, RegLocation rl_index,
RegLocation rl_src);
@@ -978,6 +978,10 @@
virtual LIR* LoadWordDisp(RegStorage r_base, int displacement, RegStorage r_dest) {
return LoadBaseDisp(r_base, displacement, r_dest, kWord, kNotVolatile);
}
+ // Load 8 bits, regardless of target.
+ virtual LIR* Load8Disp(RegStorage r_base, int displacement, RegStorage r_dest) {
+ return LoadBaseDisp(r_base, displacement, r_dest, kSignedByte, kNotVolatile);
+ }
// Load 32 bits, regardless of target.
virtual LIR* Load32Disp(RegStorage r_base, int displacement, RegStorage r_dest) {
return LoadBaseDisp(r_base, displacement, r_dest, k32, kNotVolatile);
@@ -1149,6 +1153,14 @@
(info1->StorageMask() & info2->StorageMask()) != 0);
}
+ static constexpr bool IsWide(OpSize size) {
+ return size == k64 || size == kDouble;
+ }
+
+ static constexpr bool IsRef(OpSize size) {
+ return size == kReference;
+ }
+
/**
* @brief Portable way of getting special registers from the backend.
* @param reg Enumeration describing the purpose of the register.
@@ -1483,10 +1495,6 @@
*/
virtual RegLocation ForceTempWide(RegLocation loc);
- static constexpr OpSize LoadStoreOpSize(bool wide, bool ref) {
- return wide ? k64 : ref ? kReference : k32;
- }
-
virtual void GenInstanceofFinal(bool use_declaring_class, uint32_t type_idx,
RegLocation rl_dest, RegLocation rl_src);
@@ -1724,6 +1732,9 @@
// (i.e. 8 bytes on 32-bit arch, 16 bytes on 64-bit arch) and we use ResourceMaskCache
// to deduplicate the masks.
ResourceMaskCache mask_cache_;
+
+ private:
+ static bool SizeMatchesTypeForEntrypoint(OpSize size, Primitive::Type type);
}; // Class Mir2Lir
} // namespace art