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

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

Issue 1418863003: Precompilation: Generate instance calls as IC calls that can switch to Megamoprhic calls. (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_arm.h ('k') | runtime/vm/instructions_arm64.h » ('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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 *reinterpret_cast<uword*>(pc + (0 * Instr::kInstrSize)) = movw_ip; 266 *reinterpret_cast<uword*>(pc + (0 * Instr::kInstrSize)) = movw_ip;
267 *reinterpret_cast<uword*>(pc + (1 * Instr::kInstrSize)) = movt_ip; 267 *reinterpret_cast<uword*>(pc + (1 * Instr::kInstrSize)) = movt_ip;
268 *reinterpret_cast<uword*>(pc + (2 * Instr::kInstrSize)) = blx_ip; 268 *reinterpret_cast<uword*>(pc + (2 * Instr::kInstrSize)) = blx_ip;
269 269
270 ASSERT(DeoptCallPatternLengthInBytes() == 3 * Instr::kInstrSize); 270 ASSERT(DeoptCallPatternLengthInBytes() == 3 * Instr::kInstrSize);
271 CPU::FlushICache(pc, DeoptCallPatternLengthInBytes()); 271 CPU::FlushICache(pc, DeoptCallPatternLengthInBytes());
272 } 272 }
273 } 273 }
274 274
275 275
276 SwitchableCallPattern::SwitchableCallPattern(uword pc, const Code& code)
277 : object_pool_(ObjectPool::Handle(code.GetObjectPool())),
278 cache_pool_index_(-1),
279 stub_pool_index_(-1) {
280 ASSERT(code.ContainsInstructionAt(pc));
281 // Last instruction: blx r1.
282 ASSERT(*(reinterpret_cast<uword*>(pc) - 1) == 0xe12fff31);
283
284 Register reg;
285 uword stub_load_end =
286 InstructionPattern::DecodeLoadWordFromPool(pc - 3 * Instr::kInstrSize,
287 &reg,
288 &stub_pool_index_);
289 ASSERT(reg == CODE_REG);
290 InstructionPattern::DecodeLoadWordFromPool(stub_load_end,
291 &reg,
292 &cache_pool_index_);
293 ASSERT(reg == R9);
294 }
295
296
297 RawObject* SwitchableCallPattern::cache() const {
298 return reinterpret_cast<RawCode*>(
299 object_pool_.ObjectAt(cache_pool_index_));
300 }
301
302
303 void SwitchableCallPattern::SetCache(const MegamorphicCache& cache) const {
304 ASSERT(Object::Handle(object_pool_.ObjectAt(cache_pool_index_)).IsICData());
305 object_pool_.SetObjectAt(cache_pool_index_, cache);
306 }
307
308
309 void SwitchableCallPattern::SetLookupStub(const Code& lookup_stub) const {
310 ASSERT(Object::Handle(object_pool_.ObjectAt(stub_pool_index_)).IsCode());
311 object_pool_.SetObjectAt(stub_pool_index_, lookup_stub);
312 }
313
314
276 ReturnPattern::ReturnPattern(uword pc) 315 ReturnPattern::ReturnPattern(uword pc)
277 : pc_(pc) { 316 : pc_(pc) {
278 } 317 }
279 318
280 319
281 bool ReturnPattern::IsValid() const { 320 bool ReturnPattern::IsValid() const {
282 Instr* bx_lr = Instr::At(pc_); 321 Instr* bx_lr = Instr::At(pc_);
283 const int32_t B4 = 1 << 4; 322 const int32_t B4 = 1 << 4;
284 const int32_t B21 = 1 << 21; 323 const int32_t B21 = 1 << 21;
285 const int32_t B24 = 1 << 24; 324 const int32_t B24 = 1 << 24;
286 int32_t instruction = (static_cast<int32_t>(AL) << kConditionShift) | 325 int32_t instruction = (static_cast<int32_t>(AL) << kConditionShift) |
287 B24 | B21 | (0xfff << 8) | B4 | 326 B24 | B21 | (0xfff << 8) | B4 |
288 (static_cast<int32_t>(LR) << kRmShift); 327 (static_cast<int32_t>(LR) << kRmShift);
289 const ARMVersion version = TargetCPUFeatures::arm_version(); 328 const ARMVersion version = TargetCPUFeatures::arm_version();
290 if ((version == ARMv5TE) || (version == ARMv6)) { 329 if ((version == ARMv5TE) || (version == ARMv6)) {
291 return bx_lr->InstructionBits() == instruction; 330 return bx_lr->InstructionBits() == instruction;
292 } else { 331 } else {
293 ASSERT(version == ARMv7); 332 ASSERT(version == ARMv7);
294 return bx_lr->InstructionBits() == instruction; 333 return bx_lr->InstructionBits() == instruction;
295 } 334 }
296 return false; 335 return false;
297 } 336 }
298 337
299 } // namespace dart 338 } // namespace dart
300 339
301 #endif // defined TARGET_ARCH_ARM 340 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/instructions_arm.h ('k') | runtime/vm/instructions_arm64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698