| Index: runtime/vm/code_generator.cc
|
| diff --git a/runtime/vm/code_generator.cc b/runtime/vm/code_generator.cc
|
| index 22005f0796f98f707b0e57f508a8c723680c9222..bf44083dd4dfe08bde5dc7d37fcc1598a6cea7bf 100644
|
| --- a/runtime/vm/code_generator.cc
|
| +++ b/runtime/vm/code_generator.cc
|
| @@ -658,10 +658,10 @@ DEFINE_RUNTIME_ENTRY(PatchStaticCall, 0) {
|
| const Function& target_function = Function::Handle(
|
| zone, caller_code.GetStaticCallTargetFunctionAt(caller_frame->pc()));
|
| if (!target_function.HasCode()) {
|
| - const Error& error =
|
| - Error::Handle(zone, Compiler::CompileFunction(thread, target_function));
|
| - if (!error.IsNull()) {
|
| - Exceptions::PropagateError(error);
|
| + const Object& result = Object::Handle(
|
| + zone, Compiler::CompileFunction(thread, target_function));
|
| + if (result.IsError()) {
|
| + Exceptions::PropagateError(Error::Cast(result));
|
| }
|
| }
|
| const Code& target_code = Code::Handle(zone, target_function.CurrentCode());
|
| @@ -941,10 +941,10 @@ DEFINE_RUNTIME_ENTRY(StaticCallMissHandlerOneArg, 2) {
|
| ASSERT(ic_data.NumberOfChecksIs(1));
|
| const Function& target = Function::Handle(ic_data.GetTargetAt(0));
|
| if (!target.HasCode()) {
|
| - const Error& error =
|
| - Error::Handle(Compiler::CompileFunction(thread, target));
|
| - if (!error.IsNull()) {
|
| - Exceptions::PropagateError(error);
|
| + const Object& result =
|
| + Object::Handle(Compiler::CompileFunction(thread, target));
|
| + if (result.IsError()) {
|
| + Exceptions::PropagateError(Error::Cast(result));
|
| }
|
| }
|
| ASSERT(!target.IsNull() && target.HasCode());
|
| @@ -973,10 +973,10 @@ DEFINE_RUNTIME_ENTRY(StaticCallMissHandlerTwoArgs, 3) {
|
| ASSERT(!ic_data.NumberOfChecksIs(0));
|
| const Function& target = Function::Handle(ic_data.GetTargetAt(0));
|
| if (!target.HasCode()) {
|
| - const Error& error =
|
| - Error::Handle(Compiler::CompileFunction(thread, target));
|
| - if (!error.IsNull()) {
|
| - Exceptions::PropagateError(error);
|
| + const Object& result =
|
| + Object::Handle(Compiler::CompileFunction(thread, target));
|
| + if (result.IsError()) {
|
| + Exceptions::PropagateError(Error::Cast(result));
|
| }
|
| }
|
| ASSERT(!target.IsNull() && target.HasCode());
|
| @@ -1322,10 +1322,10 @@ DEFINE_RUNTIME_ENTRY(MegamorphicCacheMissHandler, 3) {
|
| // treeshaker.
|
|
|
| if (!target_function.HasCode()) {
|
| - const Error& error =
|
| - Error::Handle(Compiler::CompileFunction(thread, target_function));
|
| - if (!error.IsNull()) {
|
| - Exceptions::PropagateError(error);
|
| + const Object& result =
|
| + Object::Handle(Compiler::CompileFunction(thread, target_function));
|
| + if (result.IsError()) {
|
| + Exceptions::PropagateError(Error::Cast(result));
|
| }
|
| }
|
|
|
| @@ -1706,28 +1706,20 @@ DEFINE_RUNTIME_ENTRY(StackOverflow, 0) {
|
| function.usage_counter());
|
| }
|
|
|
| - const Code& original_code = Code::Handle(function.CurrentCode());
|
| // Since the code is referenced from the frame and the ZoneHandle,
|
| // it cannot have been removed from the function.
|
| - ASSERT(!original_code.IsNull());
|
| - const Error& error = Error::Handle(
|
| + const Object& result = Object::Handle(
|
| Compiler::CompileOptimizedFunction(thread, function, osr_id));
|
| - if (!error.IsNull()) {
|
| - Exceptions::PropagateError(error);
|
| + if (result.IsError()) {
|
| + Exceptions::PropagateError(Error::Cast(result));
|
| }
|
|
|
| - const Code& optimized_code = Code::Handle(function.CurrentCode());
|
| - // The current code will not be changed in the case that the compiler
|
| - // bailed out during OSR compilation.
|
| - if (optimized_code.raw() != original_code.raw()) {
|
| - // The OSR code does not work for calling the function, so restore the
|
| - // unoptimized code. Patch the stack frame to return into the OSR
|
| - // code.
|
| + if (!result.IsNull()) {
|
| + const Code& code = Code::Cast(result);
|
| uword optimized_entry =
|
| - Instructions::UncheckedEntryPoint(optimized_code.instructions());
|
| - function.AttachCode(original_code);
|
| + Instructions::UncheckedEntryPoint(code.instructions());
|
| frame->set_pc(optimized_entry);
|
| - frame->set_pc_marker(optimized_code.raw());
|
| + frame->set_pc_marker(code.raw());
|
| }
|
| }
|
| }
|
| @@ -1800,13 +1792,11 @@ DEFINE_RUNTIME_ENTRY(OptimizeInvokedFunction, 1) {
|
| function.ToFullyQualifiedCString());
|
| }
|
| }
|
| - const Error& error = Error::Handle(
|
| + const Object& result = Object::Handle(
|
| zone, Compiler::CompileOptimizedFunction(thread, function));
|
| - if (!error.IsNull()) {
|
| - Exceptions::PropagateError(error);
|
| + if (result.IsError()) {
|
| + Exceptions::PropagateError(Error::Cast(result));
|
| }
|
| - const Code& optimized_code = Code::Handle(zone, function.CurrentCode());
|
| - ASSERT(!optimized_code.IsNull());
|
| }
|
| arguments.SetReturn(function);
|
| #else
|
| @@ -1836,10 +1826,10 @@ DEFINE_RUNTIME_ENTRY(FixCallersTarget, 0) {
|
| const Function& target_function = Function::Handle(
|
| zone, caller_code.GetStaticCallTargetFunctionAt(frame->pc()));
|
| if (!target_function.HasCode()) {
|
| - const Error& error =
|
| - Error::Handle(zone, Compiler::CompileFunction(thread, target_function));
|
| - if (!error.IsNull()) {
|
| - Exceptions::PropagateError(error);
|
| + const Object& result =
|
| + Object::Handle(Compiler::CompileFunction(thread, target_function));
|
| + if (result.IsError()) {
|
| + Exceptions::PropagateError(Error::Cast(result));
|
| }
|
| }
|
| ASSERT(target_function.HasCode());
|
|
|