Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: test/unittests/compiler/js-builtin-reducer-unittest.cc

Issue 990963003: [turbofan] Unify Math.floor / Math.ceil optimization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 230
231 TEST_F(JSBuiltinReducerTest, MathFloorAvailable) { 231 TEST_F(JSBuiltinReducerTest, MathFloorAvailable) {
232 Handle<JSFunction> f = MathFunction("floor"); 232 Handle<JSFunction> f = MathFunction("floor");
233 233
234 TRACED_FOREACH(Type*, t0, kNumberTypes) { 234 TRACED_FOREACH(Type*, t0, kNumberTypes) {
235 Node* p0 = Parameter(t0, 0); 235 Node* p0 = Parameter(t0, 0);
236 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f)); 236 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f));
237 Node* call = 237 Node* call =
238 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), 238 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS),
239 fun, UndefinedConstant(), p0); 239 fun, UndefinedConstant(), p0);
240 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kFloat64Floor); 240 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kFloat64RoundDown);
241 241
242 ASSERT_TRUE(r.Changed()); 242 ASSERT_TRUE(r.Changed());
243 EXPECT_THAT(r.replacement(), IsFloat64Floor(p0)); 243 EXPECT_THAT(r.replacement(), IsFloat64RoundDown(p0));
244 } 244 }
245 } 245 }
246 246
247 247
248 TEST_F(JSBuiltinReducerTest, MathFloorUnavailable) { 248 TEST_F(JSBuiltinReducerTest, MathFloorUnavailable) {
249 Handle<JSFunction> f = MathFunction("floor"); 249 Handle<JSFunction> f = MathFunction("floor");
250 250
251 TRACED_FOREACH(Type*, t0, kNumberTypes) { 251 TRACED_FOREACH(Type*, t0, kNumberTypes) {
252 Node* p0 = Parameter(t0, 0); 252 Node* p0 = Parameter(t0, 0);
253 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f)); 253 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f));
254 Node* call = 254 Node* call =
255 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), 255 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS),
256 fun, UndefinedConstant(), p0); 256 fun, UndefinedConstant(), p0);
257 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kNoFlags); 257 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kNoFlags);
258 258
259 ASSERT_FALSE(r.Changed()); 259 ASSERT_FALSE(r.Changed());
260 } 260 }
261 } 261 }
262 262
263
264 // -----------------------------------------------------------------------------
265 // Math.ceil
266
267
268 TEST_F(JSBuiltinReducerTest, MathCeilAvailable) {
269 Handle<JSFunction> f = MathFunction("ceil");
270
271 TRACED_FOREACH(Type*, t0, kNumberTypes) {
272 Node* p0 = Parameter(t0, 0);
273 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f));
274 Node* call =
275 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS),
276 fun, UndefinedConstant(), p0);
277 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kFloat64Ceil);
278
279 ASSERT_TRUE(r.Changed());
280 EXPECT_THAT(r.replacement(), IsFloat64Ceil(p0));
281 }
282 }
283
284
285 TEST_F(JSBuiltinReducerTest, MathCeilUnavailable) {
286 Handle<JSFunction> f = MathFunction("ceil");
287
288 TRACED_FOREACH(Type*, t0, kNumberTypes) {
289 Node* p0 = Parameter(t0, 0);
290 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f));
291 Node* call =
292 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS),
293 fun, UndefinedConstant(), p0);
294 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kNoFlags);
295
296 ASSERT_FALSE(r.Changed());
297 }
298 }
299 } // namespace compiler 263 } // namespace compiler
300 } // namespace internal 264 } // namespace internal
301 } // namespace v8 265 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-machops.cc ('k') | test/unittests/compiler/machine-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698