Commit b881c908 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Switch GetConcurrentlyOptimizedCode to MaybeHandle.

The function in question can already return an empty handle in the case
of failures. This makes that contract explicit by using MaybeHandle like
all other compiler API functions.

R=yangguo@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#33839}
parent 33c78c39
......@@ -1784,8 +1784,8 @@ MaybeHandle<Code> Compiler::GetOptimizedCode(Handle<JSFunction> function,
return MaybeHandle<Code>();
}
Handle<Code> Compiler::GetConcurrentlyOptimizedCode(OptimizedCompileJob* job) {
MaybeHandle<Code> Compiler::GetConcurrentlyOptimizedCode(
OptimizedCompileJob* job) {
// Take ownership of compilation info. Deleting compilation info
// also tears down the zone and the recompile job.
base::SmartPointer<CompilationInfo> info(job->info());
......@@ -1830,7 +1830,7 @@ Handle<Code> Compiler::GetConcurrentlyOptimizedCode(OptimizedCompileJob* job) {
info->closure()->ShortPrint();
PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason()));
}
return Handle<Code>::null();
return MaybeHandle<Code>();
}
......
......@@ -637,7 +637,8 @@ class Compiler : public AllStatic {
// Generate and return code from previously queued optimization job.
// On failure, return the empty handle.
static Handle<Code> GetConcurrentlyOptimizedCode(OptimizedCompileJob* job);
MUST_USE_RESULT static MaybeHandle<Code> GetConcurrentlyOptimizedCode(
OptimizedCompileJob* job);
};
......
......@@ -244,9 +244,9 @@ void OptimizingCompileDispatcher::InstallOptimizedFunctions() {
}
DisposeOptimizedCompileJob(job, false);
} else {
Handle<Code> code = Compiler::GetConcurrentlyOptimizedCode(job);
MaybeHandle<Code> code = Compiler::GetConcurrentlyOptimizedCode(job);
function->ReplaceCode(code.is_null() ? function->shared()->code()
: *code);
: *code.ToHandleChecked());
}
}
}
......
......@@ -248,7 +248,6 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) {
function->shared()->ast_node_count() > 512)
? Compiler::CONCURRENT
: Compiler::NOT_CONCURRENT;
Handle<Code> result = Handle<Code>::null();
OptimizedCompileJob* job = NULL;
if (mode == Compiler::CONCURRENT) {
......@@ -269,22 +268,24 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) {
job = dispatcher->FindReadyOSRCandidate(function, ast_id);
}
MaybeHandle<Code> maybe_result;
if (job != NULL) {
if (FLAG_trace_osr) {
PrintF("[OSR - Found ready: ");
function->PrintName();
PrintF(" at AST id %d]\n", ast_id.ToInt());
}
result = Compiler::GetConcurrentlyOptimizedCode(job);
maybe_result = Compiler::GetConcurrentlyOptimizedCode(job);
} else if (IsSuitableForOnStackReplacement(isolate, function)) {
if (FLAG_trace_osr) {
PrintF("[OSR - Compiling: ");
function->PrintName();
PrintF(" at AST id %d]\n", ast_id.ToInt());
}
MaybeHandle<Code> maybe_result = Compiler::GetOptimizedCode(
maybe_result = Compiler::GetOptimizedCode(
function, mode, ast_id,
(mode == Compiler::NOT_CONCURRENT) ? frame : nullptr);
Handle<Code> result;
if (maybe_result.ToHandle(&result) &&
result.is_identical_to(isolate->builtins()->InOptimizationQueue())) {
// Optimization is queued. Return to check later.
......@@ -296,7 +297,9 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) {
BackEdgeTable::Revert(isolate, *caller_code);
// Check whether we ended up with usable optimized code.
if (!result.is_null() && result->kind() == Code::OPTIMIZED_FUNCTION) {
Handle<Code> result;
if (maybe_result.ToHandle(&result) &&
result->kind() == Code::OPTIMIZED_FUNCTION) {
DeoptimizationInputData* data =
DeoptimizationInputData::cast(result->deoptimization_data());
......
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