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

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

Issue 1439893002: - Annotate instructions that load objects from the ObjectPool or Thread. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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/instructions.h ('k') | runtime/vm/instructions_arm64.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) 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/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/constants_arm.h" 9 #include "vm/constants_arm.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 ASSERT((instr & 0xfff00000) == 0xe3000000); // movw reg, #imm_lo 162 ASSERT((instr & 0xfff00000) == 0xe3000000); // movw reg, #imm_lo
163 imm |= (instr & 0xf0000) >> 4; 163 imm |= (instr & 0xf0000) >> 4;
164 imm |= instr & 0xfff; 164 imm |= instr & 0xfff;
165 *reg = static_cast<Register>((instr & 0xf000) >> 12); 165 *reg = static_cast<Register>((instr & 0xf000) >> 12);
166 *value = imm; 166 *value = imm;
167 } 167 }
168 return start; 168 return start;
169 } 169 }
170 170
171 171
172 static bool IsLoadWithOffset(int32_t instr, Register base,
173 intptr_t* offset, Register* dst) {
174 if ((instr & 0xffff0000) == (0xe5900000 | (base << 16))) {
175 // ldr reg, [base, #+offset]
176 *offset = instr & 0xfff;
177 *dst = static_cast<Register>((instr & 0xf000) >> 12);
178 return true;
179 }
180 return false;
181 }
182
183
172 // Decodes a load sequence ending at 'end' (the last instruction of the load 184 // Decodes a load sequence ending at 'end' (the last instruction of the load
173 // sequence is the instruction before the one at end). Returns a pointer to 185 // sequence is the instruction before the one at end). Returns a pointer to
174 // the first instruction in the sequence. Returns the register being loaded 186 // the first instruction in the sequence. Returns the register being loaded
175 // and the index in the pool being read from in the output parameters 'reg' 187 // and the index in the pool being read from in the output parameters 'reg'
176 // and 'index' respectively. 188 // and 'index' respectively.
177 uword InstructionPattern::DecodeLoadWordFromPool(uword end, 189 uword InstructionPattern::DecodeLoadWordFromPool(uword end,
178 Register* reg, 190 Register* reg,
179 intptr_t* index) { 191 intptr_t* index) {
180 uword start = end - Instr::kInstrSize; 192 uword start = end - Instr::kInstrSize;
181 int32_t instr = Instr::At(start)->InstructionBits(); 193 int32_t instr = Instr::At(start)->InstructionBits();
182 intptr_t offset = 0; 194 intptr_t offset = 0;
183 if ((instr & 0xffff0000) == (0xe5950000 | (PP << 16))) { 195 if (IsLoadWithOffset(instr, PP, &offset, reg)) {
184 // ldr reg, [pp, #+offset] 196 // ldr reg, [PP, #+offset]
185 offset = instr & 0xfff;
186 *reg = static_cast<Register>((instr & 0xf000) >> 12);
187 } else { 197 } else {
188 ASSERT((instr & 0xfff00000) == 0xe5900000); // ldr reg, [reg, #+offset] 198 ASSERT((instr & 0xfff00000) == 0xe5900000); // ldr reg, [reg, #+offset]
189 offset = instr & 0xfff; 199 offset = instr & 0xfff;
190 start -= Instr::kInstrSize; 200 start -= Instr::kInstrSize;
191 instr = Instr::At(start)->InstructionBits(); 201 instr = Instr::At(start)->InstructionBits();
192 if ((instr & 0xffff0000) == (0xe2850000 | (PP << 16))) { 202 if ((instr & 0xffff0000) == (0xe2850000 | (PP << 16))) {
193 // add reg, pp, operand 203 // add reg, pp, operand
194 const intptr_t rot = (instr & 0xf00) >> 7; 204 const intptr_t rot = (instr & 0xf00) >> 7;
195 const intptr_t imm8 = instr & 0xff; 205 const intptr_t imm8 = instr & 0xff;
196 offset += (imm8 >> rot) | (imm8 << (32 - rot)); 206 offset += (imm8 >> rot) | (imm8 << (32 - rot));
197 *reg = static_cast<Register>((instr & 0xf000) >> 12); 207 *reg = static_cast<Register>((instr & 0xf000) >> 12);
198 } else { 208 } else {
199 ASSERT((instr & 0xffff0000) == (0xe0800000 | (PP << 16))); 209 ASSERT((instr & 0xffff0000) == (0xe0800000 | (PP << 16)));
200 // add reg, pp, reg 210 // add reg, pp, reg
201 end = DecodeLoadWordImmediate(end, reg, &offset); 211 end = DecodeLoadWordImmediate(end, reg, &offset);
202 } 212 }
203 } 213 }
204 *index = ObjectPool::IndexFromOffset(offset); 214 *index = ObjectPool::IndexFromOffset(offset);
205 return start; 215 return start;
206 } 216 }
207 217
208 218
219 bool DecodeLoadObjectFromPoolOrThread(uword pc,
220 const Code& code,
221 Object* obj) {
222 ASSERT(code.ContainsInstructionAt(pc));
223
224 int32_t instr = Instr::At(pc)->InstructionBits();
225 intptr_t offset;
226 Register dst;
227 if (IsLoadWithOffset(instr, PP, &offset, &dst)) {
228 intptr_t index = ObjectPool::IndexFromOffset(offset);
229 const ObjectPool& pool = ObjectPool::Handle(code.object_pool());
230 if (pool.InfoAt(index) == ObjectPool::kTaggedObject) {
231 *obj = pool.ObjectAt(index);
232 return true;
233 }
234 } else if (IsLoadWithOffset(instr, THR, &offset, &dst)) {
235 return Thread::ObjectAtOffset(offset, obj);
236 }
237 // TODO(rmacnak): Sequence for loads beyond 12 bits.
238
239 return false;
240 }
241
242
209 RawICData* CallPattern::IcData() { 243 RawICData* CallPattern::IcData() {
210 if (ic_data_.IsNull()) { 244 if (ic_data_.IsNull()) {
211 Register reg; 245 Register reg;
212 InstructionPattern::DecodeLoadObject(ic_data_load_end_, 246 InstructionPattern::DecodeLoadObject(ic_data_load_end_,
213 object_pool_, 247 object_pool_,
214 &reg, 248 &reg,
215 &ic_data_); 249 &ic_data_);
216 ASSERT(reg == R9); 250 ASSERT(reg == R9);
217 } 251 }
218 return ic_data_.raw(); 252 return ic_data_.raw();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 } else { 365 } else {
332 ASSERT(version == ARMv7); 366 ASSERT(version == ARMv7);
333 return bx_lr->InstructionBits() == instruction; 367 return bx_lr->InstructionBits() == instruction;
334 } 368 }
335 return false; 369 return false;
336 } 370 }
337 371
338 } // namespace dart 372 } // namespace dart
339 373
340 #endif // defined TARGET_ARCH_ARM 374 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/instructions.h ('k') | runtime/vm/instructions_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698