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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 } | 649 } |
650 | 650 |
651 | 651 |
652 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 652 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
653 HEnvironment* hydrogen_env = current_block_->last_environment(); | 653 HEnvironment* hydrogen_env = current_block_->last_environment(); |
654 instr->set_environment(CreateEnvironment(hydrogen_env)); | 654 instr->set_environment(CreateEnvironment(hydrogen_env)); |
655 return instr; | 655 return instr; |
656 } | 656 } |
657 | 657 |
658 | 658 |
| 659 LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment( |
| 660 LInstruction* instr, int ast_id) { |
| 661 ASSERT(instructions_pending_deoptimization_environment_ == NULL); |
| 662 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); |
| 663 instructions_pending_deoptimization_environment_ = instr; |
| 664 pending_deoptimization_ast_id_ = ast_id; |
| 665 return instr; |
| 666 } |
| 667 |
| 668 |
| 669 void LChunkBuilder::ClearInstructionPendingDeoptimizationEnvironment() { |
| 670 instructions_pending_deoptimization_environment_ = NULL; |
| 671 pending_deoptimization_ast_id_ = AstNode::kNoNumber; |
| 672 } |
| 673 |
| 674 |
659 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 675 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
660 HInstruction* hinstr, | 676 HInstruction* hinstr, |
661 CanDeoptimize can_deoptimize) { | 677 CanDeoptimize can_deoptimize) { |
662 allocator_->MarkAsCall(); | 678 allocator_->MarkAsCall(); |
663 instr = AssignPointerMap(instr); | 679 instr = AssignPointerMap(instr); |
664 | 680 |
665 if (hinstr->HasSideEffects()) { | 681 if (hinstr->HasSideEffects()) { |
666 ASSERT(hinstr->next()->IsSimulate()); | 682 ASSERT(hinstr->next()->IsSimulate()); |
667 HSimulate* sim = HSimulate::cast(hinstr->next()); | 683 HSimulate* sim = HSimulate::cast(hinstr->next()); |
668 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); | 684 instr = SetInstructionPendingDeoptimizationEnvironment( |
669 pending_deoptimization_ast_id_ = sim->ast_id(); | 685 instr, sim->ast_id()); |
670 } | 686 } |
671 | 687 |
672 // If instruction does not have side-effects lazy deoptimization | 688 // If instruction does not have side-effects lazy deoptimization |
673 // after the call will try to deoptimize to the point before the call. | 689 // after the call will try to deoptimize to the point before the call. |
674 // Thus we still need to attach environment to this call even if | 690 // Thus we still need to attach environment to this call even if |
675 // call sequence can not deoptimize eagerly. | 691 // call sequence can not deoptimize eagerly. |
676 bool needs_environment = | 692 bool needs_environment = |
677 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || !hinstr->HasSideEffects(); | 693 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || !hinstr->HasSideEffects(); |
678 if (needs_environment && !instr->HasEnvironment()) { | 694 if (needs_environment && !instr->HasEnvironment()) { |
679 instr = AssignEnvironment(instr); | 695 instr = AssignEnvironment(instr); |
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 if (instr->HasAssignedIndexAt(i)) { | 1867 if (instr->HasAssignedIndexAt(i)) { |
1852 env->Bind(instr->GetAssignedIndexAt(i), value); | 1868 env->Bind(instr->GetAssignedIndexAt(i), value); |
1853 } else { | 1869 } else { |
1854 env->Push(value); | 1870 env->Push(value); |
1855 } | 1871 } |
1856 } | 1872 } |
1857 ASSERT(env->length() == instr->environment_length()); | 1873 ASSERT(env->length() == instr->environment_length()); |
1858 | 1874 |
1859 // If there is an instruction pending deoptimization environment create a | 1875 // If there is an instruction pending deoptimization environment create a |
1860 // lazy bailout instruction to capture the environment. | 1876 // lazy bailout instruction to capture the environment. |
1861 if (pending_deoptimization_ast_id_ != AstNode::kNoNumber) { | 1877 if (pending_deoptimization_ast_id_ == instr->ast_id()) { |
1862 ASSERT(pending_deoptimization_ast_id_ == instr->ast_id()); | |
1863 LLazyBailout* lazy_bailout = new LLazyBailout; | 1878 LLazyBailout* lazy_bailout = new LLazyBailout; |
1864 LInstruction* result = AssignEnvironment(lazy_bailout); | 1879 LInstruction* result = AssignEnvironment(lazy_bailout); |
1865 pending_deoptimization_ast_id_ = AstNode::kNoNumber; | 1880 instructions_pending_deoptimization_environment_-> |
| 1881 set_deoptimization_environment(result->environment()); |
| 1882 ClearInstructionPendingDeoptimizationEnvironment(); |
1866 return result; | 1883 return result; |
1867 } | 1884 } |
1868 | 1885 |
1869 return NULL; | 1886 return NULL; |
1870 } | 1887 } |
1871 | 1888 |
1872 | 1889 |
1873 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 1890 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
1874 return MarkAsCall(new LStackCheck, instr); | 1891 return MarkAsCall(new LStackCheck, instr); |
1875 } | 1892 } |
(...skipping 15 matching lines...) Expand all Loading... |
1891 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 1908 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
1892 HEnvironment* outer = current_block_->last_environment()->outer(); | 1909 HEnvironment* outer = current_block_->last_environment()->outer(); |
1893 current_block_->UpdateEnvironment(outer); | 1910 current_block_->UpdateEnvironment(outer); |
1894 return NULL; | 1911 return NULL; |
1895 } | 1912 } |
1896 | 1913 |
1897 | 1914 |
1898 } } // namespace v8::internal | 1915 } } // namespace v8::internal |
1899 | 1916 |
1900 #endif // V8_TARGET_ARCH_IA32 | 1917 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |