OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 GenerateJumpTable() && | 70 GenerateJumpTable() && |
71 GenerateSafepointTable(); | 71 GenerateSafepointTable(); |
72 } | 72 } |
73 | 73 |
74 | 74 |
75 void LCodeGen::FinishCode(Handle<Code> code) { | 75 void LCodeGen::FinishCode(Handle<Code> code) { |
76 DCHECK(is_done()); | 76 DCHECK(is_done()); |
77 code->set_stack_slots(GetStackSlotCount()); | 77 code->set_stack_slots(GetStackSlotCount()); |
78 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); | 78 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); |
79 PopulateDeoptimizationData(code); | 79 PopulateDeoptimizationData(code); |
80 if (!info()->IsStub()) { | 80 if (info()->ShouldEnsureSpaceForLazyDeopt()) { |
81 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code); | 81 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 | 85 |
86 #ifdef _MSC_VER | 86 #ifdef _MSC_VER |
87 void LCodeGen::MakeSureStackPagesMapped(int offset) { | 87 void LCodeGen::MakeSureStackPagesMapped(int offset) { |
88 const int kPageSize = 4 * KB; | 88 const int kPageSize = 4 * KB; |
89 for (offset -= kPageSize; offset > 0; offset -= kPageSize) { | 89 for (offset -= kPageSize; offset > 0; offset -= kPageSize) { |
90 __ mov(Operand(esp, offset), eax); | 90 __ mov(Operand(esp, offset), eax); |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 | 490 |
491 // Deferred code is the last part of the instruction sequence. Mark | 491 // Deferred code is the last part of the instruction sequence. Mark |
492 // the generated code as done unless we bailed out. | 492 // the generated code as done unless we bailed out. |
493 if (!is_aborted()) status_ = DONE; | 493 if (!is_aborted()) status_ = DONE; |
494 return !is_aborted(); | 494 return !is_aborted(); |
495 } | 495 } |
496 | 496 |
497 | 497 |
498 bool LCodeGen::GenerateSafepointTable() { | 498 bool LCodeGen::GenerateSafepointTable() { |
499 DCHECK(is_done()); | 499 DCHECK(is_done()); |
500 if (!info()->IsStub()) { | 500 if (info()->ShouldEnsureSpaceForLazyDeopt()) { |
501 // For lazy deoptimization we need space to patch a call after every call. | 501 // For lazy deoptimization we need space to patch a call after every call. |
502 // Ensure there is always space for such patching, even if the code ends | 502 // Ensure there is always space for such patching, even if the code ends |
503 // in a call. | 503 // in a call. |
504 int target_offset = masm()->pc_offset() + Deoptimizer::patch_size(); | 504 int target_offset = masm()->pc_offset() + Deoptimizer::patch_size(); |
505 while (masm()->pc_offset() < target_offset) { | 505 while (masm()->pc_offset() < target_offset) { |
506 masm()->nop(); | 506 masm()->nop(); |
507 } | 507 } |
508 } | 508 } |
509 safepoints_.Emit(masm(), GetStackSlotCount()); | 509 safepoints_.Emit(masm(), GetStackSlotCount()); |
510 return !is_aborted(); | 510 return !is_aborted(); |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 } | 1086 } |
1087 | 1087 |
1088 | 1088 |
1089 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, | 1089 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, |
1090 Deoptimizer::DeoptReason deopt_reason, | 1090 Deoptimizer::DeoptReason deopt_reason, |
1091 Deoptimizer::BailoutType bailout_type) { | 1091 Deoptimizer::BailoutType bailout_type) { |
1092 LEnvironment* environment = instr->environment(); | 1092 LEnvironment* environment = instr->environment(); |
1093 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 1093 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
1094 DCHECK(environment->HasBeenRegistered()); | 1094 DCHECK(environment->HasBeenRegistered()); |
1095 int id = environment->deoptimization_index(); | 1095 int id = environment->deoptimization_index(); |
1096 DCHECK(info()->IsOptimizing() || info()->IsStub()); | |
1097 Address entry = | 1096 Address entry = |
1098 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type); | 1097 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type); |
1099 if (entry == NULL) { | 1098 if (entry == NULL) { |
1100 Abort(kBailoutWasNotPrepared); | 1099 Abort(kBailoutWasNotPrepared); |
1101 return; | 1100 return; |
1102 } | 1101 } |
1103 | 1102 |
1104 if (DeoptEveryNTimes()) { | 1103 if (DeoptEveryNTimes()) { |
1105 ExternalReference count = ExternalReference::stress_deopt_count(isolate()); | 1104 ExternalReference count = ExternalReference::stress_deopt_count(isolate()); |
1106 Label no_deopt; | 1105 Label no_deopt; |
(...skipping 4982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6089 __ mov(temp, Operand(temp, StandardFrameConstants::kCallerFPOffset)); | 6088 __ mov(temp, Operand(temp, StandardFrameConstants::kCallerFPOffset)); |
6090 | 6089 |
6091 // Check the marker in the calling frame. | 6090 // Check the marker in the calling frame. |
6092 __ bind(&check_frame_marker); | 6091 __ bind(&check_frame_marker); |
6093 __ cmp(Operand(temp, StandardFrameConstants::kMarkerOffset), | 6092 __ cmp(Operand(temp, StandardFrameConstants::kMarkerOffset), |
6094 Immediate(Smi::FromInt(StackFrame::CONSTRUCT))); | 6093 Immediate(Smi::FromInt(StackFrame::CONSTRUCT))); |
6095 } | 6094 } |
6096 | 6095 |
6097 | 6096 |
6098 void LCodeGen::EnsureSpaceForLazyDeopt(int space_needed) { | 6097 void LCodeGen::EnsureSpaceForLazyDeopt(int space_needed) { |
6099 if (!info()->IsStub()) { | 6098 if (info()->ShouldEnsureSpaceForLazyDeopt()) { |
6100 // Ensure that we have enough space after the previous lazy-bailout | 6099 // Ensure that we have enough space after the previous lazy-bailout |
6101 // instruction for patching the code here. | 6100 // instruction for patching the code here. |
6102 int current_pc = masm()->pc_offset(); | 6101 int current_pc = masm()->pc_offset(); |
6103 if (current_pc < last_lazy_deopt_pc_ + space_needed) { | 6102 if (current_pc < last_lazy_deopt_pc_ + space_needed) { |
6104 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 6103 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
6105 __ Nop(padding_size); | 6104 __ Nop(padding_size); |
6106 } | 6105 } |
6107 } | 6106 } |
6108 last_lazy_deopt_pc_ = masm()->pc_offset(); | 6107 last_lazy_deopt_pc_ = masm()->pc_offset(); |
6109 } | 6108 } |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6363 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6362 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6364 } | 6363 } |
6365 | 6364 |
6366 | 6365 |
6367 #undef __ | 6366 #undef __ |
6368 | 6367 |
6369 } // namespace internal | 6368 } // namespace internal |
6370 } // namespace v8 | 6369 } // namespace v8 |
6371 | 6370 |
6372 #endif // V8_TARGET_ARCH_X87 | 6371 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |