| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 // | .... | | .... | | 452 // | .... | | .... | |
| 453 // +-------------------------+ +-------------------------+ | 453 // +-------------------------+ +-------------------------+ |
| 454 // | JSFunction continuation | | JSFunction continuation | | 454 // | JSFunction continuation | | JSFunction continuation | |
| 455 // +-------------------------+ +-------------------------+ | 455 // +-------------------------+ +-------------------------+ |
| 456 // | | saved frame (fp) | | saved frame (fp) | | 456 // | | saved frame (fp) | | saved frame (fp) | |
| 457 // | +=========================+<-fp +=========================+<-fp | 457 // | +=========================+<-fp +=========================+<-fp |
| 458 // | | JSFunction context | | JSFunction context | | 458 // | | JSFunction context | | JSFunction context | |
| 459 // v +-------------------------+ +-------------------------| | 459 // v +-------------------------+ +-------------------------| |
| 460 // | COMPILED_STUB marker | | STUB_FAILURE marker | | 460 // | COMPILED_STUB marker | | STUB_FAILURE marker | |
| 461 // +-------------------------+ +-------------------------+ | 461 // +-------------------------+ +-------------------------+ |
| 462 // | | | stub parameter 1 | | 462 // | | | caller args.length_ | |
| 463 // | ... | +-------------------------+ | 463 // | ... | +-------------------------+ |
| 464 // | | | ... | | 464 // | | | caller args.arguments_ | |
| 465 // |-------------------------|<-sp +-------------------------+ | 465 // |-------------------------|<-sp +-------------------------+ |
| 466 // | stub parameter n | | 466 // | caller args pointer | |
| 467 // parameters in registers +-------------------------+<-sp | 467 // +-------------------------+ |
| 468 // and spilled to stack s0-s1 = number of parameters | 468 // | caller stack param 1 | |
| 469 // parameters in registers +-------------------------+ |
| 470 // and spilled to stack | .... | |
| 471 // +-------------------------+ |
| 472 // | caller stack param n | |
| 473 // +-------------------------+<-sp |
| 474 // s0-s1 = number of parameters |
| 469 // s2 = failure handler address | 475 // s2 = failure handler address |
| 470 // fp = saved frame | 476 // fp = saved frame |
| 471 // cp = JSFunction context | 477 // cp = JSFunction context |
| 472 // | 478 // |
| 473 | 479 |
| 474 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); | 480 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); |
| 475 int major_key = compiled_code_->major_key(); | 481 int major_key = compiled_code_->major_key(); |
| 476 CodeStubInterfaceDescriptor* descriptor = | 482 CodeStubInterfaceDescriptor* descriptor = |
| 477 isolate_->code_stub_interface_descriptor(major_key); | 483 isolate_->code_stub_interface_descriptor(major_key); |
| 478 | 484 |
| 485 // The output frame must have room for all pushed register parameters |
| 486 // and the standard stack frame slots. |
| 479 int output_frame_size = StandardFrameConstants::kFixedFrameSize + | 487 int output_frame_size = StandardFrameConstants::kFixedFrameSize + |
| 480 kPointerSize * descriptor->register_param_count_; | 488 kPointerSize * descriptor->register_param_count_; |
| 481 | 489 |
| 490 // Include space for an argument object to the callee and optionally |
| 491 // the space to pass the argument object to the stub failure handler. |
| 492 output_frame_size += sizeof(Arguments) + kPointerSize; |
| 493 |
| 482 FrameDescription* output_frame = | 494 FrameDescription* output_frame = |
| 483 new(output_frame_size) FrameDescription(output_frame_size, 0); | 495 new(output_frame_size) FrameDescription(output_frame_size, 0); |
| 484 ASSERT(frame_index == 0); | 496 ASSERT(frame_index == 0); |
| 485 output_[frame_index] = output_frame; | 497 output_[frame_index] = output_frame; |
| 486 Code* notify_failure = | 498 Code* notify_failure = |
| 487 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); | 499 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); |
| 488 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); | 500 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); |
| 489 output_frame->SetContinuation( | 501 output_frame->SetContinuation( |
| 490 reinterpret_cast<intptr_t>(notify_failure->entry())); | 502 reinterpret_cast<intptr_t>(notify_failure->entry())); |
| 491 | 503 |
| 492 Code* trampoline = NULL; | 504 Code* trampoline = NULL; |
| 493 StubFailureTrampolineStub().FindCodeInCache(&trampoline, isolate_); | 505 int extra = descriptor->extra_expression_stack_count_; |
| 506 StubFailureTrampolineStub(extra).FindCodeInCache(&trampoline, isolate_); |
| 494 ASSERT(trampoline != NULL); | 507 ASSERT(trampoline != NULL); |
| 495 output_frame->SetPc(reinterpret_cast<intptr_t>( | 508 output_frame->SetPc(reinterpret_cast<intptr_t>( |
| 496 trampoline->instruction_start())); | 509 trampoline->instruction_start())); |
| 497 unsigned input_frame_size = input_->GetFrameSize(); | 510 unsigned input_frame_size = input_->GetFrameSize(); |
| 498 | 511 |
| 512 intptr_t frame_ptr = input_->GetRegister(fp.code()); |
| 513 |
| 499 // JSFunction continuation | 514 // JSFunction continuation |
| 500 intptr_t input_frame_offset = input_frame_size - kPointerSize; | 515 intptr_t input_frame_offset = input_frame_size - kPointerSize; |
| 501 intptr_t output_frame_offset = output_frame_size - kPointerSize; | 516 intptr_t output_frame_offset = output_frame_size - kPointerSize; |
| 502 intptr_t value = input_->GetFrameSlot(input_frame_offset); | 517 intptr_t value = input_->GetFrameSlot(input_frame_offset); |
| 503 output_frame->SetFrameSlot(output_frame_offset, value); | 518 output_frame->SetFrameSlot(output_frame_offset, value); |
| 504 | 519 |
| 505 // saved frame ptr | 520 // saved frame ptr |
| 506 input_frame_offset -= kPointerSize; | 521 input_frame_offset -= kPointerSize; |
| 507 value = input_->GetFrameSlot(input_frame_offset); | 522 value = input_->GetFrameSlot(input_frame_offset); |
| 508 output_frame_offset -= kPointerSize; | 523 output_frame_offset -= kPointerSize; |
| 509 output_frame->SetFrameSlot(output_frame_offset, value); | 524 output_frame->SetFrameSlot(output_frame_offset, value); |
| 510 | 525 |
| 511 // Restore context | 526 // Restore context |
| 512 input_frame_offset -= kPointerSize; | 527 input_frame_offset -= kPointerSize; |
| 513 value = input_->GetFrameSlot(input_frame_offset); | 528 value = input_->GetFrameSlot(input_frame_offset); |
| 514 output_frame->SetRegister(cp.code(), value); | 529 output_frame->SetRegister(cp.code(), value); |
| 515 output_frame_offset -= kPointerSize; | 530 output_frame_offset -= kPointerSize; |
| 516 output_frame->SetFrameSlot(output_frame_offset, value); | 531 output_frame->SetFrameSlot(output_frame_offset, value); |
| 517 | 532 |
| 518 // Internal frame markers | 533 // Internal frame markers |
| 519 output_frame_offset -= kPointerSize; | 534 output_frame_offset -= kPointerSize; |
| 520 value = reinterpret_cast<intptr_t>( | 535 value = reinterpret_cast<intptr_t>( |
| 521 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); | 536 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); |
| 522 output_frame->SetFrameSlot(output_frame_offset, value); | 537 output_frame->SetFrameSlot(output_frame_offset, value); |
| 523 | 538 |
| 539 int caller_arg_count = 0; |
| 540 if (descriptor->stack_parameter_count_ != NULL) { |
| 541 caller_arg_count = |
| 542 input_->GetRegister(descriptor->stack_parameter_count_->code()); |
| 543 } |
| 544 |
| 545 // Build the Arguments object for the caller's parameters and a pointer to it. |
| 546 output_frame_offset -= kPointerSize; |
| 547 value = frame_ptr + StandardFrameConstants::kCallerSPOffset + |
| 548 (caller_arg_count - 1) * kPointerSize; |
| 549 output_frame->SetFrameSlot(output_frame_offset, value); |
| 550 |
| 551 output_frame->SetFrameSlot(output_frame_offset, value); |
| 552 output_frame_offset -= kPointerSize; |
| 553 output_frame->SetFrameSlot(output_frame_offset, caller_arg_count); |
| 554 |
| 555 value = frame_ptr - (output_frame_size - output_frame_offset) - |
| 556 StandardFrameConstants::kMarkerOffset; |
| 557 output_frame_offset -= kPointerSize; |
| 558 output_frame->SetFrameSlot(output_frame_offset, value); |
| 559 |
| 560 // Copy the register parameters to the failure frame. |
| 524 for (int i = 0; i < descriptor->register_param_count_; ++i) { | 561 for (int i = 0; i < descriptor->register_param_count_; ++i) { |
| 525 output_frame_offset -= kPointerSize; | 562 output_frame_offset -= kPointerSize; |
| 526 DoTranslateCommand(iterator, 0, output_frame_offset); | 563 DoTranslateCommand(iterator, 0, output_frame_offset); |
| 527 } | 564 } |
| 528 | 565 |
| 529 for (int i = 0; i < DoubleRegister::kMaxNumRegisters; ++i) { | 566 for (int i = 0; i < DoubleRegister::kMaxNumRegisters; ++i) { |
| 530 double double_value = input_->GetDoubleRegister(i); | 567 double double_value = input_->GetDoubleRegister(i); |
| 531 output_frame->SetDoubleRegister(i, double_value); | 568 output_frame->SetDoubleRegister(i, double_value); |
| 532 } | 569 } |
| 533 | 570 |
| 534 value = input_->GetRegister(fp.code()); | 571 output_frame->SetRegister(fp.code(), frame_ptr); |
| 535 output_frame->SetRegister(fp.code(), value); | 572 output_frame->SetFp(frame_ptr); |
| 536 output_frame->SetFp(value); | |
| 537 | 573 |
| 538 ApiFunction function(descriptor->deoptimization_handler_); | 574 ApiFunction function(descriptor->deoptimization_handler_); |
| 539 ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_); | 575 ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_); |
| 540 intptr_t handler = reinterpret_cast<intptr_t>(xref.address()); | 576 intptr_t handler = reinterpret_cast<intptr_t>(xref.address()); |
| 541 output_frame->SetRegister(s0.code(), descriptor->register_param_count_); | 577 int params = descriptor->register_param_count_; |
| 542 output_frame->SetRegister(s1.code(), | 578 if (descriptor->stack_parameter_count_ != NULL) { |
| 543 (descriptor->register_param_count_ - 1) * kPointerSize); | 579 params++; |
| 580 } |
| 581 output_frame->SetRegister(s0.code(), params); |
| 582 output_frame->SetRegister(s1.code(), (params - 1) * kPointerSize); |
| 544 output_frame->SetRegister(s2.code(), handler); | 583 output_frame->SetRegister(s2.code(), handler); |
| 545 } | 584 } |
| 546 | 585 |
| 547 | 586 |
| 548 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, | 587 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, |
| 549 int frame_index) { | 588 int frame_index) { |
| 550 Builtins* builtins = isolate_->builtins(); | 589 Builtins* builtins = isolate_->builtins(); |
| 551 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); | 590 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); |
| 552 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 591 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
| 553 unsigned height = iterator->Next(); | 592 unsigned height = iterator->Next(); |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 } | 1282 } |
| 1244 | 1283 |
| 1245 ASSERT_EQ(masm()->SizeOfCodeGeneratedSince(&table_start), | 1284 ASSERT_EQ(masm()->SizeOfCodeGeneratedSince(&table_start), |
| 1246 count() * table_entry_size_); | 1285 count() * table_entry_size_); |
| 1247 } | 1286 } |
| 1248 | 1287 |
| 1249 #undef __ | 1288 #undef __ |
| 1250 | 1289 |
| 1251 | 1290 |
| 1252 } } // namespace v8::internal | 1291 } } // namespace v8::internal |
| OLD | NEW |