Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: src/compiler/code-generator.cc

Issue 2109673003: Use source position table in turbofan code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: drive-by fix for relocation info size reservation Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/code-generator.h ('k') | src/debug/debug-frames.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 safepoints_(code->zone()), 45 safepoints_(code->zone()),
46 handlers_(code->zone()), 46 handlers_(code->zone()),
47 deoptimization_exits_(code->zone()), 47 deoptimization_exits_(code->zone()),
48 deoptimization_states_(code->zone()), 48 deoptimization_states_(code->zone()),
49 deoptimization_literals_(code->zone()), 49 deoptimization_literals_(code->zone()),
50 inlined_function_count_(0), 50 inlined_function_count_(0),
51 translations_(code->zone()), 51 translations_(code->zone()),
52 last_lazy_deopt_pc_(0), 52 last_lazy_deopt_pc_(0),
53 jump_tables_(nullptr), 53 jump_tables_(nullptr),
54 ools_(nullptr), 54 ools_(nullptr),
55 osr_pc_offset_(-1) { 55 osr_pc_offset_(-1),
56 source_position_table_builder_(info->isolate(), zone()) {
56 for (int i = 0; i < code->InstructionBlockCount(); ++i) { 57 for (int i = 0; i < code->InstructionBlockCount(); ++i) {
57 new (&labels_[i]) Label; 58 new (&labels_[i]) Label;
58 } 59 }
59 CreateFrameAccessState(frame); 60 CreateFrameAccessState(frame);
60 } 61 }
61 62
62 void CodeGenerator::CreateFrameAccessState(Frame* frame) { 63 void CodeGenerator::CreateFrameAccessState(Frame* frame) {
63 FinishFrame(frame); 64 FinishFrame(frame);
64 frame_access_state_ = new (code()->zone()) FrameAccessState(frame); 65 frame_access_state_ = new (code()->zone()) FrameAccessState(frame);
65 } 66 }
66 67
67 Handle<Code> CodeGenerator::GenerateCode() { 68 Handle<Code> CodeGenerator::GenerateCode() {
68 CompilationInfo* info = this->info(); 69 CompilationInfo* info = this->info();
69 70
70 // 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
71 // 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
72 // the frame (that is done in AssemblePrologue). 73 // the frame (that is done in AssemblePrologue).
73 FrameScope frame_scope(masm(), StackFrame::MANUAL); 74 FrameScope frame_scope(masm(), StackFrame::MANUAL);
74 75
75 // Emit a code line info recording start event. 76 // Emit a code line info recording start event.
76 PositionsRecorder* recorder = masm()->positions_recorder(); 77 LOG_CODE_EVENT(isolate(), CodeStartLinePosInfoRecordEvent(
77 LOG_CODE_EVENT(isolate(), CodeStartLinePosInfoRecordEvent(recorder)); 78 &source_position_table_builder_));
78 79
79 // Place function entry hook if requested to do so. 80 // Place function entry hook if requested to do so.
80 if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) { 81 if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) {
81 ProfileEntryHookStub::MaybeCallEntryHook(masm()); 82 ProfileEntryHookStub::MaybeCallEntryHook(masm());
82 } 83 }
83 // Architecture-specific, linkage-specific prologue. 84 // Architecture-specific, linkage-specific prologue.
84 info->set_prologue_offset(masm()->pc_offset()); 85 info->set_prologue_offset(masm()->pc_offset());
85 86
86 // Define deoptimization literals for all inlined functions. 87 // Define deoptimization literals for all inlined functions.
87 DCHECK_EQ(0u, deoptimization_literals_.size()); 88 DCHECK_EQ(0u, deoptimization_literals_.size());
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 203 }
203 } 204 }
204 205
205 safepoints()->Emit(masm(), frame()->GetTotalFrameSlotCount()); 206 safepoints()->Emit(masm(), frame()->GetTotalFrameSlotCount());
206 207
207 Handle<Code> result = 208 Handle<Code> result =
208 v8::internal::CodeGenerator::MakeCodeEpilogue(masm(), info); 209 v8::internal::CodeGenerator::MakeCodeEpilogue(masm(), info);
209 result->set_is_turbofanned(true); 210 result->set_is_turbofanned(true);
210 result->set_stack_slots(frame()->GetTotalFrameSlotCount()); 211 result->set_stack_slots(frame()->GetTotalFrameSlotCount());
211 result->set_safepoint_table_offset(safepoints()->GetCodeOffset()); 212 result->set_safepoint_table_offset(safepoints()->GetCodeOffset());
213 Handle<ByteArray> source_positions =
214 source_position_table_builder_.ToSourcePositionTable();
215 result->set_source_position_table(*source_positions);
212 216
213 // Emit exception handler table. 217 // Emit exception handler table.
214 if (!handlers_.empty()) { 218 if (!handlers_.empty()) {
215 Handle<HandlerTable> table = 219 Handle<HandlerTable> table =
216 Handle<HandlerTable>::cast(isolate()->factory()->NewFixedArray( 220 Handle<HandlerTable>::cast(isolate()->factory()->NewFixedArray(
217 HandlerTable::LengthForReturn(static_cast<int>(handlers_.size())), 221 HandlerTable::LengthForReturn(static_cast<int>(handlers_.size())),
218 TENURED)); 222 TENURED));
219 for (size_t i = 0; i < handlers_.size(); ++i) { 223 for (size_t i = 0; i < handlers_.size(); ++i) {
220 int position = handlers_[i].handler->pos(); 224 int position = handlers_[i].handler->pos();
221 HandlerTable::CatchPrediction prediction = handlers_[i].caught_locally 225 HandlerTable::CatchPrediction prediction = handlers_[i].caught_locally
222 ? HandlerTable::CAUGHT 226 ? HandlerTable::CAUGHT
223 : HandlerTable::UNCAUGHT; 227 : HandlerTable::UNCAUGHT;
224 table->SetReturnOffset(static_cast<int>(i), handlers_[i].pc_offset); 228 table->SetReturnOffset(static_cast<int>(i), handlers_[i].pc_offset);
225 table->SetReturnHandler(static_cast<int>(i), position, prediction); 229 table->SetReturnHandler(static_cast<int>(i), position, prediction);
226 } 230 }
227 result->set_handler_table(*table); 231 result->set_handler_table(*table);
228 } 232 }
229 233
230 PopulateDeoptimizationData(result); 234 PopulateDeoptimizationData(result);
231 235
232 // Ensure there is space for lazy deoptimization in the relocation info. 236 // Ensure there is space for lazy deoptimization in the relocation info.
233 if (info->ShouldEnsureSpaceForLazyDeopt()) { 237 if (info->ShouldEnsureSpaceForLazyDeopt()) {
234 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(result); 238 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(result);
235 } 239 }
236 240
237 // Emit a code line info recording stop event. 241 // Emit a code line info recording stop event.
238 void* line_info = recorder->DetachJITHandlerData(); 242 void* line_info = source_position_table_builder_.DetachJITHandlerData();
239 LOG_CODE_EVENT(isolate(), CodeEndLinePosInfoRecordEvent( 243 LOG_CODE_EVENT(isolate(), CodeEndLinePosInfoRecordEvent(
240 AbstractCode::cast(*result), line_info)); 244 AbstractCode::cast(*result), line_info));
241 245
242 return result; 246 return result;
243 } 247 }
244 248
245 249
246 bool CodeGenerator::IsNextInAssemblyOrder(RpoNumber block) const { 250 bool CodeGenerator::IsNextInAssemblyOrder(RpoNumber block) const {
247 return code() 251 return code()
248 ->InstructionBlockAt(current_block_) 252 ->InstructionBlockAt(current_block_)
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 395 }
392 396
393 397
394 void CodeGenerator::AssembleSourcePosition(Instruction* instr) { 398 void CodeGenerator::AssembleSourcePosition(Instruction* instr) {
395 SourcePosition source_position; 399 SourcePosition source_position;
396 if (!code()->GetSourcePosition(instr, &source_position)) return; 400 if (!code()->GetSourcePosition(instr, &source_position)) return;
397 if (source_position == current_source_position_) return; 401 if (source_position == current_source_position_) return;
398 current_source_position_ = source_position; 402 current_source_position_ = source_position;
399 if (source_position.IsUnknown()) return; 403 if (source_position.IsUnknown()) return;
400 int code_pos = source_position.raw(); 404 int code_pos = source_position.raw();
401 masm()->positions_recorder()->RecordPosition(code_pos); 405 source_position_table_builder_.AddPosition(masm()->pc_offset(), code_pos,
406 false);
402 if (FLAG_code_comments) { 407 if (FLAG_code_comments) {
403 CompilationInfo* info = this->info(); 408 CompilationInfo* info = this->info();
404 if (!info->parse_info()) return; 409 if (!info->parse_info()) return;
405 Vector<char> buffer = Vector<char>::New(256); 410 Vector<char> buffer = Vector<char>::New(256);
406 int ln = Script::GetLineNumber(info->script(), code_pos); 411 int ln = Script::GetLineNumber(info->script(), code_pos);
407 int cn = Script::GetColumnNumber(info->script(), code_pos); 412 int cn = Script::GetColumnNumber(info->script(), code_pos);
408 if (info->script()->name()->IsString()) { 413 if (info->script()->name()->IsString()) {
409 Handle<String> file(String::cast(info->script()->name())); 414 Handle<String> file(String::cast(info->script()->name()));
410 base::OS::SNPrintF(buffer.start(), buffer.length(), "-- %s:%d:%d --", 415 base::OS::SNPrintF(buffer.start(), buffer.length(), "-- %s:%d:%d --",
411 file->ToCString().get(), ln, cn); 416 file->ToCString().get(), ln, cn);
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { 820 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) {
816 gen->ools_ = this; 821 gen->ools_ = this;
817 } 822 }
818 823
819 824
820 OutOfLineCode::~OutOfLineCode() {} 825 OutOfLineCode::~OutOfLineCode() {}
821 826
822 } // namespace compiler 827 } // namespace compiler
823 } // namespace internal 828 } // namespace internal
824 } // namespace v8 829 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/code-generator.h ('k') | src/debug/debug-frames.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698