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

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

Issue 1294113004: VM: Link native calls lazily. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comments Created 5 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_arm64.h ('k') | runtime/vm/instructions_mips.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) 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 14 matching lines...) Expand all
25 25
26 Register reg; 26 Register reg;
27 ic_data_load_end_ = 27 ic_data_load_end_ =
28 InstructionPattern::DecodeLoadWordFromPool(end_ - Instr::kInstrSize, 28 InstructionPattern::DecodeLoadWordFromPool(end_ - Instr::kInstrSize,
29 &reg, 29 &reg,
30 &target_address_pool_index_); 30 &target_address_pool_index_);
31 ASSERT(reg == IP0); 31 ASSERT(reg == IP0);
32 } 32 }
33 33
34 34
35 NativeCallPattern::NativeCallPattern(uword pc, const Code& code)
36 : object_pool_(ObjectPool::Handle(code.GetObjectPool())),
37 end_(pc),
38 native_function_pool_index_(-1),
39 target_address_pool_index_(-1) {
40 ASSERT(code.ContainsInstructionAt(pc));
41 // Last instruction: blr ip0.
42 ASSERT(*(reinterpret_cast<uint32_t*>(end_) - 1) == 0xd63f0200);
43
44 Register reg;
45 uword native_function_load_end =
46 InstructionPattern::DecodeLoadWordFromPool(end_ - Instr::kInstrSize,
47 &reg,
48 &target_address_pool_index_);
49 ASSERT(reg == IP0);
50 InstructionPattern::DecodeLoadWordFromPool(native_function_load_end,
51 &reg,
52 &native_function_pool_index_);
53 ASSERT(reg == R5);
54 }
55
56
57 uword NativeCallPattern::target() const {
58 return object_pool_.RawValueAt(target_address_pool_index_);
59 }
60
61
62 void NativeCallPattern::set_target(uword target_address) const {
63 object_pool_.SetRawValueAt(target_address_pool_index_, target_address);
64 // No need to flush the instruction cache, since the code is not modified.
65 }
66
67
68 NativeFunction NativeCallPattern::native_function() const {
69 return reinterpret_cast<NativeFunction>(
70 object_pool_.RawValueAt(native_function_pool_index_));
71 }
72
73
74 void NativeCallPattern::set_native_function(NativeFunction func) const {
75 object_pool_.SetRawValueAt(native_function_pool_index_,
76 reinterpret_cast<uword>(func));
77 }
78
79
35 intptr_t InstructionPattern::OffsetFromPPIndex(intptr_t index) { 80 intptr_t InstructionPattern::OffsetFromPPIndex(intptr_t index) {
36 return Array::element_offset(index); 81 return Array::element_offset(index);
37 } 82 }
38 83
39 84
40 // Decodes a load sequence ending at 'end' (the last instruction of the load 85 // Decodes a load sequence ending at 'end' (the last instruction of the load
41 // sequence is the instruction before the one at end). Returns a pointer to 86 // sequence is the instruction before the one at end). Returns a pointer to
42 // the first instruction in the sequence. Returns the register being loaded 87 // the first instruction in the sequence. Returns the register being loaded
43 // and the loaded object in the output parameters 'reg' and 'obj' 88 // and the loaded object in the output parameters 'reg' and 'obj'
44 // respectively. 89 // respectively.
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 bool ReturnPattern::IsValid() const { 395 bool ReturnPattern::IsValid() const {
351 Instr* bx_lr = Instr::At(pc_); 396 Instr* bx_lr = Instr::At(pc_);
352 const Register crn = ConcreteRegister(LR); 397 const Register crn = ConcreteRegister(LR);
353 const int32_t instruction = RET | (static_cast<int32_t>(crn) << kRnShift); 398 const int32_t instruction = RET | (static_cast<int32_t>(crn) << kRnShift);
354 return bx_lr->InstructionBits() == instruction; 399 return bx_lr->InstructionBits() == instruction;
355 } 400 }
356 401
357 } // namespace dart 402 } // namespace dart
358 403
359 #endif // defined TARGET_ARCH_ARM64 404 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/instructions_arm64.h ('k') | runtime/vm/instructions_mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698