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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 10915200: Optimistically inline Math.sqrt as unboxed sqrtsd instruction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | runtime/vm/il_printer.cc » ('j') | runtime/vm/il_printer.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index e161f28dd31b27764a3b80ff0b0d001c7f2f1476..d78a9112eed5b2347796b953b2ca4fee9b2a36f2 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -274,6 +274,16 @@ static void RemovePushArguments(InstanceCallInstr* call) {
}
+static void RemovePushArguments(StaticCallInstr* call) {
+ // Remove original push arguments.
+ for (intptr_t i = 0; i < call->ArgumentCount(); ++i) {
+ PushArgumentInstr* push = call->ArgumentAt(i);
+ push->ReplaceUsesWith(push->value()->definition());
+ push->RemoveFromGraph();
+ }
+}
+
+
// Returns true if all targets are the same.
// TODO(srdjan): if targets are native use their C_function to compare.
static bool HasOneTarget(const ICData& ic_data) {
@@ -774,11 +784,13 @@ void FlowGraphOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
}
-void FlowGraphOptimizer::VisitStaticCall(StaticCallInstr* instr) {
+void FlowGraphOptimizer::VisitStaticCall(StaticCallInstr* call) {
MethodRecognizer::Kind recognized_kind =
- MethodRecognizer::RecognizeKind(instr->function());
+ MethodRecognizer::RecognizeKind(call->function());
if (recognized_kind == MethodRecognizer::kMathSqrt) {
- instr->set_recognized(MethodRecognizer::kMathSqrt);
+ MathSqrtInstr* sqrt = new MathSqrtInstr(call->ArgumentAt(0)->value(), call);
+ call->ReplaceWith(sqrt, current_iterator());
+ RemovePushArguments(call);
}
}
« no previous file with comments | « no previous file | runtime/vm/il_printer.cc » ('j') | runtime/vm/il_printer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698