| OLD | NEW |
| 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 Loading... |
| 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); // Int32x4 doesn't have a multiply op. |
| 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 break; |
| 2047 case Token::kMUL: | |
| 2048 if (HasOnlyTwoOf(ic_data, kSmiCid)) { | |
| 2049 // Don't generate smi code if the IC data is marked because of an | |
| 2050 // overflow. | |
| 2051 // TODO(fschneider): Add unboxed mint multiplication. | |
| 2052 if (ic_data.HasDeoptReason(ICData::kDeoptBinarySmiOp)) return false; | |
| 2053 operands_type = kSmiCid; | |
| 2054 } else if (ShouldSpecializeForDouble(ic_data)) { | |
| 2055 operands_type = kDoubleCid; | |
| 2056 } else if (HasOnlyTwoOf(ic_data, kFloat32x4Cid)) { | |
| 2057 operands_type = kFloat32x4Cid; | |
| 2058 } else if (HasOnlyTwoOf(ic_data, kFloat64x2Cid)) { | |
| 2059 operands_type = kFloat64x2Cid; | |
| 2060 } else { | |
| 2061 return false; | |
| 2062 } | |
| 2063 break; | |
| 2064 case Token::kDIV: | 2049 case Token::kDIV: |
| 2065 if (ShouldSpecializeForDouble(ic_data) || | 2050 if (ShouldSpecializeForDouble(ic_data) || |
| 2066 HasOnlyTwoOf(ic_data, kSmiCid)) { | 2051 HasOnlyTwoOf(ic_data, kSmiCid)) { |
| 2067 operands_type = kDoubleCid; | 2052 operands_type = kDoubleCid; |
| 2068 } else if (HasOnlyTwoOf(ic_data, kFloat32x4Cid)) { | 2053 } else if (HasOnlyTwoOf(ic_data, kFloat32x4Cid)) { |
| 2069 operands_type = kFloat32x4Cid; | 2054 operands_type = kFloat32x4Cid; |
| 2070 } else if (HasOnlyTwoOf(ic_data, kFloat64x2Cid)) { | 2055 } else if (HasOnlyTwoOf(ic_data, kFloat64x2Cid)) { |
| 2071 operands_type = kFloat64x2Cid; | 2056 operands_type = kFloat64x2Cid; |
| 2072 } else { | 2057 } else { |
| 2073 return false; | 2058 return false; |
| (...skipping 8051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10125 } | 10110 } |
| 10126 | 10111 |
| 10127 // Insert materializations at environment uses. | 10112 // Insert materializations at environment uses. |
| 10128 for (intptr_t i = 0; i < exits.length(); i++) { | 10113 for (intptr_t i = 0; i < exits.length(); i++) { |
| 10129 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots); | 10114 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots); |
| 10130 } | 10115 } |
| 10131 } | 10116 } |
| 10132 | 10117 |
| 10133 | 10118 |
| 10134 } // namespace dart | 10119 } // namespace dart |
| OLD | NEW |