From ee8d971b14edfc1e0af9436fd223277df966e4c2 Mon Sep 17 00:00:00 2001 From: Mark Mendell Date: Tue, 12 Jul 2016 11:13:15 -0400 Subject: 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 --- compiler/optimizing/graph_visualizer.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'compiler/optimizing/graph_visualizer.cc') diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc index 9d67373321..e14f603fe1 100644 --- a/compiler/optimizing/graph_visualizer.cc +++ b/compiler/optimizing/graph_visualizer.cc @@ -401,6 +401,9 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor { void VisitArrayLength(HArrayLength* array_length) OVERRIDE { StartAttributeStream("is_string_length") << std::boolalpha << array_length->IsStringLength() << std::noboolalpha; + if (array_length->IsEmittedAtUseSite()) { + StartAttributeStream("emitted_at_use") << "true"; + } } void VisitBoundsCheck(HBoundsCheck* bounds_check) OVERRIDE { -- cgit v1.2.3