OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 4631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4642 class DeferredStackCheck: public LDeferredCode { | 4642 class DeferredStackCheck: public LDeferredCode { |
4643 public: | 4643 public: |
4644 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr) | 4644 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr) |
4645 : LDeferredCode(codegen), instr_(instr) { } | 4645 : LDeferredCode(codegen), instr_(instr) { } |
4646 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); } | 4646 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); } |
4647 virtual LInstruction* instr() { return instr_; } | 4647 virtual LInstruction* instr() { return instr_; } |
4648 private: | 4648 private: |
4649 LStackCheck* instr_; | 4649 LStackCheck* instr_; |
4650 }; | 4650 }; |
4651 | 4651 |
4652 DeferredStackCheck* deferred_stack_check = | 4652 ASSERT(instr->HasEnvironment()); |
4653 new DeferredStackCheck(this, instr); | 4653 LEnvironment* env = instr->environment(); |
4654 __ LoadRoot(ip, Heap::kStackLimitRootIndex); | |
4655 __ cmp(sp, Operand(ip)); | |
4656 __ b(lo, deferred_stack_check->entry()); | |
4657 EnsureSpaceForLazyDeopt(); | |
4658 __ bind(instr->done_label()); | |
4659 deferred_stack_check->SetExit(instr->done_label()); | |
4660 // There is no LLazyBailout instruction for stack-checks. We have to | 4654 // There is no LLazyBailout instruction for stack-checks. We have to |
4661 // prepare for lazy deoptimization explicitly here. | 4655 // prepare for lazy deoptimization explicitly here. |
4662 ASSERT(instr->HasEnvironment()); | 4656 if (instr->hydrogen()->is_function_entry()) { |
4663 LEnvironment* env = instr->environment(); | 4657 // Perform stack overflow check. |
4664 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); | 4658 Label done; |
4665 // Don't record a deoptimization index for the safepoint here. | 4659 __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
4666 // This will be done explicitly when emitting call and the safepoint in | 4660 __ cmp(sp, Operand(ip)); |
4667 // the deferred code. | 4661 __ b(hs, &done); |
| 4662 StackCheckStub stub; |
| 4663 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 4664 EnsureSpaceForLazyDeopt(); |
| 4665 __ bind(&done); |
| 4666 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); |
| 4667 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); |
| 4668 } else { |
| 4669 ASSERT(instr->hydrogen()->is_backwards_branch()); |
| 4670 // Perform stack overflow check if this goto needs it before jumping. |
| 4671 DeferredStackCheck* deferred_stack_check = |
| 4672 new DeferredStackCheck(this, instr); |
| 4673 __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
| 4674 __ cmp(sp, Operand(ip)); |
| 4675 __ b(lo, deferred_stack_check->entry()); |
| 4676 EnsureSpaceForLazyDeopt(); |
| 4677 __ bind(instr->done_label()); |
| 4678 deferred_stack_check->SetExit(instr->done_label()); |
| 4679 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); |
| 4680 // Don't record a deoptimization index for the safepoint here. |
| 4681 // This will be done explicitly when emitting call and the safepoint in |
| 4682 // the deferred code. |
| 4683 } |
4668 } | 4684 } |
4669 | 4685 |
4670 | 4686 |
4671 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 4687 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
4672 // This is a pseudo-instruction that ensures that the environment here is | 4688 // This is a pseudo-instruction that ensures that the environment here is |
4673 // properly registered for deoptimization and records the assembler's PC | 4689 // properly registered for deoptimization and records the assembler's PC |
4674 // offset. | 4690 // offset. |
4675 LEnvironment* environment = instr->environment(); | 4691 LEnvironment* environment = instr->environment(); |
4676 environment->SetSpilledRegisters(instr->SpilledRegisterArray(), | 4692 environment->SetSpilledRegisters(instr->SpilledRegisterArray(), |
4677 instr->SpilledDoubleRegisterArray()); | 4693 instr->SpilledDoubleRegisterArray()); |
4678 | 4694 |
4679 // If the environment were already registered, we would have no way of | 4695 // If the environment were already registered, we would have no way of |
4680 // backpatching it with the spill slot operands. | 4696 // backpatching it with the spill slot operands. |
4681 ASSERT(!environment->HasBeenRegistered()); | 4697 ASSERT(!environment->HasBeenRegistered()); |
4682 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 4698 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
4683 ASSERT(osr_pc_offset_ == -1); | 4699 ASSERT(osr_pc_offset_ == -1); |
4684 osr_pc_offset_ = masm()->pc_offset(); | 4700 osr_pc_offset_ = masm()->pc_offset(); |
4685 } | 4701 } |
4686 | 4702 |
4687 | 4703 |
4688 | 4704 |
4689 | 4705 |
4690 #undef __ | 4706 #undef __ |
4691 | 4707 |
4692 } } // namespace v8::internal | 4708 } } // namespace v8::internal |
OLD | NEW |