| 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 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2241 } else { | 2221 } else { |
| 2242 env->Push(value); | 2222 env->Push(value); |
| 2243 } | 2223 } |
| 2244 } | 2224 } |
| 2245 | 2225 |
| 2246 // If there is an instruction pending deoptimization environment create a | 2226 // If there is an instruction pending deoptimization environment create a |
| 2247 // lazy bailout instruction to capture the environment. | 2227 // lazy bailout instruction to capture the environment. |
| 2248 if (pending_deoptimization_ast_id_ == instr->ast_id()) { | 2228 if (pending_deoptimization_ast_id_ == instr->ast_id()) { |
| 2249 LInstruction* result = new(zone()) LLazyBailout; | 2229 LInstruction* result = new(zone()) LLazyBailout; |
| 2250 result = AssignEnvironment(result); | 2230 result = AssignEnvironment(result); |
| 2231 // Store the lazy deopt environment with the instruction if needed. Right |
| 2232 // now it is only used for LInstanceOfKnownGlobal. |
| 2251 instruction_pending_deoptimization_environment_-> | 2233 instruction_pending_deoptimization_environment_-> |
| 2252 set_deoptimization_environment(result->environment()); | 2234 SetDeferredLazyDeoptimizationEnvironment(result->environment()); |
| 2253 ClearInstructionPendingDeoptimizationEnvironment(); | 2235 instruction_pending_deoptimization_environment_ = NULL; |
| 2236 pending_deoptimization_ast_id_ = AstNode::kNoNumber; |
| 2254 return result; | 2237 return result; |
| 2255 } | 2238 } |
| 2256 | 2239 |
| 2257 return NULL; | 2240 return NULL; |
| 2258 } | 2241 } |
| 2259 | 2242 |
| 2260 | 2243 |
| 2261 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 2244 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
| 2262 if (instr->is_function_entry()) { | 2245 if (instr->is_function_entry()) { |
| 2263 return MarkAsCall(new(zone()) LStackCheck, instr); | 2246 return MarkAsCall(new(zone()) LStackCheck, instr); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2335 | 2318 |
| 2336 | 2319 |
| 2337 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2320 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2338 LOperand* object = UseRegister(instr->object()); | 2321 LOperand* object = UseRegister(instr->object()); |
| 2339 LOperand* index = UseRegister(instr->index()); | 2322 LOperand* index = UseRegister(instr->index()); |
| 2340 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2323 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2341 } | 2324 } |
| 2342 | 2325 |
| 2343 | 2326 |
| 2344 } } // namespace v8::internal | 2327 } } // namespace v8::internal |
| OLD | NEW |