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

Unified Diff: runtime/vm/code_generator.cc

Issue 10228010: Address perf regression by using the expected frame layout when traversing frames in the code gener… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 months 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 | no next file » | 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 6959)
+++ runtime/vm/code_generator.cc (working copy)
@@ -33,6 +33,23 @@
DECLARE_FLAG(int, deoptimization_counter_threshold);
+static StackFrame* GetTopDartFrame(
+ StackFrameIterator* iterator, bool has_stub_frame) {
srdjan 2012/04/25 19:31:13 You could move the StackFrameIterator in here, ins
siva 2012/04/25 20:08:49 Not really because the caller_frame that is return
+ // When runtime calls are made from dart code we assume that we will
+ // always have an exit frame and an optional stub frame before we hit
+ // the first dart frame.
+ StackFrame* exit_frame = iterator->NextFrame();
+ ASSERT(exit_frame != NULL && exit_frame->IsExitFrame());
+ if (has_stub_frame) {
+ StackFrame* stub_frame = iterator->NextFrame();
+ ASSERT(stub_frame != NULL && stub_frame->IsStubFrame());
+ }
+ StackFrame* caller_frame = iterator->NextFrame();
+ ASSERT(caller_frame != NULL && caller_frame->IsDartFrame());
+ return caller_frame;
+}
+
+
bool CodeGenerator::CanOptimize() {
return
!FLAG_report_usage_count &&
@@ -343,9 +360,8 @@
String::Handle(instantiated_type.Name()).ToCString(),
String::Handle(type.Name()).ToCString());
}
- DartFrameIterator iterator;
- StackFrame* caller_frame = iterator.NextFrame();
- ASSERT(caller_frame != NULL && caller_frame->IsDartFrame());
+ StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames);
+ StackFrame* caller_frame = GetTopDartFrame(&iterator, false);
const Function& function = Function::Handle(
caller_frame->LookupDartFunction());
OS::Print(" -> Function %s\n", function.ToFullyQualifiedCString());
@@ -362,9 +378,8 @@
// Update cache: add class of instance and result.
if (type.IsInstantiated() &&
!Class::Handle(type.type_class()).HasTypeArguments()) {
- DartFrameIterator iterator;
- StackFrame* caller_frame = iterator.NextFrame();
- ASSERT(caller_frame != NULL && caller_frame->IsDartFrame());
+ StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames);
+ StackFrame* caller_frame = GetTopDartFrame(&iterator, false);
const Code& code = Code::Handle(caller_frame->LookupDartCode());
ASSERT(!code.IsNull());
uword loc = code.GetTypeTestAtNodeId(node_id);
@@ -456,9 +471,8 @@
dst_name.ToCString(),
String::Handle(dst_type.Name()).ToCString());
}
- DartFrameIterator iterator;
- StackFrame* caller_frame = iterator.NextFrame();
- ASSERT(caller_frame != NULL && caller_frame->IsDartFrame());
+ StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames);
+ StackFrame* caller_frame = GetTopDartFrame(&iterator, false);
const Function& function = Function::Handle(
caller_frame->LookupDartFunction());
OS::Print(" -> Function %s\n", function.ToFullyQualifiedCString());
@@ -486,9 +500,8 @@
// Update cache: add class of instance and result.
if (dst_type.IsInstantiated() &&
!Class::Handle(dst_type.type_class()).HasTypeArguments()) {
- DartFrameIterator iterator;
- StackFrame* caller_frame = iterator.NextFrame();
- ASSERT(caller_frame != NULL && caller_frame->IsDartFrame());
+ StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames);
+ StackFrame* caller_frame = GetTopDartFrame(&iterator, false);
const Code& code = Code::Handle(caller_frame->LookupDartCode());
ASSERT(!code.IsNull());
uword loc = code.GetTypeTestAtNodeId(node_id);
@@ -647,9 +660,8 @@
// This function is called after successful resolving and compilation of
// the target method.
ASSERT(arguments.Count() == kPatchStaticCallRuntimeEntry.argument_count());
- DartFrameIterator iterator;
- StackFrame* caller_frame = iterator.NextFrame();
- ASSERT(caller_frame != NULL && caller_frame->IsDartFrame());
+ StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames);
+ StackFrame* caller_frame = GetTopDartFrame(&iterator, true);
uword target = 0;
Function& target_function = Function::Handle();
CodePatcher::GetStaticCallAt(caller_frame->pc(), &target_function, &target);
@@ -672,13 +684,12 @@
// Only the number of named arguments is checked, but not the actual names.
RawCode* ResolveCompileInstanceCallTarget(Isolate* isolate,
const Instance& receiver) {
- DartFrameIterator iterator;
- StackFrame* caller_frame = iterator.NextFrame();
- ASSERT(caller_frame != NULL && caller_frame->IsDartFrame());
int num_arguments = -1;
int num_named_arguments = -1;
uword target = 0;
String& function_name = String::Handle();
+ StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames);
+ StackFrame* caller_frame = GetTopDartFrame(&iterator, true);
CodePatcher::GetInstanceCallAt(caller_frame->pc(),
&function_name,
&num_arguments,
@@ -816,9 +827,8 @@
}
return target_function.raw();
}
- DartFrameIterator iterator;
- StackFrame* caller_frame = iterator.NextFrame();
- ASSERT(caller_frame != NULL && caller_frame->IsDartFrame());
+ StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames);
+ StackFrame* caller_frame = GetTopDartFrame(&iterator, true);
ICData& ic_data = ICData::Handle(
CodePatcher::GetInstanceCallIcDataAt(caller_frame->pc()));
#if defined(DEBUG)
@@ -1284,9 +1294,8 @@
DEFINE_RUNTIME_ENTRY(Deoptimize, 1) {
ASSERT(arguments.Count() == kDeoptimizeRuntimeEntry.argument_count());
const Smi& deoptimization_reason_id = Smi::CheckedHandle(arguments.At(0));
- DartFrameIterator iterator;
- StackFrame* caller_frame = iterator.NextFrame();
- ASSERT(caller_frame != NULL && caller_frame->IsDartFrame());
+ StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames);
+ StackFrame* caller_frame = GetTopDartFrame(&iterator, true);
const Code& optimized_code = Code::Handle(caller_frame->LookupDartCode());
const Function& function = Function::Handle(optimized_code.function());
ASSERT(!function.IsNull());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698