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

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

Issue 20198002: Optimize division for two Smi-s as well. Gives ~ 15% speedup on NavierStokes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 operands_type = kSmiCid; 1028 operands_type = kSmiCid;
1029 } else if (ShouldSpecializeForDouble(ic_data)) { 1029 } else if (ShouldSpecializeForDouble(ic_data)) {
1030 operands_type = kDoubleCid; 1030 operands_type = kDoubleCid;
1031 } else if (HasOnlyTwoFloat32x4s(ic_data)) { 1031 } else if (HasOnlyTwoFloat32x4s(ic_data)) {
1032 operands_type = kFloat32x4Cid; 1032 operands_type = kFloat32x4Cid;
1033 } else { 1033 } else {
1034 return false; 1034 return false;
1035 } 1035 }
1036 break; 1036 break;
1037 case Token::kDIV: 1037 case Token::kDIV:
1038 if (ShouldSpecializeForDouble(ic_data)) { 1038 if (ShouldSpecializeForDouble(ic_data) || HasOnlyTwoSmis(ic_data)) {
1039 operands_type = kDoubleCid; 1039 operands_type = kDoubleCid;
1040 } else if (HasOnlyTwoFloat32x4s(ic_data)) { 1040 } else if (HasOnlyTwoFloat32x4s(ic_data)) {
1041 operands_type = kFloat32x4Cid; 1041 operands_type = kFloat32x4Cid;
1042 } else { 1042 } else {
1043 return false; 1043 return false;
1044 } 1044 }
1045 break; 1045 break;
1046 case Token::kMOD: 1046 case Token::kMOD:
1047 if (HasOnlyTwoSmis(ic_data)) { 1047 if (HasOnlyTwoSmis(ic_data)) {
1048 operands_type = kSmiCid; 1048 operands_type = kSmiCid;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 break; 1095 break;
1096 default: 1096 default:
1097 UNREACHABLE(); 1097 UNREACHABLE();
1098 } 1098 }
1099 1099
1100 ASSERT(call->ArgumentCount() == 2); 1100 ASSERT(call->ArgumentCount() == 2);
1101 Definition* left = call->ArgumentAt(0); 1101 Definition* left = call->ArgumentAt(0);
1102 Definition* right = call->ArgumentAt(1); 1102 Definition* right = call->ArgumentAt(1);
1103 if (operands_type == kDoubleCid) { 1103 if (operands_type == kDoubleCid) {
1104 // Check that either left or right are not a smi. Result of a 1104 // Check that either left or right are not a smi. Result of a
1105 // binary operation with two smis is a smi not a double. 1105 // binary operation with two smis is a smi not a double, except '/' which
1106 InsertBefore(call, 1106 // returns a double for two smis.
1107 new CheckEitherNonSmiInstr(new Value(left), 1107 if (op_kind != Token::kDIV) {
1108 new Value(right), 1108 InsertBefore(call,
1109 call->deopt_id()), 1109 new CheckEitherNonSmiInstr(new Value(left),
1110 call->env(), 1110 new Value(right),
1111 Definition::kEffect); 1111 call->deopt_id()),
1112 call->env(),
1113 Definition::kEffect);
1114 }
1112 1115
1113 BinaryDoubleOpInstr* double_bin_op = 1116 BinaryDoubleOpInstr* double_bin_op =
1114 new BinaryDoubleOpInstr(op_kind, new Value(left), new Value(right), 1117 new BinaryDoubleOpInstr(op_kind, new Value(left), new Value(right),
1115 call->deopt_id()); 1118 call->deopt_id());
1116 ReplaceCall(call, double_bin_op); 1119 ReplaceCall(call, double_bin_op);
1117 } else if (operands_type == kMintCid) { 1120 } else if (operands_type == kMintCid) {
1118 if (!FlowGraphCompiler::SupportsUnboxedMints()) return false; 1121 if (!FlowGraphCompiler::SupportsUnboxedMints()) return false;
1119 if ((op_kind == Token::kSHR) || (op_kind == Token::kSHL)) { 1122 if ((op_kind == Token::kSHR) || (op_kind == Token::kSHL)) {
1120 ShiftMintOpInstr* shift_op = 1123 ShiftMintOpInstr* shift_op =
1121 new ShiftMintOpInstr(op_kind, new Value(left), new Value(right), 1124 new ShiftMintOpInstr(op_kind, new Value(left), new Value(right),
(...skipping 6119 matching lines...) Expand 10 before | Expand all | Expand 10 after
7241 7244
7242 // Insert materializations at environment uses. 7245 // Insert materializations at environment uses.
7243 const Class& cls = Class::Handle(alloc->constructor().Owner()); 7246 const Class& cls = Class::Handle(alloc->constructor().Owner());
7244 for (intptr_t i = 0; i < exits.length(); i++) { 7247 for (intptr_t i = 0; i < exits.length(); i++) {
7245 CreateMaterializationAt(exits[i], alloc, cls, *fields); 7248 CreateMaterializationAt(exits[i], alloc, cls, *fields);
7246 } 7249 }
7247 } 7250 }
7248 7251
7249 7252
7250 } // namespace dart 7253 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698