Index: src/compiler.cc |
diff --git a/src/compiler.cc b/src/compiler.cc |
index 426752e4bffdab40c0bef8a0df58be1f20184a68..0d85844760ce766de43e4c409bb656c31eb991d5 100644 |
--- a/src/compiler.cc |
+++ b/src/compiler.cc |
@@ -441,7 +441,7 @@ void EnsureFeedbackMetadata(CompilationInfo* info) { |
info->literal()->feedback_vector_spec())); |
} |
-bool UseIgnition(CompilationInfo* info) { |
+bool ShouldUseIgnition(CompilationInfo* info) { |
DCHECK(info->has_shared_info()); |
// When requesting debug code as a replacement for existing code, we provide |
@@ -489,7 +489,7 @@ bool GenerateUnoptimizedCode(CompilationInfo* info) { |
return true; |
} |
} |
- if (FLAG_ignition && UseIgnition(info)) { |
+ if (FLAG_ignition && ShouldUseIgnition(info)) { |
success = interpreter::Interpreter::MakeBytecode(info); |
} else { |
success = FullCodeGenerator::MakeCode(info); |
@@ -801,8 +801,11 @@ MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function, |
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.OptimizeCode"); |
// TurboFan can optimize directly from existing bytecode. |
- if (FLAG_turbo_from_bytecode && use_turbofan && |
- info->shared_info()->HasBytecodeArray()) { |
+ if (FLAG_turbo_from_bytecode && use_turbofan && ShouldUseIgnition(info)) { |
+ if (!Compiler::EnsureBytecode(info)) { |
+ if (isolate->has_pending_exception()) isolate->clear_pending_exception(); |
+ return MaybeHandle<Code>(); |
+ } |
info->MarkAsOptimizeFromBytecode(); |
} |
@@ -1344,6 +1347,16 @@ MaybeHandle<JSArray> Compiler::CompileForLiveEdit(Handle<Script> script) { |
return infos; |
} |
+bool Compiler::EnsureBytecode(CompilationInfo* info) { |
+ DCHECK(ShouldUseIgnition(info)); |
+ if (!info->shared_info()->HasBytecodeArray()) { |
+ DCHECK(!info->shared_info()->is_compiled()); |
+ if (GetUnoptimizedCode(info).is_null()) return false; |
+ } |
+ DCHECK(info->shared_info()->HasBytecodeArray()); |
+ return true; |
+} |
+ |
// TODO(turbofan): In the future, unoptimized code with deopt support could |
// be generated lazily once deopt is triggered. |
bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { |
@@ -1405,6 +1418,20 @@ bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { |
return true; |
} |
+// static |
+Compiler::CompilationTier Compiler::NextCompilationTier(JSFunction* function) { |
+ Handle<SharedFunctionInfo> shared(function->shared(), function->GetIsolate()); |
+ if (shared->code()->is_interpreter_trampoline_builtin()) { |
+ if (FLAG_turbo_from_bytecode && UseTurboFan(shared)) { |
+ return OPTIMIZED; |
+ } else { |
+ return BASELINE; |
+ } |
+ } else { |
+ return OPTIMIZED; |
+ } |
+} |
+ |
MaybeHandle<JSFunction> Compiler::GetFunctionFromEval( |
Handle<String> source, Handle<SharedFunctionInfo> outer_info, |
Handle<Context> context, LanguageMode language_mode, |