OLD | NEW |
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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 bool is_unsupported_by_crankshaft_but_turbofanable = | 341 bool is_unsupported_by_crankshaft_but_turbofanable = |
342 must_use_ignition_turbo && strcmp(FLAG_turbo_filter, "~~") == 0; | 342 must_use_ignition_turbo && strcmp(FLAG_turbo_filter, "~~") == 0; |
343 | 343 |
344 // 3. Explicitly enabled by the command-line filter. | 344 // 3. Explicitly enabled by the command-line filter. |
345 bool passes_turbo_filter = shared->PassesFilter(FLAG_turbo_filter); | 345 bool passes_turbo_filter = shared->PassesFilter(FLAG_turbo_filter); |
346 | 346 |
347 return is_turbofanable_asm || is_unsupported_by_crankshaft_but_turbofanable || | 347 return is_turbofanable_asm || is_unsupported_by_crankshaft_but_turbofanable || |
348 passes_turbo_filter; | 348 passes_turbo_filter; |
349 } | 349 } |
350 | 350 |
351 bool ShouldUseIgnition(CompilationInfo* info) { | 351 bool ShouldUseIgnition(Handle<SharedFunctionInfo> shared, |
352 DCHECK(info->has_shared_info()); | 352 bool marked_as_debug) { |
353 Handle<SharedFunctionInfo> shared = info->shared_info(); | |
354 | |
355 // Code which can't be supported by the old pipeline should use Ignition. | 353 // Code which can't be supported by the old pipeline should use Ignition. |
356 if (shared->must_use_ignition_turbo()) return true; | 354 if (shared->must_use_ignition_turbo()) return true; |
357 | 355 |
358 // Resumable functions are not supported by {FullCodeGenerator}, suspended | 356 // Resumable functions are not supported by {FullCodeGenerator}, suspended |
359 // activations stored as {JSGeneratorObject} on the heap always assume the | 357 // activations stored as {JSGeneratorObject} on the heap always assume the |
360 // underlying code to be based on the bytecode array. | 358 // underlying code to be based on the bytecode array. |
361 DCHECK(!IsResumableFunction(shared->kind())); | 359 DCHECK(!IsResumableFunction(shared->kind())); |
362 | 360 |
363 // Skip Ignition for asm.js functions. | 361 // Skip Ignition for asm.js functions. |
364 if (shared->asm_function()) return false; | 362 if (shared->asm_function()) return false; |
365 | 363 |
366 // Skip Ignition for asm wasm code. | 364 // Skip Ignition for asm wasm code. |
367 if (FLAG_validate_asm && shared->HasAsmWasmData()) { | 365 if (FLAG_validate_asm && shared->HasAsmWasmData()) { |
368 return false; | 366 return false; |
369 } | 367 } |
370 | 368 |
371 // When requesting debug code as a replacement for existing code, we provide | 369 // When requesting debug code as a replacement for existing code, we provide |
372 // the same kind as the existing code (to prevent implicit tier-change). | 370 // the same kind as the existing code (to prevent implicit tier-change). |
373 if (info->is_debug() && shared->is_compiled()) { | 371 if (marked_as_debug && shared->is_compiled()) { |
374 return !shared->HasBaselineCode(); | 372 return !shared->HasBaselineCode(); |
375 } | 373 } |
376 | 374 |
377 // Code destined for TurboFan should be compiled with Ignition first. | 375 // Code destined for TurboFan should be compiled with Ignition first. |
378 if (UseTurboFan(shared)) return true; | 376 if (UseTurboFan(shared)) return true; |
379 | 377 |
380 // Only use Ignition for any other function if FLAG_ignition is true. | 378 // Only use Ignition for any other function if FLAG_ignition is true. |
381 return FLAG_ignition; | 379 return FLAG_ignition; |
382 } | 380 } |
383 | 381 |
| 382 bool ShouldUseIgnition(CompilationInfo* info) { |
| 383 DCHECK(info->has_shared_info()); |
| 384 return ShouldUseIgnition(info->shared_info(), info->is_debug()); |
| 385 } |
| 386 |
384 bool UseAsmWasm(DeclarationScope* scope, Handle<SharedFunctionInfo> shared_info, | 387 bool UseAsmWasm(DeclarationScope* scope, Handle<SharedFunctionInfo> shared_info, |
385 bool is_debug) { | 388 bool is_debug) { |
386 return FLAG_validate_asm && scope->asm_module() && | 389 return FLAG_validate_asm && scope->asm_module() && |
387 !shared_info->is_asm_wasm_broken() && !is_debug; | 390 !shared_info->is_asm_wasm_broken() && !is_debug; |
388 } | 391 } |
389 | 392 |
390 bool UseCompilerDispatcher(Compiler::ConcurrencyMode inner_function_mode, | 393 bool UseCompilerDispatcher(Compiler::ConcurrencyMode inner_function_mode, |
391 CompilerDispatcher* dispatcher, | 394 CompilerDispatcher* dispatcher, |
392 DeclarationScope* scope, | 395 DeclarationScope* scope, |
393 Handle<SharedFunctionInfo> shared_info, | 396 Handle<SharedFunctionInfo> shared_info, |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 if (shared->HasBaselineCode()) { | 841 if (shared->HasBaselineCode()) { |
839 shared->code()->set_profiler_ticks(0); | 842 shared->code()->set_profiler_ticks(0); |
840 } else if (shared->HasBytecodeArray()) { | 843 } else if (shared->HasBytecodeArray()) { |
841 shared->set_profiler_ticks(0); | 844 shared->set_profiler_ticks(0); |
842 } | 845 } |
843 | 846 |
844 VMState<COMPILER> state(isolate); | 847 VMState<COMPILER> state(isolate); |
845 DCHECK(!isolate->has_pending_exception()); | 848 DCHECK(!isolate->has_pending_exception()); |
846 PostponeInterruptsScope postpone(isolate); | 849 PostponeInterruptsScope postpone(isolate); |
847 bool use_turbofan = UseTurboFan(shared) || ignition_osr; | 850 bool use_turbofan = UseTurboFan(shared) || ignition_osr; |
| 851 bool has_script = shared->script()->IsScript(); |
| 852 // BUG(5946): This DCHECK is necessary to make certain that we won't tolerate |
| 853 // the lack of a script without bytecode. |
| 854 DCHECK_IMPLIES(!has_script, ShouldUseIgnition(shared, false)); |
848 std::unique_ptr<CompilationJob> job( | 855 std::unique_ptr<CompilationJob> job( |
849 use_turbofan ? compiler::Pipeline::NewCompilationJob(function) | 856 use_turbofan ? compiler::Pipeline::NewCompilationJob(function, has_script) |
850 : new HCompilationJob(function)); | 857 : new HCompilationJob(function)); |
851 CompilationInfo* info = job->info(); | 858 CompilationInfo* info = job->info(); |
852 ParseInfo* parse_info = info->parse_info(); | 859 ParseInfo* parse_info = info->parse_info(); |
853 | 860 |
854 info->SetOptimizingForOsr(osr_ast_id, osr_frame); | 861 info->SetOptimizingForOsr(osr_ast_id, osr_frame); |
855 | 862 |
856 // Do not use Crankshaft/TurboFan if we need to be able to set break points. | 863 // Do not use Crankshaft/TurboFan if we need to be able to set break points. |
857 if (info->shared_info()->HasDebugInfo()) { | 864 if (info->shared_info()->HasDebugInfo()) { |
858 info->AbortOptimization(kFunctionBeingDebugged); | 865 info->AbortOptimization(kFunctionBeingDebugged); |
859 return MaybeHandle<Code>(); | 866 return MaybeHandle<Code>(); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 } | 1069 } |
1063 | 1070 |
1064 if (function->shared()->is_compiled() && | 1071 if (function->shared()->is_compiled() && |
1065 function->shared()->marked_for_tier_up()) { | 1072 function->shared()->marked_for_tier_up()) { |
1066 DCHECK(FLAG_mark_shared_functions_for_tier_up); | 1073 DCHECK(FLAG_mark_shared_functions_for_tier_up); |
1067 | 1074 |
1068 function->shared()->set_marked_for_tier_up(false); | 1075 function->shared()->set_marked_for_tier_up(false); |
1069 | 1076 |
1070 switch (Compiler::NextCompilationTier(*function)) { | 1077 switch (Compiler::NextCompilationTier(*function)) { |
1071 case Compiler::BASELINE: { | 1078 case Compiler::BASELINE: { |
1072 if (FLAG_trace_opt) { | 1079 // We don't try to handle baseline here because GetBaselineCode() |
1073 PrintF("[recompiling function "); | 1080 // doesn't handle top-level code. We aren't supporting |
1074 function->ShortPrint(); | 1081 // the hybrid pipeline going forward (where Ignition is a first |
1075 PrintF( | 1082 // tier followed by full-code). |
1076 " to baseline eagerly (shared function marked for tier up)]\n"); | |
1077 } | |
1078 | |
1079 Handle<Code> code; | |
1080 if (GetBaselineCode(function).ToHandle(&code)) { | |
1081 return code; | |
1082 } | |
1083 break; | 1083 break; |
1084 } | 1084 } |
1085 case Compiler::OPTIMIZED: { | 1085 case Compiler::OPTIMIZED: { |
1086 if (FLAG_trace_opt) { | 1086 if (FLAG_trace_opt) { |
1087 PrintF("[optimizing method "); | 1087 PrintF("[optimizing method "); |
1088 function->ShortPrint(); | 1088 function->ShortPrint(); |
1089 PrintF(" eagerly (shared function marked for tier up)]\n"); | 1089 PrintF(" eagerly (shared function marked for tier up)]\n"); |
1090 } | 1090 } |
1091 | 1091 |
1092 Handle<Code> code; | 1092 Handle<Code> code; |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1915 } | 1915 } |
1916 | 1916 |
1917 if (shared->is_compiled()) { | 1917 if (shared->is_compiled()) { |
1918 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1918 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
1919 JSFunction::EnsureLiterals(function); | 1919 JSFunction::EnsureLiterals(function); |
1920 } | 1920 } |
1921 } | 1921 } |
1922 | 1922 |
1923 } // namespace internal | 1923 } // namespace internal |
1924 } // namespace v8 | 1924 } // namespace v8 |
OLD | NEW |