| 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 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1803 env->Bind(instr->GetAssignedIndexAt(i), value); | 1819 env->Bind(instr->GetAssignedIndexAt(i), value); |
| 1804 } else { | 1820 } else { |
| 1805 env->Push(value); | 1821 env->Push(value); |
| 1806 } | 1822 } |
| 1807 } | 1823 } |
| 1808 | 1824 |
| 1809 ASSERT(env->length() == instr->environment_length()); | 1825 ASSERT(env->length() == instr->environment_length()); |
| 1810 | 1826 |
| 1811 // If there is an instruction pending deoptimization environment create a | 1827 // If there is an instruction pending deoptimization environment create a |
| 1812 // lazy bailout instruction to capture the environment. | 1828 // lazy bailout instruction to capture the environment. |
| 1813 if (pending_deoptimization_ast_id_ != AstNode::kNoNumber) { | 1829 if (pending_deoptimization_ast_id_ == instr->ast_id()) { |
| 1814 ASSERT(pending_deoptimization_ast_id_ == instr->ast_id()); | 1830 LInstruction* result = new LLazyBailout; |
| 1815 LInstruction* lazy_bailout = new LLazyBailout; | 1831 result = AssignEnvironment(result); |
| 1816 LInstruction* result = AssignEnvironment(lazy_bailout); | 1832 instructions_pending_deoptimization_environment_-> |
| 1817 pending_deoptimization_ast_id_ = AstNode::kNoNumber; | 1833 set_deoptimization_environment(result->environment()); |
| 1834 ClearInstructionPendingDeoptimizationEnvironment(); |
| 1818 return result; | 1835 return result; |
| 1819 } | 1836 } |
| 1820 | 1837 |
| 1821 return NULL; | 1838 return NULL; |
| 1822 } | 1839 } |
| 1823 | 1840 |
| 1824 | 1841 |
| 1825 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 1842 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
| 1826 return MarkAsCall(new LStackCheck, instr); | 1843 return MarkAsCall(new LStackCheck, instr); |
| 1827 } | 1844 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1841 | 1858 |
| 1842 | 1859 |
| 1843 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 1860 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
| 1844 HEnvironment* outer = current_block_->last_environment()->outer(); | 1861 HEnvironment* outer = current_block_->last_environment()->outer(); |
| 1845 current_block_->UpdateEnvironment(outer); | 1862 current_block_->UpdateEnvironment(outer); |
| 1846 return NULL; | 1863 return NULL; |
| 1847 } | 1864 } |
| 1848 | 1865 |
| 1849 | 1866 |
| 1850 } } // namespace v8::internal | 1867 } } // namespace v8::internal |
| OLD | NEW |