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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 612 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
613 HInstruction* hinstr, | 613 HInstruction* hinstr, |
614 CanDeoptimize can_deoptimize) { | 614 CanDeoptimize can_deoptimize) { |
615 info()->MarkAsNonDeferredCalling(); | 615 info()->MarkAsNonDeferredCalling(); |
616 #ifdef DEBUG | 616 #ifdef DEBUG |
617 instr->VerifyCall(); | 617 instr->VerifyCall(); |
618 #endif | 618 #endif |
619 instr->MarkAsCall(); | 619 instr->MarkAsCall(); |
620 instr = AssignPointerMap(instr); | 620 instr = AssignPointerMap(instr); |
621 | 621 |
622 if (hinstr->HasObservableSideEffects()) { | |
623 ASSERT(hinstr->next()->IsSimulate()); | |
624 HSimulate* sim = HSimulate::cast(hinstr->next()); | |
625 ASSERT(instruction_pending_deoptimization_environment_ == NULL); | |
626 ASSERT(pending_deoptimization_ast_id_.IsNone()); | |
627 instruction_pending_deoptimization_environment_ = instr; | |
628 pending_deoptimization_ast_id_ = sim->ast_id(); | |
629 } | |
630 | |
631 // If instruction does not have side-effects lazy deoptimization | 622 // If instruction does not have side-effects lazy deoptimization |
632 // after the call will try to deoptimize to the point before the call. | 623 // after the call will try to deoptimize to the point before the call. |
633 // Thus we still need to attach environment to this call even if | 624 // Thus we still need to attach environment to this call even if |
634 // call sequence can not deoptimize eagerly. | 625 // call sequence can not deoptimize eagerly. |
635 bool needs_environment = | 626 bool needs_environment = |
636 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || | 627 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || |
637 !hinstr->HasObservableSideEffects(); | 628 !hinstr->HasObservableSideEffects(); |
638 if (needs_environment && !instr->HasEnvironment()) { | 629 if (needs_environment && !instr->HasEnvironment()) { |
639 instr = AssignEnvironment(instr); | 630 instr = AssignEnvironment(instr); |
640 } | 631 } |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 } | 897 } |
907 #endif | 898 #endif |
908 | 899 |
909 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { | 900 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
910 instr = AssignPointerMap(instr); | 901 instr = AssignPointerMap(instr); |
911 } | 902 } |
912 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 903 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
913 instr = AssignEnvironment(instr); | 904 instr = AssignEnvironment(instr); |
914 } | 905 } |
915 chunk_->AddInstruction(instr, current_block_); | 906 chunk_->AddInstruction(instr, current_block_); |
| 907 |
| 908 if (instr->IsCall()) { |
| 909 HValue* hydrogen_value_for_lazy_bailout = current; |
| 910 LInstruction* instruction_needing_environment = NULL; |
| 911 if (current->HasObservableSideEffects()) { |
| 912 HSimulate* sim = HSimulate::cast(current->next()); |
| 913 instruction_needing_environment = instr; |
| 914 sim->ReplayEnvironment(current_block_->last_environment()); |
| 915 hydrogen_value_for_lazy_bailout = sim; |
| 916 } |
| 917 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); |
| 918 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); |
| 919 chunk_->AddInstruction(bailout, current_block_); |
| 920 if (instruction_needing_environment != NULL) { |
| 921 // Store the lazy deopt environment with the instruction if needed. |
| 922 // Right now it is only used for LInstanceOfKnownGlobal. |
| 923 instruction_needing_environment-> |
| 924 SetDeferredLazyDeoptimizationEnvironment(bailout->environment()); |
| 925 } |
| 926 } |
916 } | 927 } |
917 current_instruction_ = old_current; | 928 current_instruction_ = old_current; |
918 } | 929 } |
919 | 930 |
920 | 931 |
921 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 932 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
922 return new(zone()) LGoto(instr->FirstSuccessor()); | 933 return new(zone()) LGoto(instr->FirstSuccessor()); |
923 } | 934 } |
924 | 935 |
925 | 936 |
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2345 | 2356 |
2346 | 2357 |
2347 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( | 2358 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( |
2348 HIsConstructCallAndBranch* instr) { | 2359 HIsConstructCallAndBranch* instr) { |
2349 return new(zone()) LIsConstructCallAndBranch(TempRegister()); | 2360 return new(zone()) LIsConstructCallAndBranch(TempRegister()); |
2350 } | 2361 } |
2351 | 2362 |
2352 | 2363 |
2353 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { | 2364 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { |
2354 instr->ReplayEnvironment(current_block_->last_environment()); | 2365 instr->ReplayEnvironment(current_block_->last_environment()); |
2355 | |
2356 // If there is an instruction pending deoptimization environment create a | |
2357 // lazy bailout instruction to capture the environment. | |
2358 if (pending_deoptimization_ast_id_ == instr->ast_id()) { | |
2359 LInstruction* result = new(zone()) LLazyBailout; | |
2360 result = AssignEnvironment(result); | |
2361 // Store the lazy deopt environment with the instruction if needed. Right | |
2362 // now it is only used for LInstanceOfKnownGlobal. | |
2363 instruction_pending_deoptimization_environment_-> | |
2364 SetDeferredLazyDeoptimizationEnvironment(result->environment()); | |
2365 instruction_pending_deoptimization_environment_ = NULL; | |
2366 pending_deoptimization_ast_id_ = BailoutId::None(); | |
2367 return result; | |
2368 } | |
2369 | |
2370 return NULL; | 2366 return NULL; |
2371 } | 2367 } |
2372 | 2368 |
2373 | 2369 |
2374 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | 2370 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { |
2375 if (instr->is_function_entry()) { | 2371 if (instr->is_function_entry()) { |
2376 LOperand* context = UseFixed(instr->context(), cp); | 2372 LOperand* context = UseFixed(instr->context(), cp); |
2377 return MarkAsCall(new(zone()) LStackCheck(context), instr); | 2373 return MarkAsCall(new(zone()) LStackCheck(context), instr); |
2378 } else { | 2374 } else { |
2379 ASSERT(instr->is_backwards_branch()); | 2375 ASSERT(instr->is_backwards_branch()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2444 | 2440 |
2445 | 2441 |
2446 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2442 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2447 LOperand* object = UseRegister(instr->object()); | 2443 LOperand* object = UseRegister(instr->object()); |
2448 LOperand* index = UseRegister(instr->index()); | 2444 LOperand* index = UseRegister(instr->index()); |
2449 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2445 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2450 } | 2446 } |
2451 | 2447 |
2452 | 2448 |
2453 } } // namespace v8::internal | 2449 } } // namespace v8::internal |
OLD | NEW |