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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
8 | 8 |
9 // Note on Mips implementation: | 9 // Note on Mips implementation: |
10 // | 10 // |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // derived constructors with super calls. | 248 // derived constructors with super calls. |
249 Variable* this_function_var = scope()->this_function_var(); | 249 Variable* this_function_var = scope()->this_function_var(); |
250 if (this_function_var != nullptr) { | 250 if (this_function_var != nullptr) { |
251 Comment cmnt(masm_, "[ This function"); | 251 Comment cmnt(masm_, "[ This function"); |
252 SetVar(this_function_var, a1, a2, a3); | 252 SetVar(this_function_var, a1, a2, a3); |
253 } | 253 } |
254 | 254 |
255 Variable* new_target_var = scope()->new_target_var(); | 255 Variable* new_target_var = scope()->new_target_var(); |
256 if (new_target_var != nullptr) { | 256 if (new_target_var != nullptr) { |
257 Comment cmnt(masm_, "[ new.target"); | 257 Comment cmnt(masm_, "[ new.target"); |
258 // new.target is parameter -2. | 258 // Get the frame pointer for the calling frame. |
259 int offset = 2 * kPointerSize + | 259 __ ld(a2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
260 (info_->scope()->num_parameters() + 1) * kPointerSize; | 260 |
261 __ ld(v0, MemOperand(fp, offset)); | 261 // Skip the arguments adaptor frame if it exists. |
| 262 Label check_frame_marker; |
| 263 __ ld(a1, MemOperand(a2, StandardFrameConstants::kContextOffset)); |
| 264 __ Branch(&check_frame_marker, ne, a1, |
| 265 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
| 266 __ ld(a2, MemOperand(a2, StandardFrameConstants::kCallerFPOffset)); |
| 267 |
| 268 // Check the marker in the calling frame. |
| 269 __ bind(&check_frame_marker); |
| 270 __ ld(a1, MemOperand(a2, StandardFrameConstants::kMarkerOffset)); |
| 271 |
| 272 Label non_construct_frame, done; |
| 273 __ Branch(&non_construct_frame, ne, a1, |
| 274 Operand(Smi::FromInt(StackFrame::CONSTRUCT))); |
| 275 |
| 276 __ ld(v0, MemOperand(a2, StandardFrameConstants::kExpressionsOffset - |
| 277 2 * kPointerSize)); |
| 278 __ Branch(&done); |
| 279 |
| 280 __ bind(&non_construct_frame); |
| 281 __ LoadRoot(v0, Heap::kUndefinedValueRootIndex); |
| 282 __ bind(&done); |
| 283 |
262 SetVar(new_target_var, v0, a2, a3); | 284 SetVar(new_target_var, v0, a2, a3); |
263 } | 285 } |
264 | 286 |
265 ArgumentsAccessStub::HasNewTarget has_new_target = | |
266 IsSubclassConstructor(info->function()->kind()) | |
267 ? ArgumentsAccessStub::HAS_NEW_TARGET | |
268 : ArgumentsAccessStub::NO_NEW_TARGET; | |
269 | |
270 // Possibly allocate RestParameters | 287 // Possibly allocate RestParameters |
271 int rest_index; | 288 int rest_index; |
272 Variable* rest_param = scope()->rest_parameter(&rest_index); | 289 Variable* rest_param = scope()->rest_parameter(&rest_index); |
273 if (rest_param) { | 290 if (rest_param) { |
274 Comment cmnt(masm_, "[ Allocate rest parameter array"); | 291 Comment cmnt(masm_, "[ Allocate rest parameter array"); |
275 | 292 |
276 int num_parameters = info->scope()->num_parameters(); | 293 int num_parameters = info->scope()->num_parameters(); |
277 int offset = num_parameters * kPointerSize; | 294 int offset = num_parameters * kPointerSize; |
278 if (has_new_target == ArgumentsAccessStub::HAS_NEW_TARGET) { | |
279 --num_parameters; | |
280 ++rest_index; | |
281 } | |
282 | 295 |
283 __ Daddu(a3, fp, | 296 __ Daddu(a3, fp, |
284 Operand(StandardFrameConstants::kCallerSPOffset + offset)); | 297 Operand(StandardFrameConstants::kCallerSPOffset + offset)); |
285 __ li(a2, Operand(Smi::FromInt(num_parameters))); | 298 __ li(a2, Operand(Smi::FromInt(num_parameters))); |
286 __ li(a1, Operand(Smi::FromInt(rest_index))); | 299 __ li(a1, Operand(Smi::FromInt(rest_index))); |
287 __ li(a0, Operand(Smi::FromInt(language_mode()))); | 300 __ li(a0, Operand(Smi::FromInt(language_mode()))); |
288 __ Push(a3, a2, a1, a0); | 301 __ Push(a3, a2, a1, a0); |
289 | 302 |
290 RestParamAccessStub stub(isolate()); | 303 RestParamAccessStub stub(isolate()); |
291 __ CallStub(&stub); | 304 __ CallStub(&stub); |
(...skipping 24 matching lines...) Expand all Loading... |
316 // The stub will rewrite receiever and parameter count if the previous | 329 // The stub will rewrite receiever and parameter count if the previous |
317 // stack frame was an arguments adapter frame. | 330 // stack frame was an arguments adapter frame. |
318 ArgumentsAccessStub::Type type; | 331 ArgumentsAccessStub::Type type; |
319 if (is_strict(language_mode()) || !is_simple_parameter_list()) { | 332 if (is_strict(language_mode()) || !is_simple_parameter_list()) { |
320 type = ArgumentsAccessStub::NEW_STRICT; | 333 type = ArgumentsAccessStub::NEW_STRICT; |
321 } else if (function()->has_duplicate_parameters()) { | 334 } else if (function()->has_duplicate_parameters()) { |
322 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; | 335 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; |
323 } else { | 336 } else { |
324 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; | 337 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; |
325 } | 338 } |
326 ArgumentsAccessStub stub(isolate(), type, has_new_target); | 339 ArgumentsAccessStub stub(isolate(), type); |
327 __ CallStub(&stub); | 340 __ CallStub(&stub); |
328 | 341 |
329 SetVar(arguments, v0, a1, a2); | 342 SetVar(arguments, v0, a1, a2); |
330 } | 343 } |
331 | 344 |
332 if (FLAG_trace) { | 345 if (FLAG_trace) { |
333 __ CallRuntime(Runtime::kTraceEnter, 0); | 346 __ CallRuntime(Runtime::kTraceEnter, 0); |
334 } | 347 } |
335 // Visit the declarations and body unless there is an illegal | 348 // Visit the declarations and body unless there is an illegal |
336 // redeclaration. | 349 // redeclaration. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 // Add a label for checking the size of the code used for returning. | 490 // Add a label for checking the size of the code used for returning. |
478 Label check_exit_codesize; | 491 Label check_exit_codesize; |
479 masm_->bind(&check_exit_codesize); | 492 masm_->bind(&check_exit_codesize); |
480 #endif | 493 #endif |
481 // Make sure that the constant pool is not emitted inside of the return | 494 // Make sure that the constant pool is not emitted inside of the return |
482 // sequence. | 495 // sequence. |
483 { Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); | 496 { Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); |
484 // Here we use masm_-> instead of the __ macro to avoid the code coverage | 497 // Here we use masm_-> instead of the __ macro to avoid the code coverage |
485 // tool from instrumenting as we rely on the code size here. | 498 // tool from instrumenting as we rely on the code size here. |
486 int32_t arg_count = info_->scope()->num_parameters() + 1; | 499 int32_t arg_count = info_->scope()->num_parameters() + 1; |
487 if (IsSubclassConstructor(info_->function()->kind())) { | |
488 arg_count++; | |
489 } | |
490 int32_t sp_delta = arg_count * kPointerSize; | 500 int32_t sp_delta = arg_count * kPointerSize; |
491 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); | 501 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); |
492 __ RecordJSReturn(); | 502 __ RecordJSReturn(); |
493 masm_->mov(sp, fp); | 503 masm_->mov(sp, fp); |
494 int no_frame_start = masm_->pc_offset(); | 504 int no_frame_start = masm_->pc_offset(); |
495 masm_->MultiPop(static_cast<RegList>(fp.bit() | ra.bit())); | 505 masm_->MultiPop(static_cast<RegList>(fp.bit() | ra.bit())); |
496 masm_->Daddu(sp, sp, Operand(sp_delta)); | 506 masm_->Daddu(sp, sp, Operand(sp_delta)); |
497 masm_->Jump(ra); | 507 masm_->Jump(ra); |
498 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); | 508 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); |
499 } | 509 } |
(...skipping 3777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4277 // default constructor has no arguments, so no adaptor frame means no args. | 4287 // default constructor has no arguments, so no adaptor frame means no args. |
4278 __ mov(a0, zero_reg); | 4288 __ mov(a0, zero_reg); |
4279 __ Branch(&args_set_up); | 4289 __ Branch(&args_set_up); |
4280 | 4290 |
4281 // Copy arguments from adaptor frame. | 4291 // Copy arguments from adaptor frame. |
4282 { | 4292 { |
4283 __ bind(&adaptor_frame); | 4293 __ bind(&adaptor_frame); |
4284 __ ld(a1, MemOperand(a2, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 4294 __ ld(a1, MemOperand(a2, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
4285 __ SmiUntag(a1, a1); | 4295 __ SmiUntag(a1, a1); |
4286 | 4296 |
4287 // Subtract 1 from arguments count, for new.target. | |
4288 __ Daddu(a1, a1, Operand(-1)); | |
4289 __ mov(a0, a1); | 4297 __ mov(a0, a1); |
4290 | 4298 |
4291 // Get arguments pointer in a2. | 4299 // Get arguments pointer in a2. |
4292 __ dsll(at, a1, kPointerSizeLog2); | 4300 __ dsll(at, a1, kPointerSizeLog2); |
4293 __ Daddu(a2, a2, Operand(at)); | 4301 __ Daddu(a2, a2, Operand(at)); |
4294 __ Daddu(a2, a2, Operand(StandardFrameConstants::kCallerSPOffset)); | 4302 __ Daddu(a2, a2, Operand(StandardFrameConstants::kCallerSPOffset)); |
4295 Label loop; | 4303 Label loop; |
4296 __ bind(&loop); | 4304 __ bind(&loop); |
4297 // Pre-decrement a2 with kPointerSize on each iteration. | 4305 // Pre-decrement a2 with kPointerSize on each iteration. |
4298 // Pre-decrement in order to skip receiver. | 4306 // Pre-decrement in order to skip receiver. |
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5560 reinterpret_cast<uint64_t>( | 5568 reinterpret_cast<uint64_t>( |
5561 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5569 isolate->builtins()->OsrAfterStackCheck()->entry())); |
5562 return OSR_AFTER_STACK_CHECK; | 5570 return OSR_AFTER_STACK_CHECK; |
5563 } | 5571 } |
5564 | 5572 |
5565 | 5573 |
5566 } // namespace internal | 5574 } // namespace internal |
5567 } // namespace v8 | 5575 } // namespace v8 |
5568 | 5576 |
5569 #endif // V8_TARGET_ARCH_MIPS64 | 5577 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |