1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ART_COMPILER_OPTIMIZING_NODES_ARM_H_ 18 #define ART_COMPILER_OPTIMIZING_NODES_ARM_H_ 19 20 namespace art { 21 22 class HArmDexCacheArraysBase : public HExpression<0> { 23 public: 24 explicit HArmDexCacheArraysBase(const DexFile& dex_file) 25 : HExpression(Primitive::kPrimInt, SideEffects::None(), kNoDexPc), 26 dex_file_(&dex_file), 27 element_offset_(static_cast<size_t>(-1)) { } 28 29 void UpdateElementOffset(size_t element_offset) { 30 // Use the lowest offset from the requested elements so that all offsets from 31 // this base are non-negative because our assemblers emit negative-offset loads 32 // as a sequence of two or more instructions. (However, positive offsets beyond 33 // 4KiB also require two or more instructions, so this simple heuristic could 34 // be improved for cases where there is a dense cluster of elements far from 35 // the lowest offset. This is expected to be rare enough though, so we choose 36 // not to spend compile time on elaborate calculations.) 37 element_offset_ = std::min(element_offset_, element_offset); 38 } 39 40 const DexFile& GetDexFile() const { 41 return *dex_file_; 42 } 43 44 size_t GetElementOffset() const { 45 return element_offset_; 46 } 47 48 DECLARE_INSTRUCTION(ArmDexCacheArraysBase); 49 50 private: 51 const DexFile* dex_file_; 52 size_t element_offset_; 53 54 DISALLOW_COPY_AND_ASSIGN(HArmDexCacheArraysBase); 55 }; 56 57 } // namespace art 58 59 #endif // ART_COMPILER_OPTIMIZING_NODES_ARM_H_ 60