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

Side by Side Diff: src/codegen.cc

Issue 43273004: Allow redirecting disassembly and deoptimization traces into a file. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/code-stubs.cc ('k') | src/d8.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 bool print_code = info->isolate()->bootstrapper()->IsActive() 129 bool print_code = info->isolate()->bootstrapper()->IsActive()
130 ? FLAG_print_builtin_code 130 ? FLAG_print_builtin_code
131 : (FLAG_print_code || 131 : (FLAG_print_code ||
132 (info->IsStub() && FLAG_print_code_stubs) || 132 (info->IsStub() && FLAG_print_code_stubs) ||
133 (info->IsOptimizing() && FLAG_print_opt_code)); 133 (info->IsOptimizing() && FLAG_print_opt_code));
134 if (print_code) { 134 if (print_code) {
135 // Print the source code if available. 135 // Print the source code if available.
136 FunctionLiteral* function = info->function(); 136 FunctionLiteral* function = info->function();
137 bool print_source = code->kind() == Code::OPTIMIZED_FUNCTION || 137 bool print_source = code->kind() == Code::OPTIMIZED_FUNCTION ||
138 code->kind() == Code::FUNCTION; 138 code->kind() == Code::FUNCTION;
139
140 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer());
139 if (print_source) { 141 if (print_source) {
140 Handle<Script> script = info->script(); 142 Handle<Script> script = info->script();
141 if (!script->IsUndefined() && !script->source()->IsUndefined()) { 143 if (!script->IsUndefined() && !script->source()->IsUndefined()) {
142 PrintF("--- Raw source ---\n"); 144 PrintF(tracing_scope.file(), "--- Raw source ---\n");
143 ConsStringIteratorOp op; 145 ConsStringIteratorOp op;
144 StringCharacterStream stream(String::cast(script->source()), 146 StringCharacterStream stream(String::cast(script->source()),
145 &op, 147 &op,
146 function->start_position()); 148 function->start_position());
147 // fun->end_position() points to the last character in the stream. We 149 // fun->end_position() points to the last character in the stream. We
148 // need to compensate by adding one to calculate the length. 150 // need to compensate by adding one to calculate the length.
149 int source_len = 151 int source_len =
150 function->end_position() - function->start_position() + 1; 152 function->end_position() - function->start_position() + 1;
151 for (int i = 0; i < source_len; i++) { 153 for (int i = 0; i < source_len; i++) {
152 if (stream.HasMore()) PrintF("%c", stream.GetNext()); 154 if (stream.HasMore()) {
155 PrintF(tracing_scope.file(), "%c", stream.GetNext());
156 }
153 } 157 }
154 PrintF("\n\n"); 158 PrintF(tracing_scope.file(), "\n\n");
155 } 159 }
156 } 160 }
157 if (info->IsOptimizing()) { 161 if (info->IsOptimizing()) {
158 if (FLAG_print_unopt_code) { 162 if (FLAG_print_unopt_code) {
159 PrintF("--- Unoptimized code ---\n"); 163 PrintF(tracing_scope.file(), "--- Unoptimized code ---\n");
160 info->closure()->shared()->code()->Disassemble( 164 info->closure()->shared()->code()->Disassemble(
161 *function->debug_name()->ToCString()); 165 *function->debug_name()->ToCString(), tracing_scope.file());
162 } 166 }
163 PrintF("--- Optimized code ---\n"); 167 PrintF(tracing_scope.file(), "--- Optimized code ---\n");
164 } else { 168 } else {
165 PrintF("--- Code ---\n"); 169 PrintF(tracing_scope.file(), "--- Code ---\n");
166 } 170 }
167 if (print_source) { 171 if (print_source) {
168 PrintF("source_position = %d\n", function->start_position()); 172 PrintF(tracing_scope.file(),
173 "source_position = %d\n", function->start_position());
169 } 174 }
170 if (info->IsStub()) { 175 if (info->IsStub()) {
171 CodeStub::Major major_key = info->code_stub()->MajorKey(); 176 CodeStub::Major major_key = info->code_stub()->MajorKey();
172 code->Disassemble(CodeStub::MajorName(major_key, false)); 177 code->Disassemble(CodeStub::MajorName(major_key, false),
178 tracing_scope.file());
173 } else { 179 } else {
174 code->Disassemble(*function->debug_name()->ToCString()); 180 code->Disassemble(*function->debug_name()->ToCString(),
181 tracing_scope.file());
175 } 182 }
176 PrintF("--- End code ---\n"); 183 PrintF(tracing_scope.file(), "--- End code ---\n");
177 } 184 }
178 #endif // ENABLE_DISASSEMBLER 185 #endif // ENABLE_DISASSEMBLER
179 } 186 }
180 187
181 188
182 bool CodeGenerator::ShouldGenerateLog(Isolate* isolate, Expression* type) { 189 bool CodeGenerator::ShouldGenerateLog(Isolate* isolate, Expression* type) {
183 ASSERT(type != NULL); 190 ASSERT(type != NULL);
184 if (!isolate->logger()->is_logging() && 191 if (!isolate->logger()->is_logging() &&
185 !isolate->cpu_profiler()->is_profiling()) { 192 !isolate->cpu_profiler()->is_profiling()) {
186 return false; 193 return false;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 ASSERT(result_size_ == 1 || result_size_ == 2); 238 ASSERT(result_size_ == 1 || result_size_ == 2);
232 #ifdef _WIN64 239 #ifdef _WIN64
233 return result | ((result_size_ == 1) ? 0 : 2); 240 return result | ((result_size_ == 1) ? 0 : 2);
234 #else 241 #else
235 return result; 242 return result;
236 #endif 243 #endif
237 } 244 }
238 245
239 246
240 } } // namespace v8::internal 247 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698