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" | 5 #include "src/compiler/js-builtin-reducer.h" |
6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
7 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
8 #include "src/compiler/typer.h" | 8 #include "src/compiler/typer.h" |
9 #include "test/unittests/compiler/graph-unittest.h" | 9 #include "test/unittests/compiler/graph-unittest.h" |
10 #include "test/unittests/compiler/node-test-utils.h" | 10 #include "test/unittests/compiler/node-test-utils.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 Node* call = | 216 Node* call = |
217 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), | 217 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), |
218 fun, UndefinedConstant(), p0); | 218 fun, UndefinedConstant(), p0); |
219 Reduction r = Reduce(call); | 219 Reduction r = Reduce(call); |
220 | 220 |
221 ASSERT_TRUE(r.Changed()); | 221 ASSERT_TRUE(r.Changed()); |
222 EXPECT_THAT(r.replacement(), IsTruncateFloat64ToFloat32(p0)); | 222 EXPECT_THAT(r.replacement(), IsTruncateFloat64ToFloat32(p0)); |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 | |
227 // ----------------------------------------------------------------------------- | |
228 // Math.floor | |
229 | |
230 | |
231 TEST_F(JSBuiltinReducerTest, MathFloorAvailable) { | |
232 Handle<JSFunction> f = MathFunction("floor"); | |
233 | |
234 TRACED_FOREACH(Type*, t0, kNumberTypes) { | |
235 Node* p0 = Parameter(t0, 0); | |
236 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f)); | |
237 Node* call = | |
238 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), | |
239 fun, UndefinedConstant(), p0); | |
240 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kFloat64RoundDown); | |
241 | |
242 ASSERT_TRUE(r.Changed()); | |
243 EXPECT_THAT(r.replacement(), IsFloat64RoundDown(p0)); | |
244 } | |
245 } | |
246 | |
247 | |
248 TEST_F(JSBuiltinReducerTest, MathFloorUnavailable) { | |
249 Handle<JSFunction> f = MathFunction("floor"); | |
250 | |
251 TRACED_FOREACH(Type*, t0, kNumberTypes) { | |
252 Node* p0 = Parameter(t0, 0); | |
253 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f)); | |
254 Node* call = | |
255 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), | |
256 fun, UndefinedConstant(), p0); | |
257 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kNoFlags); | |
258 | |
259 ASSERT_FALSE(r.Changed()); | |
260 } | |
261 } | |
262 | |
263 } // namespace compiler | 226 } // namespace compiler |
264 } // namespace internal | 227 } // namespace internal |
265 } // namespace v8 | 228 } // namespace v8 |
OLD | NEW |