if (FLAG_hydrogen_stats) {
timer.Start();
}
- CompilationInfoWithZone unoptimized(info()->shared_info());
- // Note that we use the same AST that we will use for generating the
- // optimized code.
- unoptimized.SetFunction(info()->function());
- unoptimized.PrepareForCompilation(info()->scope());
- unoptimized.SetContext(info()->context());
- if (should_recompile) unoptimized.EnableDeoptimizationSupport();
- bool succeeded = FullCodeGenerator::MakeCode(&unoptimized);
- if (should_recompile) {
- if (!succeeded) return SetLastStatus(FAILED);
- Handle<SharedFunctionInfo> shared = info()->shared_info();
- shared->EnableDeoptimizationSupport(*unoptimized.code());
- // The existing unoptimized code was replaced with the new one.
- Compiler::RecordFunctionCompilation(
- Logger::LAZY_COMPILE_TAG, &unoptimized, shared);
+ if (!Compiler::EnsureDeoptimizationSupport(info())) {
+ return SetLastStatus(FAILED);
}
if (FLAG_hydrogen_stats) {
isolate()->GetHStatistics()->IncrementFullCodeGen(timer.Elapsed());
}
+// TODO(turbofan): In the future, unoptimized code with deopt support could
+// be generated lazily once deopt is triggered.
+bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) {
+ if (!info->shared_info()->has_deoptimization_support()) {
+ CompilationInfoWithZone unoptimized(info->shared_info());
+ // Note that we use the same AST that we will use for generating the
+ // optimized code.
+ unoptimized.SetFunction(info->function());
+ unoptimized.PrepareForCompilation(info->scope());
+ unoptimized.SetContext(info->context());
+ unoptimized.EnableDeoptimizationSupport();
+ if (!FullCodeGenerator::MakeCode(&unoptimized)) return false;
+
+ Handle<SharedFunctionInfo> shared = info->shared_info();
+ shared->EnableDeoptimizationSupport(*unoptimized.code());
+ shared->set_feedback_vector(*unoptimized.feedback_vector());
+
+ // The scope info might not have been set if a lazily compiled
+ // function is inlined before being called for the first time.
+ if (shared->scope_info() == ScopeInfo::Empty(info->isolate())) {
+ Handle<ScopeInfo> target_scope_info =
+ ScopeInfo::Create(info->scope(), info->zone());
+ shared->set_scope_info(*target_scope_info);
+ }
+
+ // The existing unoptimized code was replaced with the new one.
+ RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, &unoptimized, shared);
+ }
+ return true;
+}
+
+
// Compile full code for debugging. This code will have debug break slots
// and deoptimization information. Deoptimization information is required
// in case that an optimized version of this function is still activated on
Handle<JSFunction> function);
MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCode(
Handle<SharedFunctionInfo> shared);
- static bool EnsureCompiled(Handle<JSFunction> function,
- ClearExceptionFlag flag);
MUST_USE_RESULT static MaybeHandle<Code> GetDebugCode(
Handle<JSFunction> function);
+ static bool EnsureCompiled(Handle<JSFunction> function,
+ ClearExceptionFlag flag);
+
+ static bool EnsureDeoptimizationSupport(CompilationInfo* info);
+
static void CompileForLiveEdit(Handle<Script> script);
// Compile a String source within a context for eval.
CHECK(Parser::Parse(info));
CHECK(Rewriter::Rewrite(info));
CHECK(Scope::Analyze(info));
- CHECK_NE(NULL, info->scope());
- Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope(), info->zone());
- info->shared_info()->set_scope_info(*scope_info);
+ CHECK(Compiler::EnsureDeoptimizationSupport(info));
}
CompilationInfoWithZone info(function);
Parse(function, &info);
- if (!function->shared()->has_deoptimization_support()) {
- // TODO(turbofan) In the future, unoptimized code with deopt support could
- // be generated lazily once deopt is triggered.
- info.EnableDeoptimizationSupport();
- if (!FullCodeGenerator::MakeCode(&info)) {
- DCHECK(false);
- return;
- }
- function->shared()->EnableDeoptimizationSupport(*info.code());
- function->shared()->set_feedback_vector(*info.feedback_vector());
- }
-
if (info.scope()->arguments() != NULL) {
// For now do not inline functions that use their arguments array.
SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString();
// Generate the deoptimization data for the unoptimized version of
// the target function if we don't already have it.
- if (!target_shared->has_deoptimization_support()) {
- // Note that we compile here using the same AST that we will use for
- // generating the optimized inline code.
- target_info.EnableDeoptimizationSupport();
- if (!FullCodeGenerator::MakeCode(&target_info)) {
- TraceInline(target, caller, "could not generate deoptimization info");
- return false;
- }
- if (target_shared->scope_info() == ScopeInfo::Empty(isolate())) {
- // The scope info might not have been set if a lazily compiled
- // function is inlined before being called for the first time.
- Handle<ScopeInfo> target_scope_info =
- ScopeInfo::Create(target_info.scope(), zone());
- target_shared->set_scope_info(*target_scope_info);
- }
- target_shared->EnableDeoptimizationSupport(*target_info.code());
- target_shared->set_feedback_vector(*target_info.feedback_vector());
- Compiler::RecordFunctionCompilation(Logger::FUNCTION_TAG,
- &target_info,
- target_shared);
+ if (!Compiler::EnsureDeoptimizationSupport(&target_info)) {
+ TraceInline(target, caller, "could not generate deoptimization info");
+ return false;
}
// ----------------------------------------------------------------
}
CHECK(Rewriter::Rewrite(&info));
CHECK(Scope::Analyze(&info));
- CHECK_NE(NULL, info.scope());
- Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), info.zone());
- info.shared_info()->set_scope_info(*scope_info);
-
- EnsureDeoptimizationSupport(&info);
+ CHECK(Compiler::EnsureDeoptimizationSupport(&info));
Pipeline pipeline(&info);
Handle<Code> code = pipeline.GenerateCode();
return function;
}
- static void EnsureDeoptimizationSupport(CompilationInfo* info) {
- bool should_recompile = !info->shared_info()->has_deoptimization_support();
- if (should_recompile) {
- CompilationInfoWithZone unoptimized(info->shared_info());
- // Note that we use the same AST that we will use for generating the
- // optimized code.
- unoptimized.SetFunction(info->function());
- unoptimized.PrepareForCompilation(info->scope());
- unoptimized.SetContext(info->context());
- if (should_recompile) unoptimized.EnableDeoptimizationSupport();
- bool succeeded = FullCodeGenerator::MakeCode(&unoptimized);
- CHECK(succeeded);
- Handle<SharedFunctionInfo> shared = info->shared_info();
- shared->EnableDeoptimizationSupport(*unoptimized.code());
- }
- }
-
MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b) {
Handle<Object> args[] = {a, b};
return Execution::Call(isolate, function, undefined(), 2, args, false);
info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code()));
CHECK(Rewriter::Rewrite(&info));
CHECK(Scope::Analyze(&info));
- CHECK_NE(NULL, info.scope());
- Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), info.zone());
- info.shared_info()->set_scope_info(*scope_info);
-
- FunctionTester::EnsureDeoptimizationSupport(&info);
+ CHECK(Compiler::EnsureDeoptimizationSupport(&info));
DCHECK(info.shared_info()->has_deoptimization_support());