| 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 624 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
| 625 HInstruction* hinstr, | 625 HInstruction* hinstr, |
| 626 CanDeoptimize can_deoptimize) { | 626 CanDeoptimize can_deoptimize) { |
| 627 info()->MarkAsNonDeferredCalling(); | 627 info()->MarkAsNonDeferredCalling(); |
| 628 #ifdef DEBUG | 628 #ifdef DEBUG |
| 629 instr->VerifyCall(); | 629 instr->VerifyCall(); |
| 630 #endif | 630 #endif |
| 631 instr->MarkAsCall(); | 631 instr->MarkAsCall(); |
| 632 instr = AssignPointerMap(instr); | 632 instr = AssignPointerMap(instr); |
| 633 | 633 |
| 634 if (hinstr->HasObservableSideEffects()) { | |
| 635 ASSERT(hinstr->next()->IsSimulate()); | |
| 636 HSimulate* sim = HSimulate::cast(hinstr->next()); | |
| 637 ASSERT(instruction_pending_deoptimization_environment_ == NULL); | |
| 638 ASSERT(pending_deoptimization_ast_id_.IsNone()); | |
| 639 instruction_pending_deoptimization_environment_ = instr; | |
| 640 pending_deoptimization_ast_id_ = sim->ast_id(); | |
| 641 } | |
| 642 | |
| 643 // If instruction does not have side-effects lazy deoptimization | 634 // If instruction does not have side-effects lazy deoptimization |
| 644 // after the call will try to deoptimize to the point before the call. | 635 // after the call will try to deoptimize to the point before the call. |
| 645 // Thus we still need to attach environment to this call even if | 636 // Thus we still need to attach environment to this call even if |
| 646 // call sequence can not deoptimize eagerly. | 637 // call sequence can not deoptimize eagerly. |
| 647 bool needs_environment = | 638 bool needs_environment = |
| 648 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || | 639 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || |
| 649 !hinstr->HasObservableSideEffects(); | 640 !hinstr->HasObservableSideEffects(); |
| 650 if (needs_environment && !instr->HasEnvironment()) { | 641 if (needs_environment && !instr->HasEnvironment()) { |
| 651 instr = AssignEnvironment(instr); | 642 instr = AssignEnvironment(instr); |
| 652 } | 643 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 } | 905 } |
| 915 #endif | 906 #endif |
| 916 | 907 |
| 917 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { | 908 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
| 918 instr = AssignPointerMap(instr); | 909 instr = AssignPointerMap(instr); |
| 919 } | 910 } |
| 920 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 911 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
| 921 instr = AssignEnvironment(instr); | 912 instr = AssignEnvironment(instr); |
| 922 } | 913 } |
| 923 chunk_->AddInstruction(instr, current_block_); | 914 chunk_->AddInstruction(instr, current_block_); |
| 915 |
| 916 if (instr->IsCall()) { |
| 917 HValue* hydrogen_value_for_lazy_bailout = current; |
| 918 LInstruction* instruction_needing_environment = NULL; |
| 919 if (current->HasObservableSideEffects()) { |
| 920 HSimulate* sim = HSimulate::cast(current->next()); |
| 921 instruction_needing_environment = instr; |
| 922 sim->ReplayEnvironment(current_block_->last_environment()); |
| 923 hydrogen_value_for_lazy_bailout = sim; |
| 924 } |
| 925 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); |
| 926 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); |
| 927 chunk_->AddInstruction(bailout, current_block_); |
| 928 if (instruction_needing_environment != NULL) { |
| 929 // Store the lazy deopt environment with the instruction if needed. |
| 930 // Right now it is only used for LInstanceOfKnownGlobal. |
| 931 instruction_needing_environment-> |
| 932 SetDeferredLazyDeoptimizationEnvironment(bailout->environment()); |
| 933 } |
| 934 } |
| 924 } | 935 } |
| 925 current_instruction_ = old_current; | 936 current_instruction_ = old_current; |
| 926 } | 937 } |
| 927 | 938 |
| 928 | 939 |
| 929 LEnvironment* LChunkBuilder::CreateEnvironment( | 940 LEnvironment* LChunkBuilder::CreateEnvironment( |
| 930 HEnvironment* hydrogen_env, | 941 HEnvironment* hydrogen_env, |
| 931 int* argument_index_accumulator, | 942 int* argument_index_accumulator, |
| 932 ZoneList<HValue*>* objects_to_materialize) { | 943 ZoneList<HValue*>* objects_to_materialize) { |
| 933 if (hydrogen_env == NULL) return NULL; | 944 if (hydrogen_env == NULL) return NULL; |
| (...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2572 | 2583 |
| 2573 | 2584 |
| 2574 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( | 2585 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( |
| 2575 HIsConstructCallAndBranch* instr) { | 2586 HIsConstructCallAndBranch* instr) { |
| 2576 return new(zone()) LIsConstructCallAndBranch(TempRegister()); | 2587 return new(zone()) LIsConstructCallAndBranch(TempRegister()); |
| 2577 } | 2588 } |
| 2578 | 2589 |
| 2579 | 2590 |
| 2580 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { | 2591 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { |
| 2581 instr->ReplayEnvironment(current_block_->last_environment()); | 2592 instr->ReplayEnvironment(current_block_->last_environment()); |
| 2582 | |
| 2583 // If there is an instruction pending deoptimization environment create a | |
| 2584 // lazy bailout instruction to capture the environment. | |
| 2585 if (pending_deoptimization_ast_id_ == instr->ast_id()) { | |
| 2586 LInstruction* result = new(zone()) LLazyBailout; | |
| 2587 result = AssignEnvironment(result); | |
| 2588 // Store the lazy deopt environment with the instruction if needed. Right | |
| 2589 // now it is only used for LInstanceOfKnownGlobal. | |
| 2590 instruction_pending_deoptimization_environment_-> | |
| 2591 SetDeferredLazyDeoptimizationEnvironment(result->environment()); | |
| 2592 instruction_pending_deoptimization_environment_ = NULL; | |
| 2593 pending_deoptimization_ast_id_ = BailoutId::None(); | |
| 2594 return result; | |
| 2595 } | |
| 2596 | |
| 2597 return NULL; | 2593 return NULL; |
| 2598 } | 2594 } |
| 2599 | 2595 |
| 2600 | 2596 |
| 2601 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 2597 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
| 2602 if (instr->is_function_entry()) { | 2598 if (instr->is_function_entry()) { |
| 2603 LOperand* context = UseFixed(instr->context(), cp); | 2599 LOperand* context = UseFixed(instr->context(), cp); |
| 2604 return MarkAsCall(new(zone()) LStackCheck(context), instr); | 2600 return MarkAsCall(new(zone()) LStackCheck(context), instr); |
| 2605 } else { | 2601 } else { |
| 2606 ASSERT(instr->is_backwards_branch()); | 2602 ASSERT(instr->is_backwards_branch()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2672 | 2668 |
| 2673 | 2669 |
| 2674 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2670 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2675 LOperand* object = UseRegister(instr->object()); | 2671 LOperand* object = UseRegister(instr->object()); |
| 2676 LOperand* index = UseRegister(instr->index()); | 2672 LOperand* index = UseRegister(instr->index()); |
| 2677 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2673 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2678 } | 2674 } |
| 2679 | 2675 |
| 2680 | 2676 |
| 2681 } } // namespace v8::internal | 2677 } } // namespace v8::internal |
| OLD | NEW |