OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64. |
6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
7 | 7 |
8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
9 | 9 #include "vm/cpu.h" |
10 #include "vm/instructions.h" | 10 #include "vm/instructions.h" |
11 #include "vm/object.h" | 11 #include "vm/object.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 RawArray* CodePatcher::GetClosureArgDescAt(uword return_address, | 15 RawArray* CodePatcher::GetClosureArgDescAt(uword return_address, |
16 const Code& code) { | 16 const Code& code) { |
17 ASSERT(code.ContainsInstructionAt(return_address)); | 17 ASSERT(code.ContainsInstructionAt(return_address)); |
18 CallPattern call(return_address, code); | 18 CallPattern call(return_address, code); |
19 return call.ClosureArgumentsDescriptor(); | 19 return call.ClosureArgumentsDescriptor(); |
(...skipping 19 matching lines...) Expand all Loading... |
39 | 39 |
40 void CodePatcher::PatchInstanceCallAt(uword return_address, | 40 void CodePatcher::PatchInstanceCallAt(uword return_address, |
41 const Code& code, | 41 const Code& code, |
42 uword new_target) { | 42 uword new_target) { |
43 ASSERT(code.ContainsInstructionAt(return_address)); | 43 ASSERT(code.ContainsInstructionAt(return_address)); |
44 CallPattern call(return_address, code); | 44 CallPattern call(return_address, code); |
45 call.SetTargetAddress(new_target); | 45 call.SetTargetAddress(new_target); |
46 } | 46 } |
47 | 47 |
48 | 48 |
| 49 class PoolPointerCall : public ValueObject { |
| 50 public: |
| 51 explicit PoolPointerCall(uword pc) : end_(pc) { |
| 52 // Last instruction: blr ip0. |
| 53 ASSERT(*(reinterpret_cast<uint32_t*>(end_) - 1) == 0xd63f0200); |
| 54 InstructionPattern::DecodeLoadWordFromPool( |
| 55 end_ - Instr::kInstrSize, ®_, &index_); |
| 56 } |
| 57 |
| 58 int32_t pp_offset() const { |
| 59 return InstructionPattern::OffsetFromPPIndex(index_); |
| 60 } |
| 61 |
| 62 void set_pp_offset(int32_t offset) const { |
| 63 InstructionPattern::EncodeLoadWordFromPoolFixed( |
| 64 end_ - Instr::kInstrSize, offset); |
| 65 CPU::FlushICache(end_ - kCallPatternSize, kCallPatternSize); |
| 66 } |
| 67 |
| 68 private: |
| 69 static const int kCallPatternSize = 3 * Instr::kInstrSize; |
| 70 uword end_; |
| 71 Register reg_; |
| 72 intptr_t index_; |
| 73 DISALLOW_IMPLICIT_CONSTRUCTORS(PoolPointerCall); |
| 74 }; |
| 75 |
| 76 |
49 int32_t CodePatcher::GetPoolOffsetAt(uword return_address) { | 77 int32_t CodePatcher::GetPoolOffsetAt(uword return_address) { |
50 // TODO(zra): Needed for debugger. | 78 PoolPointerCall call(return_address); |
51 UNIMPLEMENTED(); | 79 return call.pp_offset(); |
52 return 0; | |
53 } | 80 } |
54 | 81 |
55 | 82 |
56 void CodePatcher::SetPoolOffsetAt(uword return_address, int32_t offset) { | 83 void CodePatcher::SetPoolOffsetAt(uword return_address, int32_t offset) { |
57 // TODO(zra): Needed for debugger. | 84 PoolPointerCall call(return_address); |
58 UNIMPLEMENTED(); | 85 call.set_pp_offset(offset); |
59 } | 86 } |
60 | 87 |
61 | 88 |
62 void CodePatcher::InsertCallAt(uword start, uword target) { | 89 void CodePatcher::InsertCallAt(uword start, uword target) { |
63 // The inserted call should not overlap the lazy deopt jump code. | 90 // The inserted call should not overlap the lazy deopt jump code. |
64 ASSERT(start + CallPattern::kLengthInBytes <= target); | 91 ASSERT(start + CallPattern::kLengthInBytes <= target); |
65 CallPattern::InsertAt(start, target); | 92 CallPattern::InsertAt(start, target); |
66 } | 93 } |
67 | 94 |
68 | 95 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 161 |
135 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) { | 162 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) { |
136 ASSERT(code.ContainsInstructionAt(pc)); | 163 ASSERT(code.ContainsInstructionAt(pc)); |
137 EdgeCounter counter(pc, code); | 164 EdgeCounter counter(pc, code); |
138 return counter.edge_counter(); | 165 return counter.edge_counter(); |
139 } | 166 } |
140 | 167 |
141 } // namespace dart | 168 } // namespace dart |
142 | 169 |
143 #endif // defined TARGET_ARCH_ARM64 | 170 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |