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