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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 HInstruction* hinstr, | 623 HInstruction* hinstr, |
624 CanDeoptimize can_deoptimize) { | 624 CanDeoptimize can_deoptimize) { |
625 info()->MarkAsNonDeferredCalling(); | 625 info()->MarkAsNonDeferredCalling(); |
626 | 626 |
627 #ifdef DEBUG | 627 #ifdef DEBUG |
628 instr->VerifyCall(); | 628 instr->VerifyCall(); |
629 #endif | 629 #endif |
630 instr->MarkAsCall(); | 630 instr->MarkAsCall(); |
631 instr = AssignPointerMap(instr); | 631 instr = AssignPointerMap(instr); |
632 | 632 |
633 if (hinstr->HasObservableSideEffects()) { | |
634 ASSERT(hinstr->next()->IsSimulate()); | |
635 HSimulate* sim = HSimulate::cast(hinstr->next()); | |
636 ASSERT(instruction_pending_deoptimization_environment_ == NULL); | |
637 ASSERT(pending_deoptimization_ast_id_.IsNone()); | |
638 instruction_pending_deoptimization_environment_ = instr; | |
639 pending_deoptimization_ast_id_ = sim->ast_id(); | |
640 } | |
641 | |
642 // If instruction does not have side-effects lazy deoptimization | 633 // If instruction does not have side-effects lazy deoptimization |
643 // after the call will try to deoptimize to the point before the call. | 634 // after the call will try to deoptimize to the point before the call. |
644 // Thus we still need to attach environment to this call even if | 635 // Thus we still need to attach environment to this call even if |
645 // call sequence can not deoptimize eagerly. | 636 // call sequence can not deoptimize eagerly. |
646 bool needs_environment = | 637 bool needs_environment = |
647 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || | 638 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || |
648 !hinstr->HasObservableSideEffects(); | 639 !hinstr->HasObservableSideEffects(); |
649 if (needs_environment && !instr->HasEnvironment()) { | 640 if (needs_environment && !instr->HasEnvironment()) { |
650 instr = AssignEnvironment(instr); | 641 instr = AssignEnvironment(instr); |
651 } | 642 } |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 } | 900 } |
910 #endif | 901 #endif |
911 | 902 |
912 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { | 903 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
913 instr = AssignPointerMap(instr); | 904 instr = AssignPointerMap(instr); |
914 } | 905 } |
915 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 906 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
916 instr = AssignEnvironment(instr); | 907 instr = AssignEnvironment(instr); |
917 } | 908 } |
918 chunk_->AddInstruction(instr, current_block_); | 909 chunk_->AddInstruction(instr, current_block_); |
| 910 |
| 911 if (instr->IsCall()) { |
| 912 HValue* hydrogen_value_for_lazy_bailout = current; |
| 913 LInstruction* instruction_needing_environment = NULL; |
| 914 if (current->HasObservableSideEffects()) { |
| 915 HSimulate* sim = HSimulate::cast(current->next()); |
| 916 instruction_needing_environment = instr; |
| 917 sim->ReplayEnvironment(current_block_->last_environment()); |
| 918 hydrogen_value_for_lazy_bailout = sim; |
| 919 } |
| 920 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); |
| 921 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); |
| 922 chunk_->AddInstruction(bailout, current_block_); |
| 923 if (instruction_needing_environment != NULL) { |
| 924 // Store the lazy deopt environment with the instruction if needed. |
| 925 // Right now it is only used for LInstanceOfKnownGlobal. |
| 926 instruction_needing_environment-> |
| 927 SetDeferredLazyDeoptimizationEnvironment(bailout->environment()); |
| 928 } |
| 929 } |
919 } | 930 } |
920 current_instruction_ = old_current; | 931 current_instruction_ = old_current; |
921 } | 932 } |
922 | 933 |
923 | 934 |
924 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 935 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
925 return new(zone()) LGoto(instr->FirstSuccessor()); | 936 return new(zone()) LGoto(instr->FirstSuccessor()); |
926 } | 937 } |
927 | 938 |
928 | 939 |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2428 | 2439 |
2429 | 2440 |
2430 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( | 2441 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( |
2431 HIsConstructCallAndBranch* instr) { | 2442 HIsConstructCallAndBranch* instr) { |
2432 return new(zone()) LIsConstructCallAndBranch(TempRegister()); | 2443 return new(zone()) LIsConstructCallAndBranch(TempRegister()); |
2433 } | 2444 } |
2434 | 2445 |
2435 | 2446 |
2436 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { | 2447 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { |
2437 instr->ReplayEnvironment(current_block_->last_environment()); | 2448 instr->ReplayEnvironment(current_block_->last_environment()); |
2438 | |
2439 // If there is an instruction pending deoptimization environment create a | |
2440 // lazy bailout instruction to capture the environment. | |
2441 if (pending_deoptimization_ast_id_ == instr->ast_id()) { | |
2442 LLazyBailout* lazy_bailout = new(zone()) LLazyBailout; | |
2443 LInstruction* result = AssignEnvironment(lazy_bailout); | |
2444 // Store the lazy deopt environment with the instruction if needed. Right | |
2445 // now it is only used for LInstanceOfKnownGlobal. | |
2446 instruction_pending_deoptimization_environment_-> | |
2447 SetDeferredLazyDeoptimizationEnvironment(result->environment()); | |
2448 instruction_pending_deoptimization_environment_ = NULL; | |
2449 pending_deoptimization_ast_id_ = BailoutId::None(); | |
2450 return result; | |
2451 } | |
2452 | |
2453 return NULL; | 2449 return NULL; |
2454 } | 2450 } |
2455 | 2451 |
2456 | 2452 |
2457 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 2453 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
2458 info()->MarkAsDeferredCalling(); | 2454 info()->MarkAsDeferredCalling(); |
2459 if (instr->is_function_entry()) { | 2455 if (instr->is_function_entry()) { |
2460 LOperand* context = UseFixed(instr->context(), rsi); | 2456 LOperand* context = UseFixed(instr->context(), rsi); |
2461 return MarkAsCall(new(zone()) LStackCheck(context), instr); | 2457 return MarkAsCall(new(zone()) LStackCheck(context), instr); |
2462 } else { | 2458 } else { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2531 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2527 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2532 LOperand* object = UseRegister(instr->object()); | 2528 LOperand* object = UseRegister(instr->object()); |
2533 LOperand* index = UseTempRegister(instr->index()); | 2529 LOperand* index = UseTempRegister(instr->index()); |
2534 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2530 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2535 } | 2531 } |
2536 | 2532 |
2537 | 2533 |
2538 } } // namespace v8::internal | 2534 } } // namespace v8::internal |
2539 | 2535 |
2540 #endif // V8_TARGET_ARCH_X64 | 2536 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |