OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. | |
6 #if defined(TARGET_ARCH_MIPS) | |
7 | |
8 #include "vm/code_patcher.h" | |
9 | |
10 #include "vm/instructions.h" | |
11 #include "vm/object.h" | |
12 | |
13 namespace dart { | |
14 | |
15 RawCode* CodePatcher::GetStaticCallTargetAt(uword return_address, | |
16 const Code& code) { | |
17 ASSERT(code.ContainsInstructionAt(return_address)); | |
18 CallPattern call(return_address, code); | |
19 return call.TargetCode(); | |
20 } | |
21 | |
22 | |
23 void CodePatcher::PatchStaticCallAt(uword return_address, | |
24 const Code& code, | |
25 const Code& new_target) { | |
26 ASSERT(code.ContainsInstructionAt(return_address)); | |
27 CallPattern call(return_address, code); | |
28 call.SetTargetCode(new_target); | |
29 } | |
30 | |
31 | |
32 void CodePatcher::InsertDeoptimizationCallAt(uword start) { | |
33 UNREACHABLE(); | |
34 } | |
35 | |
36 | |
37 RawCode* CodePatcher::GetInstanceCallAt(uword return_address, | |
38 const Code& code, | |
39 ICData* ic_data) { | |
40 ASSERT(code.ContainsInstructionAt(return_address)); | |
41 CallPattern call(return_address, code); | |
42 if (ic_data != NULL) { | |
43 *ic_data = call.IcData(); | |
44 } | |
45 return call.TargetCode(); | |
46 } | |
47 | |
48 | |
49 intptr_t CodePatcher::InstanceCallSizeInBytes() { | |
50 // The instance call instruction sequence has a variable size on MIPS. | |
51 UNREACHABLE(); | |
52 return 0; | |
53 } | |
54 | |
55 | |
56 RawFunction* CodePatcher::GetUnoptimizedStaticCallAt(uword return_address, | |
57 const Code& code, | |
58 ICData* ic_data_result) { | |
59 ASSERT(code.ContainsInstructionAt(return_address)); | |
60 CallPattern static_call(return_address, code); | |
61 ICData& ic_data = ICData::Handle(); | |
62 ic_data ^= static_call.IcData(); | |
63 if (ic_data_result != NULL) { | |
64 *ic_data_result = ic_data.raw(); | |
65 } | |
66 return ic_data.GetTargetAt(0); | |
67 } | |
68 | |
69 | |
70 void CodePatcher::PatchSwitchableCallAt(uword return_address, | |
71 const Code& caller_code, | |
72 const Object& data, | |
73 const Code& target) { | |
74 ASSERT(caller_code.ContainsInstructionAt(return_address)); | |
75 SwitchableCallPattern call(return_address, caller_code); | |
76 call.SetData(data); | |
77 call.SetTarget(target); | |
78 } | |
79 | |
80 | |
81 RawCode* CodePatcher::GetSwitchableCallTargetAt(uword return_address, | |
82 const Code& caller_code) { | |
83 ASSERT(caller_code.ContainsInstructionAt(return_address)); | |
84 SwitchableCallPattern call(return_address, caller_code); | |
85 return call.target(); | |
86 } | |
87 | |
88 | |
89 RawObject* CodePatcher::GetSwitchableCallDataAt(uword return_address, | |
90 const Code& caller_code) { | |
91 ASSERT(caller_code.ContainsInstructionAt(return_address)); | |
92 SwitchableCallPattern call(return_address, caller_code); | |
93 return call.data(); | |
94 } | |
95 | |
96 | |
97 void CodePatcher::PatchNativeCallAt(uword return_address, | |
98 const Code& code, | |
99 NativeFunction target, | |
100 const Code& trampoline) { | |
101 ASSERT(code.ContainsInstructionAt(return_address)); | |
102 NativeCallPattern call(return_address, code); | |
103 call.set_target(trampoline); | |
104 call.set_native_function(target); | |
105 } | |
106 | |
107 | |
108 RawCode* CodePatcher::GetNativeCallAt(uword return_address, | |
109 const Code& code, | |
110 NativeFunction* target) { | |
111 ASSERT(code.ContainsInstructionAt(return_address)); | |
112 NativeCallPattern call(return_address, code); | |
113 *target = call.native_function(); | |
114 return call.target(); | |
115 } | |
116 | |
117 } // namespace dart | |
118 | |
119 #endif // defined TARGET_ARCH_MIPS | |
OLD | NEW |