| 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(Handle<SharedFunctionInfo> shared, | 351 bool ShouldUseIgnition(CompilationInfo* info) { |
| 352 bool marked_as_debug) { | 352 DCHECK(info->has_shared_info()); |
| 353 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 354 |
| 353 // Code which can't be supported by the old pipeline should use Ignition. | 355 // Code which can't be supported by the old pipeline should use Ignition. |
| 354 if (shared->must_use_ignition_turbo()) return true; | 356 if (shared->must_use_ignition_turbo()) return true; |
| 355 | 357 |
| 356 // Resumable functions are not supported by {FullCodeGenerator}, suspended | 358 // Resumable functions are not supported by {FullCodeGenerator}, suspended |
| 357 // activations stored as {JSGeneratorObject} on the heap always assume the | 359 // activations stored as {JSGeneratorObject} on the heap always assume the |
| 358 // underlying code to be based on the bytecode array. | 360 // underlying code to be based on the bytecode array. |
| 359 DCHECK(!IsResumableFunction(shared->kind())); | 361 DCHECK(!IsResumableFunction(shared->kind())); |
| 360 | 362 |
| 361 // Skip Ignition for asm.js functions. | 363 // Skip Ignition for asm.js functions. |
| 362 if (shared->asm_function()) return false; | 364 if (shared->asm_function()) return false; |
| 363 | 365 |
| 364 // Skip Ignition for asm wasm code. | 366 // Skip Ignition for asm wasm code. |
| 365 if (FLAG_validate_asm && shared->HasAsmWasmData()) { | 367 if (FLAG_validate_asm && shared->HasAsmWasmData()) { |
| 366 return false; | 368 return false; |
| 367 } | 369 } |
| 368 | 370 |
| 369 // When requesting debug code as a replacement for existing code, we provide | 371 // When requesting debug code as a replacement for existing code, we provide |
| 370 // the same kind as the existing code (to prevent implicit tier-change). | 372 // the same kind as the existing code (to prevent implicit tier-change). |
| 371 if (marked_as_debug && shared->is_compiled()) { | 373 if (info->is_debug() && shared->is_compiled()) { |
| 372 return !shared->HasBaselineCode(); | 374 return !shared->HasBaselineCode(); |
| 373 } | 375 } |
| 374 | 376 |
| 375 // Code destined for TurboFan should be compiled with Ignition first. | 377 // Code destined for TurboFan should be compiled with Ignition first. |
| 376 if (UseTurboFan(shared)) return true; | 378 if (UseTurboFan(shared)) return true; |
| 377 | 379 |
| 378 // Only use Ignition for any other function if FLAG_ignition is true. | 380 // Only use Ignition for any other function if FLAG_ignition is true. |
| 379 return FLAG_ignition; | 381 return FLAG_ignition; |
| 380 } | 382 } |
| 381 | 383 |
| 382 bool ShouldUseIgnition(CompilationInfo* info) { | |
| 383 DCHECK(info->has_shared_info()); | |
| 384 return ShouldUseIgnition(info->shared_info(), info->is_debug()); | |
| 385 } | |
| 386 | |
| 387 bool UseAsmWasm(DeclarationScope* scope, Handle<SharedFunctionInfo> shared_info, | 384 bool UseAsmWasm(DeclarationScope* scope, Handle<SharedFunctionInfo> shared_info, |
| 388 bool is_debug) { | 385 bool is_debug) { |
| 389 return FLAG_validate_asm && scope->asm_module() && | 386 return FLAG_validate_asm && scope->asm_module() && |
| 390 !shared_info->is_asm_wasm_broken() && !is_debug; | 387 !shared_info->is_asm_wasm_broken() && !is_debug; |
| 391 } | 388 } |
| 392 | 389 |
| 393 bool UseCompilerDispatcher(Compiler::ConcurrencyMode inner_function_mode, | 390 bool UseCompilerDispatcher(Compiler::ConcurrencyMode inner_function_mode, |
| 394 CompilerDispatcher* dispatcher, | 391 CompilerDispatcher* dispatcher, |
| 395 DeclarationScope* scope, | 392 DeclarationScope* scope, |
| 396 Handle<SharedFunctionInfo> shared_info, | 393 Handle<SharedFunctionInfo> shared_info, |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 if (shared->HasBaselineCode()) { | 838 if (shared->HasBaselineCode()) { |
| 842 shared->code()->set_profiler_ticks(0); | 839 shared->code()->set_profiler_ticks(0); |
| 843 } else if (shared->HasBytecodeArray()) { | 840 } else if (shared->HasBytecodeArray()) { |
| 844 shared->set_profiler_ticks(0); | 841 shared->set_profiler_ticks(0); |
| 845 } | 842 } |
| 846 | 843 |
| 847 VMState<COMPILER> state(isolate); | 844 VMState<COMPILER> state(isolate); |
| 848 DCHECK(!isolate->has_pending_exception()); | 845 DCHECK(!isolate->has_pending_exception()); |
| 849 PostponeInterruptsScope postpone(isolate); | 846 PostponeInterruptsScope postpone(isolate); |
| 850 bool use_turbofan = UseTurboFan(shared) || ignition_osr; | 847 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)); | |
| 855 std::unique_ptr<CompilationJob> job( | 848 std::unique_ptr<CompilationJob> job( |
| 856 use_turbofan ? compiler::Pipeline::NewCompilationJob(function, has_script) | 849 use_turbofan ? compiler::Pipeline::NewCompilationJob(function) |
| 857 : new HCompilationJob(function)); | 850 : new HCompilationJob(function)); |
| 858 CompilationInfo* info = job->info(); | 851 CompilationInfo* info = job->info(); |
| 859 ParseInfo* parse_info = info->parse_info(); | 852 ParseInfo* parse_info = info->parse_info(); |
| 860 | 853 |
| 861 info->SetOptimizingForOsr(osr_ast_id, osr_frame); | 854 info->SetOptimizingForOsr(osr_ast_id, osr_frame); |
| 862 | 855 |
| 863 // Do not use Crankshaft/TurboFan if we need to be able to set break points. | 856 // Do not use Crankshaft/TurboFan if we need to be able to set break points. |
| 864 if (info->shared_info()->HasDebugInfo()) { | 857 if (info->shared_info()->HasDebugInfo()) { |
| 865 info->AbortOptimization(kFunctionBeingDebugged); | 858 info->AbortOptimization(kFunctionBeingDebugged); |
| 866 return MaybeHandle<Code>(); | 859 return MaybeHandle<Code>(); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 } | 1062 } |
| 1070 | 1063 |
| 1071 if (function->shared()->is_compiled() && | 1064 if (function->shared()->is_compiled() && |
| 1072 function->shared()->marked_for_tier_up()) { | 1065 function->shared()->marked_for_tier_up()) { |
| 1073 DCHECK(FLAG_mark_shared_functions_for_tier_up); | 1066 DCHECK(FLAG_mark_shared_functions_for_tier_up); |
| 1074 | 1067 |
| 1075 function->shared()->set_marked_for_tier_up(false); | 1068 function->shared()->set_marked_for_tier_up(false); |
| 1076 | 1069 |
| 1077 switch (Compiler::NextCompilationTier(*function)) { | 1070 switch (Compiler::NextCompilationTier(*function)) { |
| 1078 case Compiler::BASELINE: { | 1071 case Compiler::BASELINE: { |
| 1079 // We don't try to handle baseline here because GetBaselineCode() | 1072 if (FLAG_trace_opt) { |
| 1080 // doesn't handle top-level code. We aren't supporting | 1073 PrintF("[recompiling function "); |
| 1081 // the hybrid pipeline going forward (where Ignition is a first | 1074 function->ShortPrint(); |
| 1082 // tier followed by full-code). | 1075 PrintF( |
| 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 |