Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: runtime/vm/code_patcher_arm64.cc

Issue 1343383003: VM: Store edge counters in one per-function array. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/code_patcher_arm.cc ('k') | runtime/vm/code_patcher_ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/instructions.h" 10 #include "vm/instructions.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 RawCode* CodePatcher::GetNativeCallAt(uword return_address, 123 RawCode* CodePatcher::GetNativeCallAt(uword return_address,
124 const Code& code, 124 const Code& code,
125 NativeFunction* target) { 125 NativeFunction* target) {
126 ASSERT(code.ContainsInstructionAt(return_address)); 126 ASSERT(code.ContainsInstructionAt(return_address));
127 NativeCallPattern call(return_address, code); 127 NativeCallPattern call(return_address, code);
128 *target = call.native_function(); 128 *target = call.native_function();
129 return call.target(); 129 return call.target();
130 } 130 }
131 131
132
133 // This class pattern matches on a load from the object pool. Loading on
134 // ARM64 is complicated because it can take more than one form. We
135 // match backwards from the end of the sequence so we can reuse the code for
136 // matching object pool loads at calls.
137 class EdgeCounter : public ValueObject {
138 public:
139 EdgeCounter(uword pc, const Code& code)
140 : end_(pc - kAdjust),
141 object_pool_(ObjectPool::Handle(code.GetObjectPool())) {
142 // An IsValid predicate is complicated and duplicates the code in the
143 // decoding function. Instead we rely on decoding the pattern which
144 // will assert partial validity.
145 }
146
147 RawObject* edge_counter() const {
148 Register ignored;
149 intptr_t index;
150 InstructionPattern::DecodeLoadWordFromPool(end_, &ignored, &index);
151 ASSERT(ignored == R0);
152 return object_pool_.ObjectAt(index);
153 }
154
155 private:
156 // The object pool load is followed by the fixed-size edge counter
157 // incrementing code:
158 // ldr ip, [r0, #+11]
159 // adds ip, ip, #2
160 // str ip, [r0, #+11]
161 static const intptr_t kAdjust = 3 * Instr::kInstrSize;
162
163 uword end_;
164 const ObjectPool& object_pool_;
165 };
166
167
168 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) {
169 ASSERT(code.ContainsInstructionAt(pc));
170 EdgeCounter counter(pc, code);
171 return counter.edge_counter();
172 }
173
174 } // namespace dart 132 } // namespace dart
175 133
176 #endif // defined TARGET_ARCH_ARM64 134 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/code_patcher_arm.cc ('k') | runtime/vm/code_patcher_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698