| 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 4502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4513 class DeferredStackCheck: public LDeferredCode { | 4513 class DeferredStackCheck: public LDeferredCode { |
| 4514 public: | 4514 public: |
| 4515 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr) | 4515 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr) |
| 4516 : LDeferredCode(codegen), instr_(instr) { } | 4516 : LDeferredCode(codegen), instr_(instr) { } |
| 4517 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); } | 4517 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); } |
| 4518 virtual LInstruction* instr() { return instr_; } | 4518 virtual LInstruction* instr() { return instr_; } |
| 4519 private: | 4519 private: |
| 4520 LStackCheck* instr_; | 4520 LStackCheck* instr_; |
| 4521 }; | 4521 }; |
| 4522 | 4522 |
| 4523 Register scratch = scratch0(); |
| 4524 DeferredStackCheck* deferred_stack_check = |
| 4525 new DeferredStackCheck(this, instr); |
| 4526 __ LoadRoot(scratch, Heap::kStackLimitRootIndex); |
| 4527 __ Branch(deferred_stack_check->entry(), lo, sp, Operand(scratch)); |
| 4528 EnsureSpaceForLazyDeopt(); |
| 4529 __ bind(instr->done_label()); |
| 4530 deferred_stack_check->SetExit(instr->done_label()); |
| 4531 // There is no LLazyBailout instruction for stack-checks. We have to |
| 4532 // prepare for lazy deoptimization explicitly here. |
| 4523 ASSERT(instr->HasEnvironment()); | 4533 ASSERT(instr->HasEnvironment()); |
| 4524 LEnvironment* env = instr->environment(); | 4534 LEnvironment* env = instr->environment(); |
| 4525 // There is no LLazyBailout instruction for stack-checks. We have to | 4535 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); |
| 4526 // prepare for lazy deoptimization explicitly here. | 4536 // Don't record a deoptimization index for the safepoint here. |
| 4527 if (instr->hydrogen()->is_function_entry()) { | 4537 // This will be done explicitly when emitting call and the safepoint in |
| 4528 // Perform stack overflow check. | 4538 // the deferred code. |
| 4529 Label done; | |
| 4530 __ LoadRoot(at, Heap::kStackLimitRootIndex); | |
| 4531 __ Branch(&done, hs, sp, Operand(at)); | |
| 4532 StackCheckStub stub; | |
| 4533 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | |
| 4534 EnsureSpaceForLazyDeopt(); | |
| 4535 __ bind(&done); | |
| 4536 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); | |
| 4537 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); | |
| 4538 } else { | |
| 4539 ASSERT(instr->hydrogen()->is_backwards_branch()); | |
| 4540 // Perform stack overflow check if this goto needs it before jumping. | |
| 4541 DeferredStackCheck* deferred_stack_check = | |
| 4542 new DeferredStackCheck(this, instr); | |
| 4543 __ LoadRoot(at, Heap::kStackLimitRootIndex); | |
| 4544 __ Branch(deferred_stack_check->entry(), lo, sp, Operand(at)); | |
| 4545 EnsureSpaceForLazyDeopt(); | |
| 4546 __ bind(instr->done_label()); | |
| 4547 deferred_stack_check->SetExit(instr->done_label()); | |
| 4548 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); | |
| 4549 // Don't record a deoptimization index for the safepoint here. | |
| 4550 // This will be done explicitly when emitting call and the safepoint in | |
| 4551 // the deferred code. | |
| 4552 } | |
| 4553 } | 4539 } |
| 4554 | 4540 |
| 4555 | 4541 |
| 4556 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 4542 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
| 4557 // This is a pseudo-instruction that ensures that the environment here is | 4543 // This is a pseudo-instruction that ensures that the environment here is |
| 4558 // properly registered for deoptimization and records the assembler's PC | 4544 // properly registered for deoptimization and records the assembler's PC |
| 4559 // offset. | 4545 // offset. |
| 4560 LEnvironment* environment = instr->environment(); | 4546 LEnvironment* environment = instr->environment(); |
| 4561 environment->SetSpilledRegisters(instr->SpilledRegisterArray(), | 4547 environment->SetSpilledRegisters(instr->SpilledRegisterArray(), |
| 4562 instr->SpilledDoubleRegisterArray()); | 4548 instr->SpilledDoubleRegisterArray()); |
| 4563 | 4549 |
| 4564 // If the environment were already registered, we would have no way of | 4550 // If the environment were already registered, we would have no way of |
| 4565 // backpatching it with the spill slot operands. | 4551 // backpatching it with the spill slot operands. |
| 4566 ASSERT(!environment->HasBeenRegistered()); | 4552 ASSERT(!environment->HasBeenRegistered()); |
| 4567 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 4553 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
| 4568 ASSERT(osr_pc_offset_ == -1); | 4554 ASSERT(osr_pc_offset_ == -1); |
| 4569 osr_pc_offset_ = masm()->pc_offset(); | 4555 osr_pc_offset_ = masm()->pc_offset(); |
| 4570 } | 4556 } |
| 4571 | 4557 |
| 4572 | 4558 |
| 4573 #undef __ | 4559 #undef __ |
| 4574 | 4560 |
| 4575 } } // namespace v8::internal | 4561 } } // namespace v8::internal |
| OLD | NEW |