| 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 if (FLAG_trace_osr) { | 456 if (FLAG_trace_osr) { |
| 457 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", | 457 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", |
| 458 ok ? "finished" : "aborted", | 458 ok ? "finished" : "aborted", |
| 459 reinterpret_cast<intptr_t>(function_)); | 459 reinterpret_cast<intptr_t>(function_)); |
| 460 function_->PrintName(); | 460 function_->PrintName(); |
| 461 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc()); | 461 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc()); |
| 462 } | 462 } |
| 463 } | 463 } |
| 464 | 464 |
| 465 | 465 |
| 466 void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator, | |
| 467 int frame_index) { | |
| 468 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); | |
| 469 unsigned height = iterator->Next(); | |
| 470 unsigned height_in_bytes = height * kPointerSize; | |
| 471 if (trace_) { | |
| 472 PrintF(" translating arguments adaptor => height=%d\n", height_in_bytes); | |
| 473 } | |
| 474 | |
| 475 unsigned fixed_frame_size = ArgumentsAdaptorFrameConstants::kFrameSize; | |
| 476 unsigned output_frame_size = height_in_bytes + fixed_frame_size; | |
| 477 | |
| 478 // Allocate and store the output frame description. | |
| 479 FrameDescription* output_frame = | |
| 480 new(output_frame_size) FrameDescription(output_frame_size, function); | |
| 481 output_frame->SetFrameType(StackFrame::ARGUMENTS_ADAPTOR); | |
| 482 | |
| 483 // Arguments adaptor can not be topmost or bottommost. | |
| 484 ASSERT(frame_index > 0 && frame_index < output_count_ - 1); | |
| 485 ASSERT(output_[frame_index] == NULL); | |
| 486 output_[frame_index] = output_frame; | |
| 487 | |
| 488 // The top address of the frame is computed from the previous | |
| 489 // frame's top and this frame's size. | |
| 490 uint32_t top_address; | |
| 491 top_address = output_[frame_index - 1]->GetTop() - output_frame_size; | |
| 492 output_frame->SetTop(top_address); | |
| 493 | |
| 494 // Compute the incoming parameter translation. | |
| 495 int parameter_count = height; | |
| 496 unsigned output_offset = output_frame_size; | |
| 497 for (int i = 0; i < parameter_count; ++i) { | |
| 498 output_offset -= kPointerSize; | |
| 499 DoTranslateCommand(iterator, frame_index, output_offset); | |
| 500 } | |
| 501 | |
| 502 // Read caller's PC from the previous frame. | |
| 503 output_offset -= kPointerSize; | |
| 504 intptr_t callers_pc = output_[frame_index - 1]->GetPc(); | |
| 505 output_frame->SetFrameSlot(output_offset, callers_pc); | |
| 506 if (trace_) { | |
| 507 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's pc\n", | |
| 508 top_address + output_offset, output_offset, callers_pc); | |
| 509 } | |
| 510 | |
| 511 // Read caller's FP from the previous frame, and set this frame's FP. | |
| 512 output_offset -= kPointerSize; | |
| 513 intptr_t value = output_[frame_index - 1]->GetFp(); | |
| 514 output_frame->SetFrameSlot(output_offset, value); | |
| 515 intptr_t fp_value = top_address + output_offset; | |
| 516 output_frame->SetFp(fp_value); | |
| 517 if (trace_) { | |
| 518 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n", | |
| 519 fp_value, output_offset, value); | |
| 520 } | |
| 521 | |
| 522 // A marker value is used in place of the context. | |
| 523 output_offset -= kPointerSize; | |
| 524 intptr_t context = reinterpret_cast<intptr_t>( | |
| 525 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | |
| 526 output_frame->SetFrameSlot(output_offset, context); | |
| 527 if (trace_) { | |
| 528 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context (adaptor sentinel)\n", | |
| 529 top_address + output_offset, output_offset, context); | |
| 530 } | |
| 531 | |
| 532 // The function was mentioned explicitly in the ARGUMENTS_ADAPTOR_FRAME. | |
| 533 output_offset -= kPointerSize; | |
| 534 value = reinterpret_cast<intptr_t>(function); | |
| 535 output_frame->SetFrameSlot(output_offset, value); | |
| 536 if (trace_) { | |
| 537 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function\n", | |
| 538 top_address + output_offset, output_offset, value); | |
| 539 } | |
| 540 | |
| 541 // Number of incoming arguments. | |
| 542 output_offset -= kPointerSize; | |
| 543 value = reinterpret_cast<uint32_t>(Smi::FromInt(height - 1)); | |
| 544 output_frame->SetFrameSlot(output_offset, value); | |
| 545 if (trace_) { | |
| 546 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; argc (%d)\n", | |
| 547 top_address + output_offset, output_offset, value, height - 1); | |
| 548 } | |
| 549 | |
| 550 ASSERT(0 == output_offset); | |
| 551 | |
| 552 Builtins* builtins = isolate_->builtins(); | |
| 553 Code* adaptor_trampoline = | |
| 554 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline); | |
| 555 uint32_t pc = reinterpret_cast<uint32_t>( | |
| 556 adaptor_trampoline->instruction_start() + | |
| 557 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value()); | |
| 558 output_frame->SetPc(pc); | |
| 559 } | |
| 560 | |
| 561 | |
| 562 void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator, | 466 void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator, |
| 563 int frame_index) { | 467 int frame_index) { |
| 564 // | 468 // |
| 565 // FROM TO | 469 // FROM TO |
| 566 // | .... | | .... | | 470 // | .... | | .... | |
| 567 // +-------------------------+ +-------------------------+ | 471 // +-------------------------+ +-------------------------+ |
| 568 // | JSFunction continuation | | JSFunction continuation | | 472 // | JSFunction continuation | | JSFunction continuation | |
| 569 // +-------------------------+ +-------------------------+ | 473 // +-------------------------+ +-------------------------+ |
| 570 // | | saved frame (ebp) | | saved frame (ebp) | | 474 // | | saved frame (ebp) | | saved frame (ebp) | |
| 571 // | +=========================+<-ebp +=========================+<-ebp | 475 // | +=========================+<-ebp +=========================+<-ebp |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 | 749 |
| 846 ASSERT(0 == output_offset); | 750 ASSERT(0 == output_offset); |
| 847 | 751 |
| 848 uint32_t pc = reinterpret_cast<uint32_t>( | 752 uint32_t pc = reinterpret_cast<uint32_t>( |
| 849 construct_stub->instruction_start() + | 753 construct_stub->instruction_start() + |
| 850 isolate_->heap()->construct_stub_deopt_pc_offset()->value()); | 754 isolate_->heap()->construct_stub_deopt_pc_offset()->value()); |
| 851 output_frame->SetPc(pc); | 755 output_frame->SetPc(pc); |
| 852 } | 756 } |
| 853 | 757 |
| 854 | 758 |
| 855 void Deoptimizer::DoComputeAccessorStubFrame(TranslationIterator* iterator, | |
| 856 int frame_index, | |
| 857 bool is_setter_stub_frame) { | |
| 858 JSFunction* accessor = JSFunction::cast(ComputeLiteral(iterator->Next())); | |
| 859 // The receiver (and the implicit return value, if any) are expected in | |
| 860 // registers by the LoadIC/StoreIC, so they don't belong to the output stack | |
| 861 // frame. This means that we have to use a height of 0. | |
| 862 unsigned height = 0; | |
| 863 unsigned height_in_bytes = height * kPointerSize; | |
| 864 const char* kind = is_setter_stub_frame ? "setter" : "getter"; | |
| 865 if (trace_) { | |
| 866 PrintF(" translating %s stub => height=%u\n", kind, height_in_bytes); | |
| 867 } | |
| 868 | |
| 869 // We need 1 stack entry for the return address + 4 stack entries from | |
| 870 // StackFrame::INTERNAL (FP, context, frame type, code object, see | |
| 871 // MacroAssembler::EnterFrame). For a setter stub frame we need one additional | |
| 872 // entry for the implicit return value, see | |
| 873 // StoreStubCompiler::CompileStoreViaSetter. | |
| 874 unsigned fixed_frame_entries = 1 + 4 + (is_setter_stub_frame ? 1 : 0); | |
| 875 unsigned fixed_frame_size = fixed_frame_entries * kPointerSize; | |
| 876 unsigned output_frame_size = height_in_bytes + fixed_frame_size; | |
| 877 | |
| 878 // Allocate and store the output frame description. | |
| 879 FrameDescription* output_frame = | |
| 880 new(output_frame_size) FrameDescription(output_frame_size, accessor); | |
| 881 output_frame->SetFrameType(StackFrame::INTERNAL); | |
| 882 | |
| 883 // A frame for an accessor stub can not be the topmost or bottommost one. | |
| 884 ASSERT(frame_index > 0 && frame_index < output_count_ - 1); | |
| 885 ASSERT(output_[frame_index] == NULL); | |
| 886 output_[frame_index] = output_frame; | |
| 887 | |
| 888 // The top address of the frame is computed from the previous frame's top and | |
| 889 // this frame's size. | |
| 890 intptr_t top_address = output_[frame_index - 1]->GetTop() - output_frame_size; | |
| 891 output_frame->SetTop(top_address); | |
| 892 | |
| 893 unsigned output_offset = output_frame_size; | |
| 894 | |
| 895 // Read caller's PC from the previous frame. | |
| 896 output_offset -= kPointerSize; | |
| 897 intptr_t callers_pc = output_[frame_index - 1]->GetPc(); | |
| 898 output_frame->SetFrameSlot(output_offset, callers_pc); | |
| 899 if (trace_) { | |
| 900 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
| 901 " ; caller's pc\n", | |
| 902 top_address + output_offset, output_offset, callers_pc); | |
| 903 } | |
| 904 | |
| 905 // Read caller's FP from the previous frame, and set this frame's FP. | |
| 906 output_offset -= kPointerSize; | |
| 907 intptr_t value = output_[frame_index - 1]->GetFp(); | |
| 908 output_frame->SetFrameSlot(output_offset, value); | |
| 909 intptr_t fp_value = top_address + output_offset; | |
| 910 output_frame->SetFp(fp_value); | |
| 911 if (trace_) { | |
| 912 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
| 913 " ; caller's fp\n", | |
| 914 fp_value, output_offset, value); | |
| 915 } | |
| 916 | |
| 917 // The context can be gotten from the previous frame. | |
| 918 output_offset -= kPointerSize; | |
| 919 value = output_[frame_index - 1]->GetContext(); | |
| 920 output_frame->SetFrameSlot(output_offset, value); | |
| 921 if (trace_) { | |
| 922 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
| 923 " ; context\n", | |
| 924 top_address + output_offset, output_offset, value); | |
| 925 } | |
| 926 | |
| 927 // A marker value is used in place of the function. | |
| 928 output_offset -= kPointerSize; | |
| 929 value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::INTERNAL)); | |
| 930 output_frame->SetFrameSlot(output_offset, value); | |
| 931 if (trace_) { | |
| 932 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
| 933 " ; function (%s sentinel)\n", | |
| 934 top_address + output_offset, output_offset, value, kind); | |
| 935 } | |
| 936 | |
| 937 // Get Code object from accessor stub. | |
| 938 output_offset -= kPointerSize; | |
| 939 Builtins::Name name = is_setter_stub_frame ? | |
| 940 Builtins::kStoreIC_Setter_ForDeopt : | |
| 941 Builtins::kLoadIC_Getter_ForDeopt; | |
| 942 Code* accessor_stub = isolate_->builtins()->builtin(name); | |
| 943 value = reinterpret_cast<intptr_t>(accessor_stub); | |
| 944 output_frame->SetFrameSlot(output_offset, value); | |
| 945 if (trace_) { | |
| 946 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
| 947 " ; code object\n", | |
| 948 top_address + output_offset, output_offset, value); | |
| 949 } | |
| 950 | |
| 951 // Skip receiver. | |
| 952 Translation::Opcode opcode = | |
| 953 static_cast<Translation::Opcode>(iterator->Next()); | |
| 954 iterator->Skip(Translation::NumberOfOperandsFor(opcode)); | |
| 955 | |
| 956 if (is_setter_stub_frame) { | |
| 957 // The implicit return value was part of the artificial setter stub | |
| 958 // environment. | |
| 959 output_offset -= kPointerSize; | |
| 960 DoTranslateCommand(iterator, frame_index, output_offset); | |
| 961 } | |
| 962 | |
| 963 ASSERT(0 == output_offset); | |
| 964 | |
| 965 Smi* offset = is_setter_stub_frame ? | |
| 966 isolate_->heap()->setter_stub_deopt_pc_offset() : | |
| 967 isolate_->heap()->getter_stub_deopt_pc_offset(); | |
| 968 intptr_t pc = reinterpret_cast<intptr_t>( | |
| 969 accessor_stub->instruction_start() + offset->value()); | |
| 970 output_frame->SetPc(pc); | |
| 971 } | |
| 972 | |
| 973 | |
| 974 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, | 759 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
| 975 int frame_index) { | 760 int frame_index) { |
| 976 BailoutId node_id = BailoutId(iterator->Next()); | 761 BailoutId node_id = BailoutId(iterator->Next()); |
| 977 JSFunction* function; | 762 JSFunction* function; |
| 978 if (frame_index != 0) { | 763 if (frame_index != 0) { |
| 979 function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 764 function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
| 980 } else { | 765 } else { |
| 981 int closure_id = iterator->Next(); | 766 int closure_id = iterator->Next(); |
| 982 USE(closure_id); | 767 USE(closure_id); |
| 983 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); | 768 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 } | 1175 } |
| 1391 __ bind(&done); | 1176 __ bind(&done); |
| 1392 } | 1177 } |
| 1393 | 1178 |
| 1394 #undef __ | 1179 #undef __ |
| 1395 | 1180 |
| 1396 | 1181 |
| 1397 } } // namespace v8::internal | 1182 } } // namespace v8::internal |
| 1398 | 1183 |
| 1399 #endif // V8_TARGET_ARCH_IA32 | 1184 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |