Chromium Code Reviews| Index: runtime/vm/code_generator.cc |
| =================================================================== |
| --- runtime/vm/code_generator.cc (revision 30197) |
| +++ runtime/vm/code_generator.cc (working copy) |
| @@ -1343,9 +1343,13 @@ |
| if (FLAG_use_osr && (interrupt_bits == 0)) { |
| DartFrameIterator iterator; |
| StackFrame* frame = iterator.NextFrame(); |
| - const Function& function = Function::Handle(frame->LookupDartFunction()); |
| + const Code& code = Code::ZoneHandle(frame->LookupDartCode()); |
|
srdjan
2013/11/19 19:18:29
Optional, as it will fail in next line: ASSERT(!co
zra
2013/11/22 17:18:54
Done.
|
| + const Function& function = Function::Handle(code.function()); |
| ASSERT(!function.IsNull()); |
| - if (!CanOptimizeFunction(function, isolate)) return; |
| + ASSERT(function.HasCode()); |
|
srdjan
2013/11/19 19:18:29
Why does this need to be true? Is this because onc
zra
2013/11/22 17:18:54
Done.
|
| + if (!CanOptimizeFunction(function, isolate)) { |
| + return; |
| + } |
| intptr_t osr_id = |
| Code::Handle(function.unoptimized_code()).GetDeoptIdForOsr(frame->pc()); |
| if (FLAG_trace_osr) { |
| @@ -1356,9 +1360,12 @@ |
| } |
| const Code& original_code = Code::Handle(function.CurrentCode()); |
| + ASSERT(!original_code.IsNull()); |
| const Error& error = |
| Error::Handle(Compiler::CompileOptimizedFunction(function, osr_id)); |
| - if (!error.IsNull()) Exceptions::PropagateError(error); |
| + if (!error.IsNull()) { |
| + Exceptions::PropagateError(error); |
| + } |
| const Code& optimized_code = Code::Handle(function.CurrentCode()); |
| // The current code will not be changed in the case that the compiler |
| @@ -1436,21 +1443,11 @@ |
| const Function& target_function = Function::Handle( |
| caller_code.GetStaticCallTargetFunctionAt(frame->pc())); |
|
srdjan
2013/11/19 19:18:29
GetStaticCallTargetCodeAt ->target_code -> functio
zra
2013/11/22 17:18:54
Done.
|
| - // Check whether the code object has been detached from the target function. |
| - // If it has been detached, reattach it. |
| - Code& target_code = Code::Handle(); |
| - if (target_function.HasCode()) { |
| - target_code ^= target_function.CurrentCode(); |
| - CodePatcher::PatchStaticCallAt(frame->pc(), caller_code, |
| - target_code.EntryPoint()); |
| - caller_code.SetStaticCallTargetCodeAt(frame->pc(), target_code); |
| - } else { |
| - ASSERT(target_function.unoptimized_code() == Code::null()); |
| - target_code ^= caller_code.GetStaticCallTargetCodeAt(frame->pc()); |
| - ASSERT(!target_code.IsNull()); |
| - ASSERT(!target_code.is_optimized()); |
| - target_function.ReattachCode(target_code); |
| - } |
| + ASSERT(target_function.HasCode()); |
| + Code& target_code = Code::Handle(target_function.CurrentCode()); |
| + CodePatcher::PatchStaticCallAt(frame->pc(), caller_code, |
| + target_code.EntryPoint()); |
| + caller_code.SetStaticCallTargetCodeAt(frame->pc(), target_code); |
| if (FLAG_trace_patching) { |
| OS::PrintErr("FixCallersTarget: patching from %#" Px " to '%s' %#" Px "\n", |
| frame->pc(), |
| @@ -1483,7 +1480,7 @@ |
| const Function& function = Function::Handle(optimized_code.function()); |
| const Code& unoptimized_code = Code::Handle(function.unoptimized_code()); |
| ASSERT(!unoptimized_code.IsNull()); |
| - // The switch to unoptimized code may have already occured. |
| + // The switch to unoptimized code may have already occurred. |
| if (function.HasOptimizedCode()) { |
| function.SwitchToUnoptimizedCode(); |
| } |