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