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

Unified Diff: runtime/vm/flow_graph_compiler_ia32.cc

Issue 10668034: Recognize leaf functions: skip stack check and populating the pc slot, store the pc slot lazily in … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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
Index: runtime/vm/flow_graph_compiler_ia32.cc
===================================================================
--- runtime/vm/flow_graph_compiler_ia32.cc (revision 9089)
+++ runtime/vm/flow_graph_compiler_ia32.cc (working copy)
@@ -33,6 +33,16 @@
__ pushl(registers_[i]);
}
}
+ if (compiler->IsLeaf()) {
+ Label L;
+ __ call(&L);
+ const intptr_t offset = assem->CodeSize();
+ __ Bind(&L);
+ __ popl(EAX);
+ __ subl(EAX,
+ Immediate(offset - AssemblerMacros::kOffsetOfSavedPCfromEntrypoint));
+ __ movl(Address(EBP, -kWordSize), EAX);
+ }
__ movl(EAX, Immediate(Smi::RawValue(reason_)));
__ call(&StubCode::DeoptimizeLabel());
compiler->AddCurrentDescriptor(PcDescriptors::kOther,
@@ -762,6 +772,7 @@
CatchClauseNode::kInvalidTryIndex,
kClosureArgumentMismatchRuntimeEntry);
} else {
+ ASSERT(!IsLeaf());
// Invoke noSuchMethod function.
const int kNumArgsChecked = 1;
ICData& ic_data = ICData::ZoneHandle();
@@ -881,7 +892,11 @@
const int parameter_count = function.num_fixed_parameters();
const int num_copied_params = parsed_function().copied_parameter_count();
const int local_count = parsed_function().stack_local_count();
- AssemblerMacros::EnterDartFrame(assembler(), (StackSize() * kWordSize));
+ if (IsLeaf()) {
+ AssemblerMacros::EnterDartLeafFrame(assembler(), (StackSize() * kWordSize));
+ } else {
+ AssemblerMacros::EnterDartFrame(assembler(), (StackSize() * kWordSize));
+ }
// We check the number of passed arguments when we have to copy them due to
// the presence of optional named parameters.
// No such checking code is generated if only fixed parameters are declared,
@@ -924,17 +939,18 @@
}
}
- // Generate stack overflow check.
- __ cmpl(ESP,
- Address::Absolute(Isolate::Current()->stack_limit_address()));
- Label no_stack_overflow;
- __ j(ABOVE, &no_stack_overflow, Assembler::kNearJump);
- GenerateCallRuntime(AstNode::kNoId,
- function.token_pos(),
- CatchClauseNode::kInvalidTryIndex,
- kStackOverflowRuntimeEntry);
- __ Bind(&no_stack_overflow);
-
+ if (!IsLeaf()) {
+ // Generate stack overflow check.
+ __ cmpl(ESP,
+ Address::Absolute(Isolate::Current()->stack_limit_address()));
+ Label no_stack_overflow;
+ __ j(ABOVE, &no_stack_overflow, Assembler::kNearJump);
+ GenerateCallRuntime(AstNode::kNoId,
+ function.token_pos(),
+ CatchClauseNode::kInvalidTryIndex,
+ kStackOverflowRuntimeEntry);
+ __ Bind(&no_stack_overflow);
+ }
if (FLAG_print_scopes) {
// Print the function scope (again) after generating the prologue in order
// to see annotations such as allocation indices of locals.
@@ -964,6 +980,7 @@
intptr_t try_index,
const ExternalLabel* label,
PcDescriptors::Kind kind) {
+ ASSERT(!IsLeaf());
ASSERT(frame_register_allocator()->IsSpilled());
__ call(label);
AddCurrentDescriptor(kind, AstNode::kNoId, token_pos, try_index);
@@ -974,6 +991,7 @@
intptr_t token_pos,
intptr_t try_index,
const RuntimeEntry& entry) {
+ ASSERT(!IsLeaf());
ASSERT(frame_register_allocator()->IsSpilled());
__ CallRuntime(entry);
AddCurrentDescriptor(PcDescriptors::kOther, cid, token_pos, try_index);
@@ -984,6 +1002,7 @@
const ICData& ic_data,
const Array& arguments_descriptor,
intptr_t argument_count) {
+ ASSERT(!IsLeaf());
__ LoadObject(ECX, ic_data);
__ LoadObject(EDX, arguments_descriptor);
@@ -997,6 +1016,7 @@
intptr_t FlowGraphCompiler::EmitStaticCall(const Function& function,
const Array& arguments_descriptor,
intptr_t argument_count) {
+ ASSERT(!IsLeaf());
__ LoadObject(ECX, function);
__ LoadObject(EDX, arguments_descriptor);
__ call(&StubCode::CallStaticFunctionLabel());

Powered by Google App Engine
This is Rietveld 408576698