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

Side by Side Diff: src/codegen.cc

Issue 1297203002: Add CompileInfo::GetDebugName() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@interpreter_immed_bytecodes
Patch Set: Fix test crash Created 5 years, 4 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/code-stubs-hydrogen.cc ('k') | src/compiler.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/codegen.h" 5 #include "src/codegen.h"
6 6
7 #if defined(V8_OS_AIX) 7 #if defined(V8_OS_AIX)
8 #include <fenv.h> 8 #include <fenv.h>
9 #endif 9 #endif
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 print_source = FLAG_print_builtin_source; 114 print_source = FLAG_print_builtin_source;
115 print_ast = FLAG_print_builtin_ast; 115 print_ast = FLAG_print_builtin_ast;
116 ftype = "builtin"; 116 ftype = "builtin";
117 } else { 117 } else {
118 print_source = FLAG_print_source; 118 print_source = FLAG_print_source;
119 print_ast = FLAG_print_ast; 119 print_ast = FLAG_print_ast;
120 ftype = "user-defined"; 120 ftype = "user-defined";
121 } 121 }
122 122
123 if (FLAG_trace_codegen || print_source || print_ast) { 123 if (FLAG_trace_codegen || print_source || print_ast) {
124 PrintF("[generating %s code for %s function: ", kind, ftype); 124 base::SmartArrayPointer<char> name = info->GetDebugName();
125 if (info->IsStub()) { 125 PrintF("[generating %s code for %s function: %s]", kind, ftype, name.get());
126 const char* name =
127 CodeStub::MajorName(info->code_stub()->MajorKey(), true);
128 PrintF("%s", name == NULL ? "<unknown>" : name);
129 } else {
130 AllowDeferredHandleDereference allow_deference_for_trace;
131 PrintF("%s", info->literal()->debug_name()->ToCString().get());
132 }
133 PrintF("]\n");
134 } 126 }
135 127
136 #ifdef DEBUG 128 #ifdef DEBUG
137 if (info->parse_info() && print_source) { 129 if (info->parse_info() && print_source) {
138 PrintF("--- Source from AST ---\n%s\n", 130 PrintF("--- Source from AST ---\n%s\n",
139 PrettyPrinter(info->isolate(), info->zone()) 131 PrettyPrinter(info->isolate(), info->zone())
140 .PrintProgram(info->literal())); 132 .PrintProgram(info->literal()));
141 } 133 }
142 134
143 if (info->parse_info() && print_ast) { 135 if (info->parse_info() && print_ast) {
144 PrintF("--- AST ---\n%s\n", AstPrinter(info->isolate(), info->zone()) 136 PrintF("--- AST ---\n%s\n", AstPrinter(info->isolate(), info->zone())
145 .PrintProgram(info->literal())); 137 .PrintProgram(info->literal()));
146 } 138 }
147 #endif // DEBUG 139 #endif // DEBUG
148 } 140 }
149 141
150 142
151 Handle<Code> CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm, 143 Handle<Code> CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm,
152 CompilationInfo* info) { 144 CompilationInfo* info) {
153 Isolate* isolate = info->isolate(); 145 Isolate* isolate = info->isolate();
154 146
155 Code::Flags flags = 147 Code::Flags flags =
156 info->code_stub() != nullptr 148 info->IsStub()
157 ? Code::ComputeFlags(info->code_stub()->GetCodeKind(), 149 ? info->code_stub()
158 info->code_stub()->GetICState(), 150 ? Code::ComputeFlags(info->code_stub()->GetCodeKind(),
159 info->code_stub()->GetExtraICState(), 151 info->code_stub()->GetICState(),
160 info->code_stub()->GetStubType()) 152 info->code_stub()->GetExtraICState(),
153 info->code_stub()->GetStubType())
154 : Code::ComputeFlags(Code::STUB)
161 : Code::ComputeFlags(info->IsOptimizing() ? Code::OPTIMIZED_FUNCTION 155 : Code::ComputeFlags(info->IsOptimizing() ? Code::OPTIMIZED_FUNCTION
162 : Code::FUNCTION); 156 : Code::FUNCTION);
163 157
164 // Allocate and install the code. 158 // Allocate and install the code.
165 CodeDesc desc; 159 CodeDesc desc;
166 bool is_crankshafted = 160 bool is_crankshafted =
167 Code::ExtractKindFromFlags(flags) == Code::OPTIMIZED_FUNCTION || 161 Code::ExtractKindFromFlags(flags) == Code::OPTIMIZED_FUNCTION ||
168 info->IsStub(); 162 info->IsStub();
169 masm->GetCode(&desc); 163 masm->GetCode(&desc);
170 Handle<Code> code = 164 Handle<Code> code =
(...skipping 11 matching lines...) Expand all
182 176
183 void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) { 177 void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) {
184 #ifdef ENABLE_DISASSEMBLER 178 #ifdef ENABLE_DISASSEMBLER
185 AllowDeferredHandleDereference allow_deference_for_print_code; 179 AllowDeferredHandleDereference allow_deference_for_print_code;
186 bool print_code = info->isolate()->bootstrapper()->IsActive() 180 bool print_code = info->isolate()->bootstrapper()->IsActive()
187 ? FLAG_print_builtin_code 181 ? FLAG_print_builtin_code
188 : (FLAG_print_code || 182 : (FLAG_print_code ||
189 (info->IsStub() && FLAG_print_code_stubs) || 183 (info->IsStub() && FLAG_print_code_stubs) ||
190 (info->IsOptimizing() && FLAG_print_opt_code)); 184 (info->IsOptimizing() && FLAG_print_opt_code));
191 if (print_code) { 185 if (print_code) {
192 const char* debug_name; 186 base::SmartArrayPointer<char> debug_name = info->GetDebugName();
193 base::SmartArrayPointer<char> debug_name_holder;
194 if (info->IsStub()) {
195 CodeStub::Major major_key = info->code_stub()->MajorKey();
196 debug_name = CodeStub::MajorName(major_key, false);
197 } else {
198 debug_name_holder = info->literal()->debug_name()->ToCString();
199 debug_name = debug_name_holder.get();
200 }
201
202 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); 187 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer());
203 OFStream os(tracing_scope.file()); 188 OFStream os(tracing_scope.file());
204 189
205 // Print the source code if available. 190 // Print the source code if available.
206 bool print_source = 191 bool print_source =
207 info->parse_info() && (code->kind() == Code::OPTIMIZED_FUNCTION || 192 info->parse_info() && (code->kind() == Code::OPTIMIZED_FUNCTION ||
208 code->kind() == Code::FUNCTION); 193 code->kind() == Code::FUNCTION);
209 if (print_source) { 194 if (print_source) {
210 FunctionLiteral* literal = info->literal(); 195 FunctionLiteral* literal = info->literal();
211 Handle<Script> script = info->script(); 196 Handle<Script> script = info->script();
212 if (!script->IsUndefined() && !script->source()->IsUndefined()) { 197 if (!script->IsUndefined() && !script->source()->IsUndefined()) {
213 os << "--- Raw source ---\n"; 198 os << "--- Raw source ---\n";
214 StringCharacterStream stream(String::cast(script->source()), 199 StringCharacterStream stream(String::cast(script->source()),
215 literal->start_position()); 200 literal->start_position());
216 // fun->end_position() points to the last character in the stream. We 201 // fun->end_position() points to the last character in the stream. We
217 // need to compensate by adding one to calculate the length. 202 // need to compensate by adding one to calculate the length.
218 int source_len = 203 int source_len =
219 literal->end_position() - literal->start_position() + 1; 204 literal->end_position() - literal->start_position() + 1;
220 for (int i = 0; i < source_len; i++) { 205 for (int i = 0; i < source_len; i++) {
221 if (stream.HasMore()) { 206 if (stream.HasMore()) {
222 os << AsReversiblyEscapedUC16(stream.GetNext()); 207 os << AsReversiblyEscapedUC16(stream.GetNext());
223 } 208 }
224 } 209 }
225 os << "\n\n"; 210 os << "\n\n";
226 } 211 }
227 } 212 }
228 if (info->IsOptimizing()) { 213 if (info->IsOptimizing()) {
229 if (FLAG_print_unopt_code && info->parse_info()) { 214 if (FLAG_print_unopt_code && info->parse_info()) {
230 os << "--- Unoptimized code ---\n"; 215 os << "--- Unoptimized code ---\n";
231 info->closure()->shared()->code()->Disassemble(debug_name, os); 216 info->closure()->shared()->code()->Disassemble(debug_name.get(), os);
232 } 217 }
233 os << "--- Optimized code ---\n" 218 os << "--- Optimized code ---\n"
234 << "optimization_id = " << info->optimization_id() << "\n"; 219 << "optimization_id = " << info->optimization_id() << "\n";
235 } else { 220 } else {
236 os << "--- Code ---\n"; 221 os << "--- Code ---\n";
237 } 222 }
238 if (print_source) { 223 if (print_source) {
239 FunctionLiteral* literal = info->literal(); 224 FunctionLiteral* literal = info->literal();
240 os << "source_position = " << literal->start_position() << "\n"; 225 os << "source_position = " << literal->start_position() << "\n";
241 } 226 }
242 code->Disassemble(debug_name, os); 227 code->Disassemble(debug_name.get(), os);
243 os << "--- End code ---\n"; 228 os << "--- End code ---\n";
244 } 229 }
245 #endif // ENABLE_DISASSEMBLER 230 #endif // ENABLE_DISASSEMBLER
246 } 231 }
247 232
248 } // namespace internal 233 } // namespace internal
249 } // namespace v8 234 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698