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

Unified Diff: runtime/vm/flow_graph_compiler_x64.cc

Issue 14682020: Optimize functions containing try-catch. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: rebased Created 7 years, 7 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 | « runtime/vm/flow_graph_compiler_ia32.cc ('k') | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_compiler_x64.cc
===================================================================
--- runtime/vm/flow_graph_compiler_x64.cc (revision 22613)
+++ runtime/vm/flow_graph_compiler_x64.cc (working copy)
@@ -642,10 +642,84 @@
Scanner::kDummyTokenIndex);
}
AllocateRegistersLocally(instr);
+ } else if (instr->MayThrow() &&
+ (CurrentTryIndex() != CatchClauseNode::kInvalidTryIndex)) {
+ // Optimized try-block: Sync locals to fixed stack locations.
+ EmitTrySync(instr, CurrentTryIndex());
}
}
+void FlowGraphCompiler::EmitTrySyncMove(Address dest,
+ Location loc,
+ bool* push_emitted) {
+ if (loc.IsConstant()) {
+ if (!*push_emitted) {
+ __ pushq(RAX);
+ *push_emitted = true;
+ }
+ __ LoadObject(RAX, loc.constant());
+ __ movq(dest, RAX);
+ } else if (loc.IsRegister()) {
+ if (*push_emitted && loc.reg() == RAX) {
+ __ movq(RAX, Address(RSP, 0));
+ __ movq(dest, RAX);
+ } else {
+ __ movq(dest, loc.reg());
+ }
+ } else {
+ Address src = loc.ToStackSlotAddress();
+ if (!src.Equals(dest)) {
+ if (!*push_emitted) {
+ __ pushq(RAX);
+ *push_emitted = true;
+ }
+ __ movq(RAX, src);
+ __ movq(dest, RAX);
+ }
+ }
+}
+
+
+void FlowGraphCompiler::EmitTrySync(Instruction* instr, intptr_t try_index) {
+ ASSERT(is_optimizing());
+ Environment* env = instr->env();
+ CatchBlockEntryInstr* catch_block =
+ flow_graph().graph_entry()->GetCatchEntry(try_index);
+ const GrowableArray<Definition*>* idefs = catch_block->initial_definitions();
+ // Parameters.
+ intptr_t i = 0;
+ bool push_emitted = false;
+ const intptr_t num_non_copied_params = flow_graph().num_non_copied_params();
+ const intptr_t param_base = kParamEndSlotFromFp + num_non_copied_params;
+ for (; i < num_non_copied_params; ++i) {
+ if ((*idefs)[i]->IsConstant()) continue; // Common constants
+ Location loc = env->LocationAt(i);
+ Address dest(RBP, (param_base - i) * kWordSize);
+ EmitTrySyncMove(dest, loc, &push_emitted);
+ }
+
+ // Process locals. Skip exception_var and stacktrace_var.
+ CatchEntryInstr* catch_entry = catch_block->next()->AsCatchEntry();
+ intptr_t local_base = kFirstLocalSlotFromFp + num_non_copied_params;
+ intptr_t ex_idx = local_base - catch_entry->exception_var().index();
+ intptr_t st_idx = local_base - catch_entry->stacktrace_var().index();
+ for (; i < flow_graph().variable_count(); ++i) {
+ if (i == ex_idx || i == st_idx) continue;
+ if ((*idefs)[i]->IsConstant()) continue;
+ Location loc = env->LocationAt(i);
+ Address dest(RBP, (local_base - i) * kWordSize);
+ EmitTrySyncMove(dest, loc, &push_emitted);
+ // Update safepoint bitmap to indicate that the target location
+ // now contains a pointer.
+ instr->locs()->stack_bitmap()->Set(i - num_non_copied_params, true);
+ }
+ if (push_emitted) {
+ __ popq(RAX);
+ }
+}
+
+
void FlowGraphCompiler::EmitInstructionEpilogue(Instruction* instr) {
if (is_optimizing()) return;
Definition* defn = instr->AsDefinition();
@@ -937,7 +1011,7 @@
0); // No token position.
}
__ Comment("Enter frame");
- __ EnterDartFrame((StackSize() * kWordSize));
+ __ EnterDartFrame(StackSize() * kWordSize);
}
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.cc ('k') | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698