• 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_LINKER_ARM_RELATIVE_PATCHER_THUMB2_H_
18 #define ART_COMPILER_LINKER_ARM_RELATIVE_PATCHER_THUMB2_H_
19 
20 #include "linker/arm/relative_patcher_arm_base.h"
21 
22 namespace art {
23 namespace linker {
24 
25 class Thumb2RelativePatcher FINAL : public ArmBaseRelativePatcher {
26  public:
27   explicit Thumb2RelativePatcher(RelativePatcherTargetProvider* provider);
28 
29   void PatchCall(std::vector<uint8_t>* code,
30                  uint32_t literal_offset,
31                  uint32_t patch_offset,
32                  uint32_t target_offset) OVERRIDE;
33   void PatchPcRelativeReference(std::vector<uint8_t>* code,
34                                 const LinkerPatch& patch,
35                                 uint32_t patch_offset,
36                                 uint32_t target_offset) OVERRIDE;
37   void PatchBakerReadBarrierBranch(std::vector<uint8_t>* code,
38                                    const LinkerPatch& patch,
39                                    uint32_t patch_offset) OVERRIDE;
40 
41  protected:
42   ThunkKey GetBakerReadBarrierKey(const LinkerPatch& patch) OVERRIDE;
43   std::vector<uint8_t> CompileThunk(const ThunkKey& key) OVERRIDE;
44   uint32_t MaxPositiveDisplacement(ThunkType type) OVERRIDE;
45   uint32_t MaxNegativeDisplacement(ThunkType type) OVERRIDE;
46 
47  private:
48   void SetInsn32(std::vector<uint8_t>* code, uint32_t offset, uint32_t value);
49   static uint32_t GetInsn32(ArrayRef<const uint8_t> code, uint32_t offset);
50 
51   template <typename Vector>
52   static uint32_t GetInsn32(Vector* code, uint32_t offset);
53 
54   friend class Thumb2RelativePatcherTest;
55 
56   DISALLOW_COPY_AND_ASSIGN(Thumb2RelativePatcher);
57 };
58 
59 }  // namespace linker
60 }  // namespace art
61 
62 #endif  // ART_COMPILER_LINKER_ARM_RELATIVE_PATCHER_THUMB2_H_
63