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

Side by Side Diff: src/compiler.cc

Issue 2631253002: [compiler] Unify EnsureFeedbackMetadata call sites. (Closed)
Patch Set: Remove helper method. Created 3 years, 11 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 | « no previous file | src/interpreter/bytecode-generator.cc » ('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/compiler.h" 5 #include "src/compiler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/asmjs/asm-js.h" 10 #include "src/asmjs/asm-js.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 CodeEventListener::LogEventsAndTags log_tag = 285 CodeEventListener::LogEventsAndTags log_tag =
286 Logger::ToNativeByScript(tag, *script); 286 Logger::ToNativeByScript(tag, *script);
287 PROFILE(info->isolate(), 287 PROFILE(info->isolate(),
288 CodeCreateEvent(log_tag, *abstract_code, *shared, script_name, 288 CodeCreateEvent(log_tag, *abstract_code, *shared, script_name,
289 line_num, column_num)); 289 line_num, column_num));
290 } 290 }
291 } 291 }
292 292
293 void EnsureFeedbackMetadata(CompilationInfo* info) { 293 void EnsureFeedbackMetadata(CompilationInfo* info) {
294 DCHECK(info->has_shared_info()); 294 DCHECK(info->has_shared_info());
295 TypeFeedbackMetadata::EnsureAllocated( 295
296 info->isolate(), info->shared_info(), 296 // If no type feedback metadata exists, create it. At this point the
297 info->literal()->feedback_vector_spec()); 297 // AstNumbering pass has already run. Note the snapshot can contain outdated
298 // vectors for a different configuration, hence we also recreate a new vector
299 // when the function is not compiled (i.e. no code was serialized).
300
301 // TODO(mvstanton): reintroduce is_empty() predicate to feedback_metadata().
302 if (info->shared_info()->feedback_metadata()->length() == 0 ||
303 !info->shared_info()->is_compiled()) {
304 Handle<TypeFeedbackMetadata> feedback_metadata = TypeFeedbackMetadata::New(
305 info->isolate(), info->literal()->feedback_vector_spec());
306 info->shared_info()->set_feedback_metadata(*feedback_metadata);
307 }
308
309 // It's very important that recompiles do not alter the structure of the type
310 // feedback vector. Verify that the structure fits the function literal.
311 CHECK(!info->shared_info()->feedback_metadata()->SpecDiffersFrom(
312 info->literal()->feedback_vector_spec()));
298 } 313 }
299 314
300 bool UseTurboFan(Handle<SharedFunctionInfo> shared) { 315 bool UseTurboFan(Handle<SharedFunctionInfo> shared) {
301 bool optimization_disabled = shared->optimization_disabled(); 316 bool optimization_disabled = shared->optimization_disabled();
302 bool must_use_ignition_turbo = shared->must_use_ignition_turbo(); 317 bool must_use_ignition_turbo = shared->must_use_ignition_turbo();
303 318
304 // Check the enabling conditions for Turbofan. 319 // Check the enabling conditions for Turbofan.
305 // 1. "use asm" code. 320 // 1. "use asm" code.
306 bool is_turbofanable_asm = 321 bool is_turbofanable_asm =
307 FLAG_turbo_asm && shared->asm_function() && !optimization_disabled; 322 FLAG_turbo_asm && shared->asm_function() && !optimization_disabled;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 return shared->PassesFilter(FLAG_ignition_filter); 375 return shared->PassesFilter(FLAG_ignition_filter);
361 } 376 }
362 377
363 CompilationJob* GetUnoptimizedCompilationJob(CompilationInfo* info) { 378 CompilationJob* GetUnoptimizedCompilationJob(CompilationInfo* info) {
364 // Function should have been parsed and analyzed before creating a compilation 379 // Function should have been parsed and analyzed before creating a compilation
365 // job. 380 // job.
366 DCHECK_NOT_NULL(info->literal()); 381 DCHECK_NOT_NULL(info->literal());
367 DCHECK_NOT_NULL(info->scope()); 382 DCHECK_NOT_NULL(info->scope());
368 383
369 if (ShouldUseIgnition(info)) { 384 if (ShouldUseIgnition(info)) {
370 // The bytecode generator will take care of feedback metadata creation.
371 return interpreter::Interpreter::NewCompilationJob(info); 385 return interpreter::Interpreter::NewCompilationJob(info);
372 } else { 386 } else {
373 EnsureFeedbackMetadata(info);
374 return FullCodeGenerator::NewCompilationJob(info); 387 return FullCodeGenerator::NewCompilationJob(info);
375 } 388 }
376 } 389 }
377 390
378 void InstallSharedScopeInfo(CompilationInfo* info, 391 void InstallSharedScopeInfo(CompilationInfo* info,
379 Handle<SharedFunctionInfo> shared) { 392 Handle<SharedFunctionInfo> shared) {
380 Handle<ScopeInfo> scope_info = info->scope()->scope_info(); 393 Handle<ScopeInfo> scope_info = info->scope()->scope_info();
381 shared->set_scope_info(*scope_info); 394 shared->set_scope_info(*scope_info);
382 Scope* outer_scope = info->scope()->GetOuterScopeWithContext(); 395 Scope* outer_scope = info->scope()->GetOuterScopeWithContext();
383 if (outer_scope) { 396 if (outer_scope) {
(...skipping 23 matching lines...) Expand all
407 // Update the shared function info with the scope info. 420 // Update the shared function info with the scope info.
408 InstallSharedScopeInfo(info, shared); 421 InstallSharedScopeInfo(info, shared);
409 422
410 // Install compilation result on the shared function info 423 // Install compilation result on the shared function info
411 InstallSharedCompilationResult(info, shared); 424 InstallSharedCompilationResult(info, shared);
412 } 425 }
413 426
414 CompilationJob::Status FinalizeUnoptimizedCompilationJob(CompilationJob* job) { 427 CompilationJob::Status FinalizeUnoptimizedCompilationJob(CompilationJob* job) {
415 CompilationJob::Status status = job->FinalizeJob(); 428 CompilationJob::Status status = job->FinalizeJob();
416 if (status == CompilationJob::SUCCEEDED) { 429 if (status == CompilationJob::SUCCEEDED) {
430 EnsureFeedbackMetadata(job->info());
417 InstallUnoptimizedCode(job->info()); 431 InstallUnoptimizedCode(job->info());
418 job->RecordUnoptimizedCompilationStats(); 432 job->RecordUnoptimizedCompilationStats();
419 } 433 }
420 return status; 434 return status;
421 } 435 }
422 436
423 bool Renumber(ParseInfo* parse_info, 437 bool Renumber(ParseInfo* parse_info,
424 Compiler::EagerInnerFunctionLiterals* eager_literals) { 438 Compiler::EagerInnerFunctionLiterals* eager_literals) {
425 RuntimeCallTimerScope runtimeTimer(parse_info->isolate(), 439 RuntimeCallTimerScope runtimeTimer(parse_info->isolate(),
426 &RuntimeCallStats::CompileRenumber); 440 &RuntimeCallStats::CompileRenumber);
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 } 1763 }
1750 1764
1751 if (shared->is_compiled()) { 1765 if (shared->is_compiled()) {
1752 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1766 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1753 JSFunction::EnsureLiterals(function); 1767 JSFunction::EnsureLiterals(function);
1754 } 1768 }
1755 } 1769 }
1756 1770
1757 } // namespace internal 1771 } // namespace internal
1758 } // namespace v8 1772 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/interpreter/bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698