Commit 79045760 authored by yangguo's avatar yangguo Committed by Commit bot

Refactor use of Isolate::use_crankshaft.

R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/755883003

Cr-Commit-Position: refs/heads/master@{#25499}
parent 2ed39d93
......@@ -1382,6 +1382,7 @@ MaybeHandle<Code> Compiler::GetOptimizedCode(Handle<JSFunction> function,
Isolate* isolate = info->isolate();
DCHECK(AllowCompilation::IsAllowed(isolate));
VMState<COMPILER> state(isolate);
DCHECK(isolate->use_crankshaft());
DCHECK(!isolate->has_pending_exception());
PostponeInterruptsScope postpone(isolate);
......
......@@ -9409,12 +9409,14 @@ void JSFunction::JSFunctionIterateBody(int object_size, ObjectVisitor* v) {
void JSFunction::MarkForOptimization() {
Isolate* isolate = GetIsolate();
DCHECK(isolate->use_crankshaft());
DCHECK(!IsOptimized());
DCHECK(shared()->allows_lazy_compilation() ||
code()->optimizable());
DCHECK(!shared()->is_generator());
set_code_no_write_barrier(
GetIsolate()->builtins()->builtin(Builtins::kCompileOptimized));
isolate->builtins()->builtin(Builtins::kCompileOptimized));
// No write barrier required, since the builtin is part of the root set.
}
......@@ -9434,6 +9436,7 @@ void JSFunction::AttemptConcurrentOptimization() {
// recompilation race. This goes away as soon as OSR becomes one-shot.
return;
}
DCHECK(isolate->use_crankshaft());
DCHECK(!IsInOptimizationQueue());
DCHECK(is_compiled() || isolate->DebuggerHasBreakPoints());
DCHECK(!IsOptimized());
......@@ -9451,24 +9454,6 @@ void JSFunction::AttemptConcurrentOptimization() {
}
void JSFunction::MarkInOptimizationQueue() {
// We can only arrive here via the concurrent-recompilation builtin. If
// break points were set, the code would point to the lazy-compile builtin.
DCHECK(!GetIsolate()->DebuggerHasBreakPoints());
DCHECK(IsMarkedForConcurrentOptimization() && !IsOptimized());
DCHECK(shared()->allows_lazy_compilation() || code()->optimizable());
DCHECK(GetIsolate()->concurrent_recompilation_enabled());
if (FLAG_trace_concurrent_recompilation) {
PrintF(" ** Queueing ");
ShortPrint();
PrintF(" for concurrent recompilation.\n");
}
set_code_no_write_barrier(
GetIsolate()->builtins()->builtin(Builtins::kInOptimizationQueue));
// No write barrier required, since the builtin is part of the root set.
}
Handle<JSFunction> JSFunction::CloneClosure(Handle<JSFunction> function) {
Isolate* isolate = function->GetIsolate();
Handle<Map> map(function->map());
......
......@@ -7335,7 +7335,6 @@ class JSFunction: public JSObject {
// recompiled the next time it is executed.
void MarkForOptimization();
void AttemptConcurrentOptimization();
void MarkInOptimizationQueue();
// Tells whether or not the function is already marked for lazy
// recompilation.
......
......@@ -148,7 +148,7 @@ void RuntimeProfiler::AttemptOnStackReplacement(JSFunction* function,
void RuntimeProfiler::OptimizeNow() {
HandleScope scope(isolate_);
if (isolate_->DebuggerHasBreakPoints()) return;
if (!isolate_->use_crankshaft() || isolate_->DebuggerHasBreakPoints()) return;
DisallowHeapAllocation no_gc;
......
......@@ -47,10 +47,10 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized) {
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1);
DCHECK(isolate->use_crankshaft());
Handle<Code> unoptimized(function->shared()->code());
if (!isolate->use_crankshaft() ||
function->shared()->optimization_disabled() ||
if (function->shared()->optimization_disabled() ||
isolate->DebuggerHasBreakPoints()) {
// If the function is not optimizable or debugger is active continue
// using the code from the full compiler.
......@@ -176,7 +176,7 @@ static bool IsSuitableForOnStackReplacement(Isolate* isolate,
Handle<JSFunction> function,
Handle<Code> current_code) {
// Keep track of whether we've succeeded in optimizing.
if (!isolate->use_crankshaft() || !current_code->optimizable()) return false;
if (!current_code->optimizable()) return false;
// If we are trying to do OSR when there are already optimized
// activations of the function, it means (a) the function is directly or
// indirectly recursive and (b) an optimized invocation has been
......
......@@ -60,6 +60,8 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
(function->code()->kind() == Code::FUNCTION &&
function->code()->optimizable()));
if (!isolate->use_crankshaft()) return isolate->heap()->undefined_value();
// If the function is optimized, just return.
if (function->IsOptimized()) return isolate->heap()->undefined_value();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment