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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 HInstruction* hinstr, | 672 HInstruction* hinstr, |
673 CanDeoptimize can_deoptimize) { | 673 CanDeoptimize can_deoptimize) { |
674 info()->MarkAsNonDeferredCalling(); | 674 info()->MarkAsNonDeferredCalling(); |
675 | 675 |
676 #ifdef DEBUG | 676 #ifdef DEBUG |
677 instr->VerifyCall(); | 677 instr->VerifyCall(); |
678 #endif | 678 #endif |
679 instr->MarkAsCall(); | 679 instr->MarkAsCall(); |
680 instr = AssignPointerMap(instr); | 680 instr = AssignPointerMap(instr); |
681 | 681 |
682 if (hinstr->HasObservableSideEffects()) { | |
683 ASSERT(hinstr->next()->IsSimulate()); | |
684 HSimulate* sim = HSimulate::cast(hinstr->next()); | |
685 ASSERT(instruction_pending_deoptimization_environment_ == NULL); | |
686 ASSERT(pending_deoptimization_ast_id_.IsNone()); | |
687 instruction_pending_deoptimization_environment_ = instr; | |
688 pending_deoptimization_ast_id_ = sim->ast_id(); | |
689 } | |
690 | |
691 // If instruction does not have side-effects lazy deoptimization | 682 // If instruction does not have side-effects lazy deoptimization |
692 // after the call will try to deoptimize to the point before the call. | 683 // after the call will try to deoptimize to the point before the call. |
693 // Thus we still need to attach environment to this call even if | 684 // Thus we still need to attach environment to this call even if |
694 // call sequence can not deoptimize eagerly. | 685 // call sequence can not deoptimize eagerly. |
695 bool needs_environment = | 686 bool needs_environment = |
696 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || | 687 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || |
697 !hinstr->HasObservableSideEffects(); | 688 !hinstr->HasObservableSideEffects(); |
698 if (needs_environment && !instr->HasEnvironment()) { | 689 if (needs_environment && !instr->HasEnvironment()) { |
699 instr = AssignEnvironment(instr); | 690 instr = AssignEnvironment(instr); |
700 } | 691 } |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 LGoto::cast(instr)->jumps_to_join()) { | 964 LGoto::cast(instr)->jumps_to_join()) { |
974 // TODO(olivf) Since phis of spilled values are joined as registers | 965 // TODO(olivf) Since phis of spilled values are joined as registers |
975 // (not in the stack slot), we need to allow the goto gaps to keep one | 966 // (not in the stack slot), we need to allow the goto gaps to keep one |
976 // x87 register alive. To ensure all other values are still spilled, we | 967 // x87 register alive. To ensure all other values are still spilled, we |
977 // insert a fpu register barrier right before. | 968 // insert a fpu register barrier right before. |
978 LClobberDoubles* clobber = new(zone()) LClobberDoubles(); | 969 LClobberDoubles* clobber = new(zone()) LClobberDoubles(); |
979 clobber->set_hydrogen_value(current); | 970 clobber->set_hydrogen_value(current); |
980 chunk_->AddInstruction(clobber, current_block_); | 971 chunk_->AddInstruction(clobber, current_block_); |
981 } | 972 } |
982 chunk_->AddInstruction(instr, current_block_); | 973 chunk_->AddInstruction(instr, current_block_); |
| 974 |
| 975 if (instr->IsCall()) { |
| 976 HValue* hydrogen_value_for_lazy_bailout = current; |
| 977 LInstruction* instruction_needing_environment = NULL; |
| 978 if (current->HasObservableSideEffects()) { |
| 979 HSimulate* sim = HSimulate::cast(current->next()); |
| 980 instruction_needing_environment = instr; |
| 981 sim->ReplayEnvironment(current_block_->last_environment()); |
| 982 hydrogen_value_for_lazy_bailout = sim; |
| 983 } |
| 984 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); |
| 985 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); |
| 986 chunk_->AddInstruction(bailout, current_block_); |
| 987 if (instruction_needing_environment != NULL) { |
| 988 // Store the lazy deopt environment with the instruction if needed. |
| 989 // Right now it is only used for LInstanceOfKnownGlobal. |
| 990 instruction_needing_environment-> |
| 991 SetDeferredLazyDeoptimizationEnvironment(bailout->environment()); |
| 992 } |
| 993 } |
983 } | 994 } |
984 current_instruction_ = old_current; | 995 current_instruction_ = old_current; |
985 } | 996 } |
986 | 997 |
987 | 998 |
988 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 999 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
989 return new(zone()) LGoto(instr->FirstSuccessor()); | 1000 return new(zone()) LGoto(instr->FirstSuccessor()); |
990 } | 1001 } |
991 | 1002 |
992 | 1003 |
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2578 | 2589 |
2579 | 2590 |
2580 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( | 2591 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( |
2581 HIsConstructCallAndBranch* instr) { | 2592 HIsConstructCallAndBranch* instr) { |
2582 return new(zone()) LIsConstructCallAndBranch(TempRegister()); | 2593 return new(zone()) LIsConstructCallAndBranch(TempRegister()); |
2583 } | 2594 } |
2584 | 2595 |
2585 | 2596 |
2586 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { | 2597 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { |
2587 instr->ReplayEnvironment(current_block_->last_environment()); | 2598 instr->ReplayEnvironment(current_block_->last_environment()); |
2588 | |
2589 // If there is an instruction pending deoptimization environment create a | |
2590 // lazy bailout instruction to capture the environment. | |
2591 if (!pending_deoptimization_ast_id_.IsNone()) { | |
2592 ASSERT(pending_deoptimization_ast_id_ == instr->ast_id()); | |
2593 LLazyBailout* lazy_bailout = new(zone()) LLazyBailout; | |
2594 LInstruction* result = AssignEnvironment(lazy_bailout); | |
2595 // Store the lazy deopt environment with the instruction if needed. Right | |
2596 // now it is only used for LInstanceOfKnownGlobal. | |
2597 instruction_pending_deoptimization_environment_-> | |
2598 SetDeferredLazyDeoptimizationEnvironment(result->environment()); | |
2599 instruction_pending_deoptimization_environment_ = NULL; | |
2600 pending_deoptimization_ast_id_ = BailoutId::None(); | |
2601 return result; | |
2602 } | |
2603 | |
2604 return NULL; | 2599 return NULL; |
2605 } | 2600 } |
2606 | 2601 |
2607 | 2602 |
2608 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 2603 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
2609 info()->MarkAsDeferredCalling(); | 2604 info()->MarkAsDeferredCalling(); |
2610 if (instr->is_function_entry()) { | 2605 if (instr->is_function_entry()) { |
2611 LOperand* context = UseFixed(instr->context(), esi); | 2606 LOperand* context = UseFixed(instr->context(), esi); |
2612 return MarkAsCall(new(zone()) LStackCheck(context), instr); | 2607 return MarkAsCall(new(zone()) LStackCheck(context), instr); |
2613 } else { | 2608 } else { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2681 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2676 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2682 LOperand* object = UseRegister(instr->object()); | 2677 LOperand* object = UseRegister(instr->object()); |
2683 LOperand* index = UseTempRegister(instr->index()); | 2678 LOperand* index = UseTempRegister(instr->index()); |
2684 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2679 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2685 } | 2680 } |
2686 | 2681 |
2687 | 2682 |
2688 } } // namespace v8::internal | 2683 } } // namespace v8::internal |
2689 | 2684 |
2690 #endif // V8_TARGET_ARCH_IA32 | 2685 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |