• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 FINAL : public HExpression<0> {
23  public:
HArmDexCacheArraysBase(const DexFile & dex_file)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 
CanBeMoved()29   bool CanBeMoved() const OVERRIDE { return true; }
30 
UpdateElementOffset(size_t element_offset)31   void UpdateElementOffset(size_t element_offset) {
32     // Use the lowest offset from the requested elements so that all offsets from
33     // this base are non-negative because our assemblers emit negative-offset loads
34     // as a sequence of two or more instructions. (However, positive offsets beyond
35     // 4KiB also require two or more instructions, so this simple heuristic could
36     // be improved for cases where there is a dense cluster of elements far from
37     // the lowest offset. This is expected to be rare enough though, so we choose
38     // not to spend compile time on elaborate calculations.)
39     element_offset_ = std::min(element_offset_, element_offset);
40   }
41 
GetDexFile()42   const DexFile& GetDexFile() const {
43     return *dex_file_;
44   }
45 
GetElementOffset()46   size_t GetElementOffset() const {
47     return element_offset_;
48   }
49 
50   DECLARE_INSTRUCTION(ArmDexCacheArraysBase);
51 
52  private:
53   const DexFile* dex_file_;
54   size_t element_offset_;
55 
56   DISALLOW_COPY_AND_ASSIGN(HArmDexCacheArraysBase);
57 };
58 
59 }  // namespace art
60 
61 #endif  // ART_COMPILER_OPTIMIZING_NODES_ARM_H_
62