Remove pad word from arrays
This change removes the 4 byte pad from all arrays except longs and
doubles. It saves 76kb from the boot image, and will also reduce the
size of arrays in the heap (and thereby reduce garbage collection).
Change-Id: I3ff277d5bf14c57c0f7552215818e588ec6cc275
diff --git a/src/compiler/codegen/arm/Thumb2/Gen.cc b/src/compiler/codegen/arm/Thumb2/Gen.cc
index c385f35..5a9750a 100644
--- a/src/compiler/codegen/arm/Thumb2/Gen.cc
+++ b/src/compiler/codegen/arm/Thumb2/Gen.cc
@@ -510,7 +510,8 @@
// We're don't need access checks, load type from dex cache
int32_t dex_cache_offset = Method::DexCacheResolvedTypesOffset().Int32Value();
loadWordDisp(cUnit, mReg, dex_cache_offset, resReg);
- int32_t offset_of_type = Array::DataOffset().Int32Value() + (sizeof(Class*) * type_idx);
+ int32_t offset_of_type = Array::DataOffset(sizeof(Class*)).Int32Value() +
+ (sizeof(Class*) * type_idx);
loadWordDisp(cUnit, resReg, offset_of_type, rlResult.lowReg);
if (!cUnit->compiler->CanAssumeTypeIsPresentInDexCache(cUnit->dex_cache,
type_idx) ||
@@ -571,7 +572,8 @@
{
/* NOTE: Most strings should be available at compile time */
uint32_t string_idx = mir->dalvikInsn.vB;
- int32_t offset_of_string = Array::DataOffset().Int32Value() + (sizeof(String*) * string_idx);
+ int32_t offset_of_string = Array::DataOffset(sizeof(String*)).Int32Value() +
+ (sizeof(String*) * string_idx);
if (!cUnit->compiler->CanAssumeStringIsPresentInDexCache(cUnit->dex_cache, string_idx) ||
SLOW_STRING_PATH) {
// slow path, resolve string if not in dex cache
@@ -664,7 +666,8 @@
// Load dex cache entry into classReg (r2)
loadValueDirectFixed(cUnit, rlSrc, r0); // r0 <= ref
loadWordDisp(cUnit, r1, Method::DexCacheResolvedTypesOffset().Int32Value(), classReg);
- int32_t offset_of_type = Array::DataOffset().Int32Value() + (sizeof(Class*) * type_idx);
+ int32_t offset_of_type = Array::DataOffset(sizeof(Class*)).Int32Value() +
+ (sizeof(Class*) * type_idx);
loadWordDisp(cUnit, classReg, offset_of_type, classReg);
if (!cUnit->compiler->CanAssumeTypeIsPresentInDexCache(cUnit->dex_cache, type_idx)) {
// Need to test presence of type in dex cache at runtime
@@ -728,7 +731,8 @@
} else {
// Load dex cache entry into classReg (r2)
loadWordDisp(cUnit, r1, Method::DexCacheResolvedTypesOffset().Int32Value(), classReg);
- int32_t offset_of_type = Array::DataOffset().Int32Value() + (sizeof(Class*) * type_idx);
+ int32_t offset_of_type = Array::DataOffset(sizeof(Class*)).Int32Value() +
+ (sizeof(Class*) * type_idx);
loadWordDisp(cUnit, classReg, offset_of_type, classReg);
if (!cUnit->compiler->CanAssumeTypeIsPresentInDexCache(cUnit->dex_cache, type_idx)) {
// Need to test presence of type in dex cache at runtime
@@ -1253,7 +1257,7 @@
{
RegisterClass regClass = oatRegClassBySize(kWord);
int lenOffset = Array::LengthOffset().Int32Value();
- int dataOffset = Array::DataOffset().Int32Value();
+ int dataOffset = Array::DataOffset(sizeof(Object*)).Int32Value();
oatFlushAllRegs(cUnit);
/* Make sure it's a legal object Put. Use direct regs at first */
@@ -1313,12 +1317,18 @@
{
RegisterClass regClass = oatRegClassBySize(size);
int lenOffset = Array::LengthOffset().Int32Value();
- int dataOffset = Array::DataOffset().Int32Value();
+ int dataOffset;
RegLocation rlResult;
rlArray = loadValue(cUnit, rlArray, kCoreReg);
rlIndex = loadValue(cUnit, rlIndex, kCoreReg);
int regPtr;
+ if (size == kLong || size == kDouble) {
+ dataOffset = Array::DataOffset(sizeof(int64_t)).Int32Value();
+ } else {
+ dataOffset = Array::DataOffset(sizeof(int32_t)).Int32Value();
+ }
+
/* null object? */
genNullCheck(cUnit, rlArray.sRegLow, rlArray.lowReg, mir);
@@ -1375,7 +1385,13 @@
{
RegisterClass regClass = oatRegClassBySize(size);
int lenOffset = Array::LengthOffset().Int32Value();
- int dataOffset = Array::DataOffset().Int32Value();
+ int dataOffset;
+
+ if (size == kLong || size == kDouble) {
+ dataOffset = Array::DataOffset(sizeof(int64_t)).Int32Value();
+ } else {
+ dataOffset = Array::DataOffset(sizeof(int32_t)).Int32Value();
+ }
int regPtr;
rlArray = loadValue(cUnit, rlArray, kCoreReg);