From 372f10e5b0b34e2bb6e2b79aeba6c441e14afd1f Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 17 May 2016 16:30:10 +0100 Subject: Refactor handling of input records. Introduce HInstruction::GetInputRecords(), a new virtual function that returns an ArrayRef<> to all input records. Implement all other functions dealing with input records as wrappers around GetInputRecords(). Rewrite functions that previously used multiple virtual calls to deal with input records, especially in loops, to prefetch the ArrayRef<> only once for each instruction. Besides avoiding all the extra calls, this also allows the compiler (clang++) to perform additional optimizations. This speeds up the Nexus 5 boot image compilation by ~0.5s (4% of "Compile Dex File", 2% of dex2oat time) on AOSP ToT. Change-Id: Id8ebe0fb9405e38d918972a11bd724146e4ca578 --- compiler/utils/array_ref.h | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'compiler/utils/array_ref.h') diff --git a/compiler/utils/array_ref.h b/compiler/utils/array_ref.h index 5c33639a6a..8dc9ab4a5e 100644 --- a/compiler/utils/array_ref.h +++ b/compiler/utils/array_ref.h @@ -39,9 +39,6 @@ namespace art { */ template class ArrayRef { - private: - struct tag { }; - public: typedef T value_type; typedef T& reference; @@ -63,14 +60,14 @@ class ArrayRef { template explicit constexpr ArrayRef(T (&array)[size]) - : array_(array), size_(size) { + : array_(array), size_(size) { } - template - explicit constexpr ArrayRef(U (&array)[size], - typename std::enable_if::value, tag>::type - t ATTRIBUTE_UNUSED = tag()) - : array_(array), size_(size) { + template ::value>::type> + explicit constexpr ArrayRef(U (&array)[size]) + : array_(array), size_(size) { } constexpr ArrayRef(T* array_in, size_t size_in) @@ -165,13 +162,21 @@ class ArrayRef { value_type* data() { return array_; } const value_type* data() const { return array_; } - ArrayRef SubArray(size_type pos) const { - return SubArray(pos, size_ - pos); + ArrayRef SubArray(size_type pos) { + return SubArray(pos, size() - pos); + } + ArrayRef SubArray(size_type pos) const { + return SubArray(pos, size() - pos); + } + ArrayRef SubArray(size_type pos, size_type length) { + DCHECK_LE(pos, size()); + DCHECK_LE(length, size() - pos); + return ArrayRef(data() + pos, length); } - ArrayRef SubArray(size_type pos, size_type length) const { + ArrayRef SubArray(size_type pos, size_type length) const { DCHECK_LE(pos, size()); DCHECK_LE(length, size() - pos); - return ArrayRef(array_ + pos, length); + return ArrayRef(data() + pos, length); } private: -- cgit v1.2.3-59-g8ed1b