| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 // | .... | | .... | | 455 // | .... | | .... | |
| 456 // +-------------------------+ +-------------------------+ | 456 // +-------------------------+ +-------------------------+ |
| 457 // | JSFunction continuation | | JSFunction continuation | | 457 // | JSFunction continuation | | JSFunction continuation | |
| 458 // +-------------------------+ +-------------------------+ | 458 // +-------------------------+ +-------------------------+ |
| 459 // | | saved frame (rbp) | | saved frame (rbp) | | 459 // | | saved frame (rbp) | | saved frame (rbp) | |
| 460 // | +=========================+<-rbp +=========================+<-rbp | 460 // | +=========================+<-rbp +=========================+<-rbp |
| 461 // | | JSFunction context | | JSFunction context | | 461 // | | JSFunction context | | JSFunction context | |
| 462 // v +-------------------------+ +-------------------------| | 462 // v +-------------------------+ +-------------------------| |
| 463 // | COMPILED_STUB marker | | STUB_FAILURE marker | | 463 // | COMPILED_STUB marker | | STUB_FAILURE marker | |
| 464 // +-------------------------+ +-------------------------+ | 464 // +-------------------------+ +-------------------------+ |
| 465 // | | | stub parameter 1 | | 465 // | | | caller args.length_ | |
| 466 // | ... | +-------------------------+ | 466 // | ... | +-------------------------+ |
| 467 // | | | ... | | 467 // | | | caller args.arguments_ | |
| 468 // |-------------------------|<-rsp +-------------------------+ | 468 // |-------------------------|<-rsp +-------------------------+ |
| 469 // | stub parameter n | | 469 // | caller args pointer | |
| 470 // parameters in registers +-------------------------+<-rsp | 470 // +-------------------------+ |
| 471 // and spilled to stack rax = number of parameters | 471 // | caller stack param 1 | |
| 472 // parameters in registers +-------------------------+ |
| 473 // and spilled to stack | .... | |
| 474 // +-------------------------+ |
| 475 // | caller stack param n | |
| 476 // +-------------------------+<-rsp |
| 477 // rax = number of parameters |
| 472 // rbx = failure handler address | 478 // rbx = failure handler address |
| 473 // rbp = saved frame | 479 // rbp = saved frame |
| 474 // rsi = JSFunction context | 480 // rsi = JSFunction context |
| 475 // | 481 // |
| 476 | 482 |
| 477 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); | 483 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); |
| 478 int major_key = compiled_code_->major_key(); | 484 int major_key = compiled_code_->major_key(); |
| 479 CodeStubInterfaceDescriptor* descriptor = | 485 CodeStubInterfaceDescriptor* descriptor = |
| 480 isolate_->code_stub_interface_descriptor(major_key); | 486 isolate_->code_stub_interface_descriptor(major_key); |
| 481 | 487 |
| 488 // The output frame must have room for all pushed register parameters |
| 489 // and the standard stack frame slots. |
| 482 int output_frame_size = StandardFrameConstants::kFixedFrameSize + | 490 int output_frame_size = StandardFrameConstants::kFixedFrameSize + |
| 483 kPointerSize * descriptor->register_param_count_; | 491 kPointerSize * descriptor->register_param_count_; |
| 484 | 492 |
| 493 // Include space for an argument object to the callee and optionally |
| 494 // the space to pass the argument object to the stub failure handler. |
| 495 output_frame_size += sizeof(Arguments) + kPointerSize; |
| 496 |
| 485 FrameDescription* output_frame = | 497 FrameDescription* output_frame = |
| 486 new(output_frame_size) FrameDescription(output_frame_size, 0); | 498 new(output_frame_size) FrameDescription(output_frame_size, 0); |
| 487 ASSERT(frame_index == 0); | 499 ASSERT(frame_index == 0); |
| 488 output_[frame_index] = output_frame; | 500 output_[frame_index] = output_frame; |
| 489 Code* notify_failure = | 501 Code* notify_failure = |
| 490 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); | 502 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); |
| 491 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); | 503 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); |
| 492 output_frame->SetContinuation( | 504 output_frame->SetContinuation( |
| 493 reinterpret_cast<intptr_t>(notify_failure->entry())); | 505 reinterpret_cast<intptr_t>(notify_failure->entry())); |
| 494 | 506 |
| 495 Code* trampoline = NULL; | 507 Code* trampoline = NULL; |
| 496 StubFailureTrampolineStub().FindCodeInCache(&trampoline, isolate_); | 508 int extra = descriptor->extra_expression_stack_count_; |
| 509 StubFailureTrampolineStub(extra).FindCodeInCache(&trampoline, isolate_); |
| 497 ASSERT(trampoline != NULL); | 510 ASSERT(trampoline != NULL); |
| 498 output_frame->SetPc(reinterpret_cast<intptr_t>( | 511 output_frame->SetPc(reinterpret_cast<intptr_t>( |
| 499 trampoline->instruction_start())); | 512 trampoline->instruction_start())); |
| 500 unsigned input_frame_size = input_->GetFrameSize(); | 513 unsigned input_frame_size = input_->GetFrameSize(); |
| 501 | 514 |
| 515 intptr_t frame_ptr = input_->GetRegister(rbp.code()); |
| 516 |
| 502 // JSFunction continuation | 517 // JSFunction continuation |
| 503 unsigned input_frame_offset = input_frame_size - kPointerSize; | 518 unsigned input_frame_offset = input_frame_size - kPointerSize; |
| 504 unsigned output_frame_offset = output_frame_size - kPointerSize; | 519 unsigned output_frame_offset = output_frame_size - kPointerSize; |
| 505 intptr_t value = input_->GetFrameSlot(input_frame_offset); | 520 intptr_t value = input_->GetFrameSlot(input_frame_offset); |
| 506 output_frame->SetFrameSlot(output_frame_offset, value); | 521 output_frame->SetFrameSlot(output_frame_offset, value); |
| 507 | 522 |
| 508 // saved frame ptr | 523 // saved frame ptr |
| 509 input_frame_offset -= kPointerSize; | 524 input_frame_offset -= kPointerSize; |
| 510 value = input_->GetFrameSlot(input_frame_offset); | 525 value = input_->GetFrameSlot(input_frame_offset); |
| 511 output_frame_offset -= kPointerSize; | 526 output_frame_offset -= kPointerSize; |
| 512 output_frame->SetFrameSlot(output_frame_offset, value); | 527 output_frame->SetFrameSlot(output_frame_offset, value); |
| 513 | 528 |
| 514 // Restore context | 529 // Restore context |
| 515 input_frame_offset -= kPointerSize; | 530 input_frame_offset -= kPointerSize; |
| 516 value = input_->GetFrameSlot(input_frame_offset); | 531 value = input_->GetFrameSlot(input_frame_offset); |
| 517 output_frame->SetRegister(rsi.code(), value); | 532 output_frame->SetRegister(rsi.code(), value); |
| 518 output_frame_offset -= kPointerSize; | 533 output_frame_offset -= kPointerSize; |
| 519 output_frame->SetFrameSlot(output_frame_offset, value); | 534 output_frame->SetFrameSlot(output_frame_offset, value); |
| 520 | 535 |
| 521 // Internal frame markers | 536 // Internal frame markers |
| 522 output_frame_offset -= kPointerSize; | 537 output_frame_offset -= kPointerSize; |
| 523 value = reinterpret_cast<intptr_t>( | 538 value = reinterpret_cast<intptr_t>( |
| 524 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); | 539 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); |
| 525 output_frame->SetFrameSlot(output_frame_offset, value); | 540 output_frame->SetFrameSlot(output_frame_offset, value); |
| 526 | 541 |
| 542 int caller_arg_count = 0; |
| 543 if (descriptor->stack_parameter_count_ != NULL) { |
| 544 caller_arg_count = |
| 545 input_->GetRegister(descriptor->stack_parameter_count_->code()); |
| 546 } |
| 547 |
| 548 // Build the Arguments object for the caller's parameters and a pointer to it. |
| 549 output_frame_offset -= kPointerSize; |
| 550 value = frame_ptr + StandardFrameConstants::kCallerSPOffset + |
| 551 (caller_arg_count - 1) * kPointerSize; |
| 552 output_frame->SetFrameSlot(output_frame_offset, value); |
| 553 |
| 554 output_frame->SetFrameSlot(output_frame_offset, value); |
| 555 output_frame_offset -= kPointerSize; |
| 556 output_frame->SetFrameSlot(output_frame_offset, caller_arg_count); |
| 557 |
| 558 value = frame_ptr - (output_frame_size - output_frame_offset) - |
| 559 StandardFrameConstants::kMarkerOffset; |
| 560 output_frame_offset -= kPointerSize; |
| 561 output_frame->SetFrameSlot(output_frame_offset, value); |
| 562 |
| 563 // Copy the register parameters to the failure frame. |
| 527 for (int i = 0; i < descriptor->register_param_count_; ++i) { | 564 for (int i = 0; i < descriptor->register_param_count_; ++i) { |
| 528 output_frame_offset -= kPointerSize; | 565 output_frame_offset -= kPointerSize; |
| 529 DoTranslateCommand(iterator, 0, output_frame_offset); | 566 DoTranslateCommand(iterator, 0, output_frame_offset); |
| 530 } | 567 } |
| 531 | 568 |
| 532 value = input_->GetRegister(rbp.code()); | 569 output_frame->SetRegister(rbp.code(), frame_ptr); |
| 533 output_frame->SetRegister(rbp.code(), value); | 570 output_frame->SetFp(frame_ptr); |
| 534 output_frame->SetFp(value); | |
| 535 | 571 |
| 536 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); ++i) { | 572 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); ++i) { |
| 537 double double_value = input_->GetDoubleRegister(i); | 573 double double_value = input_->GetDoubleRegister(i); |
| 538 output_frame->SetDoubleRegister(i, double_value); | 574 output_frame->SetDoubleRegister(i, double_value); |
| 539 } | 575 } |
| 540 | 576 |
| 541 intptr_t handler = | 577 intptr_t handler = |
| 542 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_); | 578 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_); |
| 543 output_frame->SetRegister(rax.code(), descriptor->register_param_count_); | 579 int params = descriptor->register_param_count_; |
| 580 if (descriptor->stack_parameter_count_ != NULL) { |
| 581 params++; |
| 582 } |
| 583 output_frame->SetRegister(rax.code(), params); |
| 544 output_frame->SetRegister(rbx.code(), handler); | 584 output_frame->SetRegister(rbx.code(), handler); |
| 545 } | 585 } |
| 546 | 586 |
| 547 | 587 |
| 548 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, | 588 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, |
| 549 int frame_index) { | 589 int frame_index) { |
| 550 Builtins* builtins = isolate_->builtins(); | 590 Builtins* builtins = isolate_->builtins(); |
| 551 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); | 591 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); |
| 552 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 592 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
| 553 unsigned height = iterator->Next(); | 593 unsigned height = iterator->Next(); |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 } | 1236 } |
| 1197 __ bind(&done); | 1237 __ bind(&done); |
| 1198 } | 1238 } |
| 1199 | 1239 |
| 1200 #undef __ | 1240 #undef __ |
| 1201 | 1241 |
| 1202 | 1242 |
| 1203 } } // namespace v8::internal | 1243 } } // namespace v8::internal |
| 1204 | 1244 |
| 1205 #endif // V8_TARGET_ARCH_X64 | 1245 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |