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/js-graph.h" | 5 #include "src/compiler/js-graph.h" |
6 #include "src/compiler/machine-operator.h" | 6 #include "src/compiler/machine-operator.h" |
7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
8 #include "src/compiler/simplified-operator-reducer.h" | 8 #include "src/compiler/simplified-operator-reducer.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 m.node()->InputAt(0)); | 91 m.node()->InputAt(0)); |
92 } | 92 } |
93 if (m.IsChangeUint32ToTagged()) return Replace(m.node()->InputAt(0)); | 93 if (m.IsChangeUint32ToTagged()) return Replace(m.node()->InputAt(0)); |
94 break; | 94 break; |
95 } | 95 } |
96 case IrOpcode::kChangeUint32ToTagged: { | 96 case IrOpcode::kChangeUint32ToTagged: { |
97 Uint32Matcher m(node->InputAt(0)); | 97 Uint32Matcher m(node->InputAt(0)); |
98 if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value())); | 98 if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value())); |
99 break; | 99 break; |
100 } | 100 } |
101 case IrOpcode::kLoadElement: { | |
102 ElementAccess access = ElementAccessOf(node->op()); | |
103 if (access.bounds_check == kTypedArrayBoundsCheck) { | |
104 NumberMatcher mkey(node->InputAt(1)); | |
105 NumberMatcher mlength(node->InputAt(2)); | |
106 if (mkey.HasValue() && mlength.HasValue()) { | |
107 // Skip the typed array bounds check if key and length are constant. | |
108 if (mkey.Value() >= 0 && mkey.Value() < mlength.Value()) { | |
109 access.bounds_check = kNoBoundsCheck; | |
110 node->set_op(simplified()->LoadElement(access)); | |
111 return Changed(node); | |
112 } | |
113 } | |
114 } | |
115 break; | |
116 } | |
117 case IrOpcode::kStoreElement: { | |
118 ElementAccess access = ElementAccessOf(node->op()); | |
119 if (access.bounds_check == kTypedArrayBoundsCheck) { | |
120 NumberMatcher mkey(node->InputAt(1)); | |
121 NumberMatcher mlength(node->InputAt(2)); | |
122 if (mkey.HasValue() && mlength.HasValue()) { | |
123 // Skip the typed array bounds check if key and length are constant. | |
124 if (mkey.Value() >= 0 && mkey.Value() < mlength.Value()) { | |
125 access.bounds_check = kNoBoundsCheck; | |
126 node->set_op(simplified()->StoreElement(access)); | |
127 return Changed(node); | |
128 } | |
129 } | |
130 } | |
131 break; | |
132 } | |
133 default: | 101 default: |
134 break; | 102 break; |
135 } | 103 } |
136 return NoChange(); | 104 return NoChange(); |
137 } | 105 } |
138 | 106 |
139 | 107 |
140 Reduction SimplifiedOperatorReducer::Change(Node* node, const Operator* op, | 108 Reduction SimplifiedOperatorReducer::Change(Node* node, const Operator* op, |
141 Node* a) { | 109 Node* a) { |
142 node->set_op(op); | 110 node->set_op(op); |
(...skipping 30 matching lines...) Expand all Loading... |
173 } | 141 } |
174 | 142 |
175 | 143 |
176 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { | 144 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { |
177 return jsgraph()->machine(); | 145 return jsgraph()->machine(); |
178 } | 146 } |
179 | 147 |
180 } // namespace compiler | 148 } // namespace compiler |
181 } // namespace internal | 149 } // namespace internal |
182 } // namespace v8 | 150 } // namespace v8 |
OLD | NEW |