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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 } | 646 } |
647 | 647 |
648 | 648 |
649 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 649 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
650 HEnvironment* hydrogen_env = current_block_->last_environment(); | 650 HEnvironment* hydrogen_env = current_block_->last_environment(); |
651 instr->set_environment(CreateEnvironment(hydrogen_env)); | 651 instr->set_environment(CreateEnvironment(hydrogen_env)); |
652 return instr; | 652 return instr; |
653 } | 653 } |
654 | 654 |
655 | 655 |
| 656 LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment( |
| 657 LInstruction* instr, int ast_id) { |
| 658 ASSERT(instructions_pending_deoptimization_environment_ == NULL); |
| 659 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); |
| 660 instructions_pending_deoptimization_environment_ = instr; |
| 661 pending_deoptimization_ast_id_ = ast_id; |
| 662 return instr; |
| 663 } |
| 664 |
| 665 |
| 666 void LChunkBuilder::ClearInstructionPendingDeoptimizationEnvironment() { |
| 667 instructions_pending_deoptimization_environment_ = NULL; |
| 668 pending_deoptimization_ast_id_ = AstNode::kNoNumber; |
| 669 } |
| 670 |
| 671 |
656 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 672 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
657 HInstruction* hinstr, | 673 HInstruction* hinstr, |
658 CanDeoptimize can_deoptimize) { | 674 CanDeoptimize can_deoptimize) { |
659 allocator_->MarkAsCall(); | 675 allocator_->MarkAsCall(); |
660 instr = AssignPointerMap(instr); | 676 instr = AssignPointerMap(instr); |
661 | 677 |
662 if (hinstr->HasSideEffects()) { | 678 if (hinstr->HasSideEffects()) { |
663 ASSERT(hinstr->next()->IsSimulate()); | 679 ASSERT(hinstr->next()->IsSimulate()); |
664 HSimulate* sim = HSimulate::cast(hinstr->next()); | 680 HSimulate* sim = HSimulate::cast(hinstr->next()); |
665 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); | 681 instr = SetInstructionPendingDeoptimizationEnvironment( |
666 pending_deoptimization_ast_id_ = sim->ast_id(); | 682 instr, sim->ast_id()); |
667 } | 683 } |
668 | 684 |
669 // If instruction does not have side-effects lazy deoptimization | 685 // If instruction does not have side-effects lazy deoptimization |
670 // after the call will try to deoptimize to the point before the call. | 686 // after the call will try to deoptimize to the point before the call. |
671 // Thus we still need to attach environment to this call even if | 687 // Thus we still need to attach environment to this call even if |
672 // call sequence can not deoptimize eagerly. | 688 // call sequence can not deoptimize eagerly. |
673 bool needs_environment = | 689 bool needs_environment = |
674 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || !hinstr->HasSideEffects(); | 690 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || !hinstr->HasSideEffects(); |
675 if (needs_environment && !instr->HasEnvironment()) { | 691 if (needs_environment && !instr->HasEnvironment()) { |
676 instr = AssignEnvironment(instr); | 692 instr = AssignEnvironment(instr); |
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 env->Bind(instr->GetAssignedIndexAt(i), value); | 1820 env->Bind(instr->GetAssignedIndexAt(i), value); |
1805 } else { | 1821 } else { |
1806 env->Push(value); | 1822 env->Push(value); |
1807 } | 1823 } |
1808 } | 1824 } |
1809 | 1825 |
1810 ASSERT(env->length() == instr->environment_length()); | 1826 ASSERT(env->length() == instr->environment_length()); |
1811 | 1827 |
1812 // If there is an instruction pending deoptimization environment create a | 1828 // If there is an instruction pending deoptimization environment create a |
1813 // lazy bailout instruction to capture the environment. | 1829 // lazy bailout instruction to capture the environment. |
1814 if (pending_deoptimization_ast_id_ != AstNode::kNoNumber) { | 1830 if (pending_deoptimization_ast_id_ == instr->ast_id()) { |
1815 ASSERT(pending_deoptimization_ast_id_ == instr->ast_id()); | 1831 LInstruction* result = new LLazyBailout; |
1816 LInstruction* lazy_bailout = new LLazyBailout; | 1832 result = AssignEnvironment(result); |
1817 LInstruction* result = AssignEnvironment(lazy_bailout); | 1833 instructions_pending_deoptimization_environment_-> |
1818 pending_deoptimization_ast_id_ = AstNode::kNoNumber; | 1834 set_deoptimization_environment(result->environment()); |
| 1835 ClearInstructionPendingDeoptimizationEnvironment(); |
1819 return result; | 1836 return result; |
1820 } | 1837 } |
1821 | 1838 |
1822 return NULL; | 1839 return NULL; |
1823 } | 1840 } |
1824 | 1841 |
1825 | 1842 |
1826 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 1843 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
1827 return MarkAsCall(new LStackCheck, instr); | 1844 return MarkAsCall(new LStackCheck, instr); |
1828 } | 1845 } |
(...skipping 13 matching lines...) Expand all Loading... |
1842 | 1859 |
1843 | 1860 |
1844 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 1861 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
1845 HEnvironment* outer = current_block_->last_environment()->outer(); | 1862 HEnvironment* outer = current_block_->last_environment()->outer(); |
1846 current_block_->UpdateEnvironment(outer); | 1863 current_block_->UpdateEnvironment(outer); |
1847 return NULL; | 1864 return NULL; |
1848 } | 1865 } |
1849 | 1866 |
1850 | 1867 |
1851 } } // namespace v8::internal | 1868 } } // namespace v8::internal |
OLD | NEW |