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

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
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // sequence is the instruction before the one at end). Returns a pointer to 173 // 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 174 // 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' 175 // and the index in the pool being read from in the output parameters 'reg'
176 // and 'index' respectively. 176 // and 'index' respectively.
177 uword InstructionPattern::DecodeLoadWordFromPool(uword end, 177 uword InstructionPattern::DecodeLoadWordFromPool(uword end,
178 Register* reg, 178 Register* reg,
179 intptr_t* index) { 179 intptr_t* index) {
180 uword start = end - Instr::kInstrSize; 180 uword start = end - Instr::kInstrSize;
181 int32_t instr = Instr::At(start)->InstructionBits(); 181 int32_t instr = Instr::At(start)->InstructionBits();
182 intptr_t offset = 0; 182 intptr_t offset = 0;
183 if ((instr & 0xffff0000) == (0xe5950000 | (PP << 16))) { 183 if ((instr & 0xffff0000) == (0xe5900000 | (PP << 16))) {
Cutch 2015/11/12 17:33:52 How about a kConst for these patterns?
rmacnak 2015/11/12 21:50:46 Extracted as IsLoadWithOffset
184 // ldr reg, [pp, #+offset] 184 // ldr reg, [pp, #+offset]
185 offset = instr & 0xfff; 185 offset = instr & 0xfff;
186 *reg = static_cast<Register>((instr & 0xf000) >> 12); 186 *reg = static_cast<Register>((instr & 0xf000) >> 12);
187 } else { 187 } else {
188 ASSERT((instr & 0xfff00000) == 0xe5900000); // ldr reg, [reg, #+offset] 188 ASSERT((instr & 0xfff00000) == 0xe5900000); // ldr reg, [reg, #+offset]
189 offset = instr & 0xfff; 189 offset = instr & 0xfff;
190 start -= Instr::kInstrSize; 190 start -= Instr::kInstrSize;
191 instr = Instr::At(start)->InstructionBits(); 191 instr = Instr::At(start)->InstructionBits();
192 if ((instr & 0xffff0000) == (0xe2850000 | (PP << 16))) { 192 if ((instr & 0xffff0000) == (0xe2850000 | (PP << 16))) {
193 // add reg, pp, operand 193 // add reg, pp, operand
194 const intptr_t rot = (instr & 0xf00) >> 7; 194 const intptr_t rot = (instr & 0xf00) >> 7;
195 const intptr_t imm8 = instr & 0xff; 195 const intptr_t imm8 = instr & 0xff;
196 offset += (imm8 >> rot) | (imm8 << (32 - rot)); 196 offset += (imm8 >> rot) | (imm8 << (32 - rot));
197 *reg = static_cast<Register>((instr & 0xf000) >> 12); 197 *reg = static_cast<Register>((instr & 0xf000) >> 12);
198 } else { 198 } else {
199 ASSERT((instr & 0xffff0000) == (0xe0800000 | (PP << 16))); 199 ASSERT((instr & 0xffff0000) == (0xe0800000 | (PP << 16)));
200 // add reg, pp, reg 200 // add reg, pp, reg
201 end = DecodeLoadWordImmediate(end, reg, &offset); 201 end = DecodeLoadWordImmediate(end, reg, &offset);
202 } 202 }
203 } 203 }
204 *index = ObjectPool::IndexFromOffset(offset); 204 *index = ObjectPool::IndexFromOffset(offset);
205 return start; 205 return start;
206 } 206 }
207 207
208 208
209 bool DecodeLoadObjectFromPoolOrThread(uword pc,
210 const Code& code,
211 Object* obj) {
212 ASSERT(code.ContainsInstructionAt(pc));
213
214 int32_t instr = Instr::At(pc)->InstructionBits();
215 if ((instr & 0xffff0000) == (0xe5900000 | (PP << 16))) {
216 // ldr reg, [pp, #+offset]
217 intptr_t offset = instr & 0xfff;
218 intptr_t index = ObjectPool::IndexFromOffset(offset);
219 const ObjectPool& pool = ObjectPool::Handle(code.object_pool());
220 if (pool.InfoAt(index) == ObjectPool::kTaggedObject) {
221 *obj = pool.ObjectAt(index);
222 return true;
223 }
224 } else if ((instr & 0xffff0000) == (0xe5900000 | (THR << 16))) {
225 // ldr reg, [thr, #+offset]
226 intptr_t offset = instr & 0xfff;
227 return Thread::ObjectAtOffset(offset, obj);
228 }
229 // TODO(rmacnak): Sequence for loads beyond 12 bits.
230
231 return false;
232 }
233
234
209 RawICData* CallPattern::IcData() { 235 RawICData* CallPattern::IcData() {
210 if (ic_data_.IsNull()) { 236 if (ic_data_.IsNull()) {
211 Register reg; 237 Register reg;
212 InstructionPattern::DecodeLoadObject(ic_data_load_end_, 238 InstructionPattern::DecodeLoadObject(ic_data_load_end_,
213 object_pool_, 239 object_pool_,
214 &reg, 240 &reg,
215 &ic_data_); 241 &ic_data_);
216 ASSERT(reg == R9); 242 ASSERT(reg == R9);
217 } 243 }
218 return ic_data_.raw(); 244 return ic_data_.raw();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 } else { 357 } else {
332 ASSERT(version == ARMv7); 358 ASSERT(version == ARMv7);
333 return bx_lr->InstructionBits() == instruction; 359 return bx_lr->InstructionBits() == instruction;
334 } 360 }
335 return false; 361 return false;
336 } 362 }
337 363
338 } // namespace dart 364 } // namespace dart
339 365
340 #endif // defined TARGET_ARCH_ARM 366 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698