| 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 LInstruction* instruction_needing_environment = NULL; |
| 734 if (current->HasObservableSideEffects()) { |
| 735 HSimulate* sim = HSimulate::cast(current->next()); |
| 736 instruction_needing_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_needing_environment != NULL) { |
| 744 // Store the lazy deopt environment with the instruction if needed. |
| 745 // Right now it is only used for LInstanceOfKnownGlobal. |
| 746 instruction_needing_environment-> |
| 747 SetDeferredLazyDeoptimizationEnvironment(bailout->environment()); |
| 748 } |
| 749 } |
| 739 } | 750 } |
| 740 current_instruction_ = old_current; | 751 current_instruction_ = old_current; |
| 741 } | 752 } |
| 742 | 753 |
| 743 | 754 |
| 744 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 755 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
| 745 HEnvironment* hydrogen_env = current_block_->last_environment(); | 756 HEnvironment* hydrogen_env = current_block_->last_environment(); |
| 746 int argument_index_accumulator = 0; | 757 int argument_index_accumulator = 0; |
| 747 ZoneList<HValue*> objects_to_materialize(0, zone()); | 758 ZoneList<HValue*> objects_to_materialize(0, zone()); |
| 748 instr->set_environment(CreateEnvironment(hydrogen_env, | 759 instr->set_environment(CreateEnvironment(hydrogen_env, |
| (...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2100 } | 2111 } |
| 2101 | 2112 |
| 2102 | 2113 |
| 2103 LInstruction* LChunkBuilder::DoShr(HShr* instr) { | 2114 LInstruction* LChunkBuilder::DoShr(HShr* instr) { |
| 2104 return DoShift(Token::SHR, instr); | 2115 return DoShift(Token::SHR, instr); |
| 2105 } | 2116 } |
| 2106 | 2117 |
| 2107 | 2118 |
| 2108 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { | 2119 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { |
| 2109 instr->ReplayEnvironment(current_block_->last_environment()); | 2120 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; | 2121 return NULL; |
| 2126 } | 2122 } |
| 2127 | 2123 |
| 2128 | 2124 |
| 2129 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 2125 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
| 2130 if (instr->is_function_entry()) { | 2126 if (instr->is_function_entry()) { |
| 2131 LOperand* context = UseFixed(instr->context(), cp); | 2127 LOperand* context = UseFixed(instr->context(), cp); |
| 2132 return MarkAsCall(new(zone()) LStackCheck(context), instr); | 2128 return MarkAsCall(new(zone()) LStackCheck(context), instr); |
| 2133 } else { | 2129 } else { |
| 2134 ASSERT(instr->is_backwards_branch()); | 2130 ASSERT(instr->is_backwards_branch()); |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2557 | 2553 |
| 2558 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { | 2554 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { |
| 2559 LOperand* receiver = UseRegister(instr->receiver()); | 2555 LOperand* receiver = UseRegister(instr->receiver()); |
| 2560 LOperand* function = UseRegister(instr->function()); | 2556 LOperand* function = UseRegister(instr->function()); |
| 2561 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function); | 2557 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function); |
| 2562 return AssignEnvironment(DefineAsRegister(result)); | 2558 return AssignEnvironment(DefineAsRegister(result)); |
| 2563 } | 2559 } |
| 2564 | 2560 |
| 2565 | 2561 |
| 2566 } } // namespace v8::internal | 2562 } } // namespace v8::internal |
| OLD | NEW |