| 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 // Do a tail-call of the compiled function. | 535 // Do a tail-call of the compiled function. |
| 536 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); | 536 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); |
| 537 __ jmp(eax); | 537 __ jmp(eax); |
| 538 } | 538 } |
| 539 | 539 |
| 540 | 540 |
| 541 static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm, | 541 static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm, |
| 542 Deoptimizer::BailoutType type) { | 542 Deoptimizer::BailoutType type) { |
| 543 { | 543 { |
| 544 FrameScope scope(masm, StackFrame::INTERNAL); | 544 FrameScope scope(masm, StackFrame::INTERNAL); |
| 545 | 545 // Registers set in the output frame that need to be preserved. |
| 546 if (type == Deoptimizer::LAZY) { |
| 547 __ push(eax); // Exception when throwing to optimized code. |
| 548 } |
| 546 // Pass deoptimization type to the runtime system. | 549 // Pass deoptimization type to the runtime system. |
| 547 __ push(Immediate(Smi::FromInt(static_cast<int>(type)))); | 550 __ push(Immediate(Smi::FromInt(static_cast<int>(type)))); |
| 548 __ CallRuntime(Runtime::kNotifyDeoptimized, 1); | 551 __ CallRuntime(Runtime::kNotifyDeoptimized, 1); |
| 549 | 552 |
| 553 if (type == Deoptimizer::LAZY) { |
| 554 __ pop(eax); |
| 555 } |
| 550 // Tear down internal frame. | 556 // Tear down internal frame. |
| 551 } | 557 } |
| 552 | 558 |
| 553 // Get the full codegen state from the stack and untag it. | |
| 554 __ mov(ecx, Operand(esp, 1 * kPointerSize)); | |
| 555 __ SmiUntag(ecx); | |
| 556 | |
| 557 // Switch on the state. | 559 // Switch on the state. |
| 558 Label not_no_registers, not_tos_eax; | 560 Label not_no_registers; |
| 559 __ cmp(ecx, FullCodeGenerator::NO_REGISTERS); | 561 __ cmp(Operand(esp, 1 * kPointerSize), |
| 562 Immediate(Smi::FromInt(FullCodeGenerator::NO_REGISTERS))); |
| 560 __ j(not_equal, ¬_no_registers, Label::kNear); | 563 __ j(not_equal, ¬_no_registers, Label::kNear); |
| 561 __ ret(1 * kPointerSize); // Remove state. | 564 __ ret(1 * kPointerSize); // Remove state. |
| 562 | 565 |
| 563 __ bind(¬_no_registers); | 566 __ bind(¬_no_registers); |
| 564 __ mov(eax, Operand(esp, 2 * kPointerSize)); | 567 __ mov(eax, Operand(esp, 2 * kPointerSize)); |
| 565 __ cmp(ecx, FullCodeGenerator::TOS_REG); | 568 if (masm->emit_debug_code()) { |
| 566 __ j(not_equal, ¬_tos_eax, Label::kNear); | 569 __ cmp(Operand(esp, 1 * kPointerSize), |
| 570 Immediate(Smi::FromInt(FullCodeGenerator::TOS_REG))); |
| 571 __ Assert(equal, "Invalid deoptimization state."); |
| 572 } |
| 567 __ ret(2 * kPointerSize); // Remove state, eax. | 573 __ ret(2 * kPointerSize); // Remove state, eax. |
| 568 | |
| 569 __ bind(¬_tos_eax); | |
| 570 __ Abort("no cases left"); | |
| 571 } | 574 } |
| 572 | 575 |
| 573 | 576 |
| 574 void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) { | 577 void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) { |
| 575 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::EAGER); | 578 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::EAGER); |
| 576 } | 579 } |
| 577 | 580 |
| 578 | 581 |
| 579 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { | 582 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { |
| 580 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); | 583 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); |
| (...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1767 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1770 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
| 1768 generator.Generate(); | 1771 generator.Generate(); |
| 1769 } | 1772 } |
| 1770 | 1773 |
| 1771 | 1774 |
| 1772 #undef __ | 1775 #undef __ |
| 1773 } | 1776 } |
| 1774 } // namespace v8::internal | 1777 } // namespace v8::internal |
| 1775 | 1778 |
| 1776 #endif // V8_TARGET_ARCH_IA32 | 1779 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |