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

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

Issue 2026313002: Emit unwinding information for TurboFan code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@eh-frame
Patch Set: Clarify assumptions on frame ction/dtion routines in arm/arm64. 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
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/base/adapters.h" 8 #include "src/base/adapters.h"
9 #include "src/compiler/code-generator-impl.h" 9 #include "src/compiler/code-generator-impl.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 translations_(code->zone()), 52 translations_(code->zone()),
53 last_lazy_deopt_pc_(0), 53 last_lazy_deopt_pc_(0),
54 jump_tables_(nullptr), 54 jump_tables_(nullptr),
55 ools_(nullptr), 55 ools_(nullptr),
56 osr_pc_offset_(-1), 56 osr_pc_offset_(-1),
57 source_position_table_builder_(info->isolate(), zone()) { 57 source_position_table_builder_(info->isolate(), zone()) {
58 for (int i = 0; i < code->InstructionBlockCount(); ++i) { 58 for (int i = 0; i < code->InstructionBlockCount(); ++i) {
59 new (&labels_[i]) Label; 59 new (&labels_[i]) Label;
60 } 60 }
61 CreateFrameAccessState(frame); 61 CreateFrameAccessState(frame);
62 if (FLAG_perf_prof_unwinding_info) {
63 unwinding_info_writer_.Reset(new UnwindingInfoWriter);
64 }
62 } 65 }
63 66
64 void CodeGenerator::CreateFrameAccessState(Frame* frame) { 67 void CodeGenerator::CreateFrameAccessState(Frame* frame) {
65 FinishFrame(frame); 68 FinishFrame(frame);
66 frame_access_state_ = new (code()->zone()) FrameAccessState(frame); 69 frame_access_state_ = new (code()->zone()) FrameAccessState(frame);
67 } 70 }
68 71
69 Handle<Code> CodeGenerator::GenerateCode() { 72 Handle<Code> CodeGenerator::GenerateCode() {
70 CompilationInfo* info = this->info(); 73 CompilationInfo* info = this->info();
71 74
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 for (const InstructionBlock* block : code()->instruction_blocks()) { 108 for (const InstructionBlock* block : code()->instruction_blocks()) {
106 if (block->IsDeferred() == (deferred == 0)) { 109 if (block->IsDeferred() == (deferred == 0)) {
107 continue; 110 continue;
108 } 111 }
109 // Align loop headers on 16-byte boundaries. 112 // Align loop headers on 16-byte boundaries.
110 if (block->IsLoopHeader()) masm()->Align(16); 113 if (block->IsLoopHeader()) masm()->Align(16);
111 // Ensure lazy deopt doesn't patch handler entry points. 114 // Ensure lazy deopt doesn't patch handler entry points.
112 if (block->IsHandler()) EnsureSpaceForLazyDeopt(); 115 if (block->IsHandler()) EnsureSpaceForLazyDeopt();
113 // Bind a label for a block. 116 // Bind a label for a block.
114 current_block_ = block->rpo_number(); 117 current_block_ = block->rpo_number();
118 if (!unwinding_info_writer_.is_empty()) {
119 unwinding_info_writer_->BeginInstructionBlock(masm()->pc_offset(),
120 block);
121 }
115 if (FLAG_code_comments) { 122 if (FLAG_code_comments) {
116 // TODO(titzer): these code comments are a giant memory leak. 123 // TODO(titzer): these code comments are a giant memory leak.
117 Vector<char> buffer = Vector<char>::New(200); 124 Vector<char> buffer = Vector<char>::New(200);
118 char* buffer_start = buffer.start(); 125 char* buffer_start = buffer.start();
119 126
120 int next = SNPrintF( 127 int next = SNPrintF(
121 buffer, "-- B%d start%s%s%s%s", block->rpo_number().ToInt(), 128 buffer, "-- B%d start%s%s%s%s", block->rpo_number().ToInt(),
122 block->IsDeferred() ? " (deferred)" : "", 129 block->IsDeferred() ? " (deferred)" : "",
123 block->needs_frame() ? "" : " (no frame)", 130 block->needs_frame() ? "" : " (no frame)",
124 block->must_construct_frame() ? " (construct frame)" : "", 131 block->must_construct_frame() ? " (construct frame)" : "",
(...skipping 30 matching lines...) Expand all
155 } 162 }
156 163
157 CodeGenResult result; 164 CodeGenResult result;
158 if (FLAG_enable_embedded_constant_pool && !block->needs_frame()) { 165 if (FLAG_enable_embedded_constant_pool && !block->needs_frame()) {
159 ConstantPoolUnavailableScope constant_pool_unavailable(masm()); 166 ConstantPoolUnavailableScope constant_pool_unavailable(masm());
160 result = AssembleBlock(block); 167 result = AssembleBlock(block);
161 } else { 168 } else {
162 result = AssembleBlock(block); 169 result = AssembleBlock(block);
163 } 170 }
164 if (result != kSuccess) return Handle<Code>(); 171 if (result != kSuccess) return Handle<Code>();
172 if (!unwinding_info_writer_.is_empty()) {
173 unwinding_info_writer_->EndInstructionBlock(block);
174 }
165 } 175 }
166 } 176 }
167 177
168 // Assemble all out-of-line code. 178 // Assemble all out-of-line code.
169 if (ools_) { 179 if (ools_) {
170 masm()->RecordComment("-- Out of line code --"); 180 masm()->RecordComment("-- Out of line code --");
171 for (OutOfLineCode* ool = ools_; ool; ool = ool->next()) { 181 for (OutOfLineCode* ool = ools_; ool; ool = ool->next()) {
172 masm()->bind(ool->entry()); 182 masm()->bind(ool->entry());
173 ool->Generate(); 183 ool->Generate();
174 if (ool->exit()->is_bound()) masm()->jmp(ool->exit()); 184 if (ool->exit()->is_bound()) masm()->jmp(ool->exit());
(...skipping 20 matching lines...) Expand all
195 if (jump_tables_) { 205 if (jump_tables_) {
196 masm()->Align(kPointerSize); 206 masm()->Align(kPointerSize);
197 for (JumpTable* table = jump_tables_; table; table = table->next()) { 207 for (JumpTable* table = jump_tables_; table; table = table->next()) {
198 masm()->bind(table->label()); 208 masm()->bind(table->label());
199 AssembleJumpTable(table->targets(), table->target_count()); 209 AssembleJumpTable(table->targets(), table->target_count());
200 } 210 }
201 } 211 }
202 212
203 safepoints()->Emit(masm(), frame()->GetTotalFrameSlotCount()); 213 safepoints()->Emit(masm(), frame()->GetTotalFrameSlotCount());
204 214
205 Handle<Code> result = 215 EhFrameWriter* eh_frame_writer = nullptr;
206 v8::internal::CodeGenerator::MakeCodeEpilogue(masm(), nullptr, info); 216 if (!unwinding_info_writer_.is_empty()) {
217 unwinding_info_writer_->Finish(masm()->pc_offset());
218 eh_frame_writer = unwinding_info_writer_->eh_frame_writer();
219 }
220
221 Handle<Code> result = v8::internal::CodeGenerator::MakeCodeEpilogue(
222 masm(), eh_frame_writer, info);
207 result->set_is_turbofanned(true); 223 result->set_is_turbofanned(true);
208 result->set_stack_slots(frame()->GetTotalFrameSlotCount()); 224 result->set_stack_slots(frame()->GetTotalFrameSlotCount());
209 result->set_safepoint_table_offset(safepoints()->GetCodeOffset()); 225 result->set_safepoint_table_offset(safepoints()->GetCodeOffset());
210 Handle<ByteArray> source_positions = 226 Handle<ByteArray> source_positions =
211 source_position_table_builder_.ToSourcePositionTable(); 227 source_position_table_builder_.ToSourcePositionTable();
212 result->set_source_position_table(*source_positions); 228 result->set_source_position_table(*source_positions);
213 source_position_table_builder_.EndJitLogging(AbstractCode::cast(*result)); 229 source_position_table_builder_.EndJitLogging(AbstractCode::cast(*result));
214 230
215 // Emit exception handler table. 231 // Emit exception handler table.
216 if (!handlers_.empty()) { 232 if (!handlers_.empty()) {
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { 913 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) {
898 gen->ools_ = this; 914 gen->ools_ = this;
899 } 915 }
900 916
901 917
902 OutOfLineCode::~OutOfLineCode() {} 918 OutOfLineCode::~OutOfLineCode() {}
903 919
904 } // namespace compiler 920 } // namespace compiler
905 } // namespace internal 921 } // namespace internal
906 } // namespace v8 922 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698