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

Unified Diff: runtime/vm/flow_graph_compiler_x64.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_x64.cc
===================================================================
--- runtime/vm/flow_graph_compiler_x64.cc (revision 9089)
+++ runtime/vm/flow_graph_compiler_x64.cc (working copy)
@@ -33,6 +33,16 @@
__ pushq(registers_[i]);
}
}
+ if (compiler->IsLeaf()) {
+ Label L;
+ __ call(&L);
+ const intptr_t offset = assem->CodeSize();
+ __ Bind(&L);
+ __ popq(RAX);
+ __ subq(RAX,
+ Immediate(offset - AssemblerMacros::kOffsetOfSavedPCfromEntrypoint));
+ __ movq(Address(RBP, -kWordSize), RAX);
+ }
__ movq(RAX, Immediate(Smi::RawValue(reason_)));
__ call(&StubCode::DeoptimizeLabel());
compiler->AddCurrentDescriptor(PcDescriptors::kOther,
@@ -765,6 +775,7 @@
CatchClauseNode::kInvalidTryIndex,
kClosureArgumentMismatchRuntimeEntry);
} else {
+ ASSERT(!IsLeaf());
// Invoke noSuchMethod function.
const int kNumArgsChecked = 1;
ICData& ic_data = ICData::ZoneHandle();
@@ -885,7 +896,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,
@@ -928,17 +943,18 @@
}
}
- // Generate stack overflow check.
- __ movq(RDI, Immediate(Isolate::Current()->stack_limit_address()));
- __ cmpq(RSP, Address(RDI, 0));
- 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.
+ __ movq(RDI, Immediate(Isolate::Current()->stack_limit_address()));
+ __ cmpq(RSP, Address(RDI, 0));
+ 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.
@@ -968,6 +984,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);
@@ -978,6 +995,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);
@@ -988,6 +1006,7 @@
const ICData& ic_data,
const Array& arguments_descriptor,
intptr_t argument_count) {
+ ASSERT(!IsLeaf());
__ LoadObject(RBX, ic_data);
__ LoadObject(R10, arguments_descriptor);
@@ -1001,6 +1020,7 @@
intptr_t FlowGraphCompiler::EmitStaticCall(const Function& function,
const Array& arguments_descriptor,
intptr_t argument_count) {
+ ASSERT(!IsLeaf());
__ LoadObject(RBX, function);
__ LoadObject(R10, arguments_descriptor);
__ call(&StubCode::CallStaticFunctionLabel());

Powered by Google App Engine
This is Rietveld 408576698