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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 code->instruction_size()); | 140 code->instruction_size()); |
141 isolate->heap()->IncrementCodeGeneratedBytes(is_crankshafted, | 141 isolate->heap()->IncrementCodeGeneratedBytes(is_crankshafted, |
142 code->instruction_size()); | 142 code->instruction_size()); |
143 return code; | 143 return code; |
144 } | 144 } |
145 | 145 |
146 | 146 |
147 void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) { | 147 void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) { |
148 #ifdef ENABLE_DISASSEMBLER | 148 #ifdef ENABLE_DISASSEMBLER |
149 AllowDeferredHandleDereference allow_deference_for_print_code; | 149 AllowDeferredHandleDereference allow_deference_for_print_code; |
150 bool print_code = info->isolate()->bootstrapper()->IsActive() | 150 Isolate* isolate = info->isolate(); |
151 ? FLAG_print_builtin_code | 151 bool print_code = |
152 : (FLAG_print_code || | 152 isolate->bootstrapper()->IsActive() |
153 (info->IsStub() && FLAG_print_code_stubs) || | 153 ? FLAG_print_builtin_code |
154 (info->IsOptimizing() && FLAG_print_opt_code)); | 154 : (FLAG_print_code || (info->IsStub() && FLAG_print_code_stubs) || |
| 155 (info->IsOptimizing() && FLAG_print_opt_code)); |
155 if (print_code) { | 156 if (print_code) { |
156 base::SmartArrayPointer<char> debug_name = info->GetDebugName(); | 157 base::SmartArrayPointer<char> debug_name = info->GetDebugName(); |
157 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); | 158 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); |
158 OFStream os(tracing_scope.file()); | 159 OFStream os(tracing_scope.file()); |
159 | 160 |
160 // Print the source code if available. | 161 // Print the source code if available. |
161 bool print_source = | 162 bool print_source = |
162 info->parse_info() && (code->kind() == Code::OPTIMIZED_FUNCTION || | 163 info->parse_info() && (code->kind() == Code::OPTIMIZED_FUNCTION || |
163 code->kind() == Code::FUNCTION); | 164 code->kind() == Code::FUNCTION); |
164 if (print_source) { | 165 if (print_source) { |
165 Handle<SharedFunctionInfo> shared = info->shared_info(); | 166 Handle<SharedFunctionInfo> shared = info->shared_info(); |
166 Handle<Script> script = info->script(); | 167 Handle<Script> script = info->script(); |
167 if (!script->IsUndefined() && !script->source()->IsUndefined()) { | 168 if (!script->IsUndefined(isolate) && |
| 169 !script->source()->IsUndefined(isolate)) { |
168 os << "--- Raw source ---\n"; | 170 os << "--- Raw source ---\n"; |
169 StringCharacterStream stream(String::cast(script->source()), | 171 StringCharacterStream stream(String::cast(script->source()), |
170 shared->start_position()); | 172 shared->start_position()); |
171 // fun->end_position() points to the last character in the stream. We | 173 // fun->end_position() points to the last character in the stream. We |
172 // need to compensate by adding one to calculate the length. | 174 // need to compensate by adding one to calculate the length. |
173 int source_len = shared->end_position() - shared->start_position() + 1; | 175 int source_len = shared->end_position() - shared->start_position() + 1; |
174 for (int i = 0; i < source_len; i++) { | 176 for (int i = 0; i < source_len; i++) { |
175 if (stream.HasMore()) { | 177 if (stream.HasMore()) { |
176 os << AsReversiblyEscapedUC16(stream.GetNext()); | 178 os << AsReversiblyEscapedUC16(stream.GetNext()); |
177 } | 179 } |
(...skipping 16 matching lines...) Expand all Loading... |
194 os << "source_position = " << shared->start_position() << "\n"; | 196 os << "source_position = " << shared->start_position() << "\n"; |
195 } | 197 } |
196 code->Disassemble(debug_name.get(), os); | 198 code->Disassemble(debug_name.get(), os); |
197 os << "--- End code ---\n"; | 199 os << "--- End code ---\n"; |
198 } | 200 } |
199 #endif // ENABLE_DISASSEMBLER | 201 #endif // ENABLE_DISASSEMBLER |
200 } | 202 } |
201 | 203 |
202 } // namespace internal | 204 } // namespace internal |
203 } // namespace v8 | 205 } // namespace v8 |
OLD | NEW |