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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
836 if (shared->HasBaselineCode()) { | 839 if (shared->HasBaselineCode()) { |
837 shared->code()->set_profiler_ticks(0); | 840 shared->code()->set_profiler_ticks(0); |
838 } else if (shared->HasBytecodeArray()) { | 841 } else if (shared->HasBytecodeArray()) { |
839 shared->set_profiler_ticks(0); | 842 shared->set_profiler_ticks(0); |
840 } | 843 } |
841 | 844 |
842 VMState<COMPILER> state(isolate); | 845 VMState<COMPILER> state(isolate); |
843 DCHECK(!isolate->has_pending_exception()); | 846 DCHECK(!isolate->has_pending_exception()); |
844 PostponeInterruptsScope postpone(isolate); | 847 PostponeInterruptsScope postpone(isolate); |
845 bool use_turbofan = UseTurboFan(shared) || ignition_osr; | 848 bool use_turbofan = UseTurboFan(shared) || ignition_osr; |
849 bool has_script = shared->script()->IsScript(); | |
850 // BUG(5946): This DCHECK is necessary to make certain that we won't tolerate | |
851 // the lack of a script without bytecode. | |
852 DCHECK_IMPLIES(!has_script, ShouldUseIgnition(shared, false)); | |
846 std::unique_ptr<CompilationJob> job( | 853 std::unique_ptr<CompilationJob> job( |
847 use_turbofan ? compiler::Pipeline::NewCompilationJob(function) | 854 use_turbofan ? compiler::Pipeline::NewCompilationJob(function, has_script) |
848 : new HCompilationJob(function)); | 855 : new HCompilationJob(function)); |
849 CompilationInfo* info = job->info(); | 856 CompilationInfo* info = job->info(); |
850 ParseInfo* parse_info = info->parse_info(); | 857 ParseInfo* parse_info = info->parse_info(); |
851 | 858 |
852 info->SetOptimizingForOsr(osr_ast_id, osr_frame); | 859 info->SetOptimizingForOsr(osr_ast_id, osr_frame); |
853 | 860 |
854 // Do not use Crankshaft/TurboFan if we need to be able to set break points. | 861 // Do not use Crankshaft/TurboFan if we need to be able to set break points. |
855 if (info->shared_info()->HasDebugInfo()) { | 862 if (info->shared_info()->HasDebugInfo()) { |
856 info->AbortOptimization(kFunctionBeingDebugged); | 863 info->AbortOptimization(kFunctionBeingDebugged); |
857 return MaybeHandle<Code>(); | 864 return MaybeHandle<Code>(); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1059 return cached_code; | 1066 return cached_code; |
1060 } | 1067 } |
1061 | 1068 |
1062 if (function->shared()->is_compiled() && | 1069 if (function->shared()->is_compiled() && |
1063 function->shared()->marked_for_tier_up()) { | 1070 function->shared()->marked_for_tier_up()) { |
1064 DCHECK(FLAG_mark_shared_functions_for_tier_up); | 1071 DCHECK(FLAG_mark_shared_functions_for_tier_up); |
1065 | 1072 |
1066 function->shared()->set_marked_for_tier_up(false); | 1073 function->shared()->set_marked_for_tier_up(false); |
1067 | 1074 |
1068 switch (Compiler::NextCompilationTier(*function)) { | 1075 switch (Compiler::NextCompilationTier(*function)) { |
1069 case Compiler::BASELINE: { | 1076 case Compiler::BASELINE: { |
Leszek Swirski
2017/02/15 14:58:37
Can you add a comment here stating that we don't t
mvstanton
2017/02/15 15:18:46
Yep, done.
| |
1070 if (FLAG_trace_opt) { | |
1071 PrintF("[recompiling function "); | |
1072 function->ShortPrint(); | |
1073 PrintF( | |
1074 " to baseline eagerly (shared function marked for tier up)]\n"); | |
1075 } | |
1076 | |
1077 Handle<Code> code; | |
1078 if (GetBaselineCode(function).ToHandle(&code)) { | |
1079 return code; | |
1080 } | |
1081 break; | 1077 break; |
1082 } | 1078 } |
1083 case Compiler::OPTIMIZED: { | 1079 case Compiler::OPTIMIZED: { |
1084 if (FLAG_trace_opt) { | 1080 if (FLAG_trace_opt) { |
1085 PrintF("[optimizing method "); | 1081 PrintF("[optimizing method "); |
1086 function->ShortPrint(); | 1082 function->ShortPrint(); |
1087 PrintF(" eagerly (shared function marked for tier up)]\n"); | 1083 PrintF(" eagerly (shared function marked for tier up)]\n"); |
1088 } | 1084 } |
1089 | 1085 |
1090 Handle<Code> code; | 1086 Handle<Code> code; |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1913 } | 1909 } |
1914 | 1910 |
1915 if (shared->is_compiled()) { | 1911 if (shared->is_compiled()) { |
1916 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1912 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
1917 JSFunction::EnsureLiterals(function); | 1913 JSFunction::EnsureLiterals(function); |
1918 } | 1914 } |
1919 } | 1915 } |
1920 | 1916 |
1921 } // namespace internal | 1917 } // namespace internal |
1922 } // namespace v8 | 1918 } // namespace v8 |
OLD | NEW |