OLD | NEW |
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> // NOLINT(build/c++11) | 8 #include <fenv.h> // NOLINT(build/c++11) |
9 #endif | 9 #endif |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 Comment::~Comment() { | 77 Comment::~Comment() { |
78 if (msg_[0] == '[') __ RecordComment("]"); | 78 if (msg_[0] == '[') __ RecordComment("]"); |
79 } | 79 } |
80 | 80 |
81 #endif // DEBUG | 81 #endif // DEBUG |
82 | 82 |
83 #undef __ | 83 #undef __ |
84 | 84 |
85 | 85 |
86 void CodeGenerator::MakeCodePrologue(CompilationInfo* info, const char* kind) { | 86 void CodeGenerator::MakeCodePrologue(CompilationInfo* info, const char* kind) { |
87 bool print_source = false; | |
88 bool print_ast = false; | 87 bool print_ast = false; |
89 const char* ftype; | 88 const char* ftype; |
90 | 89 |
91 if (info->isolate()->bootstrapper()->IsActive()) { | 90 if (info->isolate()->bootstrapper()->IsActive()) { |
92 print_source = FLAG_print_builtin_source; | |
93 print_ast = FLAG_print_builtin_ast; | 91 print_ast = FLAG_print_builtin_ast; |
94 ftype = "builtin"; | 92 ftype = "builtin"; |
95 } else { | 93 } else { |
96 print_source = FLAG_print_source; | |
97 print_ast = FLAG_print_ast; | 94 print_ast = FLAG_print_ast; |
98 ftype = "user-defined"; | 95 ftype = "user-defined"; |
99 } | 96 } |
100 | 97 |
101 if (FLAG_trace_codegen || print_source || print_ast) { | 98 if (FLAG_trace_codegen || print_ast) { |
102 base::SmartArrayPointer<char> name = info->GetDebugName(); | 99 base::SmartArrayPointer<char> name = info->GetDebugName(); |
103 PrintF("[generating %s code for %s function: %s]\n", kind, ftype, | 100 PrintF("[generating %s code for %s function: %s]\n", kind, ftype, |
104 name.get()); | 101 name.get()); |
105 } | 102 } |
106 | 103 |
107 #ifdef DEBUG | 104 #ifdef DEBUG |
108 if (info->parse_info() && print_source) { | |
109 PrintF("--- Source from AST ---\n%s\n", | |
110 PrettyPrinter(info->isolate()).PrintProgram(info->literal())); | |
111 } | |
112 | |
113 if (info->parse_info() && print_ast) { | 105 if (info->parse_info() && print_ast) { |
114 PrintF("--- AST ---\n%s\n", | 106 PrintF("--- AST ---\n%s\n", |
115 AstPrinter(info->isolate()).PrintProgram(info->literal())); | 107 AstPrinter(info->isolate()).PrintProgram(info->literal())); |
116 } | 108 } |
117 #endif // DEBUG | 109 #endif // DEBUG |
118 } | 110 } |
119 | 111 |
120 | 112 |
121 Handle<Code> CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm, | 113 Handle<Code> CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm, |
122 CompilationInfo* info) { | 114 CompilationInfo* info) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 os << "source_position = " << shared->start_position() << "\n"; | 186 os << "source_position = " << shared->start_position() << "\n"; |
195 } | 187 } |
196 code->Disassemble(debug_name.get(), os); | 188 code->Disassemble(debug_name.get(), os); |
197 os << "--- End code ---\n"; | 189 os << "--- End code ---\n"; |
198 } | 190 } |
199 #endif // ENABLE_DISASSEMBLER | 191 #endif // ENABLE_DISASSEMBLER |
200 } | 192 } |
201 | 193 |
202 } // namespace internal | 194 } // namespace internal |
203 } // namespace v8 | 195 } // namespace v8 |
OLD | NEW |