Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: src/compiler.cc

Issue 996153003: CpuProfiler: simplify inlined function info magic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler.h ('k') | src/hydrogen.cc » ('j') | src/hydrogen.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 pareint_id) {
yurys 2015/03/11 13:05:21 typo: parent_id
loislo 2015/03/11 13:15:47 Done.
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(pareint_id, position, 0, shared->start_position());
yurys 2015/03/11 13:05:21 0 -> kNoScriptId ?
loislo 2015/03/11 13:15:47 Done.
285 int id = 0; 284 if (!shared->script()->IsUndefined()) {
286 for (; id < inlined_function_infos_->length(); id++) { 285 Handle<Script> script(Script::cast(shared->script()));
287 if (inlined_function_infos_->at(id).shared().is_identical_to(shared)) { 286 info.script_id = script->id()->value();
288 break;
289 }
290 }
291 if (id == inlined_function_infos_->length()) {
292 inlined_function_infos_->Add(InlinedFunctionInfo(shared));
293 287
294 if (!shared->script()->IsUndefined()) { 288 if (!script->source()->IsUndefined()) {
295 Handle<Script> script(Script::cast(shared->script())); 289 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
296 if (!script->source()->IsUndefined()) { 290 OFStream os(tracing_scope.file());
297 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); 291 os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get()
298 OFStream os(tracing_scope.file()); 292 << ") id{" << optimization_id() << "," << inline_id << "} ---\n";
299 os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get() 293 {
300 << ") id{" << optimization_id() << "," << id << "} ---\n"; 294 DisallowHeapAllocation no_allocation;
301 { 295 int start = shared->start_position();
302 DisallowHeapAllocation no_allocation; 296 int len = shared->end_position() - start;
303 int start = shared->start_position(); 297 String::SubStringRange source(String::cast(script->source()), start,
304 int len = shared->end_position() - start; 298 len);
305 String::SubStringRange source(String::cast(script->source()), start, 299 for (const auto& c : source) {
306 len); 300 os << AsReversiblyEscapedUC16(c);
307 for (const auto& c : source) {
308 os << AsReversiblyEscapedUC16(c);
309 }
310 } 301 }
302 }
311 303
312 os << "\n--- END ---\n"; 304 os << "\n--- END ---\n";
313 }
314 } 305 }
315 } 306 }
316 307
317 int inline_id = inlining_id_to_function_id_->length(); 308 inlined_function_infos_->Add(info);
318 inlining_id_to_function_id_->Add(id);
319 309
320 if (inline_id != 0) { 310 if (inline_id != 0) {
321 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); 311 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
322 OFStream os(tracing_scope.file()); 312 OFStream os(tracing_scope.file());
323 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" 313 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{"
324 << optimization_id() << "," << id << "} AS " << inline_id << " AT " 314 << optimization_id() << "," << inline_id << "} AS " << inline_id
325 << position << std::endl; 315 << " AT " << position << std::endl;
326 } 316 }
327 317
328 return inline_id; 318 return inline_id;
329 } 319 }
330 320
331 321
332 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { 322 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder {
333 public: 323 public:
334 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) 324 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info)
335 : HOptimizedGraphBuilder(info) { 325 : HOptimizedGraphBuilder(info) {
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 parse_info_ = nullptr; 1590 parse_info_ = nullptr;
1601 } 1591 }
1602 1592
1603 #if DEBUG 1593 #if DEBUG
1604 void CompilationInfo::PrintAstForTesting() { 1594 void CompilationInfo::PrintAstForTesting() {
1605 PrintF("--- Source from AST ---\n%s\n", 1595 PrintF("--- Source from AST ---\n%s\n",
1606 PrettyPrinter(isolate(), zone()).PrintProgram(function())); 1596 PrettyPrinter(isolate(), zone()).PrintProgram(function()));
1607 } 1597 }
1608 #endif 1598 #endif
1609 } } // namespace v8::internal 1599 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/hydrogen.cc » ('j') | src/hydrogen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698