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