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

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

Issue 2226893002: Optimize AOT's switchable calls for the monomorphic case. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync Created 4 years, 4 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/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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 *reinterpret_cast<uword*>(pc + (2 * Instr::kInstrSize)) = blx_ip; 302 *reinterpret_cast<uword*>(pc + (2 * Instr::kInstrSize)) = blx_ip;
303 303
304 ASSERT(DeoptCallPatternLengthInBytes() == 3 * Instr::kInstrSize); 304 ASSERT(DeoptCallPatternLengthInBytes() == 3 * Instr::kInstrSize);
305 CPU::FlushICache(pc, DeoptCallPatternLengthInBytes()); 305 CPU::FlushICache(pc, DeoptCallPatternLengthInBytes());
306 } 306 }
307 } 307 }
308 308
309 309
310 SwitchableCallPattern::SwitchableCallPattern(uword pc, const Code& code) 310 SwitchableCallPattern::SwitchableCallPattern(uword pc, const Code& code)
311 : object_pool_(ObjectPool::Handle(code.GetObjectPool())), 311 : object_pool_(ObjectPool::Handle(code.GetObjectPool())),
312 cache_pool_index_(-1), 312 data_pool_index_(-1),
313 stub_pool_index_(-1) { 313 target_pool_index_(-1) {
314 ASSERT(code.ContainsInstructionAt(pc)); 314 ASSERT(code.ContainsInstructionAt(pc));
315 // Last instruction: blx r1. 315 // Last instruction: blx lr.
316 ASSERT(*(reinterpret_cast<uword*>(pc) - 1) == 0xe12fff31); 316 ASSERT(*(reinterpret_cast<uword*>(pc) - 1) == 0xe12fff3e);
317 317
318 Register reg; 318 Register reg;
319 uword stub_load_end = 319 uword stub_load_end =
320 InstructionPattern::DecodeLoadWordFromPool(pc - 3 * Instr::kInstrSize, 320 InstructionPattern::DecodeLoadWordFromPool(pc - 2 * Instr::kInstrSize,
321 &reg, 321 &reg,
322 &stub_pool_index_); 322 &target_pool_index_);
323 ASSERT(reg == CODE_REG); 323 ASSERT(reg == CODE_REG);
324 InstructionPattern::DecodeLoadWordFromPool(stub_load_end, 324 InstructionPattern::DecodeLoadWordFromPool(stub_load_end,
325 &reg, 325 &reg,
326 &cache_pool_index_); 326 &data_pool_index_);
327 ASSERT(reg == R9); 327 ASSERT(reg == R9);
328 } 328 }
329 329
330 330
331 RawObject* SwitchableCallPattern::cache() const { 331 RawObject* SwitchableCallPattern::data() const {
332 return reinterpret_cast<RawCode*>( 332 return object_pool_.ObjectAt(data_pool_index_);
333 object_pool_.ObjectAt(cache_pool_index_));
334 } 333 }
335 334
336 335
337 void SwitchableCallPattern::SetCache(const MegamorphicCache& cache) const { 336 RawCode* SwitchableCallPattern::target() const {
338 ASSERT(Object::Handle(object_pool_.ObjectAt(cache_pool_index_)).IsICData()); 337 return reinterpret_cast<RawCode*>(
339 object_pool_.SetObjectAt(cache_pool_index_, cache); 338 object_pool_.ObjectAt(target_pool_index_));
340 } 339 }
341 340
342 341
343 void SwitchableCallPattern::SetLookupStub(const Code& lookup_stub) const { 342 void SwitchableCallPattern::SetData(const Object& data) const {
344 ASSERT(Object::Handle(object_pool_.ObjectAt(stub_pool_index_)).IsCode()); 343 ASSERT(!Object::Handle(object_pool_.ObjectAt(data_pool_index_)).IsCode());
345 object_pool_.SetObjectAt(stub_pool_index_, lookup_stub); 344 object_pool_.SetObjectAt(data_pool_index_, data);
346 } 345 }
347 346
348 347
348 void SwitchableCallPattern::SetTarget(const Code& target) const {
349 ASSERT(Object::Handle(object_pool_.ObjectAt(target_pool_index_)).IsCode());
350 object_pool_.SetObjectAt(target_pool_index_, target);
351 }
352
353
349 ReturnPattern::ReturnPattern(uword pc) 354 ReturnPattern::ReturnPattern(uword pc)
350 : pc_(pc) { 355 : pc_(pc) {
351 } 356 }
352 357
353 358
354 bool ReturnPattern::IsValid() const { 359 bool ReturnPattern::IsValid() const {
355 Instr* bx_lr = Instr::At(pc_); 360 Instr* bx_lr = Instr::At(pc_);
356 const int32_t B4 = 1 << 4; 361 const int32_t B4 = 1 << 4;
357 const int32_t B21 = 1 << 21; 362 const int32_t B21 = 1 << 21;
358 const int32_t B24 = 1 << 24; 363 const int32_t B24 = 1 << 24;
359 int32_t instruction = (static_cast<int32_t>(AL) << kConditionShift) | 364 int32_t instruction = (static_cast<int32_t>(AL) << kConditionShift) |
360 B24 | B21 | (0xfff << 8) | B4 | 365 B24 | B21 | (0xfff << 8) | B4 |
361 (static_cast<int32_t>(LR) << kRmShift); 366 (static_cast<int32_t>(LR) << kRmShift);
362 const ARMVersion version = TargetCPUFeatures::arm_version(); 367 const ARMVersion version = TargetCPUFeatures::arm_version();
363 if ((version == ARMv5TE) || (version == ARMv6)) { 368 if ((version == ARMv5TE) || (version == ARMv6)) {
364 return bx_lr->InstructionBits() == instruction; 369 return bx_lr->InstructionBits() == instruction;
365 } else { 370 } else {
366 ASSERT(version == ARMv7); 371 ASSERT(version == ARMv7);
367 return bx_lr->InstructionBits() == instruction; 372 return bx_lr->InstructionBits() == instruction;
368 } 373 }
369 return false; 374 return false;
370 } 375 }
371 376
372 } // namespace dart 377 } // namespace dart
373 378
374 #endif // defined TARGET_ARCH_ARM 379 #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