| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
| 6 | 6 |
| 7 #include "src/address-map.h" | 7 #include "src/address-map.h" |
| 8 #include "src/base/adapters.h" | 8 #include "src/base/adapters.h" |
| 9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
| 10 #include "src/compiler/code-generator-impl.h" | 10 #include "src/compiler/code-generator-impl.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 // Place function entry hook if requested to do so. | 82 // Place function entry hook if requested to do so. |
| 83 if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) { | 83 if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) { |
| 84 ProfileEntryHookStub::MaybeCallEntryHook(masm()); | 84 ProfileEntryHookStub::MaybeCallEntryHook(masm()); |
| 85 } | 85 } |
| 86 // Architecture-specific, linkage-specific prologue. | 86 // Architecture-specific, linkage-specific prologue. |
| 87 info->set_prologue_offset(masm()->pc_offset()); | 87 info->set_prologue_offset(masm()->pc_offset()); |
| 88 | 88 |
| 89 // Define deoptimization literals for all inlined functions. | 89 // Define deoptimization literals for all inlined functions. |
| 90 DCHECK_EQ(0u, deoptimization_literals_.size()); | 90 DCHECK_EQ(0u, deoptimization_literals_.size()); |
| 91 for (const CompilationInfo::InlinedFunctionHolder& inlined : | 91 for (CompilationInfo::InlinedFunctionHolder& inlined : |
| 92 info->inlined_functions()) { | 92 info->inlined_functions()) { |
| 93 if (!inlined.shared_info.is_identical_to(info->shared_info())) { | 93 if (!inlined.shared_info.is_identical_to(info->shared_info())) { |
| 94 inlined.RegisterInlinedFunctionId(deoptimization_literals_.size()); |
| 94 DefineDeoptimizationLiteral(inlined.shared_info); | 95 DefineDeoptimizationLiteral(inlined.shared_info); |
| 95 } | 96 } |
| 96 } | 97 } |
| 97 inlined_function_count_ = deoptimization_literals_.size(); | 98 inlined_function_count_ = deoptimization_literals_.size(); |
| 98 | 99 |
| 99 // Define deoptimization literals for all unoptimized code objects of inlined | 100 // Define deoptimization literals for all unoptimized code objects of inlined |
| 100 // functions. This ensures unoptimized code is kept alive by optimized code. | 101 // functions. This ensures unoptimized code is kept alive by optimized code. |
| 101 for (const CompilationInfo::InlinedFunctionHolder& inlined : | 102 for (const CompilationInfo::InlinedFunctionHolder& inlined : |
| 102 info->inlined_functions()) { | 103 info->inlined_functions()) { |
| 103 if (!inlined.shared_info.is_identical_to(info->shared_info())) { | 104 if (!inlined.shared_info.is_identical_to(info->shared_info())) { |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 return kSuccess; | 468 return kSuccess; |
| 468 } | 469 } |
| 469 | 470 |
| 470 | 471 |
| 471 void CodeGenerator::AssembleSourcePosition(Instruction* instr) { | 472 void CodeGenerator::AssembleSourcePosition(Instruction* instr) { |
| 472 SourcePosition source_position; | 473 SourcePosition source_position; |
| 473 if (!code()->GetSourcePosition(instr, &source_position)) return; | 474 if (!code()->GetSourcePosition(instr, &source_position)) return; |
| 474 if (source_position == current_source_position_) return; | 475 if (source_position == current_source_position_) return; |
| 475 current_source_position_ = source_position; | 476 current_source_position_ = source_position; |
| 476 if (source_position.IsUnknown()) return; | 477 if (source_position.IsUnknown()) return; |
| 477 int code_pos = source_position.raw(); | 478 source_position_table_builder_.AddPosition(masm()->pc_offset(), |
| 478 source_position_table_builder_.AddPosition(masm()->pc_offset(), code_pos, | 479 source_position, false); |
| 479 false); | |
| 480 if (FLAG_code_comments) { | 480 if (FLAG_code_comments) { |
| 481 CompilationInfo* info = this->info(); | 481 CompilationInfo* info = this->info(); |
| 482 if (!info->parse_info()) return; | 482 if (!info->parse_info()) return; |
| 483 Vector<char> buffer = Vector<char>::New(256); | 483 std::ostringstream buffer; |
| 484 int ln = Script::GetLineNumber(info->script(), code_pos); | 484 buffer << "-- " << source_position.Info(info) << " --"; |
| 485 int cn = Script::GetColumnNumber(info->script(), code_pos); | 485 masm()->RecordComment(buffer.str().c_str()); |
| 486 if (info->script()->name()->IsString()) { | |
| 487 Handle<String> file(String::cast(info->script()->name())); | |
| 488 base::OS::SNPrintF(buffer.start(), buffer.length(), "-- %s:%d:%d --", | |
| 489 file->ToCString().get(), ln, cn); | |
| 490 } else { | |
| 491 base::OS::SNPrintF(buffer.start(), buffer.length(), | |
| 492 "-- <unknown>:%d:%d --", ln, cn); | |
| 493 } | |
| 494 masm()->RecordComment(buffer.start()); | |
| 495 } | 486 } |
| 496 } | 487 } |
| 497 | 488 |
| 498 bool CodeGenerator::GetSlotAboveSPBeforeTailCall(Instruction* instr, | 489 bool CodeGenerator::GetSlotAboveSPBeforeTailCall(Instruction* instr, |
| 499 int* slot) { | 490 int* slot) { |
| 500 if (instr->IsTailCall()) { | 491 if (instr->IsTailCall()) { |
| 501 InstructionOperandConverter g(this, instr); | 492 InstructionOperandConverter g(this, instr); |
| 502 *slot = g.InputInt32(instr->InputCount() - 1); | 493 *slot = g.InputInt32(instr->InputCount() - 1); |
| 503 return true; | 494 return true; |
| 504 } else { | 495 } else { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 Handle<FixedArray> literals = isolate()->factory()->NewFixedArray( | 532 Handle<FixedArray> literals = isolate()->factory()->NewFixedArray( |
| 542 static_cast<int>(deoptimization_literals_.size()), TENURED); | 533 static_cast<int>(deoptimization_literals_.size()), TENURED); |
| 543 { | 534 { |
| 544 AllowDeferredHandleDereference copy_handles; | 535 AllowDeferredHandleDereference copy_handles; |
| 545 for (unsigned i = 0; i < deoptimization_literals_.size(); i++) { | 536 for (unsigned i = 0; i < deoptimization_literals_.size(); i++) { |
| 546 literals->set(i, *deoptimization_literals_[i]); | 537 literals->set(i, *deoptimization_literals_[i]); |
| 547 } | 538 } |
| 548 data->SetLiteralArray(*literals); | 539 data->SetLiteralArray(*literals); |
| 549 } | 540 } |
| 550 | 541 |
| 542 data->SetInliningPositions(*info->CreateInliningPositions()); |
| 543 |
| 551 if (info->is_osr()) { | 544 if (info->is_osr()) { |
| 552 DCHECK(osr_pc_offset_ >= 0); | 545 DCHECK(osr_pc_offset_ >= 0); |
| 553 data->SetOsrAstId(Smi::FromInt(info_->osr_ast_id().ToInt())); | 546 data->SetOsrAstId(Smi::FromInt(info_->osr_ast_id().ToInt())); |
| 554 data->SetOsrPcOffset(Smi::FromInt(osr_pc_offset_)); | 547 data->SetOsrPcOffset(Smi::FromInt(osr_pc_offset_)); |
| 555 } else { | 548 } else { |
| 556 BailoutId osr_ast_id = BailoutId::None(); | 549 BailoutId osr_ast_id = BailoutId::None(); |
| 557 data->SetOsrAstId(Smi::FromInt(osr_ast_id.ToInt())); | 550 data->SetOsrAstId(Smi::FromInt(osr_ast_id.ToInt())); |
| 558 data->SetOsrPcOffset(Smi::FromInt(-1)); | 551 data->SetOsrPcOffset(Smi::FromInt(-1)); |
| 559 } | 552 } |
| 560 | 553 |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { | 928 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { |
| 936 gen->ools_ = this; | 929 gen->ools_ = this; |
| 937 } | 930 } |
| 938 | 931 |
| 939 | 932 |
| 940 OutOfLineCode::~OutOfLineCode() {} | 933 OutOfLineCode::~OutOfLineCode() {} |
| 941 | 934 |
| 942 } // namespace compiler | 935 } // namespace compiler |
| 943 } // namespace internal | 936 } // namespace internal |
| 944 } // namespace v8 | 937 } // namespace v8 |
| OLD | NEW |