OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 499 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
500 HInstruction* hinstr, | 500 HInstruction* hinstr, |
501 CanDeoptimize can_deoptimize) { | 501 CanDeoptimize can_deoptimize) { |
502 info()->MarkAsNonDeferredCalling(); | 502 info()->MarkAsNonDeferredCalling(); |
503 #ifdef DEBUG | 503 #ifdef DEBUG |
504 instr->VerifyCall(); | 504 instr->VerifyCall(); |
505 #endif | 505 #endif |
506 instr->MarkAsCall(); | 506 instr->MarkAsCall(); |
507 instr = AssignPointerMap(instr); | 507 instr = AssignPointerMap(instr); |
508 | 508 |
509 if (hinstr->HasObservableSideEffects()) { | |
510 ASSERT(hinstr->next()->IsSimulate()); | |
511 HSimulate* sim = HSimulate::cast(hinstr->next()); | |
512 ASSERT(instruction_pending_deoptimization_environment_ == NULL); | |
513 ASSERT(pending_deoptimization_ast_id_.IsNone()); | |
514 instruction_pending_deoptimization_environment_ = instr; | |
515 pending_deoptimization_ast_id_ = sim->ast_id(); | |
516 } | |
517 | |
518 // If instruction does not have side-effects lazy deoptimization | 509 // If instruction does not have side-effects lazy deoptimization |
519 // after the call will try to deoptimize to the point before the call. | 510 // after the call will try to deoptimize to the point before the call. |
520 // Thus we still need to attach environment to this call even if | 511 // Thus we still need to attach environment to this call even if |
521 // call sequence can not deoptimize eagerly. | 512 // call sequence can not deoptimize eagerly. |
522 bool needs_environment = | 513 bool needs_environment = |
523 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || | 514 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || |
524 !hinstr->HasObservableSideEffects(); | 515 !hinstr->HasObservableSideEffects(); |
525 if (needs_environment && !instr->HasEnvironment()) { | 516 if (needs_environment && !instr->HasEnvironment()) { |
526 instr = AssignEnvironment(instr); | 517 instr = AssignEnvironment(instr); |
527 } | 518 } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 } | 720 } |
730 #endif | 721 #endif |
731 | 722 |
732 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { | 723 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
733 instr = AssignPointerMap(instr); | 724 instr = AssignPointerMap(instr); |
734 } | 725 } |
735 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 726 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
736 instr = AssignEnvironment(instr); | 727 instr = AssignEnvironment(instr); |
737 } | 728 } |
738 chunk_->AddInstruction(instr, current_block_); | 729 chunk_->AddInstruction(instr, current_block_); |
730 | |
731 if (instr->IsCall()) { | |
732 HValue* hydrogen_value_for_lazy_bailout = current; | |
733 if (current->HasObservableSideEffects()) { | |
734 HSimulate* sim = HSimulate::cast(current->next()); | |
735 ASSERT(instruction_pending_deoptimization_environment_ == NULL); | |
736 instruction_pending_deoptimization_environment_ = instr; | |
737 sim->ReplayEnvironment(current_block_->last_environment()); | |
738 hydrogen_value_for_lazy_bailout = sim; | |
739 } | |
740 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); | |
741 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); | |
742 chunk_->AddInstruction(bailout, current_block_); | |
743 if (instruction_pending_deoptimization_environment_ != NULL) { | |
744 // Store the lazy deopt environment with the instruction if needed. | |
745 // Right now it is only used for LInstanceOfKnownGlobal. | |
746 instruction_pending_deoptimization_environment_-> | |
Jarin
2014/03/12 00:33:58
Cannot instruction_pending_deoptimization_environm
Jakob Kummerow
2014/03/12 09:39:49
A very good point indeed. Done.
| |
747 SetDeferredLazyDeoptimizationEnvironment(bailout->environment()); | |
748 instruction_pending_deoptimization_environment_ = NULL; | |
749 } | |
750 } | |
739 } | 751 } |
740 current_instruction_ = old_current; | 752 current_instruction_ = old_current; |
741 } | 753 } |
742 | 754 |
743 | 755 |
744 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 756 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
745 HEnvironment* hydrogen_env = current_block_->last_environment(); | 757 HEnvironment* hydrogen_env = current_block_->last_environment(); |
746 int argument_index_accumulator = 0; | 758 int argument_index_accumulator = 0; |
747 ZoneList<HValue*> objects_to_materialize(0, zone()); | 759 ZoneList<HValue*> objects_to_materialize(0, zone()); |
748 instr->set_environment(CreateEnvironment(hydrogen_env, | 760 instr->set_environment(CreateEnvironment(hydrogen_env, |
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2100 } | 2112 } |
2101 | 2113 |
2102 | 2114 |
2103 LInstruction* LChunkBuilder::DoShr(HShr* instr) { | 2115 LInstruction* LChunkBuilder::DoShr(HShr* instr) { |
2104 return DoShift(Token::SHR, instr); | 2116 return DoShift(Token::SHR, instr); |
2105 } | 2117 } |
2106 | 2118 |
2107 | 2119 |
2108 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { | 2120 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { |
2109 instr->ReplayEnvironment(current_block_->last_environment()); | 2121 instr->ReplayEnvironment(current_block_->last_environment()); |
2110 | |
2111 // If there is an instruction pending deoptimization environment create a | |
2112 // lazy bailout instruction to capture the environment. | |
2113 if (pending_deoptimization_ast_id_ == instr->ast_id()) { | |
2114 LInstruction* result = new(zone()) LLazyBailout; | |
2115 result = AssignEnvironment(result); | |
2116 // Store the lazy deopt environment with the instruction if needed. Right | |
2117 // now it is only used for LInstanceOfKnownGlobal. | |
2118 instruction_pending_deoptimization_environment_-> | |
2119 SetDeferredLazyDeoptimizationEnvironment(result->environment()); | |
2120 instruction_pending_deoptimization_environment_ = NULL; | |
2121 pending_deoptimization_ast_id_ = BailoutId::None(); | |
2122 return result; | |
2123 } | |
2124 | |
2125 return NULL; | 2122 return NULL; |
2126 } | 2123 } |
2127 | 2124 |
2128 | 2125 |
2129 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 2126 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
2130 if (instr->is_function_entry()) { | 2127 if (instr->is_function_entry()) { |
2131 LOperand* context = UseFixed(instr->context(), cp); | 2128 LOperand* context = UseFixed(instr->context(), cp); |
2132 return MarkAsCall(new(zone()) LStackCheck(context), instr); | 2129 return MarkAsCall(new(zone()) LStackCheck(context), instr); |
2133 } else { | 2130 } else { |
2134 ASSERT(instr->is_backwards_branch()); | 2131 ASSERT(instr->is_backwards_branch()); |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2557 | 2554 |
2558 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { | 2555 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { |
2559 LOperand* receiver = UseRegister(instr->receiver()); | 2556 LOperand* receiver = UseRegister(instr->receiver()); |
2560 LOperand* function = UseRegister(instr->function()); | 2557 LOperand* function = UseRegister(instr->function()); |
2561 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function); | 2558 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function); |
2562 return AssignEnvironment(DefineAsRegister(result)); | 2559 return AssignEnvironment(DefineAsRegister(result)); |
2563 } | 2560 } |
2564 | 2561 |
2565 | 2562 |
2566 } } // namespace v8::internal | 2563 } } // namespace v8::internal |
OLD | NEW |