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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 uint32_t pc = reinterpret_cast<uint32_t>( | 448 uint32_t pc = reinterpret_cast<uint32_t>( |
449 adaptor_trampoline->instruction_start() + | 449 adaptor_trampoline->instruction_start() + |
450 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value()); | 450 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value()); |
451 output_frame->SetPc(pc); | 451 output_frame->SetPc(pc); |
452 } | 452 } |
453 | 453 |
454 | 454 |
455 void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, | 455 void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, |
456 int frame_index) { | 456 int frame_index) { |
457 // | 457 // |
458 // FROM TO <-fp | 458 // FROM TO |
459 // | .... | | .... | | 459 // | .... | | .... | |
460 // +-------------------------+ +-------------------------+ | 460 // +-------------------------+ +-------------------------+ |
461 // | JSFunction continuation | | parameter 1 | | 461 // | JSFunction continuation | | JSFunction continuation | |
462 // +-------------------------+ +-------------------------+ | 462 // +-------------------------+ +-------------------------+ |
463 // | | saved frame (fp) | | .... | | 463 // | | saved frame (fp) | | saved frame (fp) | |
464 // | +=========================+<-fp +-------------------------+ | 464 // | +=========================+<-fp +=========================+<-fp |
465 // | | JSFunction context | | parameter n | | 465 // | | JSFunction context | | JSFunction context | |
466 // v +-------------------------+ +-------------------------| | 466 // v +-------------------------+ +-------------------------| |
467 // | COMPILED_STUB marker | | JSFunction continuation | | 467 // | COMPILED_STUB marker | | STUB_FAILURE marker | |
468 // +-------------------------+ +-------------------------+<-sp | 468 // +-------------------------+ +-------------------------+ |
469 // | | r0 = number of parameters | 469 // | | | stub parameter 1 | |
470 // | ... | r1 = failure handler address | 470 // | ... | +-------------------------+ |
471 // | | fp = saved frame | 471 // | | | ... | |
472 // +-------------------------+<-sp cp = JSFunction context | 472 // |-------------------------|<-sp +-------------------------+ |
473 // | 473 // | stub parameter n | |
| 474 // parameters in registers +-------------------------+<-sp |
| 475 // and spilled to stack r0 = number of parameters |
| 476 // r1 = failure handler address |
| 477 // fp = saved frame |
| 478 // cp = JSFunction context |
474 // | 479 // |
475 | 480 |
476 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); | 481 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); |
477 int major_key = compiled_code_->major_key(); | 482 int major_key = compiled_code_->major_key(); |
478 CodeStubInterfaceDescriptor* descriptor = | 483 CodeStubInterfaceDescriptor* descriptor = |
479 isolate_->code_stub_interface_descriptor(major_key); | 484 isolate_->code_stub_interface_descriptor(major_key); |
480 | 485 |
481 int output_frame_size = | 486 int output_frame_size = StandardFrameConstants::kFixedFrameSize + |
482 (1 + descriptor->register_param_count_) * kPointerSize; | 487 kPointerSize * descriptor->register_param_count_; |
| 488 |
483 FrameDescription* output_frame = | 489 FrameDescription* output_frame = |
484 new(output_frame_size) FrameDescription(output_frame_size, 0); | 490 new(output_frame_size) FrameDescription(output_frame_size, 0); |
| 491 ASSERT(frame_index == 0); |
| 492 output_[frame_index] = output_frame; |
485 Code* notify_failure = | 493 Code* notify_failure = |
486 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); | 494 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); |
487 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); | 495 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); |
488 output_frame->SetContinuation( | 496 output_frame->SetContinuation( |
489 reinterpret_cast<uint32_t>(notify_failure->entry())); | 497 reinterpret_cast<intptr_t>(notify_failure->entry())); |
490 | 498 |
491 Code* code; | 499 Code* trampoline = NULL; |
492 CEntryStub(1, kSaveFPRegs).FindCodeInCache(&code, isolate_); | 500 StubFailureTrampolineStub().FindCodeInCache(&trampoline, isolate_); |
493 output_frame->SetPc(reinterpret_cast<intptr_t>(code->instruction_start())); | 501 ASSERT(trampoline != NULL); |
| 502 output_frame->SetPc(reinterpret_cast<intptr_t>( |
| 503 trampoline->instruction_start())); |
494 unsigned input_frame_size = input_->GetFrameSize(); | 504 unsigned input_frame_size = input_->GetFrameSize(); |
495 intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize); | 505 |
496 output_frame->SetFrameSlot(0, value); | 506 // JSFunction continuation |
497 value = input_->GetFrameSlot(input_frame_size - 2 * kPointerSize); | 507 intptr_t input_frame_offset = input_frame_size - kPointerSize; |
| 508 intptr_t output_frame_offset = output_frame_size - kPointerSize; |
| 509 intptr_t value = input_->GetFrameSlot(input_frame_offset); |
| 510 output_frame->SetFrameSlot(output_frame_offset, value); |
| 511 |
| 512 // saved frame ptr |
| 513 input_frame_offset -= kPointerSize; |
| 514 value = input_->GetFrameSlot(input_frame_offset); |
| 515 output_frame_offset -= kPointerSize; |
| 516 output_frame->SetFrameSlot(output_frame_offset, value); |
| 517 |
| 518 // Restore context |
| 519 input_frame_offset -= kPointerSize; |
| 520 value = input_->GetFrameSlot(input_frame_offset); |
| 521 output_frame->SetRegister(cp.code(), value); |
| 522 output_frame_offset -= kPointerSize; |
| 523 output_frame->SetFrameSlot(output_frame_offset, value); |
| 524 |
| 525 // Internal frame markers |
| 526 output_frame_offset -= kPointerSize; |
| 527 value = reinterpret_cast<intptr_t>( |
| 528 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); |
| 529 output_frame->SetFrameSlot(output_frame_offset, value); |
| 530 |
| 531 for (int i = 0; i < descriptor->register_param_count_; ++i) { |
| 532 output_frame_offset -= kPointerSize; |
| 533 DoTranslateCommand(iterator, 0, output_frame_offset); |
| 534 } |
| 535 |
| 536 value = input_->GetRegister(fp.code()); |
498 output_frame->SetRegister(fp.code(), value); | 537 output_frame->SetRegister(fp.code(), value); |
499 output_frame->SetFp(value); | 538 output_frame->SetFp(value); |
500 value = input_->GetFrameSlot(input_frame_size - 3 * kPointerSize); | |
501 output_frame->SetRegister(cp.code(), value); | |
502 | |
503 int parameter_offset = kPointerSize * descriptor->register_param_count_; | |
504 for (int i = 0; i < descriptor->register_param_count_; ++i) { | |
505 Translation::Opcode opcode = | |
506 static_cast<Translation::Opcode>(iterator->Next()); | |
507 ASSERT(opcode == Translation::REGISTER); | |
508 USE(opcode); | |
509 int input_reg = iterator->Next(); | |
510 intptr_t reg_value = input_->GetRegister(input_reg); | |
511 output_frame->SetFrameSlot(parameter_offset, reg_value); | |
512 parameter_offset -= kPointerSize; | |
513 } | |
514 | 539 |
515 ApiFunction function(descriptor->deoptimization_handler_); | 540 ApiFunction function(descriptor->deoptimization_handler_); |
516 ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_); | 541 ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_); |
517 intptr_t handler = reinterpret_cast<intptr_t>(xref.address()); | 542 intptr_t handler = reinterpret_cast<intptr_t>(xref.address()); |
518 output_frame->SetRegister(r0.code(), descriptor->register_param_count_); | 543 output_frame->SetRegister(r0.code(), descriptor->register_param_count_); |
519 output_frame->SetRegister(r1.code(), handler); | 544 output_frame->SetRegister(r1.code(), handler); |
520 | |
521 ASSERT(frame_index == 0); | |
522 output_[frame_index] = output_frame; | |
523 } | 545 } |
524 | 546 |
525 | 547 |
526 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, | 548 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, |
527 int frame_index) { | 549 int frame_index) { |
528 Builtins* builtins = isolate_->builtins(); | 550 Builtins* builtins = isolate_->builtins(); |
529 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); | 551 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); |
530 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 552 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
531 unsigned height = iterator->Next(); | 553 unsigned height = iterator->Next(); |
532 unsigned height_in_bytes = height * kPointerSize; | 554 unsigned height_in_bytes = height * kPointerSize; |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 __ push(ip); | 1230 __ push(ip); |
1209 __ b(&done); | 1231 __ b(&done); |
1210 ASSERT(masm()->pc_offset() - start == table_entry_size_); | 1232 ASSERT(masm()->pc_offset() - start == table_entry_size_); |
1211 } | 1233 } |
1212 __ bind(&done); | 1234 __ bind(&done); |
1213 } | 1235 } |
1214 | 1236 |
1215 #undef __ | 1237 #undef __ |
1216 | 1238 |
1217 } } // namespace v8::internal | 1239 } } // namespace v8::internal |
OLD | NEW |