OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 // Note on Mips implementation: | 7 // Note on Mips implementation: |
8 // | 8 // |
9 // The result_register() for mips is the 'v0' register, which is defined | 9 // The result_register() for mips is the 'v0' register, which is defined |
10 // by the ABI to contain function return values. However, the first | 10 // by the ABI to contain function return values. However, the first |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 180 } |
181 int remaining = locals_count % kMaxPushes; | 181 int remaining = locals_count % kMaxPushes; |
182 // Emit the remaining pushes. | 182 // Emit the remaining pushes. |
183 __ Dsubu(sp, sp, Operand(remaining * kPointerSize)); | 183 __ Dsubu(sp, sp, Operand(remaining * kPointerSize)); |
184 for (int i = 0; i < remaining; i++) { | 184 for (int i = 0; i < remaining; i++) { |
185 __ sd(t1, MemOperand(sp, i * kPointerSize)); | 185 __ sd(t1, MemOperand(sp, i * kPointerSize)); |
186 } | 186 } |
187 } | 187 } |
188 } | 188 } |
189 | 189 |
190 bool function_in_register = true; | 190 bool function_in_register_a1 = true; |
191 | 191 |
192 // Possibly allocate a local context. | 192 // Possibly allocate a local context. |
193 if (info->scope()->num_heap_slots() > 0) { | 193 if (info->scope()->num_heap_slots() > 0) { |
194 Comment cmnt(masm_, "[ Allocate context"); | 194 Comment cmnt(masm_, "[ Allocate context"); |
195 // Argument to NewContext is the function, which is still in a1. | 195 // Argument to NewContext is the function, which is still in a1. |
196 bool need_write_barrier = true; | 196 bool need_write_barrier = true; |
197 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 197 int slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
198 if (info->scope()->is_script_scope()) { | 198 if (info->scope()->is_script_scope()) { |
199 __ push(a1); | 199 __ push(a1); |
200 __ Push(info->scope()->GetScopeInfo(info->isolate())); | 200 __ Push(info->scope()->GetScopeInfo(info->isolate())); |
201 __ CallRuntime(Runtime::kNewScriptContext, 2); | 201 __ CallRuntime(Runtime::kNewScriptContext, 2); |
202 } else if (slots <= FastNewContextStub::kMaximumSlots) { | 202 } else if (slots <= FastNewContextStub::kMaximumSlots) { |
203 FastNewContextStub stub(isolate(), slots); | 203 FastNewContextStub stub(isolate(), slots); |
204 __ CallStub(&stub); | 204 __ CallStub(&stub); |
205 // Result of FastNewContextStub is always in new space. | 205 // Result of FastNewContextStub is always in new space. |
206 need_write_barrier = false; | 206 need_write_barrier = false; |
207 } else { | 207 } else { |
208 __ push(a1); | 208 __ push(a1); |
209 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 209 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
210 } | 210 } |
211 function_in_register = false; | 211 function_in_register_a1 = false; |
212 // Context is returned in v0. It replaces the context passed to us. | 212 // Context is returned in v0. It replaces the context passed to us. |
213 // It's saved in the stack and kept live in cp. | 213 // It's saved in the stack and kept live in cp. |
214 __ mov(cp, v0); | 214 __ mov(cp, v0); |
215 __ sd(v0, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 215 __ sd(v0, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
216 // Copy any necessary parameters into the context. | 216 // Copy any necessary parameters into the context. |
217 int num_parameters = info->scope()->num_parameters(); | 217 int num_parameters = info->scope()->num_parameters(); |
218 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; | 218 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; |
219 for (int i = first_parameter; i < num_parameters; i++) { | 219 for (int i = first_parameter; i < num_parameters; i++) { |
220 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); | 220 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
221 if (var->IsContextSlot()) { | 221 if (var->IsContextSlot()) { |
(...skipping 12 matching lines...) Expand all Loading... |
234 } else if (FLAG_debug_code) { | 234 } else if (FLAG_debug_code) { |
235 Label done; | 235 Label done; |
236 __ JumpIfInNewSpace(cp, a0, &done); | 236 __ JumpIfInNewSpace(cp, a0, &done); |
237 __ Abort(kExpectedNewSpaceObject); | 237 __ Abort(kExpectedNewSpaceObject); |
238 __ bind(&done); | 238 __ bind(&done); |
239 } | 239 } |
240 } | 240 } |
241 } | 241 } |
242 } | 242 } |
243 | 243 |
| 244 PrepareForBailoutForId(BailoutId::Prologue(), NO_REGISTERS); |
| 245 // Function register is trashed in case we bailout here. But since that |
| 246 // could happen only when we allocate a context the value of |
| 247 // |function_in_register_a1| is correct. |
| 248 |
244 // Possibly set up a local binding to the this function which is used in | 249 // Possibly set up a local binding to the this function which is used in |
245 // derived constructors with super calls. | 250 // derived constructors with super calls. |
246 Variable* this_function_var = scope()->this_function_var(); | 251 Variable* this_function_var = scope()->this_function_var(); |
247 if (this_function_var != nullptr) { | 252 if (this_function_var != nullptr) { |
248 Comment cmnt(masm_, "[ This function"); | 253 Comment cmnt(masm_, "[ This function"); |
249 if (!function_in_register) { | 254 if (!function_in_register_a1) { |
250 __ ld(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 255 __ ld(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
251 // The write barrier clobbers register again, keep is marked as such. | 256 // The write barrier clobbers register again, keep it marked as such. |
252 } | 257 } |
253 SetVar(this_function_var, a1, a2, a3); | 258 SetVar(this_function_var, a1, a2, a3); |
254 } | 259 } |
255 | 260 |
256 Variable* new_target_var = scope()->new_target_var(); | 261 Variable* new_target_var = scope()->new_target_var(); |
257 if (new_target_var != nullptr) { | 262 if (new_target_var != nullptr) { |
258 Comment cmnt(masm_, "[ new.target"); | 263 Comment cmnt(masm_, "[ new.target"); |
259 // Get the frame pointer for the calling frame. | 264 // Get the frame pointer for the calling frame. |
260 __ ld(a2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 265 __ ld(a2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
261 | 266 |
262 // Skip the arguments adaptor frame if it exists. | 267 // Skip the arguments adaptor frame if it exists. |
263 Label check_frame_marker; | 268 Label check_frame_marker; |
264 __ ld(a1, MemOperand(a2, StandardFrameConstants::kContextOffset)); | 269 __ ld(a1, MemOperand(a2, StandardFrameConstants::kContextOffset)); |
265 __ Branch(&check_frame_marker, ne, a1, | 270 __ Branch(&check_frame_marker, ne, a1, |
266 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 271 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
267 __ ld(a2, MemOperand(a2, StandardFrameConstants::kCallerFPOffset)); | 272 __ ld(a2, MemOperand(a2, StandardFrameConstants::kCallerFPOffset)); |
268 | 273 |
269 // Check the marker in the calling frame. | 274 // Check the marker in the calling frame. |
270 __ bind(&check_frame_marker); | 275 __ bind(&check_frame_marker); |
271 __ ld(a1, MemOperand(a2, StandardFrameConstants::kMarkerOffset)); | 276 __ ld(a1, MemOperand(a2, StandardFrameConstants::kMarkerOffset)); |
| 277 function_in_register_a1 = false; |
272 | 278 |
273 Label non_construct_frame, done; | 279 Label non_construct_frame, done; |
274 __ Branch(&non_construct_frame, ne, a1, | 280 __ Branch(&non_construct_frame, ne, a1, |
275 Operand(Smi::FromInt(StackFrame::CONSTRUCT))); | 281 Operand(Smi::FromInt(StackFrame::CONSTRUCT))); |
276 | 282 |
277 __ ld(v0, | 283 __ ld(v0, |
278 MemOperand(a2, ConstructFrameConstants::kOriginalConstructorOffset)); | 284 MemOperand(a2, ConstructFrameConstants::kOriginalConstructorOffset)); |
279 __ Branch(&done); | 285 __ Branch(&done); |
280 | 286 |
281 __ bind(&non_construct_frame); | 287 __ bind(&non_construct_frame); |
(...skipping 11 matching lines...) Expand all Loading... |
293 | 299 |
294 int num_parameters = info->scope()->num_parameters(); | 300 int num_parameters = info->scope()->num_parameters(); |
295 int offset = num_parameters * kPointerSize; | 301 int offset = num_parameters * kPointerSize; |
296 | 302 |
297 __ Daddu(a3, fp, | 303 __ Daddu(a3, fp, |
298 Operand(StandardFrameConstants::kCallerSPOffset + offset)); | 304 Operand(StandardFrameConstants::kCallerSPOffset + offset)); |
299 __ li(a2, Operand(Smi::FromInt(num_parameters))); | 305 __ li(a2, Operand(Smi::FromInt(num_parameters))); |
300 __ li(a1, Operand(Smi::FromInt(rest_index))); | 306 __ li(a1, Operand(Smi::FromInt(rest_index))); |
301 __ li(a0, Operand(Smi::FromInt(language_mode()))); | 307 __ li(a0, Operand(Smi::FromInt(language_mode()))); |
302 __ Push(a3, a2, a1, a0); | 308 __ Push(a3, a2, a1, a0); |
| 309 function_in_register_a1 = false; |
303 | 310 |
304 RestParamAccessStub stub(isolate()); | 311 RestParamAccessStub stub(isolate()); |
305 __ CallStub(&stub); | 312 __ CallStub(&stub); |
306 | 313 |
307 SetVar(rest_param, v0, a1, a2); | 314 SetVar(rest_param, v0, a1, a2); |
308 } | 315 } |
309 | 316 |
310 Variable* arguments = scope()->arguments(); | 317 Variable* arguments = scope()->arguments(); |
311 if (arguments != NULL) { | 318 if (arguments != NULL) { |
312 // Function uses arguments object. | 319 // Function uses arguments object. |
313 Comment cmnt(masm_, "[ Allocate arguments object"); | 320 Comment cmnt(masm_, "[ Allocate arguments object"); |
314 if (!function_in_register) { | 321 if (!function_in_register_a1) { |
315 // Load this again, if it's used by the local context below. | 322 // Load this again, if it's used by the local context below. |
316 __ ld(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 323 __ ld(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
317 } else { | 324 } else { |
318 __ mov(a3, a1); | 325 __ mov(a3, a1); |
319 } | 326 } |
320 // Receiver is just before the parameters on the caller's stack. | 327 // Receiver is just before the parameters on the caller's stack. |
321 int num_parameters = info->scope()->num_parameters(); | 328 int num_parameters = info->scope()->num_parameters(); |
322 int offset = num_parameters * kPointerSize; | 329 int offset = num_parameters * kPointerSize; |
323 __ Daddu(a2, fp, | 330 __ Daddu(a2, fp, |
324 Operand(StandardFrameConstants::kCallerSPOffset + offset)); | 331 Operand(StandardFrameConstants::kCallerSPOffset + offset)); |
(...skipping 14 matching lines...) Expand all Loading... |
339 } | 346 } |
340 ArgumentsAccessStub stub(isolate(), type); | 347 ArgumentsAccessStub stub(isolate(), type); |
341 __ CallStub(&stub); | 348 __ CallStub(&stub); |
342 | 349 |
343 SetVar(arguments, v0, a1, a2); | 350 SetVar(arguments, v0, a1, a2); |
344 } | 351 } |
345 | 352 |
346 if (FLAG_trace) { | 353 if (FLAG_trace) { |
347 __ CallRuntime(Runtime::kTraceEnter, 0); | 354 __ CallRuntime(Runtime::kTraceEnter, 0); |
348 } | 355 } |
| 356 |
349 // Visit the declarations and body unless there is an illegal | 357 // Visit the declarations and body unless there is an illegal |
350 // redeclaration. | 358 // redeclaration. |
351 if (scope()->HasIllegalRedeclaration()) { | 359 if (scope()->HasIllegalRedeclaration()) { |
352 Comment cmnt(masm_, "[ Declarations"); | 360 Comment cmnt(masm_, "[ Declarations"); |
353 scope()->VisitIllegalRedeclaration(this); | 361 scope()->VisitIllegalRedeclaration(this); |
354 | 362 |
355 } else { | 363 } else { |
356 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); | 364 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); |
357 { Comment cmnt(masm_, "[ Declarations"); | 365 { Comment cmnt(masm_, "[ Declarations"); |
358 VisitDeclarations(scope()->declarations()); | 366 VisitDeclarations(scope()->declarations()); |
(...skipping 4984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5343 reinterpret_cast<uint64_t>( | 5351 reinterpret_cast<uint64_t>( |
5344 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5352 isolate->builtins()->OsrAfterStackCheck()->entry())); |
5345 return OSR_AFTER_STACK_CHECK; | 5353 return OSR_AFTER_STACK_CHECK; |
5346 } | 5354 } |
5347 | 5355 |
5348 | 5356 |
5349 } // namespace internal | 5357 } // namespace internal |
5350 } // namespace v8 | 5358 } // namespace v8 |
5351 | 5359 |
5352 #endif // V8_TARGET_ARCH_MIPS64 | 5360 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |