summaryrefslogtreecommitdiff
path: root/compiler/optimizing/optimizing_compiler.cc
diff options
context:
space:
mode:
authorMark Mendell <mark.p.mendell@intel.com>2016-07-12 11:13:15 -0400
committerMark Mendell <mark.p.mendell@intel.com>2016-07-13 10:40:45 -0400
commitee8d971b14edfc1e0af9436fd223277df966e4c2 (patch)
tree2dc16ca40980cc716aba24d793eaa8731846a180 /compiler/optimizing/optimizing_compiler.cc
parentdedde3f10d7801ad862d1ca1de89135decff6a60 (diff)
X86: Use memory to do array range checks
Currently, an HBoundsCheck is fed by an HArrayLength, causing a load of the array length, followed by a register compare. Avoid the load when we can by comparing directly with the array length in memory. Implement this by marking the HArrayLength as 'emitted at use site', and then generating the code in the HBoundsCheck. Only do this replacement when we are the only user of the ArrayLength and it isn't visible to the environment. Handle the special case where the array is 'null' and where an implicit null check can't be eliminated. This code moves the load of the length to the slow code for the failed check, which is what we want. Test: 609-checker-x86-bounds-check Change-Id: I9cdb183301e048234bb0ffeda940eedcf4a655bd Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
Diffstat (limited to 'compiler/optimizing/optimizing_compiler.cc')
-rw-r--r--compiler/optimizing/optimizing_compiler.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index d703b0f94f..d6e09d7acb 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -37,6 +37,10 @@
#include "pc_relative_fixups_x86.h"
#endif
+#if defined(ART_ENABLE_CODEGEN_x86) || defined(ART_ENABLE_CODEGEN_x86_64)
+#include "x86_memory_gen.h"
+#endif
+
#include "art_method-inl.h"
#include "base/arena_allocator.h"
#include "base/arena_containers.h"
@@ -485,13 +489,27 @@ static void RunArchOptimizations(InstructionSet instruction_set,
case kX86: {
x86::PcRelativeFixups* pc_relative_fixups =
new (arena) x86::PcRelativeFixups(graph, codegen, stats);
+ x86::X86MemoryOperandGeneration* memory_gen =
+ new(arena) x86::X86MemoryOperandGeneration(graph, stats, codegen);
HOptimization* x86_optimizations[] = {
- pc_relative_fixups
+ pc_relative_fixups,
+ memory_gen
};
RunOptimizations(x86_optimizations, arraysize(x86_optimizations), pass_observer);
break;
}
#endif
+#ifdef ART_ENABLE_CODEGEN_x86_64
+ case kX86_64: {
+ x86::X86MemoryOperandGeneration* memory_gen =
+ new(arena) x86::X86MemoryOperandGeneration(graph, stats, codegen);
+ HOptimization* x86_64_optimizations[] = {
+ memory_gen
+ };
+ RunOptimizations(x86_64_optimizations, arraysize(x86_64_optimizations), pass_observer);
+ break;
+ }
+#endif
default:
break;
}