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-builtin-reducer.h" | |
6 | |
7 #include <limits> | |
8 | |
9 #include "src/compiler/diamond.h" | 5 #include "src/compiler/diamond.h" |
10 #include "src/compiler/graph-inl.h" | 6 #include "src/compiler/graph-inl.h" |
| 7 #include "src/compiler/js-builtin-reducer.h" |
11 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
12 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
13 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
14 #include "src/types.h" | 11 #include "src/types.h" |
15 | 12 |
16 namespace v8 { | 13 namespace v8 { |
17 namespace internal { | 14 namespace internal { |
18 namespace compiler { | 15 namespace compiler { |
19 | 16 |
20 | 17 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 131 } |
135 return NoChange(); | 132 return NoChange(); |
136 } | 133 } |
137 | 134 |
138 | 135 |
139 // ECMA-262, section 15.8.2.11. | 136 // ECMA-262, section 15.8.2.11. |
140 Reduction JSBuiltinReducer::ReduceMathMax(Node* node) { | 137 Reduction JSBuiltinReducer::ReduceMathMax(Node* node) { |
141 JSCallReduction r(node); | 138 JSCallReduction r(node); |
142 if (r.InputsMatchZero()) { | 139 if (r.InputsMatchZero()) { |
143 // Math.max() -> -Infinity | 140 // Math.max() -> -Infinity |
144 return Replace( | 141 return Replace(jsgraph()->Constant(-V8_INFINITY)); |
145 jsgraph()->Constant(-std::numeric_limits<double>::infinity())); | |
146 } | 142 } |
147 if (r.InputsMatchOne(Type::Number())) { | 143 if (r.InputsMatchOne(Type::Number())) { |
148 // Math.max(a:number) -> a | 144 // Math.max(a:number) -> a |
149 return Replace(r.left()); | 145 return Replace(r.left()); |
150 } | 146 } |
151 if (r.InputsMatchAll(Type::Integral32())) { | 147 if (r.InputsMatchAll(Type::Integral32())) { |
152 // Math.max(a:int32, b:int32, ...) | 148 // Math.max(a:int32, b:int32, ...) |
153 Node* value = r.GetJSCallInput(0); | 149 Node* value = r.GetJSCallInput(0); |
154 for (int i = 1; i < r.GetJSCallArity(); i++) { | 150 for (int i = 1; i < r.GetJSCallArity(); i++) { |
155 Node* const input = r.GetJSCallInput(i); | 151 Node* const input = r.GetJSCallInput(i); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 246 } |
251 | 247 |
252 | 248 |
253 MachineOperatorBuilder* JSBuiltinReducer::machine() const { | 249 MachineOperatorBuilder* JSBuiltinReducer::machine() const { |
254 return jsgraph()->machine(); | 250 return jsgraph()->machine(); |
255 } | 251 } |
256 | 252 |
257 } // namespace compiler | 253 } // namespace compiler |
258 } // namespace internal | 254 } // namespace internal |
259 } // namespace v8 | 255 } // namespace v8 |
OLD | NEW |