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

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

Issue 77413004: Pushes 0 for PC marker in runtime call stubs on ARM and MIPS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/stub_code_arm.cc ('k') | no next file » | 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" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 21 matching lines...) Expand all
32 // SP : address of last argument in argument array. 32 // SP : address of last argument in argument array.
33 // SP + 4*S4 - 4 : address of first argument in argument array. 33 // SP + 4*S4 - 4 : address of first argument in argument array.
34 // SP + 4*S4 : address of return value. 34 // SP + 4*S4 : address of return value.
35 // S5 : address of the runtime function to call. 35 // S5 : address of the runtime function to call.
36 // S4 : number of arguments to the call. 36 // S4 : number of arguments to the call.
37 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { 37 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) {
38 const intptr_t isolate_offset = NativeArguments::isolate_offset(); 38 const intptr_t isolate_offset = NativeArguments::isolate_offset();
39 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); 39 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset();
40 const intptr_t argv_offset = NativeArguments::argv_offset(); 40 const intptr_t argv_offset = NativeArguments::argv_offset();
41 const intptr_t retval_offset = NativeArguments::retval_offset(); 41 const intptr_t retval_offset = NativeArguments::retval_offset();
42 const intptr_t exitframe_last_param_slot_from_fp = 1; 42 const intptr_t exitframe_last_param_slot_from_fp = 2;
43 43
44 __ SetPrologueOffset(); 44 __ SetPrologueOffset();
45 __ TraceSimMsg("CallToRuntimeStub"); 45 __ TraceSimMsg("CallToRuntimeStub");
46 __ EnterFrame(); 46 __ addiu(SP, SP, Immediate(-3 * kWordSize));
47 __ sw(ZR, Address(SP, 2 * kWordSize)); // Push 0 for the PC marker
48 __ sw(RA, Address(SP, 1 * kWordSize));
49 __ sw(FP, Address(SP, 0 * kWordSize));
50 __ mov(FP, SP);
47 51
48 // Load current Isolate pointer from Context structure into A0. 52 // Load current Isolate pointer from Context structure into A0.
49 __ lw(A0, FieldAddress(CTX, Context::isolate_offset())); 53 __ lw(A0, FieldAddress(CTX, Context::isolate_offset()));
50 54
51 // Save exit frame information to enable stack walking as we are about 55 // Save exit frame information to enable stack walking as we are about
52 // to transition to Dart VM C++ code. 56 // to transition to Dart VM C++ code.
53 __ sw(SP, Address(A0, Isolate::top_exit_frame_info_offset())); 57 __ sw(SP, Address(A0, Isolate::top_exit_frame_info_offset()));
54 58
55 // Save current Context pointer into Isolate structure. 59 // Save current Context pointer into Isolate structure.
56 __ sw(CTX, Address(A0, Isolate::top_context_offset())); 60 __ sw(CTX, Address(A0, Isolate::top_context_offset()));
(...skipping 16 matching lines...) Expand all
73 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. 77 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_.
74 ASSERT(argc_tag_offset == 1 * kWordSize); 78 ASSERT(argc_tag_offset == 1 * kWordSize);
75 __ mov(A1, S4); // Set argc in NativeArguments. 79 __ mov(A1, S4); // Set argc in NativeArguments.
76 80
77 ASSERT(argv_offset == 2 * kWordSize); 81 ASSERT(argv_offset == 2 * kWordSize);
78 __ sll(A2, S4, 2); 82 __ sll(A2, S4, 2);
79 __ addu(A2, FP, A2); // Compute argv. 83 __ addu(A2, FP, A2); // Compute argv.
80 // Set argv in NativeArguments. 84 // Set argv in NativeArguments.
81 __ addiu(A2, A2, Immediate(exitframe_last_param_slot_from_fp * kWordSize)); 85 __ addiu(A2, A2, Immediate(exitframe_last_param_slot_from_fp * kWordSize));
82 86
83 ASSERT(retval_offset == 3 * kWordSize);
84
85 // Call runtime or redirection via simulator. 87 // Call runtime or redirection via simulator.
86 __ jalr(S5); 88 __ jalr(S5);
89 ASSERT(retval_offset == 3 * kWordSize);
87 // Retval is next to 1st argument. 90 // Retval is next to 1st argument.
88 __ delay_slot()->addiu(A3, A2, Immediate(kWordSize)); 91 __ delay_slot()->addiu(A3, A2, Immediate(kWordSize));
89 __ TraceSimMsg("CallToRuntimeStub return"); 92 __ TraceSimMsg("CallToRuntimeStub return");
90 93
91 // Reset exit frame information in Isolate structure. 94 // Reset exit frame information in Isolate structure.
92 __ sw(ZR, Address(CTX, Isolate::top_exit_frame_info_offset())); 95 __ sw(ZR, Address(CTX, Isolate::top_exit_frame_info_offset()));
93 96
94 // Load Context pointer from Isolate structure into A2. 97 // Load Context pointer from Isolate structure into A2.
95 __ lw(A2, Address(CTX, Isolate::top_context_offset())); 98 __ lw(A2, Address(CTX, Isolate::top_context_offset()));
96 99
97 // Load null. 100 // Load null.
98 __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null())); 101 __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null()));
99 102
100 // Reset Context pointer in Isolate structure. 103 // Reset Context pointer in Isolate structure.
101 __ sw(TMP, Address(CTX, Isolate::top_context_offset())); 104 __ sw(TMP, Address(CTX, Isolate::top_context_offset()));
102 105
103 // Cache Context pointer into CTX while executing Dart code. 106 // Cache Context pointer into CTX while executing Dart code.
104 __ mov(CTX, A2); 107 __ mov(CTX, A2);
105 108
106 __ LeaveFrameAndReturn(); 109 __ mov(SP, FP);
110 __ lw(RA, Address(SP, 1 * kWordSize));
111 __ lw(FP, Address(SP, 0 * kWordSize));
112 __ Ret();
113 __ delay_slot()->addiu(SP, SP, Immediate(3 * kWordSize));
107 } 114 }
108 115
109 116
110 // Print the stop message. 117 // Print the stop message.
111 DEFINE_LEAF_RUNTIME_ENTRY(void, PrintStopMessage, 1, const char* message) { 118 DEFINE_LEAF_RUNTIME_ENTRY(void, PrintStopMessage, 1, const char* message) {
112 OS::Print("Stop message: %s\n", message); 119 OS::Print("Stop message: %s\n", message);
113 } 120 }
114 END_LEAF_RUNTIME_ENTRY 121 END_LEAF_RUNTIME_ENTRY
115 122
116 123
(...skipping 16 matching lines...) Expand all
133 // A2 : address of first argument in argument array. 140 // A2 : address of first argument in argument array.
134 // A1 : argc_tag including number of arguments and function kind. 141 // A1 : argc_tag including number of arguments and function kind.
135 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) { 142 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) {
136 const intptr_t isolate_offset = NativeArguments::isolate_offset(); 143 const intptr_t isolate_offset = NativeArguments::isolate_offset();
137 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); 144 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset();
138 const intptr_t argv_offset = NativeArguments::argv_offset(); 145 const intptr_t argv_offset = NativeArguments::argv_offset();
139 const intptr_t retval_offset = NativeArguments::retval_offset(); 146 const intptr_t retval_offset = NativeArguments::retval_offset();
140 147
141 __ SetPrologueOffset(); 148 __ SetPrologueOffset();
142 __ TraceSimMsg("CallNativeCFunctionStub"); 149 __ TraceSimMsg("CallNativeCFunctionStub");
143 __ EnterFrame(); 150 __ addiu(SP, SP, Immediate(-3 * kWordSize));
151 __ sw(ZR, Address(SP, 2 * kWordSize)); // Push 0 for the PC marker
152 __ sw(RA, Address(SP, 1 * kWordSize));
153 __ sw(FP, Address(SP, 0 * kWordSize));
154 __ mov(FP, SP);
144 155
145 // Load current Isolate pointer from Context structure into A0. 156 // Load current Isolate pointer from Context structure into A0.
146 __ lw(A0, FieldAddress(CTX, Context::isolate_offset())); 157 __ lw(A0, FieldAddress(CTX, Context::isolate_offset()));
147 158
148 // Save exit frame information to enable stack walking as we are about 159 // Save exit frame information to enable stack walking as we are about
149 // to transition to native code. 160 // to transition to native code.
150 __ sw(SP, Address(A0, Isolate::top_exit_frame_info_offset())); 161 __ sw(SP, Address(A0, Isolate::top_exit_frame_info_offset()));
151 162
152 // Save current Context pointer into Isolate structure. 163 // Save current Context pointer into Isolate structure.
153 __ sw(CTX, Address(A0, Isolate::top_context_offset())); 164 __ sw(CTX, Address(A0, Isolate::top_context_offset()));
154 165
155 // Cache Isolate pointer into CTX while executing native code. 166 // Cache Isolate pointer into CTX while executing native code.
156 __ mov(CTX, A0); 167 __ mov(CTX, A0);
157 168
158 // Initialize NativeArguments structure and call native function. 169 // Initialize NativeArguments structure and call native function.
159 // Registers A0, A1, A2, and A3 are used. 170 // Registers A0, A1, A2, and A3 are used.
160 171
161 ASSERT(isolate_offset == 0 * kWordSize); 172 ASSERT(isolate_offset == 0 * kWordSize);
162 // Set isolate in NativeArgs: A0 already contains CTX. 173 // Set isolate in NativeArgs: A0 already contains CTX.
163 174
164 // There are no native calls to closures, so we do not need to set the tag 175 // There are no native calls to closures, so we do not need to set the tag
165 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. 176 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_.
166 ASSERT(argc_tag_offset == 1 * kWordSize); 177 ASSERT(argc_tag_offset == 1 * kWordSize);
167 // Set argc in NativeArguments: A1 already contains argc. 178 // Set argc in NativeArguments: A1 already contains argc.
168 179
169 ASSERT(argv_offset == 2 * kWordSize); 180 ASSERT(argv_offset == 2 * kWordSize);
170 // Set argv in NativeArguments: A2 already contains argv. 181 // Set argv in NativeArguments: A2 already contains argv.
171 182
172 ASSERT(retval_offset == 3 * kWordSize); 183 ASSERT(retval_offset == 3 * kWordSize);
173 __ addiu(A3, FP, Immediate(2 * kWordSize)); // Set retval in NativeArgs. 184 __ addiu(A3, FP, Immediate(3 * kWordSize)); // Set retval in NativeArgs.
174 185
175 // TODO(regis): Should we pass the structure by value as in runtime calls? 186 // TODO(regis): Should we pass the structure by value as in runtime calls?
176 // It would require changing Dart API for native functions. 187 // It would require changing Dart API for native functions.
177 // For now, space is reserved on the stack and we pass a pointer to it. 188 // For now, space is reserved on the stack and we pass a pointer to it.
178 __ addiu(SP, SP, Immediate(-4 * kWordSize)); 189 __ addiu(SP, SP, Immediate(-4 * kWordSize));
179 __ sw(A3, Address(SP, 3 * kWordSize)); 190 __ sw(A3, Address(SP, 3 * kWordSize));
180 __ sw(A2, Address(SP, 2 * kWordSize)); 191 __ sw(A2, Address(SP, 2 * kWordSize));
181 __ sw(A1, Address(SP, 1 * kWordSize)); 192 __ sw(A1, Address(SP, 1 * kWordSize));
182 __ sw(A0, Address(SP, 0 * kWordSize)); 193 __ sw(A0, Address(SP, 0 * kWordSize));
183 __ mov(A0, SP); // Pass the pointer to the NativeArguments. 194 __ mov(A0, SP); // Pass the pointer to the NativeArguments.
(...skipping 21 matching lines...) Expand all
205 216
206 // Load null. 217 // Load null.
207 __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null())); 218 __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null()));
208 219
209 // Reset Context pointer in Isolate structure. 220 // Reset Context pointer in Isolate structure.
210 __ sw(TMP, Address(CTX, Isolate::top_context_offset())); 221 __ sw(TMP, Address(CTX, Isolate::top_context_offset()));
211 222
212 // Cache Context pointer into CTX while executing Dart code. 223 // Cache Context pointer into CTX while executing Dart code.
213 __ mov(CTX, A2); 224 __ mov(CTX, A2);
214 225
215 __ LeaveFrameAndReturn(); 226 __ mov(SP, FP);
227 __ lw(RA, Address(SP, 1 * kWordSize));
228 __ lw(FP, Address(SP, 0 * kWordSize));
229 __ Ret();
230 __ delay_slot()->addiu(SP, SP, Immediate(3 * kWordSize));
216 } 231 }
217 232
218 233
219 // Input parameters: 234 // Input parameters:
220 // RA : return address. 235 // RA : return address.
221 // SP : address of return value. 236 // SP : address of return value.
222 // T5 : address of the native function to call. 237 // T5 : address of the native function to call.
223 // A2 : address of first argument in argument array. 238 // A2 : address of first argument in argument array.
224 // A1 : argc_tag including number of arguments and function kind. 239 // A1 : argc_tag including number of arguments and function kind.
225 void StubCode::GenerateCallBootstrapCFunctionStub(Assembler* assembler) { 240 void StubCode::GenerateCallBootstrapCFunctionStub(Assembler* assembler) {
226 const intptr_t isolate_offset = NativeArguments::isolate_offset(); 241 const intptr_t isolate_offset = NativeArguments::isolate_offset();
227 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); 242 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset();
228 const intptr_t argv_offset = NativeArguments::argv_offset(); 243 const intptr_t argv_offset = NativeArguments::argv_offset();
229 const intptr_t retval_offset = NativeArguments::retval_offset(); 244 const intptr_t retval_offset = NativeArguments::retval_offset();
230 245
231 __ SetPrologueOffset(); 246 __ SetPrologueOffset();
232 __ TraceSimMsg("CallNativeCFunctionStub"); 247 __ TraceSimMsg("CallNativeCFunctionStub");
233 __ EnterFrame(); 248 __ addiu(SP, SP, Immediate(-3 * kWordSize));
249 __ sw(ZR, Address(SP, 2 * kWordSize)); // Push 0 for the PC marker
250 __ sw(RA, Address(SP, 1 * kWordSize));
251 __ sw(FP, Address(SP, 0 * kWordSize));
252 __ mov(FP, SP);
234 253
235 // Load current Isolate pointer from Context structure into A0. 254 // Load current Isolate pointer from Context structure into A0.
236 __ lw(A0, FieldAddress(CTX, Context::isolate_offset())); 255 __ lw(A0, FieldAddress(CTX, Context::isolate_offset()));
237 256
238 // Save exit frame information to enable stack walking as we are about 257 // Save exit frame information to enable stack walking as we are about
239 // to transition to native code. 258 // to transition to native code.
240 __ sw(SP, Address(A0, Isolate::top_exit_frame_info_offset())); 259 __ sw(SP, Address(A0, Isolate::top_exit_frame_info_offset()));
241 260
242 // Save current Context pointer into Isolate structure. 261 // Save current Context pointer into Isolate structure.
243 __ sw(CTX, Address(A0, Isolate::top_context_offset())); 262 __ sw(CTX, Address(A0, Isolate::top_context_offset()));
244 263
245 // Cache Isolate pointer into CTX while executing native code. 264 // Cache Isolate pointer into CTX while executing native code.
246 __ mov(CTX, A0); 265 __ mov(CTX, A0);
247 266
248 // Initialize NativeArguments structure and call native function. 267 // Initialize NativeArguments structure and call native function.
249 // Registers A0, A1, A2, and A3 are used. 268 // Registers A0, A1, A2, and A3 are used.
250 269
251 ASSERT(isolate_offset == 0 * kWordSize); 270 ASSERT(isolate_offset == 0 * kWordSize);
252 // Set isolate in NativeArgs: A0 already contains CTX. 271 // Set isolate in NativeArgs: A0 already contains CTX.
253 272
254 // There are no native calls to closures, so we do not need to set the tag 273 // There are no native calls to closures, so we do not need to set the tag
255 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. 274 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_.
256 ASSERT(argc_tag_offset == 1 * kWordSize); 275 ASSERT(argc_tag_offset == 1 * kWordSize);
257 // Set argc in NativeArguments: A1 already contains argc. 276 // Set argc in NativeArguments: A1 already contains argc.
258 277
259 ASSERT(argv_offset == 2 * kWordSize); 278 ASSERT(argv_offset == 2 * kWordSize);
260 // Set argv in NativeArguments: A2 already contains argv. 279 // Set argv in NativeArguments: A2 already contains argv.
261 280
262 ASSERT(retval_offset == 3 * kWordSize); 281 ASSERT(retval_offset == 3 * kWordSize);
263 __ addiu(A3, FP, Immediate(2 * kWordSize)); // Set retval in NativeArgs. 282 __ addiu(A3, FP, Immediate(3 * kWordSize)); // Set retval in NativeArgs.
264 283
265 // TODO(regis): Should we pass the structure by value as in runtime calls? 284 // TODO(regis): Should we pass the structure by value as in runtime calls?
266 // It would require changing Dart API for native functions. 285 // It would require changing Dart API for native functions.
267 // For now, space is reserved on the stack and we pass a pointer to it. 286 // For now, space is reserved on the stack and we pass a pointer to it.
268 __ addiu(SP, SP, Immediate(-4 * kWordSize)); 287 __ addiu(SP, SP, Immediate(-4 * kWordSize));
269 __ sw(A3, Address(SP, 3 * kWordSize)); 288 __ sw(A3, Address(SP, 3 * kWordSize));
270 __ sw(A2, Address(SP, 2 * kWordSize)); 289 __ sw(A2, Address(SP, 2 * kWordSize));
271 __ sw(A1, Address(SP, 1 * kWordSize)); 290 __ sw(A1, Address(SP, 1 * kWordSize));
272 __ sw(A0, Address(SP, 0 * kWordSize)); 291 __ sw(A0, Address(SP, 0 * kWordSize));
273 __ mov(A0, SP); // Pass the pointer to the NativeArguments. 292 __ mov(A0, SP); // Pass the pointer to the NativeArguments.
(...skipping 12 matching lines...) Expand all
286 305
287 // Load null. 306 // Load null.
288 __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null())); 307 __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null()));
289 308
290 // Reset Context pointer in Isolate structure. 309 // Reset Context pointer in Isolate structure.
291 __ sw(TMP, Address(CTX, Isolate::top_context_offset())); 310 __ sw(TMP, Address(CTX, Isolate::top_context_offset()));
292 311
293 // Cache Context pointer into CTX while executing Dart code. 312 // Cache Context pointer into CTX while executing Dart code.
294 __ mov(CTX, A2); 313 __ mov(CTX, A2);
295 314
296 __ LeaveFrameAndReturn(); 315 __ mov(SP, FP);
316 __ lw(RA, Address(SP, 1 * kWordSize));
317 __ lw(FP, Address(SP, 0 * kWordSize));
318 __ Ret();
319 __ delay_slot()->addiu(SP, SP, Immediate(3 * kWordSize));
297 } 320 }
298 321
299 322
300 // Input parameters: 323 // Input parameters:
301 // S4: arguments descriptor array. 324 // S4: arguments descriptor array.
302 void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) { 325 void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) {
303 __ TraceSimMsg("CallStaticFunctionStub"); 326 __ TraceSimMsg("CallStaticFunctionStub");
304 __ EnterStubFrame(); 327 __ EnterStubFrame();
305 // Setup space on stack for return value and preserve arguments descriptor. 328 // Setup space on stack for return value and preserve arguments descriptor.
306 329
(...skipping 2104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2411 const Register right = T0; 2434 const Register right = T0;
2412 __ lw(left, Address(SP, 1 * kWordSize)); 2435 __ lw(left, Address(SP, 1 * kWordSize));
2413 __ lw(right, Address(SP, 0 * kWordSize)); 2436 __ lw(right, Address(SP, 0 * kWordSize));
2414 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp1, temp2); 2437 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp1, temp2);
2415 __ Ret(); 2438 __ Ret();
2416 } 2439 }
2417 2440
2418 } // namespace dart 2441 } // namespace dart
2419 2442
2420 #endif // defined TARGET_ARCH_MIPS 2443 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_arm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698