OLD | NEW |
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/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/constants_arm64.h" | 9 #include "vm/constants_arm64.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 movk1->SetMoveWideBits(MOVK, IP0, h1, 1, kDoubleWord); | 322 movk1->SetMoveWideBits(MOVK, IP0, h1, 1, kDoubleWord); |
323 movk2->SetMoveWideBits(MOVK, IP0, h2, 2, kDoubleWord); | 323 movk2->SetMoveWideBits(MOVK, IP0, h2, 2, kDoubleWord); |
324 movk3->SetMoveWideBits(MOVK, IP0, h3, 3, kDoubleWord); | 324 movk3->SetMoveWideBits(MOVK, IP0, h3, 3, kDoubleWord); |
325 blr->SetUnconditionalBranchRegBits(BLR, IP0); | 325 blr->SetUnconditionalBranchRegBits(BLR, IP0); |
326 | 326 |
327 ASSERT(kDeoptCallLengthInBytes == 5 * Instr::kInstrSize); | 327 ASSERT(kDeoptCallLengthInBytes == 5 * Instr::kInstrSize); |
328 CPU::FlushICache(pc, kDeoptCallLengthInBytes); | 328 CPU::FlushICache(pc, kDeoptCallLengthInBytes); |
329 } | 329 } |
330 | 330 |
331 | 331 |
| 332 SwitchableCallPattern::SwitchableCallPattern(uword pc, const Code& code) |
| 333 : object_pool_(ObjectPool::Handle(code.GetObjectPool())), |
| 334 cache_pool_index_(-1), |
| 335 stub_pool_index_(-1) { |
| 336 ASSERT(code.ContainsInstructionAt(pc)); |
| 337 // Last instruction: blr r1. |
| 338 ASSERT(*(reinterpret_cast<uint32_t*>(pc) - 1) == 0xd63f0020); |
| 339 |
| 340 Register reg; |
| 341 uword stub_load_end = |
| 342 InstructionPattern::DecodeLoadWordFromPool(pc - 3 * Instr::kInstrSize, |
| 343 ®, |
| 344 &stub_pool_index_); |
| 345 ASSERT(reg == CODE_REG); |
| 346 InstructionPattern::DecodeLoadWordFromPool(stub_load_end, |
| 347 ®, |
| 348 &cache_pool_index_); |
| 349 ASSERT(reg == R5); |
| 350 } |
| 351 |
| 352 |
| 353 RawObject* SwitchableCallPattern::cache() const { |
| 354 return reinterpret_cast<RawCode*>( |
| 355 object_pool_.ObjectAt(cache_pool_index_)); |
| 356 } |
| 357 |
| 358 |
| 359 void SwitchableCallPattern::SetCache(const MegamorphicCache& cache) const { |
| 360 ASSERT(Object::Handle(object_pool_.ObjectAt(cache_pool_index_)).IsICData()); |
| 361 object_pool_.SetObjectAt(cache_pool_index_, cache); |
| 362 } |
| 363 |
| 364 |
| 365 void SwitchableCallPattern::SetLookupStub(const Code& lookup_stub) const { |
| 366 ASSERT(Object::Handle(object_pool_.ObjectAt(stub_pool_index_)).IsCode()); |
| 367 object_pool_.SetObjectAt(stub_pool_index_, lookup_stub); |
| 368 } |
| 369 |
| 370 |
332 ReturnPattern::ReturnPattern(uword pc) | 371 ReturnPattern::ReturnPattern(uword pc) |
333 : pc_(pc) { | 372 : pc_(pc) { |
334 } | 373 } |
335 | 374 |
336 | 375 |
337 bool ReturnPattern::IsValid() const { | 376 bool ReturnPattern::IsValid() const { |
338 Instr* bx_lr = Instr::At(pc_); | 377 Instr* bx_lr = Instr::At(pc_); |
339 const Register crn = ConcreteRegister(LR); | 378 const Register crn = ConcreteRegister(LR); |
340 const int32_t instruction = RET | (static_cast<int32_t>(crn) << kRnShift); | 379 const int32_t instruction = RET | (static_cast<int32_t>(crn) << kRnShift); |
341 return bx_lr->InstructionBits() == instruction; | 380 return bx_lr->InstructionBits() == instruction; |
342 } | 381 } |
343 | 382 |
344 } // namespace dart | 383 } // namespace dart |
345 | 384 |
346 #endif // defined TARGET_ARCH_ARM64 | 385 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |