| 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 ast_id, | 349 ast_id, |
| 350 input_frame_size, | 350 input_frame_size, |
| 351 output_frame_size); | 351 output_frame_size); |
| 352 } | 352 } |
| 353 | 353 |
| 354 // There's only one output frame in the OSR case. | 354 // There's only one output frame in the OSR case. |
| 355 output_count_ = 1; | 355 output_count_ = 1; |
| 356 output_ = new FrameDescription*[1]; | 356 output_ = new FrameDescription*[1]; |
| 357 output_[0] = new(output_frame_size) FrameDescription( | 357 output_[0] = new(output_frame_size) FrameDescription( |
| 358 output_frame_size, function_); | 358 output_frame_size, function_); |
| 359 #ifdef DEBUG |
| 360 output_[0]->SetKind(Code::OPTIMIZED_FUNCTION); |
| 361 #endif |
| 359 | 362 |
| 360 // Clear the incoming parameters in the optimized frame to avoid | 363 // Clear the incoming parameters in the optimized frame to avoid |
| 361 // confusing the garbage collector. | 364 // confusing the garbage collector. |
| 362 unsigned output_offset = output_frame_size - kPointerSize; | 365 unsigned output_offset = output_frame_size - kPointerSize; |
| 363 int parameter_count = function_->shared()->formal_parameter_count() + 1; | 366 int parameter_count = function_->shared()->formal_parameter_count() + 1; |
| 364 for (int i = 0; i < parameter_count; ++i) { | 367 for (int i = 0; i < parameter_count; ++i) { |
| 365 output_[0]->SetFrameSlot(output_offset, 0); | 368 output_[0]->SetFrameSlot(output_offset, 0); |
| 366 output_offset -= kPointerSize; | 369 output_offset -= kPointerSize; |
| 367 } | 370 } |
| 368 | 371 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 | 465 |
| 463 // The 'fixed' part of the frame consists of the incoming parameters and | 466 // The 'fixed' part of the frame consists of the incoming parameters and |
| 464 // the part described by JavaScriptFrameConstants. | 467 // the part described by JavaScriptFrameConstants. |
| 465 unsigned fixed_frame_size = ComputeFixedSize(function); | 468 unsigned fixed_frame_size = ComputeFixedSize(function); |
| 466 unsigned input_frame_size = input_->GetFrameSize(); | 469 unsigned input_frame_size = input_->GetFrameSize(); |
| 467 unsigned output_frame_size = height_in_bytes + fixed_frame_size; | 470 unsigned output_frame_size = height_in_bytes + fixed_frame_size; |
| 468 | 471 |
| 469 // Allocate and store the output frame description. | 472 // Allocate and store the output frame description. |
| 470 FrameDescription* output_frame = | 473 FrameDescription* output_frame = |
| 471 new(output_frame_size) FrameDescription(output_frame_size, function); | 474 new(output_frame_size) FrameDescription(output_frame_size, function); |
| 475 #ifdef DEBUG |
| 476 output_frame->SetKind(Code::FUNCTION); |
| 477 #endif |
| 472 | 478 |
| 473 bool is_bottommost = (0 == frame_index); | 479 bool is_bottommost = (0 == frame_index); |
| 474 bool is_topmost = (output_count_ - 1 == frame_index); | 480 bool is_topmost = (output_count_ - 1 == frame_index); |
| 475 ASSERT(frame_index >= 0 && frame_index < output_count_); | 481 ASSERT(frame_index >= 0 && frame_index < output_count_); |
| 476 ASSERT(output_[frame_index] == NULL); | 482 ASSERT(output_[frame_index] == NULL); |
| 477 output_[frame_index] = output_frame; | 483 output_[frame_index] = output_frame; |
| 478 | 484 |
| 479 // The top address for the bottommost output frame can be computed from | 485 // The top address for the bottommost output frame can be computed from |
| 480 // the input frame pointer and the output frame's height. For all | 486 // the input frame pointer and the output frame's height. For all |
| 481 // subsequent output frames, it can be computed from the previous one's | 487 // subsequent output frames, it can be computed from the previous one's |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 unsigned pc_and_state = GetOutputInfo(data, node_id, function->shared()); | 594 unsigned pc_and_state = GetOutputInfo(data, node_id, function->shared()); |
| 589 unsigned pc_offset = FullCodeGenerator::PcField::decode(pc_and_state); | 595 unsigned pc_offset = FullCodeGenerator::PcField::decode(pc_and_state); |
| 590 uint32_t pc_value = reinterpret_cast<uint32_t>(start + pc_offset); | 596 uint32_t pc_value = reinterpret_cast<uint32_t>(start + pc_offset); |
| 591 output_frame->SetPc(pc_value); | 597 output_frame->SetPc(pc_value); |
| 592 | 598 |
| 593 FullCodeGenerator::State state = | 599 FullCodeGenerator::State state = |
| 594 FullCodeGenerator::StateField::decode(pc_and_state); | 600 FullCodeGenerator::StateField::decode(pc_and_state); |
| 595 output_frame->SetState(Smi::FromInt(state)); | 601 output_frame->SetState(Smi::FromInt(state)); |
| 596 | 602 |
| 597 // Set the continuation for the topmost frame. | 603 // Set the continuation for the topmost frame. |
| 598 if (is_topmost) { | 604 if (is_topmost && bailout_type_ != DEBUGGER) { |
| 599 Builtins* builtins = isolate_->builtins(); | 605 Builtins* builtins = isolate_->builtins(); |
| 600 Code* continuation = (bailout_type_ == EAGER) | 606 Code* continuation = (bailout_type_ == EAGER) |
| 601 ? builtins->builtin(Builtins::kNotifyDeoptimized) | 607 ? builtins->builtin(Builtins::kNotifyDeoptimized) |
| 602 : builtins->builtin(Builtins::kNotifyLazyDeoptimized); | 608 : builtins->builtin(Builtins::kNotifyLazyDeoptimized); |
| 603 output_frame->SetContinuation( | 609 output_frame->SetContinuation( |
| 604 reinterpret_cast<uint32_t>(continuation->entry())); | 610 reinterpret_cast<uint32_t>(continuation->entry())); |
| 605 } | 611 } |
| 606 | 612 |
| 607 if (output_count_ - 1 == frame_index) iterator->Done(); | 613 if (output_count_ - 1 == frame_index) iterator->Done(); |
| 608 } | 614 } |
| 609 | 615 |
| 610 | 616 |
| 617 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { |
| 618 // Set the register values. The values are not important as there are no |
| 619 // callee saved registers in JavaScript frames, so all registers are |
| 620 // spilled. Registers ebp and esp are set to the correct values though. |
| 621 |
| 622 for (int i = 0; i < Register::kNumRegisters; i++) { |
| 623 input_->SetRegister(i, i * 4); |
| 624 } |
| 625 input_->SetRegister(esp.code(), reinterpret_cast<intptr_t>(frame->sp())); |
| 626 input_->SetRegister(ebp.code(), reinterpret_cast<intptr_t>(frame->fp())); |
| 627 for (int i = 0; i < DoubleRegister::kNumAllocatableRegisters; i++) { |
| 628 input_->SetDoubleRegister(i, 0.0); |
| 629 } |
| 630 |
| 631 // Fill the frame content from the actual data on the frame. |
| 632 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { |
| 633 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); |
| 634 } |
| 635 } |
| 636 |
| 637 |
| 611 #define __ masm()-> | 638 #define __ masm()-> |
| 612 | 639 |
| 613 void Deoptimizer::EntryGenerator::Generate() { | 640 void Deoptimizer::EntryGenerator::Generate() { |
| 614 GeneratePrologue(); | 641 GeneratePrologue(); |
| 615 CpuFeatures::Scope scope(SSE2); | 642 CpuFeatures::Scope scope(SSE2); |
| 616 | 643 |
| 617 Isolate* isolate = masm()->isolate(); | 644 Isolate* isolate = masm()->isolate(); |
| 618 | 645 |
| 619 // Save all general purpose registers before messing with them. | 646 // Save all general purpose registers before messing with them. |
| 620 const int kNumberOfRegisters = Register::kNumRegisters; | 647 const int kNumberOfRegisters = Register::kNumRegisters; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 } | 800 } |
| 774 __ bind(&done); | 801 __ bind(&done); |
| 775 } | 802 } |
| 776 | 803 |
| 777 #undef __ | 804 #undef __ |
| 778 | 805 |
| 779 | 806 |
| 780 } } // namespace v8::internal | 807 } } // namespace v8::internal |
| 781 | 808 |
| 782 #endif // V8_TARGET_ARCH_IA32 | 809 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |