Chromium Code Reviews| Index: src/compiler.cc |
| diff --git a/src/compiler.cc b/src/compiler.cc |
| index 26daec77a353e6943b97d7c069405bd72298eb5b..6ff50fa49fea85b7a8bfe7ac362814dcbe7e408a 100644 |
| --- a/src/compiler.cc |
| +++ b/src/compiler.cc |
| @@ -147,6 +147,14 @@ void CompilationInfo::Initialize(Isolate* isolate, |
| opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); |
| no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() |
| ? new List<OffsetRange>(2) : NULL; |
| + if (FLAG_hydrogen_track_positions) { |
| + inlined_function_infos_ = new List<InlinedFunctionInfo>(5); |
| + inlining_id_to_function_id_ = new List<int>(5); |
| + } else { |
| + inlined_function_infos_ = NULL; |
| + inlining_id_to_function_id_ = NULL; |
| + } |
| + |
| for (int i = 0; i < DependentCode::kGroupCount; i++) { |
| dependencies_[i] = NULL; |
| } |
| @@ -193,6 +201,8 @@ CompilationInfo::~CompilationInfo() { |
| } |
| delete deferred_handles_; |
| delete no_frame_ranges_; |
| + if (inlined_function_infos_) delete inlined_function_infos_; |
|
Vyacheslav Egorov (Google)
2015/02/16 13:38:50
delete NULL works just fine - so no need for if.
loislo
2015/02/16 14:48:32
Done.
|
| + if (inlining_id_to_function_id_) delete inlining_id_to_function_id_; |
| if (ast_value_factory_owned_) delete ast_value_factory_; |
| #ifdef DEBUG |
| // Check that no dependent maps have been added or added dependent maps have |
| @@ -313,6 +323,44 @@ bool CompilationInfo::is_simple_parameter_list() { |
| } |
| +int CompilationInfo::GetInlinedFunctionId(Handle<SharedFunctionInfo> shared) { |
| + DCHECK(inlined_function_infos_); |
| + DCHECK(inlining_id_to_function_id_); |
| + int id = 0; |
| + for (; id < inlined_function_infos_->length(); id++) { |
| + if (inlined_function_infos_->at(id).shared().is_identical_to(shared)) { |
| + break; |
| + } |
| + } |
| + if (id == inlined_function_infos_->length()) { |
| + inlined_function_infos_->Add(InlinedFunctionInfo(shared)); |
| + |
| + if (!shared->script()->IsUndefined()) { |
|
Vyacheslav Egorov (Google)
2015/02/16 13:38:50
Given that you want to reuse this function for pro
loislo
2015/02/16 14:48:32
Yep. I supposed to do that in the next patch.
|
| + Handle<Script> script(Script::cast(shared->script())); |
| + if (!script->source()->IsUndefined()) { |
| + CodeTracer::Scope tracing_scopex(isolate()->GetCodeTracer()); |
|
Vyacheslav Egorov (Google)
2015/02/16 13:38:50
can it be called just tracing_scope here?
loislo
2015/02/16 14:48:32
Done.
|
| + OFStream os(tracing_scopex.file()); |
| + os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get() |
| + << ") id{" << optimization_id() << "," << id << "} ---\n"; |
| + { |
| + DisallowHeapAllocation no_allocation; |
| + int start = shared->start_position(); |
| + int len = shared->end_position() - start + 1; |
| + String::SubStringRange source(String::cast(script->source()), start, |
| + len); |
| + for (const auto& c : source) { |
| + os << AsReversiblyEscapedUC16(c); |
| + } |
| + } |
| + |
| + os << "\n--- END ---\n"; |
| + } |
| + } |
| + } |
| + return id; |
| +} |
| + |
| + |
| class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { |
| public: |
| explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) |