| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 | 8 |
| 9 #include "src/ast-numbering.h" | 9 #include "src/ast-numbering.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 isolate_ = isolate; | 111 isolate_ = isolate; |
| 112 zone_ = zone; | 112 zone_ = zone; |
| 113 deferred_handles_ = NULL; | 113 deferred_handles_ = NULL; |
| 114 code_stub_ = NULL; | 114 code_stub_ = NULL; |
| 115 prologue_offset_ = Code::kPrologueOffsetNotSet; | 115 prologue_offset_ = Code::kPrologueOffsetNotSet; |
| 116 opt_count_ = has_shared_info() ? shared_info()->opt_count() : 0; | 116 opt_count_ = has_shared_info() ? shared_info()->opt_count() : 0; |
| 117 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() | 117 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() |
| 118 ? new List<OffsetRange>(2) : NULL; | 118 ? new List<OffsetRange>(2) : NULL; |
| 119 if (FLAG_hydrogen_track_positions) { | 119 if (FLAG_hydrogen_track_positions) { |
| 120 inlined_function_infos_ = new List<InlinedFunctionInfo>(5); | 120 inlined_function_infos_ = new List<InlinedFunctionInfo>(5); |
| 121 inlining_id_to_function_id_ = new List<int>(5); | |
| 122 } else { | 121 } else { |
| 123 inlined_function_infos_ = NULL; | 122 inlined_function_infos_ = NULL; |
| 124 inlining_id_to_function_id_ = NULL; | |
| 125 } | 123 } |
| 126 | 124 |
| 127 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 125 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
| 128 dependencies_[i] = NULL; | 126 dependencies_[i] = NULL; |
| 129 } | 127 } |
| 130 if (mode == STUB) { | 128 if (mode == STUB) { |
| 131 mode_ = STUB; | 129 mode_ = STUB; |
| 132 return; | 130 return; |
| 133 } | 131 } |
| 134 mode_ = mode; | 132 mode_ = mode; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 156 Handle<TypeFeedbackVector>(shared_info()->feedback_vector(), isolate); | 154 Handle<TypeFeedbackVector>(shared_info()->feedback_vector(), isolate); |
| 157 } | 155 } |
| 158 } | 156 } |
| 159 | 157 |
| 160 | 158 |
| 161 CompilationInfo::~CompilationInfo() { | 159 CompilationInfo::~CompilationInfo() { |
| 162 DisableFutureOptimization(); | 160 DisableFutureOptimization(); |
| 163 delete deferred_handles_; | 161 delete deferred_handles_; |
| 164 delete no_frame_ranges_; | 162 delete no_frame_ranges_; |
| 165 delete inlined_function_infos_; | 163 delete inlined_function_infos_; |
| 166 delete inlining_id_to_function_id_; | |
| 167 #ifdef DEBUG | 164 #ifdef DEBUG |
| 168 // Check that no dependent maps have been added or added dependent maps have | 165 // Check that no dependent maps have been added or added dependent maps have |
| 169 // been rolled back or committed. | 166 // been rolled back or committed. |
| 170 for (int i = 0; i < DependentCode::kGroupCount; i++) { | 167 for (int i = 0; i < DependentCode::kGroupCount; i++) { |
| 171 DCHECK(!dependencies_[i]); | 168 DCHECK(!dependencies_[i]); |
| 172 } | 169 } |
| 173 #endif // DEBUG | 170 #endif // DEBUG |
| 174 } | 171 } |
| 175 | 172 |
| 176 | 173 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 267 } |
| 271 } | 268 } |
| 272 | 269 |
| 273 | 270 |
| 274 bool CompilationInfo::is_simple_parameter_list() { | 271 bool CompilationInfo::is_simple_parameter_list() { |
| 275 return scope()->is_simple_parameter_list(); | 272 return scope()->is_simple_parameter_list(); |
| 276 } | 273 } |
| 277 | 274 |
| 278 | 275 |
| 279 int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | 276 int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
| 280 SourcePosition position) { | 277 SourcePosition position, |
| 278 int parent_id) { |
| 281 DCHECK(FLAG_hydrogen_track_positions); | 279 DCHECK(FLAG_hydrogen_track_positions); |
| 280 DCHECK(inlined_function_infos_); |
| 282 | 281 |
| 283 DCHECK(inlined_function_infos_); | 282 int inline_id = inlined_function_infos_->length(); |
| 284 DCHECK(inlining_id_to_function_id_); | 283 InlinedFunctionInfo info(parent_id, position, UnboundScript::kNoScriptId, |
| 285 int id = 0; | 284 shared->start_position()); |
| 286 for (; id < inlined_function_infos_->length(); id++) { | 285 if (!shared->script()->IsUndefined()) { |
| 287 if (inlined_function_infos_->at(id).shared().is_identical_to(shared)) { | 286 Handle<Script> script(Script::cast(shared->script())); |
| 288 break; | 287 info.script_id = script->id()->value(); |
| 289 } | |
| 290 } | |
| 291 if (id == inlined_function_infos_->length()) { | |
| 292 inlined_function_infos_->Add(InlinedFunctionInfo(shared)); | |
| 293 | 288 |
| 294 if (!shared->script()->IsUndefined()) { | 289 if (!script->source()->IsUndefined()) { |
| 295 Handle<Script> script(Script::cast(shared->script())); | 290 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
| 296 if (!script->source()->IsUndefined()) { | 291 OFStream os(tracing_scope.file()); |
| 297 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); | 292 os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get() |
| 298 OFStream os(tracing_scope.file()); | 293 << ") id{" << optimization_id() << "," << inline_id << "} ---\n"; |
| 299 os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get() | 294 { |
| 300 << ") id{" << optimization_id() << "," << id << "} ---\n"; | 295 DisallowHeapAllocation no_allocation; |
| 301 { | 296 int start = shared->start_position(); |
| 302 DisallowHeapAllocation no_allocation; | 297 int len = shared->end_position() - start; |
| 303 int start = shared->start_position(); | 298 String::SubStringRange source(String::cast(script->source()), start, |
| 304 int len = shared->end_position() - start; | 299 len); |
| 305 String::SubStringRange source(String::cast(script->source()), start, | 300 for (const auto& c : source) { |
| 306 len); | 301 os << AsReversiblyEscapedUC16(c); |
| 307 for (const auto& c : source) { | |
| 308 os << AsReversiblyEscapedUC16(c); | |
| 309 } | |
| 310 } | 302 } |
| 303 } |
| 311 | 304 |
| 312 os << "\n--- END ---\n"; | 305 os << "\n--- END ---\n"; |
| 313 } | |
| 314 } | 306 } |
| 315 } | 307 } |
| 316 | 308 |
| 317 int inline_id = inlining_id_to_function_id_->length(); | 309 inlined_function_infos_->Add(info); |
| 318 inlining_id_to_function_id_->Add(id); | |
| 319 | 310 |
| 320 if (inline_id != 0) { | 311 if (inline_id != 0) { |
| 321 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); | 312 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
| 322 OFStream os(tracing_scope.file()); | 313 OFStream os(tracing_scope.file()); |
| 323 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" | 314 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" |
| 324 << optimization_id() << "," << id << "} AS " << inline_id << " AT " | 315 << optimization_id() << "," << inline_id << "} AS " << inline_id |
| 325 << position << std::endl; | 316 << " AT " << position << std::endl; |
| 326 } | 317 } |
| 327 | 318 |
| 328 return inline_id; | 319 return inline_id; |
| 329 } | 320 } |
| 330 | 321 |
| 331 | 322 |
| 332 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { | 323 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { |
| 333 public: | 324 public: |
| 334 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) | 325 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) |
| 335 : HOptimizedGraphBuilder(info) { | 326 : HOptimizedGraphBuilder(info) { |
| (...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 parse_info_ = nullptr; | 1591 parse_info_ = nullptr; |
| 1601 } | 1592 } |
| 1602 | 1593 |
| 1603 #if DEBUG | 1594 #if DEBUG |
| 1604 void CompilationInfo::PrintAstForTesting() { | 1595 void CompilationInfo::PrintAstForTesting() { |
| 1605 PrintF("--- Source from AST ---\n%s\n", | 1596 PrintF("--- Source from AST ---\n%s\n", |
| 1606 PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1597 PrettyPrinter(isolate(), zone()).PrintProgram(function())); |
| 1607 } | 1598 } |
| 1608 #endif | 1599 #endif |
| 1609 } } // namespace v8::internal | 1600 } } // namespace v8::internal |
| OLD | NEW |