| 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/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
| 9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
| 10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 | 67 |
| 68 Handle<Code> CodeGenerator::GenerateCode() { | 68 Handle<Code> CodeGenerator::GenerateCode() { |
| 69 CompilationInfo* info = this->info(); | 69 CompilationInfo* info = this->info(); |
| 70 | 70 |
| 71 // Open a frame scope to indicate that there is a frame on the stack. The | 71 // Open a frame scope to indicate that there is a frame on the stack. The |
| 72 // MANUAL indicates that the scope shouldn't actually generate code to set up | 72 // MANUAL indicates that the scope shouldn't actually generate code to set up |
| 73 // the frame (that is done in AssemblePrologue). | 73 // the frame (that is done in AssemblePrologue). |
| 74 FrameScope frame_scope(masm(), StackFrame::MANUAL); | 74 FrameScope frame_scope(masm(), StackFrame::MANUAL); |
| 75 | 75 |
| 76 // Emit a code line info recording start event. | |
| 77 LOG_CODE_EVENT(isolate(), CodeStartLinePosInfoRecordEvent( | |
| 78 &source_position_table_builder_)); | |
| 79 | |
| 80 // Place function entry hook if requested to do so. | 76 // Place function entry hook if requested to do so. |
| 81 if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) { | 77 if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) { |
| 82 ProfileEntryHookStub::MaybeCallEntryHook(masm()); | 78 ProfileEntryHookStub::MaybeCallEntryHook(masm()); |
| 83 } | 79 } |
| 84 // Architecture-specific, linkage-specific prologue. | 80 // Architecture-specific, linkage-specific prologue. |
| 85 info->set_prologue_offset(masm()->pc_offset()); | 81 info->set_prologue_offset(masm()->pc_offset()); |
| 86 | 82 |
| 87 // Define deoptimization literals for all inlined functions. | 83 // Define deoptimization literals for all inlined functions. |
| 88 DCHECK_EQ(0u, deoptimization_literals_.size()); | 84 DCHECK_EQ(0u, deoptimization_literals_.size()); |
| 89 for (const CompilationInfo::InlinedFunctionHolder& inlined : | 85 for (const CompilationInfo::InlinedFunctionHolder& inlined : |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 safepoints()->Emit(masm(), frame()->GetTotalFrameSlotCount()); | 202 safepoints()->Emit(masm(), frame()->GetTotalFrameSlotCount()); |
| 207 | 203 |
| 208 Handle<Code> result = | 204 Handle<Code> result = |
| 209 v8::internal::CodeGenerator::MakeCodeEpilogue(masm(), info); | 205 v8::internal::CodeGenerator::MakeCodeEpilogue(masm(), info); |
| 210 result->set_is_turbofanned(true); | 206 result->set_is_turbofanned(true); |
| 211 result->set_stack_slots(frame()->GetTotalFrameSlotCount()); | 207 result->set_stack_slots(frame()->GetTotalFrameSlotCount()); |
| 212 result->set_safepoint_table_offset(safepoints()->GetCodeOffset()); | 208 result->set_safepoint_table_offset(safepoints()->GetCodeOffset()); |
| 213 Handle<ByteArray> source_positions = | 209 Handle<ByteArray> source_positions = |
| 214 source_position_table_builder_.ToSourcePositionTable(); | 210 source_position_table_builder_.ToSourcePositionTable(); |
| 215 result->set_source_position_table(*source_positions); | 211 result->set_source_position_table(*source_positions); |
| 212 source_position_table_builder_.EndJitLogging(AbstractCode::cast(*result)); |
| 216 | 213 |
| 217 // Emit exception handler table. | 214 // Emit exception handler table. |
| 218 if (!handlers_.empty()) { | 215 if (!handlers_.empty()) { |
| 219 Handle<HandlerTable> table = | 216 Handle<HandlerTable> table = |
| 220 Handle<HandlerTable>::cast(isolate()->factory()->NewFixedArray( | 217 Handle<HandlerTable>::cast(isolate()->factory()->NewFixedArray( |
| 221 HandlerTable::LengthForReturn(static_cast<int>(handlers_.size())), | 218 HandlerTable::LengthForReturn(static_cast<int>(handlers_.size())), |
| 222 TENURED)); | 219 TENURED)); |
| 223 for (size_t i = 0; i < handlers_.size(); ++i) { | 220 for (size_t i = 0; i < handlers_.size(); ++i) { |
| 224 int position = handlers_[i].handler->pos(); | 221 int position = handlers_[i].handler->pos(); |
| 225 HandlerTable::CatchPrediction prediction = handlers_[i].caught_locally | 222 HandlerTable::CatchPrediction prediction = handlers_[i].caught_locally |
| 226 ? HandlerTable::CAUGHT | 223 ? HandlerTable::CAUGHT |
| 227 : HandlerTable::UNCAUGHT; | 224 : HandlerTable::UNCAUGHT; |
| 228 table->SetReturnOffset(static_cast<int>(i), handlers_[i].pc_offset); | 225 table->SetReturnOffset(static_cast<int>(i), handlers_[i].pc_offset); |
| 229 table->SetReturnHandler(static_cast<int>(i), position, prediction); | 226 table->SetReturnHandler(static_cast<int>(i), position, prediction); |
| 230 } | 227 } |
| 231 result->set_handler_table(*table); | 228 result->set_handler_table(*table); |
| 232 } | 229 } |
| 233 | 230 |
| 234 PopulateDeoptimizationData(result); | 231 PopulateDeoptimizationData(result); |
| 235 | 232 |
| 236 // Ensure there is space for lazy deoptimization in the relocation info. | 233 // Ensure there is space for lazy deoptimization in the relocation info. |
| 237 if (info->ShouldEnsureSpaceForLazyDeopt()) { | 234 if (info->ShouldEnsureSpaceForLazyDeopt()) { |
| 238 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(result); | 235 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(result); |
| 239 } | 236 } |
| 240 | 237 |
| 241 // Emit a code line info recording stop event. | |
| 242 void* line_info = source_position_table_builder_.DetachJITHandlerData(); | |
| 243 LOG_CODE_EVENT(isolate(), CodeEndLinePosInfoRecordEvent( | |
| 244 AbstractCode::cast(*result), line_info)); | |
| 245 | |
| 246 return result; | 238 return result; |
| 247 } | 239 } |
| 248 | 240 |
| 249 | 241 |
| 250 bool CodeGenerator::IsNextInAssemblyOrder(RpoNumber block) const { | 242 bool CodeGenerator::IsNextInAssemblyOrder(RpoNumber block) const { |
| 251 return code() | 243 return code() |
| 252 ->InstructionBlockAt(current_block_) | 244 ->InstructionBlockAt(current_block_) |
| 253 ->ao_number() | 245 ->ao_number() |
| 254 .IsNext(code()->InstructionBlockAt(block)->ao_number()); | 246 .IsNext(code()->InstructionBlockAt(block)->ao_number()); |
| 255 } | 247 } |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { | 812 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { |
| 821 gen->ools_ = this; | 813 gen->ools_ = this; |
| 822 } | 814 } |
| 823 | 815 |
| 824 | 816 |
| 825 OutOfLineCode::~OutOfLineCode() {} | 817 OutOfLineCode::~OutOfLineCode() {} |
| 826 | 818 |
| 827 } // namespace compiler | 819 } // namespace compiler |
| 828 } // namespace internal | 820 } // namespace internal |
| 829 } // namespace v8 | 821 } // namespace v8 |
| OLD | NEW |