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

Side by Side Diff: src/compiler.cc

Issue 2428413004: Revert "[compiler] Ship Ignition for all TurboFan code." (Closed)
Patch Set: Created 4 years, 2 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/bootstrapper.cc ('k') | src/compiler-dispatcher/compiler-dispatcher-job.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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 245 }
246 code->set_can_have_weak_objects(true); 246 code->set_can_have_weak_objects(true);
247 } 247 }
248 248
249 // ---------------------------------------------------------------------------- 249 // ----------------------------------------------------------------------------
250 // Local helper methods that make up the compilation pipeline. 250 // Local helper methods that make up the compilation pipeline.
251 251
252 namespace { 252 namespace {
253 253
254 bool Parse(ParseInfo* info) { 254 bool Parse(ParseInfo* info) {
255 // Create a canonical handle scope for compiling Ignition bytecode. This is 255 // Create a canonical handle scope if compiling ignition bytecode. This is
256 // required by the constant array builder to de-duplicate objects without 256 // required by the constant array builder to de-duplicate objects without
257 // dereferencing handles. 257 // dereferencing handles.
258 CanonicalHandleScope canonical(info->isolate()); 258 std::unique_ptr<CanonicalHandleScope> canonical;
259 if (FLAG_ignition) canonical.reset(new CanonicalHandleScope(info->isolate()));
259 260
260 return Parser::ParseStatic(info); 261 return Parser::ParseStatic(info);
261 } 262 }
262 263
263 void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag, 264 void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
264 CompilationInfo* info) { 265 CompilationInfo* info) {
265 // Log the code generation. If source information is available include 266 // Log the code generation. If source information is available include
266 // script name and line number. Check explicitly whether logging is 267 // script name and line number. Check explicitly whether logging is
267 // enabled as finding the line number is not free. 268 // enabled as finding the line number is not free.
268 if (info->isolate()->logger()->is_logging_code_events() || 269 if (info->isolate()->logger()->is_logging_code_events() ||
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 info->isolate(), info->literal()->feedback_vector_spec()); 307 info->isolate(), info->literal()->feedback_vector_spec());
307 info->shared_info()->set_feedback_metadata(*feedback_metadata); 308 info->shared_info()->set_feedback_metadata(*feedback_metadata);
308 } 309 }
309 310
310 // It's very important that recompiles do not alter the structure of the type 311 // It's very important that recompiles do not alter the structure of the type
311 // feedback vector. Verify that the structure fits the function literal. 312 // feedback vector. Verify that the structure fits the function literal.
312 CHECK(!info->shared_info()->feedback_metadata()->SpecDiffersFrom( 313 CHECK(!info->shared_info()->feedback_metadata()->SpecDiffersFrom(
313 info->literal()->feedback_vector_spec())); 314 info->literal()->feedback_vector_spec()));
314 } 315 }
315 316
316 bool UseTurboFan(Handle<SharedFunctionInfo> shared) { 317 bool ShouldUseIgnition(CompilationInfo* info) {
317 bool optimization_disabled = shared->optimization_disabled(); 318 if (!FLAG_ignition) return false;
318 bool dont_crankshaft = shared->dont_crankshaft();
319 319
320 // Check the enabling conditions for Turbofan.
321 // 1. "use asm" code.
322 bool is_turbofanable_asm =
323 FLAG_turbo_asm && shared->asm_function() && !optimization_disabled;
324
325 // 2. Fallback for features unsupported by Crankshaft.
326 bool is_unsupported_by_crankshaft_but_turbofanable =
327 dont_crankshaft && strcmp(FLAG_turbo_filter, "~~") == 0 &&
328 !optimization_disabled;
329
330 // 3. Explicitly enabled by the command-line filter.
331 bool passes_turbo_filter = shared->PassesFilter(FLAG_turbo_filter);
332
333 return is_turbofanable_asm || is_unsupported_by_crankshaft_but_turbofanable ||
334 passes_turbo_filter;
335 }
336
337 bool ShouldUseIgnition(CompilationInfo* info) {
338 DCHECK(info->has_shared_info()); 320 DCHECK(info->has_shared_info());
339 321
340 // Skip Ignition for asm.js functions.
341 if (info->shared_info()->asm_function()) {
342 return false;
343 }
344
345 // When requesting debug code as a replacement for existing code, we provide 322 // When requesting debug code as a replacement for existing code, we provide
346 // the same kind as the existing code (to prevent implicit tier-change). 323 // the same kind as the existing code (to prevent implicit tier-change).
347 if (info->is_debug() && info->shared_info()->is_compiled()) { 324 if (info->is_debug() && info->shared_info()->is_compiled()) {
348 return !info->shared_info()->HasBaselineCode(); 325 return !info->shared_info()->HasBaselineCode();
349 } 326 }
350 327
351 // Code destined for TurboFan should be compiled with Ignition first. 328 // Since we can't OSR from Ignition, skip Ignition for asm.js functions.
352 if (UseTurboFan(info->shared_info())) return true; 329 if (info->shared_info()->asm_function()) {
353 330 return false;
354 // Only use Ignition for any other function if FLAG_ignition is true. 331 }
355 if (!FLAG_ignition) return false;
356 332
357 // Checks whether top level functions should be passed by the filter. 333 // Checks whether top level functions should be passed by the filter.
358 if (info->shared_info()->is_toplevel()) { 334 if (info->shared_info()->is_toplevel()) {
359 Vector<const char> filter = CStrVector(FLAG_ignition_filter); 335 Vector<const char> filter = CStrVector(FLAG_ignition_filter);
360 return (filter.length() == 0) || (filter.length() == 1 && filter[0] == '*'); 336 return (filter.length() == 0) || (filter.length() == 1 && filter[0] == '*');
361 } 337 }
362 338
363 // Finally respect the filter. 339 // Finally respect the filter.
364 return info->shared_info()->PassesFilter(FLAG_ignition_filter); 340 return info->shared_info()->PassesFilter(FLAG_ignition_filter);
365 } 341 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 // Cache optimized context-specific code. 485 // Cache optimized context-specific code.
510 Handle<JSFunction> function = info->closure(); 486 Handle<JSFunction> function = info->closure();
511 Handle<SharedFunctionInfo> shared(function->shared()); 487 Handle<SharedFunctionInfo> shared(function->shared());
512 Handle<LiteralsArray> literals(function->literals()); 488 Handle<LiteralsArray> literals(function->literals());
513 Handle<Context> native_context(function->context()->native_context()); 489 Handle<Context> native_context(function->context()->native_context());
514 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, 490 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
515 literals, info->osr_ast_id()); 491 literals, info->osr_ast_id());
516 } 492 }
517 493
518 bool Renumber(ParseInfo* parse_info) { 494 bool Renumber(ParseInfo* parse_info) {
519 // Create a canonical handle scope for compiling Ignition bytecode. This is 495 // Create a canonical handle scope if compiling ignition bytecode. This is
520 // required by the constant array builder to de-duplicate objects without 496 // required by the constant array builder to de-duplicate objects without
521 // dereferencing handles. 497 // dereferencing handles.
522 CanonicalHandleScope canonical(parse_info->isolate()); 498 std::unique_ptr<CanonicalHandleScope> canonical;
499 if (FLAG_ignition) {
500 canonical.reset(new CanonicalHandleScope(parse_info->isolate()));
501 }
523 502
524 if (!AstNumbering::Renumber(parse_info->isolate(), parse_info->zone(), 503 if (!AstNumbering::Renumber(parse_info->isolate(), parse_info->zone(),
525 parse_info->literal())) { 504 parse_info->literal())) {
526 return false; 505 return false;
527 } 506 }
528 Handle<SharedFunctionInfo> shared_info = parse_info->shared_info(); 507 Handle<SharedFunctionInfo> shared_info = parse_info->shared_info();
529 if (!shared_info.is_null()) { 508 if (!shared_info.is_null()) {
530 FunctionLiteral* lit = parse_info->literal(); 509 FunctionLiteral* lit = parse_info->literal();
531 shared_info->set_ast_node_count(lit->ast_node_count()); 510 shared_info->set_ast_node_count(lit->ast_node_count());
532 if (lit->dont_optimize_reason() != kNoReason) { 511 if (lit->dont_optimize_reason() != kNoReason) {
533 shared_info->DisableOptimization(lit->dont_optimize_reason()); 512 shared_info->DisableOptimization(lit->dont_optimize_reason());
534 } 513 }
535 if (lit->flags() & AstProperties::kDontCrankshaft) { 514 if (lit->flags() & AstProperties::kDontCrankshaft) {
536 shared_info->set_dont_crankshaft(true); 515 shared_info->set_dont_crankshaft(true);
537 } 516 }
538 } 517 }
539 return true; 518 return true;
540 } 519 }
541 520
521 bool UseTurboFan(Handle<SharedFunctionInfo> shared) {
522 bool optimization_disabled = shared->optimization_disabled();
523 bool dont_crankshaft = shared->dont_crankshaft();
524
525 // Check the enabling conditions for Turbofan.
526 // 1. "use asm" code.
527 bool is_turbofanable_asm =
528 FLAG_turbo_asm && shared->asm_function() && !optimization_disabled;
529
530 // 2. Fallback for features unsupported by Crankshaft.
531 bool is_unsupported_by_crankshaft_but_turbofanable =
532 dont_crankshaft && strcmp(FLAG_turbo_filter, "~~") == 0 &&
533 !optimization_disabled;
534
535 // 3. Explicitly enabled by the command-line filter.
536 bool passes_turbo_filter = shared->PassesFilter(FLAG_turbo_filter);
537
538 return is_turbofanable_asm || is_unsupported_by_crankshaft_but_turbofanable ||
539 passes_turbo_filter;
540 }
541
542 bool GetOptimizedCodeNow(CompilationJob* job) { 542 bool GetOptimizedCodeNow(CompilationJob* job) {
543 CompilationInfo* info = job->info(); 543 CompilationInfo* info = job->info();
544 Isolate* isolate = info->isolate(); 544 Isolate* isolate = info->isolate();
545 545
546 // Parsing is not required when optimizing from existing bytecode. 546 // Parsing is not required when optimizing from existing bytecode.
547 if (!info->is_optimizing_from_bytecode()) { 547 if (!info->is_optimizing_from_bytecode()) {
548 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; 548 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false;
549 EnsureFeedbackMetadata(info); 549 EnsureFeedbackMetadata(info);
550 } 550 }
551 551
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 DCHECK(shared->is_compiled()); 1812 DCHECK(shared->is_compiled());
1813 function->set_literals(cached.literals); 1813 function->set_literals(cached.literals);
1814 } else if (shared->is_compiled()) { 1814 } else if (shared->is_compiled()) {
1815 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1815 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1816 JSFunction::EnsureLiterals(function); 1816 JSFunction::EnsureLiterals(function);
1817 } 1817 }
1818 } 1818 }
1819 1819
1820 } // namespace internal 1820 } // namespace internal
1821 } // namespace v8 1821 } // namespace v8
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/compiler-dispatcher/compiler-dispatcher-job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698