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

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

Issue 1192103004: VM: New calling convention for generated code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: ARM64 port Created 5 years, 3 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
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_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 9
10 #include "vm/instructions.h" 10 #include "vm/instructions.h"
11 #include "vm/object.h" 11 #include "vm/object.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 uword CodePatcher::GetStaticCallTargetAt(uword return_address, 15 RawCode* CodePatcher::GetStaticCallTargetAt(uword return_address,
16 const Code& code) { 16 const Code& code) {
17 ASSERT(code.ContainsInstructionAt(return_address)); 17 ASSERT(code.ContainsInstructionAt(return_address));
18 CallPattern call(return_address, code); 18 CallPattern call(return_address, code);
19 return call.TargetAddress(); 19 return call.TargetCode();
20 } 20 }
21 21
22 22
23 void CodePatcher::PatchStaticCallAt(uword return_address, 23 void CodePatcher::PatchStaticCallAt(uword return_address,
24 const Code& code, 24 const Code& code,
25 uword new_target) { 25 const Code& new_target) {
26 ASSERT(code.ContainsInstructionAt(return_address)); 26 ASSERT(code.ContainsInstructionAt(return_address));
27 CallPattern call(return_address, code); 27 CallPattern call(return_address, code);
28 call.SetTargetAddress(new_target); 28 call.SetTargetCode(new_target);
29 } 29 }
30 30
31 31
32 void CodePatcher::PatchInstanceCallAt(uword return_address, 32 void CodePatcher::PatchInstanceCallAt(uword return_address,
33 const Code& code, 33 const Code& code,
34 uword new_target) { 34 const Code& new_target) {
35 ASSERT(code.ContainsInstructionAt(return_address)); 35 ASSERT(code.ContainsInstructionAt(return_address));
36 CallPattern call(return_address, code); 36 CallPattern call(return_address, code);
37 call.SetTargetAddress(new_target); 37 call.SetTargetCode(new_target);
38 } 38 }
39 39
40 40
41 void CodePatcher::InsertCallAt(uword start, uword target) { 41 void CodePatcher::InsertDeoptimizationCallAt(uword start, uword target) {
42 // The inserted call should not overlap the lazy deopt jump code. 42 // The inserted call should not overlap the lazy deopt jump code.
43 ASSERT(start + CallPattern::kFixedLengthInBytes <= target); 43 ASSERT(start + CallPattern::kDeoptCallLengthInBytes <= target);
44 CallPattern::InsertAt(start, target); 44 CallPattern::InsertDeoptCallAt(start, target);
45 } 45 }
46 46
47 47
48 uword CodePatcher::GetInstanceCallAt(uword return_address, 48 RawCode* CodePatcher::GetInstanceCallAt(uword return_address,
49 const Code& code, 49 const Code& code,
50 ICData* ic_data) { 50 ICData* ic_data) {
51 ASSERT(code.ContainsInstructionAt(return_address)); 51 ASSERT(code.ContainsInstructionAt(return_address));
52 CallPattern call(return_address, code); 52 CallPattern call(return_address, code);
53 if (ic_data != NULL) { 53 if (ic_data != NULL) {
54 *ic_data = call.IcData(); 54 *ic_data = call.IcData();
55 } 55 }
56 return call.TargetAddress(); 56 return call.TargetCode();
57 } 57 }
58 58
59 59
60 intptr_t CodePatcher::InstanceCallSizeInBytes() { 60 intptr_t CodePatcher::InstanceCallSizeInBytes() {
61 // The instance call instruction sequence has a variable size on MIPS. 61 // The instance call instruction sequence has a variable size on MIPS.
62 UNREACHABLE(); 62 UNREACHABLE();
63 return 0; 63 return 0;
64 } 64 }
65 65
66 66
67 RawFunction* CodePatcher::GetUnoptimizedStaticCallAt( 67 RawFunction* CodePatcher::GetUnoptimizedStaticCallAt(
68 uword return_address, const Code& code, ICData* ic_data_result) { 68 uword return_address, const Code& code, ICData* ic_data_result) {
69 ASSERT(code.ContainsInstructionAt(return_address)); 69 ASSERT(code.ContainsInstructionAt(return_address));
70 CallPattern static_call(return_address, code); 70 CallPattern static_call(return_address, code);
71 ICData& ic_data = ICData::Handle(); 71 ICData& ic_data = ICData::Handle();
72 ic_data ^= static_call.IcData(); 72 ic_data ^= static_call.IcData();
73 if (ic_data_result != NULL) { 73 if (ic_data_result != NULL) {
74 *ic_data_result = ic_data.raw(); 74 *ic_data_result = ic_data.raw();
75 } 75 }
76 return ic_data.GetTargetAt(0); 76 return ic_data.GetTargetAt(0);
77 } 77 }
78 78
79 79
80 void CodePatcher::PatchNativeCallAt(uword return_address, 80 void CodePatcher::PatchNativeCallAt(uword return_address,
81 const Code& code, 81 const Code& code,
82 NativeFunction target, 82 NativeFunction target,
83 const Code& trampoline) { 83 const Code& trampoline) {
84 ASSERT(code.ContainsInstructionAt(return_address)); 84 ASSERT(code.ContainsInstructionAt(return_address));
85 NativeCallPattern call(return_address, code); 85 NativeCallPattern call(return_address, code);
86 call.set_target(trampoline.EntryPoint()); 86 call.set_target(trampoline);
87 call.set_native_function(target); 87 call.set_native_function(target);
88 } 88 }
89 89
90 90
91 uword CodePatcher::GetNativeCallAt(uword return_address, 91 RawCode* CodePatcher::GetNativeCallAt(uword return_address,
92 const Code& code, 92 const Code& code,
93 NativeFunction* target) { 93 NativeFunction* target) {
94 ASSERT(code.ContainsInstructionAt(return_address)); 94 ASSERT(code.ContainsInstructionAt(return_address));
95 NativeCallPattern call(return_address, code); 95 NativeCallPattern call(return_address, code);
96 *target = call.native_function(); 96 *target = call.native_function();
97 return call.target(); 97 return call.target();
98 } 98 }
99 99
100 100
101 // This class pattern matches on a load from the object pool. Loading on 101 // This class pattern matches on a load from the object pool. Loading on
102 // MIPS is complicated because it can take four possible different forms. 102 // MIPS is complicated because it can take four possible different forms.
103 // We match backwards from the end of the sequence so we can reuse the code 103 // We match backwards from the end of the sequence so we can reuse the code
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) { 136 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) {
137 ASSERT(code.ContainsInstructionAt(pc)); 137 ASSERT(code.ContainsInstructionAt(pc));
138 EdgeCounter counter(pc, code); 138 EdgeCounter counter(pc, code);
139 return counter.edge_counter(); 139 return counter.edge_counter();
140 } 140 }
141 141
142 } // namespace dart 142 } // namespace dart
143 143
144 #endif // defined TARGET_ARCH_MIPS 144 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698