Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Unified Diff: runtime/vm/code_generator.cc

Issue 11411072: Simplify CodePatcher::GetStaticCallAt. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/code_patcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator.cc
===================================================================
--- runtime/vm/code_generator.cc (revision 15091)
+++ runtime/vm/code_generator.cc (working copy)
@@ -770,6 +770,8 @@
}
+// Patches static call with the target's entry point. Compiles target if
+// necessary.
DEFINE_RUNTIME_ENTRY(PatchStaticCall, 0) {
// This function is called after successful resolving and compilation of
// the target method.
regis 2012/11/19 18:35:19 The comment states "called after compilation", but
srdjan 2012/11/19 19:15:44 Removed that comment. The code is in transition.
@@ -777,22 +779,29 @@
DartFrameIterator iterator;
StackFrame* caller_frame = iterator.NextFrame();
ASSERT(caller_frame != NULL);
- uword target = 0;
- Function& target_function = Function::Handle();
- CodePatcher::GetStaticCallAt(caller_frame->pc(), &target_function, &target);
- ASSERT(target_function.HasCode());
+ const Code& caller_code = Code::Handle(caller_frame->LookupDartCode());
+ ASSERT(!caller_code.IsNull());
+ const Function& target_function = Function::Handle(
+ caller_code.GetStaticCallTargetFunctionAt(caller_frame->pc()));
+ if (!target_function.HasCode()) {
+ const Error& error =
+ Error::Handle(Compiler::CompileFunction(target_function));
+ if (!error.IsNull()) {
+ Exceptions::PropagateError(error);
+ }
+ }
const Code& target_code = Code::Handle(target_function.CurrentCode());
- uword new_target = target_code.EntryPoint();
- // Verify that we are not patching repeatedly.
- ASSERT(target != new_target);
- CodePatcher::PatchStaticCallAt(caller_frame->pc(), new_target);
- const Code& code = Code::Handle(caller_frame->LookupDartCode());
- code.SetStaticCallTargetCodeAt(caller_frame->pc(), target_code);
+ // Before patching verify that we are not repeatedly patching to the same
+ // target.
+ ASSERT(target_code.EntryPoint() !=
+ CodePatcher::GetStaticCallTargetAt(caller_frame->pc()));
+ CodePatcher::PatchStaticCallAt(caller_frame->pc(), target_code.EntryPoint());
+ caller_code.SetStaticCallTargetCodeAt(caller_frame->pc(), target_code);
if (FLAG_trace_patching) {
OS::Print("PatchStaticCall: patching from %#"Px" to '%s' %#"Px"\n",
caller_frame->pc(),
target_function.ToFullyQualifiedCString(),
- new_target);
+ target_code.EntryPoint());
}
}
@@ -1538,11 +1547,7 @@
ASSERT(frame != NULL);
if (!frame->IsEntryFrame()) {
ASSERT(frame->IsDartFrame());
- uword target = 0;
- Function& target_function = Function::Handle();
- CodePatcher::GetStaticCallAt(frame->pc(), &target_function, &target);
- ASSERT(target_function.HasCode());
- ASSERT(target_function.raw() == function.raw());
+ uword target = CodePatcher::GetStaticCallTargetAt(frame->pc());
const Code& target_code = Code::Handle(function.CurrentCode());
const uword new_entry_point = target_code.EntryPoint();
ASSERT(target != new_entry_point); // Why patch otherwise.
@@ -1552,7 +1557,7 @@
if (FLAG_trace_patching) {
OS::Print("FixCallersTarget: patching from %#"Px" to '%s' %#"Px"\n",
frame->pc(),
- target_function.ToFullyQualifiedCString(),
+ Function::Handle(target_code.function()).ToFullyQualifiedCString(),
new_entry_point);
}
}
« no previous file with comments | « no previous file | runtime/vm/code_patcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698