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

Unified Diff: runtime/vm/code_generator.cc

Issue 11419073: Remove loading of function object in static calls. (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_arm.cc » ('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 15101)
+++ runtime/vm/code_generator.cc (working copy)
@@ -801,6 +801,7 @@
target_function.ToFullyQualifiedCString(),
target_code.EntryPoint());
}
+ arguments.SetReturn(target_code);
}
@@ -868,8 +869,7 @@
// Gets called from debug stub when code reaches a breakpoint.
-// Arg0: function object of the static function that was about to be called.
-DEFINE_RUNTIME_ENTRY(BreakpointStaticHandler, 1) {
+DEFINE_RUNTIME_ENTRY(BreakpointStaticHandler, 0) {
ASSERT(arguments.ArgCount() ==
kBreakpointStaticHandlerRuntimeEntry.argument_count());
ASSERT(isolate->debugger() != NULL);
@@ -877,13 +877,20 @@
// Make sure the static function that is about to be called is
// compiled. The stub will jump to the entry point without any
// further tests.
- const Function& function = Function::CheckedHandle(arguments.ArgAt(0));
+ DartFrameIterator iterator;
+ StackFrame* caller_frame = iterator.NextFrame();
+ ASSERT(caller_frame != NULL);
+ const Code& code = Code::Handle(caller_frame->LookupDartCode());
+ const Function& function =
+ Function::Handle(code.GetStaticCallTargetFunctionAt(caller_frame->pc()));
+
if (!function.HasCode()) {
const Error& error = Error::Handle(Compiler::CompileFunction(function));
if (!error.IsNull()) {
Exceptions::PropagateError(error);
}
}
+ arguments.SetReturn(Code::ZoneHandle(function.CurrentCode()));
}
@@ -1530,12 +1537,9 @@
// The caller must be a static call in a Dart frame, or an entry frame.
// Patch static call to point to valid code's entry point.
-DEFINE_RUNTIME_ENTRY(FixCallersTarget, 1) {
+DEFINE_RUNTIME_ENTRY(FixCallersTarget, 0) {
ASSERT(arguments.ArgCount() ==
kFixCallersTargetRuntimeEntry.argument_count());
- const Function& function = Function::CheckedHandle(arguments.ArgAt(0));
- ASSERT(!function.IsNull());
- ASSERT(function.HasCode());
StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames);
StackFrame* frame = iterator.NextFrame();
@@ -1543,22 +1547,25 @@
frame = iterator.NextFrame();
}
ASSERT(frame != NULL);
- if (!frame->IsEntryFrame()) {
- ASSERT(frame->IsDartFrame());
- 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.
- CodePatcher::PatchStaticCallAt(frame->pc(), new_entry_point);
- const Code& code = Code::Handle(frame->LookupDartCode());
- code.SetStaticCallTargetCodeAt(frame->pc(), target_code);
- if (FLAG_trace_patching) {
- OS::Print("FixCallersTarget: patching from %#"Px" to '%s' %#"Px"\n",
- frame->pc(),
- Function::Handle(target_code.function()).ToFullyQualifiedCString(),
- new_entry_point);
- }
+ if (frame->IsEntryFrame()) {
+ // Since function's current code is always unpatched, the entry frame always
+ // calls to unpatched code.
+ UNREACHABLE();
}
+ ASSERT(frame->IsDartFrame());
+ const Code& caller_code = Code::Handle(frame->LookupDartCode());
+ const Function& target_function = Function::Handle(
+ caller_code.GetStaticCallTargetFunctionAt(frame->pc()));
+ const Code& target_code = Code::Handle(target_function.CurrentCode());
+ CodePatcher::PatchStaticCallAt(frame->pc(), target_code.EntryPoint());
+ caller_code.SetStaticCallTargetCodeAt(frame->pc(), target_code);
+ if (FLAG_trace_patching) {
+ OS::Print("FixCallersTarget: patching from %#"Px" to '%s' %#"Px"\n",
+ frame->pc(),
+ Function::Handle(target_code.function()).ToFullyQualifiedCString(),
+ target_code.EntryPoint());
+ }
+ arguments.SetReturn(target_code);
}
« no previous file with comments | « no previous file | runtime/vm/code_patcher_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698