summaryrefslogtreecommitdiffstats
path: root/compiler
diff options
context:
space:
mode:
authorMark Mendell <mark.p.mendell@intel.com>2014-02-25 08:19:08 -0800
committerMark Mendell <mark.p.mendell@intel.com>2014-02-25 08:49:49 -0800
commite19c91fdb88ff6fd4e88bc5984772dcfb1e86f80 (patch)
tree3d0169db0c318f92865cf385b6e24028113f8f4c /compiler
parent67f8f404a242752651771ab34df18f8eab910cb3 (diff)
downloadart-e19c91fdb88ff6fd4e88bc5984772dcfb1e86f80.zip
art-e19c91fdb88ff6fd4e88bc5984772dcfb1e86f80.tar.gz
art-e19c91fdb88ff6fd4e88bc5984772dcfb1e86f80.tar.bz2
Fix hardcoded offsets in x86 String.indexOf.
Use runtime code that will work for 32 and 64 bit too. The old code copied constants from the runtime .S file and is correct for 32 bit code only. Change-Id: I668e1d7f2db8186518c358bde0759633be0d7c40 Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
Diffstat (limited to 'compiler')
-rw-r--r--compiler/dex/quick/x86/target_x86.cc26
1 files changed, 15 insertions, 11 deletions
diff --git a/compiler/dex/quick/x86/target_x86.cc b/compiler/dex/quick/x86/target_x86.cc
index ad5b154..eea7191 100644
--- a/compiler/dex/quick/x86/target_x86.cc
+++ b/compiler/dex/quick/x86/target_x86.cc
@@ -20,6 +20,8 @@
#include "codegen_x86.h"
#include "dex/compiler_internals.h"
#include "dex/quick/mir_to_lir-inl.h"
+#include "mirror/array.h"
+#include "mirror/string.h"
#include "x86_lir.h"
namespace art {
@@ -944,12 +946,6 @@ void X86Mir2Lir::InstallLiteralPools() {
Mir2Lir::InstallLiteralPools();
}
-// Offsets within java.lang.String.
-#define STRING_VALUE_OFFSET 8
-#define STRING_COUNT_OFFSET 12
-#define STRING_OFFSET_OFFSET 20
-#define STRING_DATA_OFFSET 12
-
/*
* Fast string.index_of(I) & (II). Inline check for simple case of char <= 0xffff,
* otherwise bails to standard library code.
@@ -1001,6 +997,14 @@ bool X86Mir2Lir::GenInlinedIndexOf(CallInfo* info, bool zero_based) {
}
// From here down, we know that we are looking for a char that fits in 16 bits.
+ // Location of reference to data array within the String object.
+ int value_offset = mirror::String::ValueOffset().Int32Value();
+ // Location of count within the String object.
+ int count_offset = mirror::String::CountOffset().Int32Value();
+ // Starting offset within data array.
+ int offset_offset = mirror::String::OffsetOffset().Int32Value();
+ // Start of char data with array_.
+ int data_offset = mirror::Array::DataOffset(sizeof(uint16_t)).Int32Value();
// Character is in EAX.
// Object pointer is in EDX.
@@ -1010,7 +1014,7 @@ bool X86Mir2Lir::GenInlinedIndexOf(CallInfo* info, bool zero_based) {
NewLIR1(kX86Push32R, rDI);
// Compute the number of words to search in to rCX.
- LoadWordDisp(rDX, STRING_COUNT_OFFSET, rCX);
+ LoadWordDisp(rDX, count_offset, rCX);
LIR *length_compare = nullptr;
int start_value = 0;
if (zero_based) {
@@ -1048,10 +1052,10 @@ bool X86Mir2Lir::GenInlinedIndexOf(CallInfo* info, bool zero_based) {
// ECX now contains the count in words to be searched.
// Load the address of the string into EBX.
- // The string starts at VALUE(String) + 2 * OFFSET(String) + STRING_DATA_OFFSET.
- LoadWordDisp(rDX, STRING_VALUE_OFFSET, rDI);
- LoadWordDisp(rDX, STRING_OFFSET_OFFSET, rBX);
- OpLea(rBX, rDI, rBX, 1, STRING_DATA_OFFSET);
+ // The string starts at VALUE(String) + 2 * OFFSET(String) + DATA_OFFSET.
+ LoadWordDisp(rDX, value_offset, rDI);
+ LoadWordDisp(rDX, offset_offset, rBX);
+ OpLea(rBX, rDI, rBX, 1, data_offset);
// Now compute into EDI where the search will start.
if (zero_based || rl_start.is_const) {