| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 USE(node_id); | 310 USE(node_id); |
| 311 ASSERT(node_id == ast_id); | 311 ASSERT(node_id == ast_id); |
| 312 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator.Next())); | 312 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator.Next())); |
| 313 USE(function); | 313 USE(function); |
| 314 ASSERT(function == function_); | 314 ASSERT(function == function_); |
| 315 unsigned height = iterator.Next(); | 315 unsigned height = iterator.Next(); |
| 316 unsigned height_in_bytes = height * kPointerSize; | 316 unsigned height_in_bytes = height * kPointerSize; |
| 317 USE(height_in_bytes); | 317 USE(height_in_bytes); |
| 318 | 318 |
| 319 unsigned fixed_size = ComputeFixedSize(function_); | 319 unsigned fixed_size = ComputeFixedSize(function_); |
| 320 unsigned input_frame_size = static_cast<unsigned>(input_->GetFrameSize()); | 320 unsigned input_frame_size = input_->GetFrameSize(); |
| 321 ASSERT(fixed_size + height_in_bytes == input_frame_size); | 321 ASSERT(fixed_size + height_in_bytes == input_frame_size); |
| 322 | 322 |
| 323 unsigned stack_slot_size = optimized_code_->stack_slots() * kPointerSize; | 323 unsigned stack_slot_size = optimized_code_->stack_slots() * kPointerSize; |
| 324 unsigned outgoing_height = data->ArgumentsStackHeight(bailout_id)->value(); | 324 unsigned outgoing_height = data->ArgumentsStackHeight(bailout_id)->value(); |
| 325 unsigned outgoing_size = outgoing_height * kPointerSize; | 325 unsigned outgoing_size = outgoing_height * kPointerSize; |
| 326 unsigned output_frame_size = fixed_size + stack_slot_size + outgoing_size; | 326 unsigned output_frame_size = fixed_size + stack_slot_size + outgoing_size; |
| 327 ASSERT(outgoing_size == 0); // OSR does not happen in the middle of a call. | 327 ASSERT(outgoing_size == 0); // OSR does not happen in the middle of a call. |
| 328 | 328 |
| 329 if (FLAG_trace_osr) { | 329 if (FLAG_trace_osr) { |
| 330 PrintF("[on-stack replacement: begin 0x%08" V8PRIxPTR " ", | 330 PrintF("[on-stack replacement: begin 0x%08" V8PRIxPTR " ", |
| 331 reinterpret_cast<intptr_t>(function_)); | 331 reinterpret_cast<intptr_t>(function_)); |
| 332 function_->PrintName(); | 332 function_->PrintName(); |
| 333 PrintF(" => node=%u, frame=%d->%d]\n", | 333 PrintF(" => node=%u, frame=%d->%d]\n", |
| 334 ast_id, | 334 ast_id, |
| 335 input_frame_size, | 335 input_frame_size, |
| 336 output_frame_size); | 336 output_frame_size); |
| 337 } | 337 } |
| 338 | 338 |
| 339 // There's only one output frame in the OSR case. | 339 // There's only one output frame in the OSR case. |
| 340 output_count_ = 1; | 340 output_count_ = 1; |
| 341 output_ = new FrameDescription*[1]; | 341 output_ = new FrameDescription*[1]; |
| 342 output_[0] = new(output_frame_size) FrameDescription( | 342 output_[0] = new(output_frame_size) FrameDescription( |
| 343 output_frame_size, function_); | 343 output_frame_size, function_); |
| 344 #ifdef DEBUG |
| 345 output_[0]->SetKind(Code::OPTIMIZED_FUNCTION); |
| 346 #endif |
| 344 | 347 |
| 345 // Clear the incoming parameters in the optimized frame to avoid | 348 // Clear the incoming parameters in the optimized frame to avoid |
| 346 // confusing the garbage collector. | 349 // confusing the garbage collector. |
| 347 unsigned output_offset = output_frame_size - kPointerSize; | 350 unsigned output_offset = output_frame_size - kPointerSize; |
| 348 int parameter_count = function_->shared()->formal_parameter_count() + 1; | 351 int parameter_count = function_->shared()->formal_parameter_count() + 1; |
| 349 for (int i = 0; i < parameter_count; ++i) { | 352 for (int i = 0; i < parameter_count; ++i) { |
| 350 output_[0]->SetFrameSlot(output_offset, 0); | 353 output_[0]->SetFrameSlot(output_offset, 0); |
| 351 output_offset -= kPointerSize; | 354 output_offset -= kPointerSize; |
| 352 } | 355 } |
| 353 | 356 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 unsigned height_in_bytes = height * kPointerSize; | 445 unsigned height_in_bytes = height * kPointerSize; |
| 443 if (FLAG_trace_deopt) { | 446 if (FLAG_trace_deopt) { |
| 444 PrintF(" translating "); | 447 PrintF(" translating "); |
| 445 function->PrintName(); | 448 function->PrintName(); |
| 446 PrintF(" => node=%d, height=%d\n", node_id, height_in_bytes); | 449 PrintF(" => node=%d, height=%d\n", node_id, height_in_bytes); |
| 447 } | 450 } |
| 448 | 451 |
| 449 // The 'fixed' part of the frame consists of the incoming parameters and | 452 // The 'fixed' part of the frame consists of the incoming parameters and |
| 450 // the part described by JavaScriptFrameConstants. | 453 // the part described by JavaScriptFrameConstants. |
| 451 unsigned fixed_frame_size = ComputeFixedSize(function); | 454 unsigned fixed_frame_size = ComputeFixedSize(function); |
| 452 unsigned input_frame_size = static_cast<unsigned>(input_->GetFrameSize()); | 455 unsigned input_frame_size = input_->GetFrameSize(); |
| 453 unsigned output_frame_size = height_in_bytes + fixed_frame_size; | 456 unsigned output_frame_size = height_in_bytes + fixed_frame_size; |
| 454 | 457 |
| 455 // Allocate and store the output frame description. | 458 // Allocate and store the output frame description. |
| 456 FrameDescription* output_frame = | 459 FrameDescription* output_frame = |
| 457 new(output_frame_size) FrameDescription(output_frame_size, function); | 460 new(output_frame_size) FrameDescription(output_frame_size, function); |
| 461 #ifdef DEBUG |
| 462 output_frame->SetKind(Code::FUNCTION); |
| 463 #endif |
| 458 | 464 |
| 459 bool is_bottommost = (0 == frame_index); | 465 bool is_bottommost = (0 == frame_index); |
| 460 bool is_topmost = (output_count_ - 1 == frame_index); | 466 bool is_topmost = (output_count_ - 1 == frame_index); |
| 461 ASSERT(frame_index >= 0 && frame_index < output_count_); | 467 ASSERT(frame_index >= 0 && frame_index < output_count_); |
| 462 ASSERT(output_[frame_index] == NULL); | 468 ASSERT(output_[frame_index] == NULL); |
| 463 output_[frame_index] = output_frame; | 469 output_[frame_index] = output_frame; |
| 464 | 470 |
| 465 // The top address for the bottommost output frame can be computed from | 471 // The top address for the bottommost output frame can be computed from |
| 466 // the input frame pointer and the output frame's height. For all | 472 // the input frame pointer and the output frame's height. For all |
| 467 // subsequent output frames, it can be computed from the previous one's | 473 // subsequent output frames, it can be computed from the previous one's |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 unsigned pc_and_state = GetOutputInfo(data, node_id, function->shared()); | 584 unsigned pc_and_state = GetOutputInfo(data, node_id, function->shared()); |
| 579 unsigned pc_offset = FullCodeGenerator::PcField::decode(pc_and_state); | 585 unsigned pc_offset = FullCodeGenerator::PcField::decode(pc_and_state); |
| 580 intptr_t pc_value = reinterpret_cast<intptr_t>(start + pc_offset); | 586 intptr_t pc_value = reinterpret_cast<intptr_t>(start + pc_offset); |
| 581 output_frame->SetPc(pc_value); | 587 output_frame->SetPc(pc_value); |
| 582 | 588 |
| 583 FullCodeGenerator::State state = | 589 FullCodeGenerator::State state = |
| 584 FullCodeGenerator::StateField::decode(pc_and_state); | 590 FullCodeGenerator::StateField::decode(pc_and_state); |
| 585 output_frame->SetState(Smi::FromInt(state)); | 591 output_frame->SetState(Smi::FromInt(state)); |
| 586 | 592 |
| 587 // Set the continuation for the topmost frame. | 593 // Set the continuation for the topmost frame. |
| 588 if (is_topmost) { | 594 if (is_topmost && bailout_type_ != DEBUGGER) { |
| 589 Code* continuation = (bailout_type_ == EAGER) | 595 Code* continuation = (bailout_type_ == EAGER) |
| 590 ? isolate_->builtins()->builtin(Builtins::kNotifyDeoptimized) | 596 ? isolate_->builtins()->builtin(Builtins::kNotifyDeoptimized) |
| 591 : isolate_->builtins()->builtin(Builtins::kNotifyLazyDeoptimized); | 597 : isolate_->builtins()->builtin(Builtins::kNotifyLazyDeoptimized); |
| 592 output_frame->SetContinuation( | 598 output_frame->SetContinuation( |
| 593 reinterpret_cast<intptr_t>(continuation->entry())); | 599 reinterpret_cast<intptr_t>(continuation->entry())); |
| 594 } | 600 } |
| 595 | 601 |
| 596 if (output_count_ - 1 == frame_index) iterator->Done(); | 602 if (output_count_ - 1 == frame_index) iterator->Done(); |
| 597 } | 603 } |
| 598 | 604 |
| 599 | 605 |
| 606 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { |
| 607 // Set the register values. The values are not important as there are no |
| 608 // callee saved registers in JavaScript frames, so all registers are |
| 609 // spilled. Registers rbp and rsp are set to the correct values though. |
| 610 for (int i = 0; i < Register::kNumRegisters; i++) { |
| 611 input_->SetRegister(i, i * 4); |
| 612 } |
| 613 input_->SetRegister(rsp.code(), reinterpret_cast<intptr_t>(frame->sp())); |
| 614 input_->SetRegister(rbp.code(), reinterpret_cast<intptr_t>(frame->fp())); |
| 615 for (int i = 0; i < DoubleRegister::kNumAllocatableRegisters; i++) { |
| 616 input_->SetDoubleRegister(i, 0.0); |
| 617 } |
| 618 |
| 619 // Fill the frame content from the actual data on the frame. |
| 620 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { |
| 621 input_->SetFrameSlot(i, Memory::uint64_at(tos + i)); |
| 622 } |
| 623 } |
| 624 |
| 625 |
| 600 #define __ masm()-> | 626 #define __ masm()-> |
| 601 | 627 |
| 602 void Deoptimizer::EntryGenerator::Generate() { | 628 void Deoptimizer::EntryGenerator::Generate() { |
| 603 GeneratePrologue(); | 629 GeneratePrologue(); |
| 604 | 630 |
| 605 // Save all general purpose registers before messing with them. | 631 // Save all general purpose registers before messing with them. |
| 606 const int kNumberOfRegisters = Register::kNumRegisters; | 632 const int kNumberOfRegisters = Register::kNumRegisters; |
| 607 | 633 |
| 608 const int kDoubleRegsSize = kDoubleSize * | 634 const int kDoubleRegsSize = kDoubleSize * |
| 609 XMMRegister::kNumAllocatableRegisters; | 635 XMMRegister::kNumAllocatableRegisters; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 } | 833 } |
| 808 __ bind(&done); | 834 __ bind(&done); |
| 809 } | 835 } |
| 810 | 836 |
| 811 #undef __ | 837 #undef __ |
| 812 | 838 |
| 813 | 839 |
| 814 } } // namespace v8::internal | 840 } } // namespace v8::internal |
| 815 | 841 |
| 816 #endif // V8_TARGET_ARCH_X64 | 842 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |