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 4245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4256 class DeferredStackCheck: public LDeferredCode { | 4256 class DeferredStackCheck: public LDeferredCode { |
4257 public: | 4257 public: |
4258 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr) | 4258 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr) |
4259 : LDeferredCode(codegen), instr_(instr) { } | 4259 : LDeferredCode(codegen), instr_(instr) { } |
4260 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); } | 4260 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); } |
4261 virtual LInstruction* instr() { return instr_; } | 4261 virtual LInstruction* instr() { return instr_; } |
4262 private: | 4262 private: |
4263 LStackCheck* instr_; | 4263 LStackCheck* instr_; |
4264 }; | 4264 }; |
4265 | 4265 |
4266 DeferredStackCheck* deferred_stack_check = | 4266 ASSERT(instr->HasEnvironment()); |
4267 new DeferredStackCheck(this, instr); | 4267 LEnvironment* env = instr->environment(); |
4268 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); | |
4269 __ j(below, deferred_stack_check->entry()); | |
4270 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); | |
4271 __ bind(instr->done_label()); | |
4272 deferred_stack_check->SetExit(instr->done_label()); | |
4273 // There is no LLazyBailout instruction for stack-checks. We have to | 4268 // There is no LLazyBailout instruction for stack-checks. We have to |
4274 // prepare for lazy deoptimization explicitly here. | 4269 // prepare for lazy deoptimization explicitly here. |
4275 ASSERT(instr->HasEnvironment()); | 4270 if (instr->hydrogen()->is_function_entry()) { |
4276 LEnvironment* env = instr->environment(); | 4271 // Perform stack overflow check. |
4277 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); | 4272 Label done; |
4278 // Don't record a deoptimization index for the safepoint here. | 4273 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); |
4279 // This will be done explicitly when emitting call and the safepoint in | 4274 __ j(above_equal, &done, Label::kNear); |
4280 // the deferred code. | 4275 StackCheckStub stub; |
| 4276 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 4277 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); |
| 4278 last_lazy_deopt_pc_ = masm()->pc_offset(); |
| 4279 __ bind(&done); |
| 4280 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); |
| 4281 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); |
| 4282 } else { |
| 4283 ASSERT(instr->hydrogen()->is_backwards_branch()); |
| 4284 // Perform stack overflow check if this goto needs it before jumping. |
| 4285 DeferredStackCheck* deferred_stack_check = |
| 4286 new DeferredStackCheck(this, instr); |
| 4287 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); |
| 4288 __ j(below, deferred_stack_check->entry()); |
| 4289 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); |
| 4290 last_lazy_deopt_pc_ = masm()->pc_offset(); |
| 4291 __ bind(instr->done_label()); |
| 4292 deferred_stack_check->SetExit(instr->done_label()); |
| 4293 RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); |
| 4294 // Don't record a deoptimization index for the safepoint here. |
| 4295 // This will be done explicitly when emitting call and the safepoint in |
| 4296 // the deferred code. |
| 4297 } |
4281 } | 4298 } |
4282 | 4299 |
4283 | 4300 |
4284 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 4301 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
4285 // This is a pseudo-instruction that ensures that the environment here is | 4302 // This is a pseudo-instruction that ensures that the environment here is |
4286 // properly registered for deoptimization and records the assembler's PC | 4303 // properly registered for deoptimization and records the assembler's PC |
4287 // offset. | 4304 // offset. |
4288 LEnvironment* environment = instr->environment(); | 4305 LEnvironment* environment = instr->environment(); |
4289 environment->SetSpilledRegisters(instr->SpilledRegisterArray(), | 4306 environment->SetSpilledRegisters(instr->SpilledRegisterArray(), |
4290 instr->SpilledDoubleRegisterArray()); | 4307 instr->SpilledDoubleRegisterArray()); |
4291 | 4308 |
4292 // If the environment were already registered, we would have no way of | 4309 // If the environment were already registered, we would have no way of |
4293 // backpatching it with the spill slot operands. | 4310 // backpatching it with the spill slot operands. |
4294 ASSERT(!environment->HasBeenRegistered()); | 4311 ASSERT(!environment->HasBeenRegistered()); |
4295 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 4312 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
4296 ASSERT(osr_pc_offset_ == -1); | 4313 ASSERT(osr_pc_offset_ == -1); |
4297 osr_pc_offset_ = masm()->pc_offset(); | 4314 osr_pc_offset_ = masm()->pc_offset(); |
4298 } | 4315 } |
4299 | 4316 |
4300 #undef __ | 4317 #undef __ |
4301 | 4318 |
4302 } } // namespace v8::internal | 4319 } } // namespace v8::internal |
4303 | 4320 |
4304 #endif // V8_TARGET_ARCH_X64 | 4321 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |