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

Side by Side Diff: src/compiler.cc

Issue 914413007: CpuProfiler: move InlinedFunctionInfo class from HGraphBuilder to CompilationInfo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: out of bounds access to the script source was fixed Created 5 years, 10 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.h » ('j') | no next file with comments »
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 extension_ = NULL; 140 extension_ = NULL;
141 cached_data_ = NULL; 141 cached_data_ = NULL;
142 compile_options_ = ScriptCompiler::kNoCompileOptions; 142 compile_options_ = ScriptCompiler::kNoCompileOptions;
143 zone_ = zone; 143 zone_ = zone;
144 deferred_handles_ = NULL; 144 deferred_handles_ = NULL;
145 code_stub_ = NULL; 145 code_stub_ = NULL;
146 prologue_offset_ = Code::kPrologueOffsetNotSet; 146 prologue_offset_ = Code::kPrologueOffsetNotSet;
147 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); 147 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count();
148 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() 148 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling()
149 ? new List<OffsetRange>(2) : NULL; 149 ? new List<OffsetRange>(2) : NULL;
150 if (FLAG_hydrogen_track_positions) {
151 inlined_function_infos_ = new List<InlinedFunctionInfo>(5);
152 inlining_id_to_function_id_ = new List<int>(5);
153 } else {
154 inlined_function_infos_ = NULL;
155 inlining_id_to_function_id_ = NULL;
156 }
157
150 for (int i = 0; i < DependentCode::kGroupCount; i++) { 158 for (int i = 0; i < DependentCode::kGroupCount; i++) {
151 dependencies_[i] = NULL; 159 dependencies_[i] = NULL;
152 } 160 }
153 if (mode == STUB) { 161 if (mode == STUB) {
154 mode_ = STUB; 162 mode_ = STUB;
155 return; 163 return;
156 } 164 }
157 mode_ = mode; 165 mode_ = mode;
158 if (!script_.is_null() && script_->type()->value() == Script::TYPE_NATIVE) { 166 if (!script_.is_null() && script_->type()->value() == Script::TYPE_NATIVE) {
159 MarkAsNative(); 167 MarkAsNative();
(...skipping 26 matching lines...) Expand all
186 } 194 }
187 } 195 }
188 196
189 197
190 CompilationInfo::~CompilationInfo() { 198 CompilationInfo::~CompilationInfo() {
191 if (GetFlag(kDisableFutureOptimization)) { 199 if (GetFlag(kDisableFutureOptimization)) {
192 shared_info()->DisableOptimization(bailout_reason()); 200 shared_info()->DisableOptimization(bailout_reason());
193 } 201 }
194 delete deferred_handles_; 202 delete deferred_handles_;
195 delete no_frame_ranges_; 203 delete no_frame_ranges_;
204 delete inlined_function_infos_;
205 delete inlining_id_to_function_id_;
196 if (ast_value_factory_owned_) delete ast_value_factory_; 206 if (ast_value_factory_owned_) delete ast_value_factory_;
197 #ifdef DEBUG 207 #ifdef DEBUG
198 // Check that no dependent maps have been added or added dependent maps have 208 // Check that no dependent maps have been added or added dependent maps have
199 // been rolled back or committed. 209 // been rolled back or committed.
200 for (int i = 0; i < DependentCode::kGroupCount; i++) { 210 for (int i = 0; i < DependentCode::kGroupCount; i++) {
201 DCHECK(!dependencies_[i]); 211 DCHECK(!dependencies_[i]);
202 } 212 }
203 #endif // DEBUG 213 #endif // DEBUG
204 } 214 }
205 215
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 function()->feedback_vector_spec()); 316 function()->feedback_vector_spec());
307 } 317 }
308 } 318 }
309 319
310 320
311 bool CompilationInfo::is_simple_parameter_list() { 321 bool CompilationInfo::is_simple_parameter_list() {
312 return scope_->is_simple_parameter_list(); 322 return scope_->is_simple_parameter_list();
313 } 323 }
314 324
315 325
326 int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
327 int raw_position) {
328 if (!FLAG_hydrogen_track_positions) {
329 return 0;
330 }
331
332 DCHECK(inlined_function_infos_);
333 DCHECK(inlining_id_to_function_id_);
334 int id = 0;
335 for (; id < inlined_function_infos_->length(); id++) {
336 if (inlined_function_infos_->at(id).shared().is_identical_to(shared)) {
337 break;
338 }
339 }
340 if (id == inlined_function_infos_->length()) {
341 inlined_function_infos_->Add(InlinedFunctionInfo(shared));
342
343 if (!shared->script()->IsUndefined()) {
344 Handle<Script> script(Script::cast(shared->script()));
345 if (!script->source()->IsUndefined()) {
346 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
347 OFStream os(tracing_scope.file());
348 os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get()
349 << ") id{" << optimization_id() << "," << id << "} ---\n";
350 {
351 DisallowHeapAllocation no_allocation;
352 int start = shared->start_position();
353 int len = shared->end_position() - start;
354 String::SubStringRange source(String::cast(script->source()), start,
355 len);
356 for (const auto& c : source) {
357 os << AsReversiblyEscapedUC16(c);
358 }
359 }
360
361 os << "\n--- END ---\n";
362 }
363 }
364 }
365
366 int inline_id = inlining_id_to_function_id_->length();
367 inlining_id_to_function_id_->Add(id);
368
369 if (inline_id != 0) {
370 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
371 OFStream os(tracing_scope.file());
372 HSourcePosition position = HSourcePosition::FromRaw(raw_position);
373 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{"
374 << optimization_id() << "," << id << "} AS " << inline_id << " AT "
375 << position << std::endl;
376 }
377
378 return inline_id;
379 }
380
381
316 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { 382 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder {
317 public: 383 public:
318 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) 384 explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info)
319 : HOptimizedGraphBuilder(info) { 385 : HOptimizedGraphBuilder(info) {
320 } 386 }
321 387
322 #define DEF_VISIT(type) \ 388 #define DEF_VISIT(type) \
323 void Visit##type(type* node) OVERRIDE { \ 389 void Visit##type(type* node) OVERRIDE { \
324 if (node->position() != RelocInfo::kNoPosition) { \ 390 if (node->position() != RelocInfo::kNoPosition) { \
325 SetSourcePosition(node->position()); \ 391 SetSourcePosition(node->position()); \
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 } 1587 }
1522 1588
1523 1589
1524 #if DEBUG 1590 #if DEBUG
1525 void CompilationInfo::PrintAstForTesting() { 1591 void CompilationInfo::PrintAstForTesting() {
1526 PrintF("--- Source from AST ---\n%s\n", 1592 PrintF("--- Source from AST ---\n%s\n",
1527 PrettyPrinter(isolate(), zone()).PrintProgram(function())); 1593 PrettyPrinter(isolate(), zone()).PrintProgram(function()));
1528 } 1594 }
1529 #endif 1595 #endif
1530 } } // namespace v8::internal 1596 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698