PostponeInterruptsScope postpone(isolate);
Handle<SharedFunctionInfo> shared = info->shared_info();
- DCHECK_NE(ScopeInfo::Empty(isolate), shared->scope_info());
+ if (ScopeInfo::Empty(isolate) == shared->scope_info()) {
+ // The function was never compiled. Compile it unoptimized first.
+ CompilationInfoWithZone nested(function);
+ nested.EnableDeoptimizationSupport();
+ if (!GetUnoptimizedCodeCommon(&nested).ToHandle(¤t_code)) {
+ return MaybeHandle<Code>();
+ }
+ }
int compiled_size = shared->end_position() - shared->start_position();
isolate->counters()->total_compile_size()->Increment(compiled_size);
current_code->set_profiler_ticks(0);
CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1);
Handle<Code> unoptimized(function->shared()->code());
- if (!function->shared()->is_compiled()) {
- // If the function is not compiled, do not optimize.
- // This can happen if the debugger is activated and
- // the function is returned to the not compiled state.
- // TODO(yangguo): reconsider this.
- function->ReplaceCode(function->shared()->code());
- } else if (!isolate->use_crankshaft() ||
- function->shared()->optimization_disabled() ||
- isolate->DebuggerHasBreakPoints()) {
+ if (!isolate->use_crankshaft() ||
+ function->shared()->optimization_disabled() ||
+ isolate->DebuggerHasBreakPoints()) {
// If the function is not optimizable or debugger is active continue
// using the code from the full compiler.
if (FLAG_trace_opt) {
isolate->DebuggerHasBreakPoints() ? "T" : "F");
}
function->ReplaceCode(*unoptimized);
+ return function->code();
+ }
+
+ Compiler::ConcurrencyMode mode =
+ concurrent ? Compiler::CONCURRENT : Compiler::NOT_CONCURRENT;
+ Handle<Code> code;
+ if (Compiler::GetOptimizedCode(function, unoptimized, mode).ToHandle(&code)) {
+ function->ReplaceCode(*code);
} else {
- Compiler::ConcurrencyMode mode = concurrent ? Compiler::CONCURRENT
- : Compiler::NOT_CONCURRENT;
- Handle<Code> code;
- if (Compiler::GetOptimizedCode(
- function, unoptimized, mode).ToHandle(&code)) {
- function->ReplaceCode(*code);
- } else {
- function->ReplaceCode(*unoptimized);
- }
+ function->ReplaceCode(*unoptimized);
}
DCHECK(function->code()->kind() == Code::FUNCTION ||
RUNTIME_ASSERT(args.length() == 1 || args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
- if (!function->IsOptimizable() &&
- !function->IsMarkedForConcurrentOptimization() &&
- !function->IsInOptimizationQueue()) {
- return isolate->heap()->undefined_value();
- }
+ if (function->IsOptimized()) return isolate->heap()->undefined_value();
function->MarkForOptimization();