| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/code_generator.h" | 5 #include "vm/code_generator.h" |
| 6 | 6 |
| 7 #include "vm/assembler_macros.h" | 7 #include "vm/assembler_macros.h" |
| 8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 const Error& error = | 755 const Error& error = |
| 756 Error::Handle(Compiler::CompileFunction(target_function)); | 756 Error::Handle(Compiler::CompileFunction(target_function)); |
| 757 if (!error.IsNull()) { | 757 if (!error.IsNull()) { |
| 758 Exceptions::PropagateError(error); | 758 Exceptions::PropagateError(error); |
| 759 } | 759 } |
| 760 } | 760 } |
| 761 const Code& target_code = Code::Handle(target_function.CurrentCode()); | 761 const Code& target_code = Code::Handle(target_function.CurrentCode()); |
| 762 // Before patching verify that we are not repeatedly patching to the same | 762 // Before patching verify that we are not repeatedly patching to the same |
| 763 // target. | 763 // target. |
| 764 ASSERT(target_code.EntryPoint() != | 764 ASSERT(target_code.EntryPoint() != |
| 765 CodePatcher::GetStaticCallTargetAt(caller_frame->pc())); | 765 CodePatcher::GetStaticCallTargetAt(caller_frame->pc(), caller_code)); |
| 766 CodePatcher::PatchStaticCallAt(caller_frame->pc(), target_code.EntryPoint()); | 766 CodePatcher::PatchStaticCallAt(caller_frame->pc(), caller_code, |
| 767 target_code.EntryPoint()); |
| 767 caller_code.SetStaticCallTargetCodeAt(caller_frame->pc(), target_code); | 768 caller_code.SetStaticCallTargetCodeAt(caller_frame->pc(), target_code); |
| 768 if (FLAG_trace_patching) { | 769 if (FLAG_trace_patching) { |
| 769 OS::PrintErr("PatchStaticCall: patching from %#"Px" to '%s' %#"Px"\n", | 770 OS::PrintErr("PatchStaticCall: patching from %#"Px" to '%s' %#"Px"\n", |
| 770 caller_frame->pc(), | 771 caller_frame->pc(), |
| 771 target_function.ToFullyQualifiedCString(), | 772 target_function.ToFullyQualifiedCString(), |
| 772 target_code.EntryPoint()); | 773 target_code.EntryPoint()); |
| 773 } | 774 } |
| 774 arguments.SetReturn(target_code); | 775 arguments.SetReturn(target_code); |
| 775 } | 776 } |
| 776 | 777 |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 if (frame->IsEntryFrame()) { | 1350 if (frame->IsEntryFrame()) { |
| 1350 // Since function's current code is always unpatched, the entry frame always | 1351 // Since function's current code is always unpatched, the entry frame always |
| 1351 // calls to unpatched code. | 1352 // calls to unpatched code. |
| 1352 UNREACHABLE(); | 1353 UNREACHABLE(); |
| 1353 } | 1354 } |
| 1354 ASSERT(frame->IsDartFrame()); | 1355 ASSERT(frame->IsDartFrame()); |
| 1355 const Code& caller_code = Code::Handle(frame->LookupDartCode()); | 1356 const Code& caller_code = Code::Handle(frame->LookupDartCode()); |
| 1356 const Function& target_function = Function::Handle( | 1357 const Function& target_function = Function::Handle( |
| 1357 caller_code.GetStaticCallTargetFunctionAt(frame->pc())); | 1358 caller_code.GetStaticCallTargetFunctionAt(frame->pc())); |
| 1358 const Code& target_code = Code::Handle(target_function.CurrentCode()); | 1359 const Code& target_code = Code::Handle(target_function.CurrentCode()); |
| 1359 CodePatcher::PatchStaticCallAt(frame->pc(), target_code.EntryPoint()); | 1360 CodePatcher::PatchStaticCallAt(frame->pc(), caller_code, |
| 1361 target_code.EntryPoint()); |
| 1360 caller_code.SetStaticCallTargetCodeAt(frame->pc(), target_code); | 1362 caller_code.SetStaticCallTargetCodeAt(frame->pc(), target_code); |
| 1361 if (FLAG_trace_patching) { | 1363 if (FLAG_trace_patching) { |
| 1362 OS::PrintErr("FixCallersTarget: patching from %#"Px" to '%s' %#"Px"\n", | 1364 OS::PrintErr("FixCallersTarget: patching from %#"Px" to '%s' %#"Px"\n", |
| 1363 frame->pc(), | 1365 frame->pc(), |
| 1364 Function::Handle(target_code.function()).ToFullyQualifiedCString(), | 1366 Function::Handle(target_code.function()).ToFullyQualifiedCString(), |
| 1365 target_code.EntryPoint()); | 1367 target_code.EntryPoint()); |
| 1366 } | 1368 } |
| 1367 arguments.SetReturn(target_code); | 1369 arguments.SetReturn(target_code); |
| 1368 } | 1370 } |
| 1369 | 1371 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1727 if (right < 0) { | 1729 if (right < 0) { |
| 1728 remainder -= right; | 1730 remainder -= right; |
| 1729 } else { | 1731 } else { |
| 1730 remainder += right; | 1732 remainder += right; |
| 1731 } | 1733 } |
| 1732 } | 1734 } |
| 1733 return remainder; | 1735 return remainder; |
| 1734 } | 1736 } |
| 1735 | 1737 |
| 1736 } // namespace dart | 1738 } // namespace dart |
| OLD | NEW |