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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 | 70 |
71 #define __ masm()-> | 71 #define __ masm()-> |
72 | 72 |
73 bool LCodeGen::GenerateCode() { | 73 bool LCodeGen::GenerateCode() { |
74 HPhase phase("Code generation", chunk()); | 74 HPhase phase("Code generation", chunk()); |
75 ASSERT(is_unused()); | 75 ASSERT(is_unused()); |
76 status_ = GENERATING; | 76 status_ = GENERATING; |
77 return GeneratePrologue() && | 77 return GeneratePrologue() && |
78 GenerateBody() && | 78 GenerateBody() && |
79 GenerateDeferredCode() && | 79 GenerateDeferredCode() && |
80 GenerateJumpTable() && | |
80 GenerateSafepointTable(); | 81 GenerateSafepointTable(); |
81 } | 82 } |
82 | 83 |
83 | 84 |
84 void LCodeGen::FinishCode(Handle<Code> code) { | 85 void LCodeGen::FinishCode(Handle<Code> code) { |
85 ASSERT(is_done()); | 86 ASSERT(is_done()); |
86 code->set_stack_slots(StackSlotCount()); | 87 code->set_stack_slots(StackSlotCount()); |
87 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); | 88 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); |
88 PopulateDeoptimizationData(code); | 89 PopulateDeoptimizationData(code); |
89 } | 90 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 | 234 |
234 LInstruction* LCodeGen::GetNextInstruction() { | 235 LInstruction* LCodeGen::GetNextInstruction() { |
235 if (current_instruction_ < instructions_->length() - 1) { | 236 if (current_instruction_ < instructions_->length() - 1) { |
236 return instructions_->at(current_instruction_ + 1); | 237 return instructions_->at(current_instruction_ + 1); |
237 } else { | 238 } else { |
238 return NULL; | 239 return NULL; |
239 } | 240 } |
240 } | 241 } |
241 | 242 |
242 | 243 |
244 bool LCodeGen::GenerateJumpTable() { | |
245 for (int i = 0; i < jump_table_.length(); i++) { | |
246 JumpTableEntry* info = jump_table_[i]; | |
247 __ bind(&(info->label)); | |
248 __ Jump(info->address, RelocInfo::RUNTIME_ENTRY); | |
249 } | |
250 return !is_aborted(); | |
251 } | |
252 | |
253 | |
243 bool LCodeGen::GenerateDeferredCode() { | 254 bool LCodeGen::GenerateDeferredCode() { |
244 ASSERT(is_generating()); | 255 ASSERT(is_generating()); |
245 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { | 256 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { |
246 LDeferredCode* code = deferred_[i]; | 257 LDeferredCode* code = deferred_[i]; |
247 __ bind(code->entry()); | 258 __ bind(code->entry()); |
248 code->Generate(); | 259 code->Generate(); |
249 __ jmp(code->exit()); | 260 __ jmp(code->exit()); |
250 } | 261 } |
251 | 262 |
252 // Deferred code is the last part of the instruction sequence. Mark | 263 // Deferred code is the last part of the instruction sequence. Mark |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
505 Address entry = Deoptimizer::GetDeoptimizationEntry(id, Deoptimizer::EAGER); | 516 Address entry = Deoptimizer::GetDeoptimizationEntry(id, Deoptimizer::EAGER); |
506 ASSERT(entry != NULL); | 517 ASSERT(entry != NULL); |
507 if (entry == NULL) { | 518 if (entry == NULL) { |
508 Abort("bailout was not prepared"); | 519 Abort("bailout was not prepared"); |
509 return; | 520 return; |
510 } | 521 } |
511 | 522 |
512 if (cc == no_condition) { | 523 if (cc == no_condition) { |
513 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); | 524 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); |
514 } else { | 525 } else { |
515 NearLabel done; | 526 JumpTableEntry* jump_info = new JumpTableEntry(); |
Lasse Reichstein
2011/02/28 08:42:30
Can we generate the same jump more than once? (I.e
Rico
2011/02/28 09:57:13
Done.
| |
516 __ j(NegateCondition(cc), &done); | 527 jump_info->address = entry; |
Lasse Reichstein
2011/02/28 08:42:30
Set this in a constructor.
Rico
2011/02/28 09:57:13
Done.
| |
517 __ Jump(entry, RelocInfo::RUNTIME_ENTRY); | 528 __ j(cc, &jump_info->label); |
518 __ bind(&done); | 529 jump_table_.Add(jump_info); |
519 } | 530 } |
520 } | 531 } |
521 | 532 |
522 | 533 |
523 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { | 534 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { |
524 int length = deoptimizations_.length(); | 535 int length = deoptimizations_.length(); |
525 if (length == 0) return; | 536 if (length == 0) return; |
526 ASSERT(FLAG_deopt); | 537 ASSERT(FLAG_deopt); |
527 Handle<DeoptimizationInputData> data = | 538 Handle<DeoptimizationInputData> data = |
528 Factory::NewDeoptimizationInputData(length, TENURED); | 539 Factory::NewDeoptimizationInputData(length, TENURED); |
(...skipping 3023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3552 RegisterEnvironmentForDeoptimization(environment); | 3563 RegisterEnvironmentForDeoptimization(environment); |
3553 ASSERT(osr_pc_offset_ == -1); | 3564 ASSERT(osr_pc_offset_ == -1); |
3554 osr_pc_offset_ = masm()->pc_offset(); | 3565 osr_pc_offset_ = masm()->pc_offset(); |
3555 } | 3566 } |
3556 | 3567 |
3557 #undef __ | 3568 #undef __ |
3558 | 3569 |
3559 } } // namespace v8::internal | 3570 } } // namespace v8::internal |
3560 | 3571 |
3561 #endif // V8_TARGET_ARCH_X64 | 3572 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |