| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/generic-node-inl.h" | 5 #include "src/compiler/generic-node-inl.h" |
| 6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
| 7 #include "src/compiler/machine-operator.h" | 7 #include "src/compiler/machine-operator.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/simplified-operator-reducer.h" | 9 #include "src/compiler/simplified-operator-reducer.h" |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value())); | 99 if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value())); |
| 100 break; | 100 break; |
| 101 } | 101 } |
| 102 case IrOpcode::kLoadElement: { | 102 case IrOpcode::kLoadElement: { |
| 103 ElementAccess access = ElementAccessOf(node->op()); | 103 ElementAccess access = ElementAccessOf(node->op()); |
| 104 if (access.bounds_check == kTypedArrayBoundsCheck) { | 104 if (access.bounds_check == kTypedArrayBoundsCheck) { |
| 105 NumericValueMatcher mkey(node->InputAt(1)); | 105 NumericValueMatcher mkey(node->InputAt(1)); |
| 106 NumericValueMatcher mlength(node->InputAt(2)); | 106 NumericValueMatcher mlength(node->InputAt(2)); |
| 107 if (mkey.HasValue() && mlength.HasValue()) { | 107 if (mkey.HasValue() && mlength.HasValue()) { |
| 108 // Skip the typed array bounds check if key and length are constant. | 108 // Skip the typed array bounds check if key and length are constant. |
| 109 if (mkey.Value() < mlength.Value()) { | 109 if (mkey.Value() >= 0 && mkey.Value() < mlength.Value()) { |
| 110 access.bounds_check = kNoBoundsCheck; | 110 access.bounds_check = kNoBoundsCheck; |
| 111 node->set_op(simplified()->LoadElement(access)); | 111 node->set_op(simplified()->LoadElement(access)); |
| 112 return Changed(node); | 112 return Changed(node); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 break; | 116 break; |
| 117 } | 117 } |
| 118 case IrOpcode::kStoreElement: { | 118 case IrOpcode::kStoreElement: { |
| 119 ElementAccess access = ElementAccessOf(node->op()); | 119 ElementAccess access = ElementAccessOf(node->op()); |
| 120 if (access.bounds_check == kTypedArrayBoundsCheck) { | 120 if (access.bounds_check == kTypedArrayBoundsCheck) { |
| 121 NumericValueMatcher mkey(node->InputAt(1)); | 121 NumericValueMatcher mkey(node->InputAt(1)); |
| 122 NumericValueMatcher mlength(node->InputAt(2)); | 122 NumericValueMatcher mlength(node->InputAt(2)); |
| 123 if (mkey.HasValue() && mlength.HasValue()) { | 123 if (mkey.HasValue() && mlength.HasValue()) { |
| 124 // Skip the typed array bounds check if key and length are constant. | 124 // Skip the typed array bounds check if key and length are constant. |
| 125 if (mkey.Value() < mlength.Value()) { | 125 if (mkey.Value() >= 0 && mkey.Value() < mlength.Value()) { |
| 126 access.bounds_check = kNoBoundsCheck; | 126 access.bounds_check = kNoBoundsCheck; |
| 127 node->set_op(simplified()->StoreElement(access)); | 127 node->set_op(simplified()->StoreElement(access)); |
| 128 return Changed(node); | 128 return Changed(node); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 break; | 132 break; |
| 133 } | 133 } |
| 134 default: | 134 default: |
| 135 break; | 135 break; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 | 175 |
| 176 | 176 |
| 177 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { | 177 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { |
| 178 return jsgraph()->machine(); | 178 return jsgraph()->machine(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 } // namespace compiler | 181 } // namespace compiler |
| 182 } // namespace internal | 182 } // namespace internal |
| 183 } // namespace v8 | 183 } // namespace v8 |
| OLD | NEW |