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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 | 725 |
726 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 726 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
727 HEnvironment* hydrogen_env = current_block_->last_environment(); | 727 HEnvironment* hydrogen_env = current_block_->last_environment(); |
728 int argument_index_accumulator = 0; | 728 int argument_index_accumulator = 0; |
729 instr->set_environment(CreateEnvironment(hydrogen_env, | 729 instr->set_environment(CreateEnvironment(hydrogen_env, |
730 &argument_index_accumulator)); | 730 &argument_index_accumulator)); |
731 return instr; | 731 return instr; |
732 } | 732 } |
733 | 733 |
734 | 734 |
735 LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment( | |
736 LInstruction* instr, int ast_id) { | |
737 ASSERT(instruction_pending_deoptimization_environment_ == NULL); | |
738 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); | |
739 instruction_pending_deoptimization_environment_ = instr; | |
740 pending_deoptimization_ast_id_ = ast_id; | |
741 return instr; | |
742 } | |
743 | |
744 | |
745 void LChunkBuilder::ClearInstructionPendingDeoptimizationEnvironment() { | |
746 instruction_pending_deoptimization_environment_ = NULL; | |
747 pending_deoptimization_ast_id_ = AstNode::kNoNumber; | |
748 } | |
749 | |
750 | |
751 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 735 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
752 HInstruction* hinstr, | 736 HInstruction* hinstr, |
753 CanDeoptimize can_deoptimize) { | 737 CanDeoptimize can_deoptimize) { |
754 #ifdef DEBUG | 738 #ifdef DEBUG |
755 instr->VerifyCall(); | 739 instr->VerifyCall(); |
756 #endif | 740 #endif |
757 instr->MarkAsCall(); | 741 instr->MarkAsCall(); |
758 instr = AssignPointerMap(instr); | 742 instr = AssignPointerMap(instr); |
759 | 743 |
760 if (hinstr->HasObservableSideEffects()) { | 744 if (hinstr->HasObservableSideEffects()) { |
761 ASSERT(hinstr->next()->IsSimulate()); | 745 ASSERT(hinstr->next()->IsSimulate()); |
762 HSimulate* sim = HSimulate::cast(hinstr->next()); | 746 HSimulate* sim = HSimulate::cast(hinstr->next()); |
763 instr = SetInstructionPendingDeoptimizationEnvironment( | 747 ASSERT(instruction_pending_deoptimization_environment_ == NULL); |
764 instr, sim->ast_id()); | 748 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber); |
| 749 instruction_pending_deoptimization_environment_ = instr; |
| 750 pending_deoptimization_ast_id_ = sim->ast_id(); |
765 } | 751 } |
766 | 752 |
767 // If instruction does not have side-effects lazy deoptimization | 753 // If instruction does not have side-effects lazy deoptimization |
768 // after the call will try to deoptimize to the point before the call. | 754 // after the call will try to deoptimize to the point before the call. |
769 // Thus we still need to attach environment to this call even if | 755 // Thus we still need to attach environment to this call even if |
770 // call sequence can not deoptimize eagerly. | 756 // call sequence can not deoptimize eagerly. |
771 bool needs_environment = | 757 bool needs_environment = |
772 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || | 758 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || |
773 !hinstr->HasObservableSideEffects(); | 759 !hinstr->HasObservableSideEffects(); |
774 if (needs_environment && !instr->HasEnvironment()) { | 760 if (needs_environment && !instr->HasEnvironment()) { |
775 instr = AssignEnvironment(instr); | 761 instr = AssignEnvironment(instr); |
776 } | 762 } |
777 | 763 |
778 return instr; | 764 return instr; |
779 } | 765 } |
780 | 766 |
781 | 767 |
782 LInstruction* LChunkBuilder::MarkAsSaveDoubles(LInstruction* instr) { | |
783 instr->MarkAsSaveDoubles(); | |
784 return instr; | |
785 } | |
786 | |
787 | |
788 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { | 768 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { |
789 ASSERT(!instr->HasPointerMap()); | 769 ASSERT(!instr->HasPointerMap()); |
790 instr->set_pointer_map(new(zone()) LPointerMap(position_)); | 770 instr->set_pointer_map(new(zone()) LPointerMap(position_)); |
791 return instr; | 771 return instr; |
792 } | 772 } |
793 | 773 |
794 | 774 |
795 LUnallocated* LChunkBuilder::TempRegister() { | 775 LUnallocated* LChunkBuilder::TempRegister() { |
796 LUnallocated* operand = | 776 LUnallocated* operand = |
797 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); | 777 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); |
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2235 } else { | 2215 } else { |
2236 env->Push(value); | 2216 env->Push(value); |
2237 } | 2217 } |
2238 } | 2218 } |
2239 | 2219 |
2240 // If there is an instruction pending deoptimization environment create a | 2220 // If there is an instruction pending deoptimization environment create a |
2241 // lazy bailout instruction to capture the environment. | 2221 // lazy bailout instruction to capture the environment. |
2242 if (pending_deoptimization_ast_id_ == instr->ast_id()) { | 2222 if (pending_deoptimization_ast_id_ == instr->ast_id()) { |
2243 LInstruction* result = new(zone()) LLazyBailout; | 2223 LInstruction* result = new(zone()) LLazyBailout; |
2244 result = AssignEnvironment(result); | 2224 result = AssignEnvironment(result); |
| 2225 // Store the lazy deopt environment with the instruction if needed. Right |
| 2226 // now it is only used for LInstanceOfKnownGlobal. |
2245 instruction_pending_deoptimization_environment_-> | 2227 instruction_pending_deoptimization_environment_-> |
2246 set_deoptimization_environment(result->environment()); | 2228 SetDeferredLazyDeoptimizationEnvironment(result->environment()); |
2247 ClearInstructionPendingDeoptimizationEnvironment(); | 2229 instruction_pending_deoptimization_environment_ = NULL; |
| 2230 pending_deoptimization_ast_id_ = AstNode::kNoNumber; |
2248 return result; | 2231 return result; |
2249 } | 2232 } |
2250 | 2233 |
2251 return NULL; | 2234 return NULL; |
2252 } | 2235 } |
2253 | 2236 |
2254 | 2237 |
2255 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 2238 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
2256 if (instr->is_function_entry()) { | 2239 if (instr->is_function_entry()) { |
2257 return MarkAsCall(new(zone()) LStackCheck, instr); | 2240 return MarkAsCall(new(zone()) LStackCheck, instr); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2329 | 2312 |
2330 | 2313 |
2331 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2314 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2332 LOperand* object = UseRegister(instr->object()); | 2315 LOperand* object = UseRegister(instr->object()); |
2333 LOperand* index = UseRegister(instr->index()); | 2316 LOperand* index = UseRegister(instr->index()); |
2334 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2317 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2335 } | 2318 } |
2336 | 2319 |
2337 | 2320 |
2338 } } // namespace v8::internal | 2321 } } // namespace v8::internal |
OLD | NEW |