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

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: fixed comments 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
« no previous file with comments | « runtime/vm/code_patcher_ia32.cc ('k') | runtime/vm/code_patcher_x64.cc » ('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_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::InsertDeoptimizationCallAt(uword start, uword target) {
33 const Code& code, 33 // The inserted call should not overlap the lazy deopt jump code.
34 uword new_target) { 34 ASSERT(start + CallPattern::kDeoptCallLengthInBytes <= target);
35 ASSERT(code.ContainsInstructionAt(return_address)); 35 CallPattern::InsertDeoptCallAt(start, target);
36 CallPattern call(return_address, code);
37 call.SetTargetAddress(new_target);
38 } 36 }
39 37
40 38
41 void CodePatcher::InsertCallAt(uword start, uword target) { 39 RawCode* CodePatcher::GetInstanceCallAt(uword return_address,
42 // The inserted call should not overlap the lazy deopt jump code. 40 const Code& code,
43 ASSERT(start + CallPattern::kFixedLengthInBytes <= target); 41 ICData* ic_data) {
44 CallPattern::InsertAt(start, target);
45 }
46
47
48 uword CodePatcher::GetInstanceCallAt(uword return_address,
49 const Code& code,
50 ICData* ic_data) {
51 ASSERT(code.ContainsInstructionAt(return_address)); 42 ASSERT(code.ContainsInstructionAt(return_address));
52 CallPattern call(return_address, code); 43 CallPattern call(return_address, code);
53 if (ic_data != NULL) { 44 if (ic_data != NULL) {
54 *ic_data = call.IcData(); 45 *ic_data = call.IcData();
55 } 46 }
56 return call.TargetAddress(); 47 return call.TargetCode();
57 } 48 }
58 49
59 50
60 intptr_t CodePatcher::InstanceCallSizeInBytes() { 51 intptr_t CodePatcher::InstanceCallSizeInBytes() {
61 // The instance call instruction sequence has a variable size on MIPS. 52 // The instance call instruction sequence has a variable size on MIPS.
62 UNREACHABLE(); 53 UNREACHABLE();
63 return 0; 54 return 0;
64 } 55 }
65 56
66 57
67 RawFunction* CodePatcher::GetUnoptimizedStaticCallAt( 58 RawFunction* CodePatcher::GetUnoptimizedStaticCallAt(
68 uword return_address, const Code& code, ICData* ic_data_result) { 59 uword return_address, const Code& code, ICData* ic_data_result) {
69 ASSERT(code.ContainsInstructionAt(return_address)); 60 ASSERT(code.ContainsInstructionAt(return_address));
70 CallPattern static_call(return_address, code); 61 CallPattern static_call(return_address, code);
71 ICData& ic_data = ICData::Handle(); 62 ICData& ic_data = ICData::Handle();
72 ic_data ^= static_call.IcData(); 63 ic_data ^= static_call.IcData();
73 if (ic_data_result != NULL) { 64 if (ic_data_result != NULL) {
74 *ic_data_result = ic_data.raw(); 65 *ic_data_result = ic_data.raw();
75 } 66 }
76 return ic_data.GetTargetAt(0); 67 return ic_data.GetTargetAt(0);
77 } 68 }
78 69
79 70
80 void CodePatcher::PatchNativeCallAt(uword return_address, 71 void CodePatcher::PatchNativeCallAt(uword return_address,
81 const Code& code, 72 const Code& code,
82 NativeFunction target, 73 NativeFunction target,
83 const Code& trampoline) { 74 const Code& trampoline) {
84 ASSERT(code.ContainsInstructionAt(return_address)); 75 ASSERT(code.ContainsInstructionAt(return_address));
85 NativeCallPattern call(return_address, code); 76 NativeCallPattern call(return_address, code);
86 call.set_target(trampoline.EntryPoint()); 77 call.set_target(trampoline);
87 call.set_native_function(target); 78 call.set_native_function(target);
88 } 79 }
89 80
90 81
91 uword CodePatcher::GetNativeCallAt(uword return_address, 82 RawCode* CodePatcher::GetNativeCallAt(uword return_address,
92 const Code& code, 83 const Code& code,
93 NativeFunction* target) { 84 NativeFunction* target) {
94 ASSERT(code.ContainsInstructionAt(return_address)); 85 ASSERT(code.ContainsInstructionAt(return_address));
95 NativeCallPattern call(return_address, code); 86 NativeCallPattern call(return_address, code);
96 *target = call.native_function(); 87 *target = call.native_function();
97 return call.target(); 88 return call.target();
98 } 89 }
99 90
100 91
101 // This class pattern matches on a load from the object pool. Loading on 92 // 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. 93 // 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 94 // 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 126
136 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) { 127 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) {
137 ASSERT(code.ContainsInstructionAt(pc)); 128 ASSERT(code.ContainsInstructionAt(pc));
138 EdgeCounter counter(pc, code); 129 EdgeCounter counter(pc, code);
139 return counter.edge_counter(); 130 return counter.edge_counter();
140 } 131 }
141 132
142 } // namespace dart 133 } // namespace dart
143 134
144 #endif // defined TARGET_ARCH_MIPS 135 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/code_patcher_ia32.cc ('k') | runtime/vm/code_patcher_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698