| 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 |
| 11 #include <memory> |
| 12 |
| 10 #include "src/ast/prettyprinter.h" | 13 #include "src/ast/prettyprinter.h" |
| 11 #include "src/bootstrapper.h" | 14 #include "src/bootstrapper.h" |
| 12 #include "src/compiler.h" | 15 #include "src/compiler.h" |
| 13 #include "src/debug/debug.h" | 16 #include "src/debug/debug.h" |
| 14 #include "src/eh-frame.h" | 17 #include "src/eh-frame.h" |
| 15 #include "src/parsing/parser.h" | 18 #include "src/parsing/parser.h" |
| 16 #include "src/runtime/runtime.h" | 19 #include "src/runtime/runtime.h" |
| 17 | 20 |
| 18 namespace v8 { | 21 namespace v8 { |
| 19 namespace internal { | 22 namespace internal { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 93 |
| 91 if (info->isolate()->bootstrapper()->IsActive()) { | 94 if (info->isolate()->bootstrapper()->IsActive()) { |
| 92 print_ast = FLAG_print_builtin_ast; | 95 print_ast = FLAG_print_builtin_ast; |
| 93 ftype = "builtin"; | 96 ftype = "builtin"; |
| 94 } else { | 97 } else { |
| 95 print_ast = FLAG_print_ast; | 98 print_ast = FLAG_print_ast; |
| 96 ftype = "user-defined"; | 99 ftype = "user-defined"; |
| 97 } | 100 } |
| 98 | 101 |
| 99 if (FLAG_trace_codegen || print_ast) { | 102 if (FLAG_trace_codegen || print_ast) { |
| 100 base::SmartArrayPointer<char> name = info->GetDebugName(); | 103 std::unique_ptr<char[]> name = info->GetDebugName(); |
| 101 PrintF("[generating %s code for %s function: %s]\n", kind, ftype, | 104 PrintF("[generating %s code for %s function: %s]\n", kind, ftype, |
| 102 name.get()); | 105 name.get()); |
| 103 } | 106 } |
| 104 | 107 |
| 105 #ifdef DEBUG | 108 #ifdef DEBUG |
| 106 if (info->parse_info() && print_ast) { | 109 if (info->parse_info() && print_ast) { |
| 107 PrintF("--- AST ---\n%s\n", | 110 PrintF("--- AST ---\n%s\n", |
| 108 AstPrinter(info->isolate()).PrintProgram(info->literal())); | 111 AstPrinter(info->isolate()).PrintProgram(info->literal())); |
| 109 } | 112 } |
| 110 #endif // DEBUG | 113 #endif // DEBUG |
| (...skipping 28 matching lines...) Expand all Loading... |
| 139 void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) { | 142 void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) { |
| 140 #ifdef ENABLE_DISASSEMBLER | 143 #ifdef ENABLE_DISASSEMBLER |
| 141 AllowDeferredHandleDereference allow_deference_for_print_code; | 144 AllowDeferredHandleDereference allow_deference_for_print_code; |
| 142 Isolate* isolate = info->isolate(); | 145 Isolate* isolate = info->isolate(); |
| 143 bool print_code = | 146 bool print_code = |
| 144 isolate->bootstrapper()->IsActive() | 147 isolate->bootstrapper()->IsActive() |
| 145 ? FLAG_print_builtin_code | 148 ? FLAG_print_builtin_code |
| 146 : (FLAG_print_code || (info->IsStub() && FLAG_print_code_stubs) || | 149 : (FLAG_print_code || (info->IsStub() && FLAG_print_code_stubs) || |
| 147 (info->IsOptimizing() && FLAG_print_opt_code)); | 150 (info->IsOptimizing() && FLAG_print_opt_code)); |
| 148 if (print_code) { | 151 if (print_code) { |
| 149 base::SmartArrayPointer<char> debug_name = info->GetDebugName(); | 152 std::unique_ptr<char[]> debug_name = info->GetDebugName(); |
| 150 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); | 153 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); |
| 151 OFStream os(tracing_scope.file()); | 154 OFStream os(tracing_scope.file()); |
| 152 | 155 |
| 153 // Print the source code if available. | 156 // Print the source code if available. |
| 154 bool print_source = | 157 bool print_source = |
| 155 info->parse_info() && (code->kind() == Code::OPTIMIZED_FUNCTION || | 158 info->parse_info() && (code->kind() == Code::OPTIMIZED_FUNCTION || |
| 156 code->kind() == Code::FUNCTION); | 159 code->kind() == Code::FUNCTION); |
| 157 if (print_source) { | 160 if (print_source) { |
| 158 Handle<SharedFunctionInfo> shared = info->shared_info(); | 161 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 159 Handle<Script> script = info->script(); | 162 Handle<Script> script = info->script(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 188 os << "source_position = " << shared->start_position() << "\n"; | 191 os << "source_position = " << shared->start_position() << "\n"; |
| 189 } | 192 } |
| 190 code->Disassemble(debug_name.get(), os); | 193 code->Disassemble(debug_name.get(), os); |
| 191 os << "--- End code ---\n"; | 194 os << "--- End code ---\n"; |
| 192 } | 195 } |
| 193 #endif // ENABLE_DISASSEMBLER | 196 #endif // ENABLE_DISASSEMBLER |
| 194 } | 197 } |
| 195 | 198 |
| 196 } // namespace internal | 199 } // namespace internal |
| 197 } // namespace v8 | 200 } // namespace v8 |
| OLD | NEW |