| 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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 607 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
| 608 HInstruction* hinstr, | 608 HInstruction* hinstr, |
| 609 CanDeoptimize can_deoptimize) { | 609 CanDeoptimize can_deoptimize) { |
| 610 info()->MarkAsNonDeferredCalling(); | 610 info()->MarkAsNonDeferredCalling(); |
| 611 #ifdef DEBUG | 611 #ifdef DEBUG |
| 612 instr->VerifyCall(); | 612 instr->VerifyCall(); |
| 613 #endif | 613 #endif |
| 614 instr->MarkAsCall(); | 614 instr->MarkAsCall(); |
| 615 instr = AssignPointerMap(instr); | 615 instr = AssignPointerMap(instr); |
| 616 | 616 |
| 617 if (hinstr->HasObservableSideEffects()) { | |
| 618 ASSERT(hinstr->next()->IsSimulate()); | |
| 619 HSimulate* sim = HSimulate::cast(hinstr->next()); | |
| 620 ASSERT(instruction_pending_deoptimization_environment_ == NULL); | |
| 621 ASSERT(pending_deoptimization_ast_id_.IsNone()); | |
| 622 instruction_pending_deoptimization_environment_ = instr; | |
| 623 pending_deoptimization_ast_id_ = sim->ast_id(); | |
| 624 } | |
| 625 | |
| 626 // If instruction does not have side-effects lazy deoptimization | 617 // If instruction does not have side-effects lazy deoptimization |
| 627 // after the call will try to deoptimize to the point before the call. | 618 // after the call will try to deoptimize to the point before the call. |
| 628 // Thus we still need to attach environment to this call even if | 619 // Thus we still need to attach environment to this call even if |
| 629 // call sequence can not deoptimize eagerly. | 620 // call sequence can not deoptimize eagerly. |
| 630 bool needs_environment = | 621 bool needs_environment = |
| 631 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || | 622 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || |
| 632 !hinstr->HasObservableSideEffects(); | 623 !hinstr->HasObservableSideEffects(); |
| 633 if (needs_environment && !instr->HasEnvironment()) { | 624 if (needs_environment && !instr->HasEnvironment()) { |
| 634 instr = AssignEnvironment(instr); | 625 instr = AssignEnvironment(instr); |
| 635 } | 626 } |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 } | 889 } |
| 899 #endif | 890 #endif |
| 900 | 891 |
| 901 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { | 892 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
| 902 instr = AssignPointerMap(instr); | 893 instr = AssignPointerMap(instr); |
| 903 } | 894 } |
| 904 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 895 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
| 905 instr = AssignEnvironment(instr); | 896 instr = AssignEnvironment(instr); |
| 906 } | 897 } |
| 907 chunk_->AddInstruction(instr, current_block_); | 898 chunk_->AddInstruction(instr, current_block_); |
| 899 |
| 900 if (instr->IsCall()) { |
| 901 HValue* hydrogen_value_for_lazy_bailout = current; |
| 902 LInstruction* instruction_needing_environment = NULL; |
| 903 if (current->HasObservableSideEffects()) { |
| 904 HSimulate* sim = HSimulate::cast(current->next()); |
| 905 instruction_needing_environment = instr; |
| 906 sim->ReplayEnvironment(current_block_->last_environment()); |
| 907 hydrogen_value_for_lazy_bailout = sim; |
| 908 } |
| 909 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); |
| 910 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); |
| 911 chunk_->AddInstruction(bailout, current_block_); |
| 912 if (instruction_needing_environment != NULL) { |
| 913 // Store the lazy deopt environment with the instruction if needed. |
| 914 // Right now it is only used for LInstanceOfKnownGlobal. |
| 915 instruction_needing_environment-> |
| 916 SetDeferredLazyDeoptimizationEnvironment(bailout->environment()); |
| 917 } |
| 918 } |
| 908 } | 919 } |
| 909 current_instruction_ = old_current; | 920 current_instruction_ = old_current; |
| 910 } | 921 } |
| 911 | 922 |
| 912 | 923 |
| 913 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 924 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
| 914 return new(zone()) LGoto(instr->FirstSuccessor()); | 925 return new(zone()) LGoto(instr->FirstSuccessor()); |
| 915 } | 926 } |
| 916 | 927 |
| 917 | 928 |
| (...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2438 | 2449 |
| 2439 | 2450 |
| 2440 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( | 2451 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( |
| 2441 HIsConstructCallAndBranch* instr) { | 2452 HIsConstructCallAndBranch* instr) { |
| 2442 return new(zone()) LIsConstructCallAndBranch(TempRegister()); | 2453 return new(zone()) LIsConstructCallAndBranch(TempRegister()); |
| 2443 } | 2454 } |
| 2444 | 2455 |
| 2445 | 2456 |
| 2446 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { | 2457 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { |
| 2447 instr->ReplayEnvironment(current_block_->last_environment()); | 2458 instr->ReplayEnvironment(current_block_->last_environment()); |
| 2448 | |
| 2449 // If there is an instruction pending deoptimization environment create a | |
| 2450 // lazy bailout instruction to capture the environment. | |
| 2451 if (pending_deoptimization_ast_id_ == instr->ast_id()) { | |
| 2452 LInstruction* result = new(zone()) LLazyBailout; | |
| 2453 result = AssignEnvironment(result); | |
| 2454 // Store the lazy deopt environment with the instruction if needed. Right | |
| 2455 // now it is only used for LInstanceOfKnownGlobal. | |
| 2456 instruction_pending_deoptimization_environment_-> | |
| 2457 SetDeferredLazyDeoptimizationEnvironment(result->environment()); | |
| 2458 instruction_pending_deoptimization_environment_ = NULL; | |
| 2459 pending_deoptimization_ast_id_ = BailoutId::None(); | |
| 2460 return result; | |
| 2461 } | |
| 2462 | |
| 2463 return NULL; | 2459 return NULL; |
| 2464 } | 2460 } |
| 2465 | 2461 |
| 2466 | 2462 |
| 2467 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 2463 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
| 2468 if (instr->is_function_entry()) { | 2464 if (instr->is_function_entry()) { |
| 2469 LOperand* context = UseFixed(instr->context(), cp); | 2465 LOperand* context = UseFixed(instr->context(), cp); |
| 2470 return MarkAsCall(new(zone()) LStackCheck(context), instr); | 2466 return MarkAsCall(new(zone()) LStackCheck(context), instr); |
| 2471 } else { | 2467 } else { |
| 2472 ASSERT(instr->is_backwards_branch()); | 2468 ASSERT(instr->is_backwards_branch()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2536 } | 2532 } |
| 2537 | 2533 |
| 2538 | 2534 |
| 2539 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2535 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2540 LOperand* object = UseRegister(instr->object()); | 2536 LOperand* object = UseRegister(instr->object()); |
| 2541 LOperand* index = UseRegister(instr->index()); | 2537 LOperand* index = UseRegister(instr->index()); |
| 2542 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2538 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2543 } | 2539 } |
| 2544 | 2540 |
| 2545 } } // namespace v8::internal | 2541 } } // namespace v8::internal |
| OLD | NEW |