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

Side by Side Diff: runtime/vm/flow_graph_optimizer.cc

Issue 22853009: For trigonometric functions call to C-libraries: they are faster than x87 operations (3% on Box2D). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 } 1725 }
1726 return new LoadIndexedInstr(new Value(str), 1726 return new LoadIndexedInstr(new Value(str),
1727 new Value(index), 1727 new Value(index),
1728 FlowGraphCompiler::ElementSizeFor(cid), 1728 FlowGraphCompiler::ElementSizeFor(cid),
1729 cid, 1729 cid,
1730 Isolate::kNoDeoptId); // Can't deoptimize. 1730 Isolate::kNoDeoptId); // Can't deoptimize.
1731 } 1731 }
1732 1732
1733 1733
1734 void FlowGraphOptimizer::ReplaceWithMathCFunction( 1734 void FlowGraphOptimizer::ReplaceWithMathCFunction(
1735 InstanceCallInstr* call, 1735 InstanceCallInstr* call,
1736 MethodRecognizer::Kind recognized_kind) { 1736 MethodRecognizer::Kind recognized_kind) {
1737 AddReceiverCheck(call); 1737 AddReceiverCheck(call);
1738 ZoneGrowableArray<Value*>* args = 1738 ZoneGrowableArray<Value*>* args =
1739 new ZoneGrowableArray<Value*>(call->ArgumentCount()); 1739 new ZoneGrowableArray<Value*>(call->ArgumentCount());
1740 for (intptr_t i = 0; i < call->ArgumentCount(); i++) { 1740 for (intptr_t i = 0; i < call->ArgumentCount(); i++) {
1741 args->Add(new Value(call->ArgumentAt(i))); 1741 args->Add(new Value(call->ArgumentAt(i)));
1742 } 1742 }
1743 InvokeMathCFunctionInstr* invoke = 1743 InvokeMathCFunctionInstr* invoke =
1744 new InvokeMathCFunctionInstr(args, call->deopt_id(), recognized_kind); 1744 new InvokeMathCFunctionInstr(args, call->deopt_id(), recognized_kind);
1745 ReplaceCall(call, invoke); 1745 ReplaceCall(call, invoke);
1746 } 1746 }
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
2728 instr->ReplaceWith(call, current_iterator()); 2728 instr->ReplaceWith(call, current_iterator());
2729 } 2729 }
2730 } 2730 }
2731 2731
2732 void FlowGraphOptimizer::VisitStaticCall(StaticCallInstr* call) { 2732 void FlowGraphOptimizer::VisitStaticCall(StaticCallInstr* call) {
2733 MethodRecognizer::Kind recognized_kind = 2733 MethodRecognizer::Kind recognized_kind =
2734 MethodRecognizer::RecognizeKind(call->function()); 2734 MethodRecognizer::RecognizeKind(call->function());
2735 if ((recognized_kind == MethodRecognizer::kMathSqrt) || 2735 if ((recognized_kind == MethodRecognizer::kMathSqrt) ||
2736 (recognized_kind == MethodRecognizer::kMathSin) || 2736 (recognized_kind == MethodRecognizer::kMathSin) ||
2737 (recognized_kind == MethodRecognizer::kMathCos)) { 2737 (recognized_kind == MethodRecognizer::kMathCos)) {
2738 if ((recognized_kind == MethodRecognizer::kMathSqrt) || 2738 MathUnaryInstr* math_unary =
2739 FlowGraphCompiler::SupportsInlinedTrigonometrics()) { 2739 new MathUnaryInstr(recognized_kind,
2740 MathUnaryInstr* math_unary = 2740 new Value(call->ArgumentAt(0)),
2741 new MathUnaryInstr(recognized_kind, 2741 call->deopt_id());
2742 new Value(call->ArgumentAt(0)), 2742 ReplaceCall(call, math_unary);
2743 call->deopt_id());
2744 ReplaceCall(call, math_unary);
2745 }
2746 } else if ((recognized_kind == MethodRecognizer::kFloat32x4Zero) || 2743 } else if ((recognized_kind == MethodRecognizer::kFloat32x4Zero) ||
2747 (recognized_kind == MethodRecognizer::kFloat32x4Splat) || 2744 (recognized_kind == MethodRecognizer::kFloat32x4Splat) ||
2748 (recognized_kind == MethodRecognizer::kFloat32x4Constructor)) { 2745 (recognized_kind == MethodRecognizer::kFloat32x4Constructor)) {
2749 TryInlineFloat32x4Constructor(call, recognized_kind); 2746 TryInlineFloat32x4Constructor(call, recognized_kind);
2750 } else if (recognized_kind == MethodRecognizer::kUint32x4BoolConstructor) { 2747 } else if (recognized_kind == MethodRecognizer::kUint32x4BoolConstructor) {
2751 TryInlineUint32x4Constructor(call, recognized_kind); 2748 TryInlineUint32x4Constructor(call, recognized_kind);
2752 } else if (recognized_kind == MethodRecognizer::kObjectConstructor) { 2749 } else if (recognized_kind == MethodRecognizer::kObjectConstructor) {
2753 // Remove the original push arguments. 2750 // Remove the original push arguments.
2754 for (intptr_t i = 0; i < call->ArgumentCount(); ++i) { 2751 for (intptr_t i = 0; i < call->ArgumentCount(); ++i) {
2755 PushArgumentInstr* push = call->PushArgumentAt(i); 2752 PushArgumentInstr* push = call->PushArgumentAt(i);
(...skipping 4757 matching lines...) Expand 10 before | Expand all | Expand 10 after
7513 } 7510 }
7514 7511
7515 // Insert materializations at environment uses. 7512 // Insert materializations at environment uses.
7516 for (intptr_t i = 0; i < exits.length(); i++) { 7513 for (intptr_t i = 0; i < exits.length(); i++) {
7517 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); 7514 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields);
7518 } 7515 }
7519 } 7516 }
7520 7517
7521 7518
7522 } // namespace dart 7519 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698