OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
7 | 7 |
8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
9 | 9 |
10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 | 80 |
81 // This class pattern matches on a load from the object pool. Loading on | 81 // This class pattern matches on a load from the object pool. Loading on |
82 // ARM is complicated because it can take four possible different forms. We | 82 // ARM is complicated because it can take four possible different forms. We |
83 // match backwards from the end of the sequence so we can reuse the code for | 83 // match backwards from the end of the sequence so we can reuse the code for |
84 // matching object pool loads at calls. | 84 // matching object pool loads at calls. |
85 class EdgeCounter : public ValueObject { | 85 class EdgeCounter : public ValueObject { |
86 public: | 86 public: |
87 EdgeCounter(uword pc, const Code& code) | 87 EdgeCounter(uword pc, const Code& code) |
88 : end_(pc - FlowGraphCompiler::EdgeCounterIncrementSizeInBytes()), | 88 : end_(pc - FlowGraphCompiler::EdgeCounterIncrementSizeInBytes()), |
89 object_pool_(Array::Handle(code.ObjectPool())) { | 89 object_pool_(ObjectPool::Handle(code.GetObjectPool())) { |
90 // An IsValid predicate is complicated and duplicates the code in the | 90 // An IsValid predicate is complicated and duplicates the code in the |
91 // decoding function. Instead we rely on decoding the pattern which | 91 // decoding function. Instead we rely on decoding the pattern which |
92 // will assert partial validity. | 92 // will assert partial validity. |
93 } | 93 } |
94 | 94 |
95 RawObject* edge_counter() const { | 95 RawObject* edge_counter() const { |
96 Register ignored; | 96 Register ignored; |
97 intptr_t index; | 97 intptr_t index; |
98 InstructionPattern::DecodeLoadWordFromPool(end_, &ignored, &index); | 98 InstructionPattern::DecodeLoadWordFromPool(end_, &ignored, &index); |
99 ASSERT(ignored == R0); | 99 ASSERT(ignored == R0); |
100 return object_pool_.At(index); | 100 return object_pool_.ObjectAt(index); |
101 } | 101 } |
102 | 102 |
103 private: | 103 private: |
104 // The object pool load is followed by the fixed-size edge counter | 104 // The object pool load is followed by the fixed-size edge counter |
105 // incrementing code: | 105 // incrementing code: |
106 // ldr ip, [r0, #+11] | 106 // ldr ip, [r0, #+11] |
107 // adds ip, ip, #2 | 107 // adds ip, ip, #2 |
108 // str ip, [r0, #+11] | 108 // str ip, [r0, #+11] |
109 static const intptr_t kAdjust = 3 * Instr::kInstrSize; | 109 static const intptr_t kAdjust = 3 * Instr::kInstrSize; |
110 | 110 |
111 uword end_; | 111 uword end_; |
112 const Array& object_pool_; | 112 const ObjectPool& object_pool_; |
113 }; | 113 }; |
114 | 114 |
115 | 115 |
116 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) { | 116 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) { |
117 ASSERT(code.ContainsInstructionAt(pc)); | 117 ASSERT(code.ContainsInstructionAt(pc)); |
118 EdgeCounter counter(pc, code); | 118 EdgeCounter counter(pc, code); |
119 return counter.edge_counter(); | 119 return counter.edge_counter(); |
120 } | 120 } |
121 | 121 |
122 } // namespace dart | 122 } // namespace dart |
123 | 123 |
124 #endif // defined TARGET_ARCH_ARM | 124 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |