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

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

Issue 396733006: Optimize the multiplication of two 32-bit unsigned integers. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | runtime/vm/intermediate_language.h » ('j') | 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/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 2002 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 2013
2014 2014
2015 bool FlowGraphOptimizer::TryReplaceWithBinaryOp(InstanceCallInstr* call, 2015 bool FlowGraphOptimizer::TryReplaceWithBinaryOp(InstanceCallInstr* call,
2016 Token::Kind op_kind) { 2016 Token::Kind op_kind) {
2017 intptr_t operands_type = kIllegalCid; 2017 intptr_t operands_type = kIllegalCid;
2018 ASSERT(call->HasICData()); 2018 ASSERT(call->HasICData());
2019 const ICData& ic_data = *call->ic_data(); 2019 const ICData& ic_data = *call->ic_data();
2020 switch (op_kind) { 2020 switch (op_kind) {
2021 case Token::kADD: 2021 case Token::kADD:
2022 case Token::kSUB: 2022 case Token::kSUB:
2023 case Token::kMUL:
2023 if (HasOnlyTwoOf(ic_data, kSmiCid)) { 2024 if (HasOnlyTwoOf(ic_data, kSmiCid)) {
2024 // Don't generate smi code if the IC data is marked because 2025 // Don't generate smi code if the IC data is marked because
2025 // of an overflow. 2026 // of an overflow.
2026 operands_type = ic_data.HasDeoptReason(ICData::kDeoptBinarySmiOp) 2027 operands_type = ic_data.HasDeoptReason(ICData::kDeoptBinarySmiOp)
2027 ? kMintCid 2028 ? kMintCid
2028 : kSmiCid; 2029 : kSmiCid;
2029 } else if (HasTwoMintOrSmi(ic_data) && 2030 } else if (HasTwoMintOrSmi(ic_data) &&
2030 FlowGraphCompiler::SupportsUnboxedMints()) { 2031 FlowGraphCompiler::SupportsUnboxedMints()) {
2031 // Don't generate mint code if the IC data is marked because of an 2032 // Don't generate mint code if the IC data is marked because of an
2032 // overflow. 2033 // overflow.
2033 if (ic_data.HasDeoptReason(ICData::kDeoptBinaryMintOp)) return false; 2034 if (ic_data.HasDeoptReason(ICData::kDeoptBinaryMintOp)) return false;
2034 operands_type = kMintCid; 2035 operands_type = kMintCid;
2035 } else if (ShouldSpecializeForDouble(ic_data)) { 2036 } else if (ShouldSpecializeForDouble(ic_data)) {
2036 operands_type = kDoubleCid; 2037 operands_type = kDoubleCid;
2037 } else if (HasOnlyTwoOf(ic_data, kFloat32x4Cid)) { 2038 } else if (HasOnlyTwoOf(ic_data, kFloat32x4Cid)) {
2038 operands_type = kFloat32x4Cid; 2039 operands_type = kFloat32x4Cid;
2039 } else if (HasOnlyTwoOf(ic_data, kInt32x4Cid)) { 2040 } else if (HasOnlyTwoOf(ic_data, kInt32x4Cid)) {
2041 ASSERT(op_kind != Token::kMUL);
2040 operands_type = kInt32x4Cid; 2042 operands_type = kInt32x4Cid;
2041 } else if (HasOnlyTwoOf(ic_data, kFloat64x2Cid)) { 2043 } else if (HasOnlyTwoOf(ic_data, kFloat64x2Cid)) {
2042 operands_type = kFloat64x2Cid; 2044 operands_type = kFloat64x2Cid;
2043 } else { 2045 } else {
2044 return false; 2046 return false;
2045 } 2047 }
2046 break; 2048 // The binary mint multiplication only supports uint32 as inputs.
2047 case Token::kMUL: 2049 if ((operands_type == kMintCid) && (op_kind == Token::kMUL)) {
2048 if (HasOnlyTwoOf(ic_data, kSmiCid)) { 2050 ASSERT(call->ArgumentCount() == 2);
2049 // Don't generate smi code if the IC data is marked because of an 2051 Definition* left_input = call->ArgumentAt(0);
2050 // overflow. 2052 Definition* right_input = call->ArgumentAt(1);
2051 // TODO(fschneider): Add unboxed mint multiplication. 2053 ASSERT(left_input != NULL);
2052 if (ic_data.HasDeoptReason(ICData::kDeoptBinarySmiOp)) return false; 2054 ASSERT(right_input != NULL);
2053 operands_type = kSmiCid; 2055 Range* left_range = left_input->range();
2054 } else if (ShouldSpecializeForDouble(ic_data)) { 2056 Range* right_range = right_input->range();
2055 operands_type = kDoubleCid; 2057 if ((left_range == NULL) ||
Vyacheslav Egorov (Google) 2014/07/16 23:51:35 Unfortunately range information is not available a
regis 2014/07/18 02:44:57 You are right. I removed this range check.
2056 } else if (HasOnlyTwoOf(ic_data, kFloat32x4Cid)) { 2058 !left_range->IsWithin(0, static_cast<int64_t>(kMaxUint32)) ||
2057 operands_type = kFloat32x4Cid; 2059 (right_range == NULL) ||
2058 } else if (HasOnlyTwoOf(ic_data, kFloat64x2Cid)) { 2060 !right_range->IsWithin(0, static_cast<int64_t>(kMaxUint32))) {
2059 operands_type = kFloat64x2Cid; 2061 return false;
2060 } else { 2062 }
2061 return false;
2062 } 2063 }
2063 break; 2064 break;
2064 case Token::kDIV: 2065 case Token::kDIV:
2065 if (ShouldSpecializeForDouble(ic_data) || 2066 if (ShouldSpecializeForDouble(ic_data) ||
2066 HasOnlyTwoOf(ic_data, kSmiCid)) { 2067 HasOnlyTwoOf(ic_data, kSmiCid)) {
2067 operands_type = kDoubleCid; 2068 operands_type = kDoubleCid;
2068 } else if (HasOnlyTwoOf(ic_data, kFloat32x4Cid)) { 2069 } else if (HasOnlyTwoOf(ic_data, kFloat32x4Cid)) {
2069 operands_type = kFloat32x4Cid; 2070 operands_type = kFloat32x4Cid;
2070 } else if (HasOnlyTwoOf(ic_data, kFloat64x2Cid)) { 2071 } else if (HasOnlyTwoOf(ic_data, kFloat64x2Cid)) {
2071 operands_type = kFloat64x2Cid; 2072 operands_type = kFloat64x2Cid;
(...skipping 8053 matching lines...) Expand 10 before | Expand all | Expand 10 after
10125 } 10126 }
10126 10127
10127 // Insert materializations at environment uses. 10128 // Insert materializations at environment uses.
10128 for (intptr_t i = 0; i < exits.length(); i++) { 10129 for (intptr_t i = 0; i < exits.length(); i++) {
10129 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots); 10130 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots);
10130 } 10131 }
10131 } 10132 }
10132 10133
10133 10134
10134 } // namespace dart 10135 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698