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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 bool LCodeGen::GenerateCode() { | 79 bool LCodeGen::GenerateCode() { |
80 HPhase phase("Code generation", chunk()); | 80 HPhase phase("Code generation", chunk()); |
81 ASSERT(is_unused()); | 81 ASSERT(is_unused()); |
82 status_ = GENERATING; | 82 status_ = GENERATING; |
83 CpuFeatures::Scope scope1(VFP3); | 83 CpuFeatures::Scope scope1(VFP3); |
84 CpuFeatures::Scope scope2(ARMv7); | 84 CpuFeatures::Scope scope2(ARMv7); |
85 return GeneratePrologue() && | 85 return GeneratePrologue() && |
86 GenerateBody() && | 86 GenerateBody() && |
87 GenerateDeferredCode() && | 87 GenerateDeferredCode() && |
88 GenerateDeoptJumpTable() && | |
89 GenerateSafepointTable(); | 88 GenerateSafepointTable(); |
90 } | 89 } |
91 | 90 |
92 | 91 |
93 void LCodeGen::FinishCode(Handle<Code> code) { | 92 void LCodeGen::FinishCode(Handle<Code> code) { |
94 ASSERT(is_done()); | 93 ASSERT(is_done()); |
95 code->set_stack_slots(GetStackSlotCount()); | 94 code->set_stack_slots(GetStackSlotCount()); |
96 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); | 95 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); |
97 PopulateDeoptimizationData(code); | 96 PopulateDeoptimizationData(code); |
98 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code); | 97 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 242 |
244 bool LCodeGen::GenerateDeferredCode() { | 243 bool LCodeGen::GenerateDeferredCode() { |
245 ASSERT(is_generating()); | 244 ASSERT(is_generating()); |
246 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { | 245 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { |
247 LDeferredCode* code = deferred_[i]; | 246 LDeferredCode* code = deferred_[i]; |
248 __ bind(code->entry()); | 247 __ bind(code->entry()); |
249 code->Generate(); | 248 code->Generate(); |
250 __ jmp(code->exit()); | 249 __ jmp(code->exit()); |
251 } | 250 } |
252 | 251 |
253 return !is_aborted(); | 252 // Force constant pool emission at the end of deferred code to make |
254 } | |
255 | |
256 | |
257 bool LCodeGen::GenerateDeoptJumpTable() { | |
258 // Check that the jump table is accessible from everywhere in the function | |
259 // code, ie that offsets to the table can be encoded in the 24bit signed | |
260 // immediate of a branch instruction. | |
261 // To simplify we consider the code size from the first instruction to the | |
262 // end of the jump table. We also don't consider the pc load delta. | |
263 // Each entry in the jump table generates only one instruction. | |
264 if (!is_int24((masm()->pc_offset() / Assembler::kInstrSize) + | |
265 deopt_jump_table_.length())) { | |
266 Abort("Generated code is too large"); | |
267 } | |
268 | |
269 __ RecordComment("[ Deoptimisation jump table"); | |
270 Label table_start; | |
271 __ bind(&table_start); | |
272 for (int i = 0; i < deopt_jump_table_.length(); i++) { | |
273 __ bind(&deopt_jump_table_[i].label); | |
274 __ mov(pc, Operand(reinterpret_cast<int32_t>(deopt_jump_table_[i].address), | |
275 RelocInfo::RUNTIME_ENTRY)); | |
276 } | |
277 ASSERT(masm()->InstructionsGeneratedSince(&table_start) == | |
278 deopt_jump_table_.length()); | |
279 __ RecordComment("]"); | |
280 | |
281 // Force constant pool emission at the end of the jump table to make | |
282 // sure that no constant pools are emitted after the official end of | 253 // sure that no constant pools are emitted after the official end of |
283 // the instruction sequence. | 254 // the instruction sequence. |
284 masm()->CheckConstPool(true, false); | 255 masm()->CheckConstPool(true, false); |
285 | 256 |
286 // The deoptimization jump table is the last part of the instruction | 257 // Deferred code is the last part of the instruction sequence. Mark |
287 // sequence. Mark the generated code as done unless we bailed out. | 258 // the generated code as done unless we bailed out. |
288 if (!is_aborted()) status_ = DONE; | 259 if (!is_aborted()) status_ = DONE; |
289 return !is_aborted(); | 260 return !is_aborted(); |
290 } | 261 } |
291 | 262 |
292 | 263 |
293 bool LCodeGen::GenerateSafepointTable() { | 264 bool LCodeGen::GenerateSafepointTable() { |
294 ASSERT(is_done()); | 265 ASSERT(is_done()); |
295 safepoints_.Emit(masm(), GetStackSlotCount()); | 266 safepoints_.Emit(masm(), GetStackSlotCount()); |
296 return !is_aborted(); | 267 return !is_aborted(); |
297 } | 268 } |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 } | 588 } |
618 | 589 |
619 ASSERT(FLAG_deopt_every_n_times < 2); // Other values not supported on ARM. | 590 ASSERT(FLAG_deopt_every_n_times < 2); // Other values not supported on ARM. |
620 | 591 |
621 if (FLAG_deopt_every_n_times == 1 && | 592 if (FLAG_deopt_every_n_times == 1 && |
622 info_->shared_info()->opt_count() == id) { | 593 info_->shared_info()->opt_count() == id) { |
623 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); | 594 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); |
624 return; | 595 return; |
625 } | 596 } |
626 | 597 |
627 if (FLAG_trap_on_deopt) __ stop("trap_on_deopt", cc); | |
628 | |
629 if (cc == al) { | 598 if (cc == al) { |
| 599 if (FLAG_trap_on_deopt) __ stop("trap_on_deopt"); |
630 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); | 600 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); |
631 } else { | 601 } else { |
632 // We often have several deopts to the same entry, reuse the last | 602 if (FLAG_trap_on_deopt) { |
633 // jump entry if this is the case. | 603 Label done; |
634 if (deopt_jump_table_.is_empty() || | 604 __ b(&done, NegateCondition(cc)); |
635 (deopt_jump_table_.last().address != entry)) { | 605 __ stop("trap_on_deopt"); |
636 deopt_jump_table_.Add(JumpTableEntry(entry)); | 606 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); |
| 607 __ bind(&done); |
| 608 } else { |
| 609 __ Jump(entry, RelocInfo::RUNTIME_ENTRY, cc); |
637 } | 610 } |
638 __ b(cc, &deopt_jump_table_.last().label); | |
639 } | 611 } |
640 } | 612 } |
641 | 613 |
642 | 614 |
643 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { | 615 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { |
644 int length = deoptimizations_.length(); | 616 int length = deoptimizations_.length(); |
645 if (length == 0) return; | 617 if (length == 0) return; |
646 ASSERT(FLAG_deopt); | 618 ASSERT(FLAG_deopt); |
647 Handle<DeoptimizationInputData> data = | 619 Handle<DeoptimizationInputData> data = |
648 factory()->NewDeoptimizationInputData(length, TENURED); | 620 factory()->NewDeoptimizationInputData(length, TENURED); |
(...skipping 3845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4494 ASSERT(osr_pc_offset_ == -1); | 4466 ASSERT(osr_pc_offset_ == -1); |
4495 osr_pc_offset_ = masm()->pc_offset(); | 4467 osr_pc_offset_ = masm()->pc_offset(); |
4496 } | 4468 } |
4497 | 4469 |
4498 | 4470 |
4499 | 4471 |
4500 | 4472 |
4501 #undef __ | 4473 #undef __ |
4502 | 4474 |
4503 } } // namespace v8::internal | 4475 } } // namespace v8::internal |
OLD | NEW |