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

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

Issue 2077533002: [builtins] Introduce proper Float64Exp operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Import tests from Raymond. Created 4 years, 6 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/simplified-operator.h" 8 #include "src/compiler/simplified-operator.h"
9 #include "src/compiler/typer.h" 9 #include "src/compiler/typer.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 UndefinedConstant(), p0, context, frame_state, 257 UndefinedConstant(), p0, context, frame_state,
258 effect, control); 258 effect, control);
259 Reduction r = Reduce(call); 259 Reduction r = Reduce(call);
260 260
261 ASSERT_TRUE(r.Changed()); 261 ASSERT_TRUE(r.Changed());
262 EXPECT_THAT(r.replacement(), 262 EXPECT_THAT(r.replacement(),
263 IsNumberClz32(IsNumberToUint32(IsPlainPrimitiveToNumber(p0)))); 263 IsNumberClz32(IsNumberToUint32(IsPlainPrimitiveToNumber(p0))));
264 } 264 }
265 265
266 // ----------------------------------------------------------------------------- 266 // -----------------------------------------------------------------------------
267 // Math.exp
268
269 TEST_F(JSBuiltinReducerTest, MathExpWithNumber) {
270 Node* function = MathFunction("exp");
271
272 Node* effect = graph()->start();
273 Node* control = graph()->start();
274 Node* context = UndefinedConstant();
275 Node* frame_state = graph()->start();
276 TRACED_FOREACH(Type*, t0, kNumberTypes) {
277 Node* p0 = Parameter(t0, 0);
278 Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
279 UndefinedConstant(), p0, context, frame_state,
280 effect, control);
281 Reduction r = Reduce(call);
282
283 ASSERT_TRUE(r.Changed());
284 EXPECT_THAT(r.replacement(), IsNumberExp(p0));
285 }
286 }
287
288 TEST_F(JSBuiltinReducerTest, MathExpWithPlainPrimitive) {
289 Node* function = MathFunction("exp");
290
291 Node* effect = graph()->start();
292 Node* control = graph()->start();
293 Node* context = UndefinedConstant();
294 Node* frame_state = graph()->start();
295 Node* p0 = Parameter(Type::PlainPrimitive(), 0);
296 Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
297 UndefinedConstant(), p0, context, frame_state,
298 effect, control);
299 Reduction r = Reduce(call);
300
301 ASSERT_TRUE(r.Changed());
302 EXPECT_THAT(r.replacement(), IsNumberExp(IsPlainPrimitiveToNumber(p0)));
303 }
304
305 // -----------------------------------------------------------------------------
267 // Math.floor 306 // Math.floor
268 307
269 TEST_F(JSBuiltinReducerTest, MathFloorWithNumber) { 308 TEST_F(JSBuiltinReducerTest, MathFloorWithNumber) {
270 Node* function = MathFunction("floor"); 309 Node* function = MathFunction("floor");
271 310
272 Node* effect = graph()->start(); 311 Node* effect = graph()->start();
273 Node* control = graph()->start(); 312 Node* control = graph()->start();
274 Node* context = UndefinedConstant(); 313 Node* context = UndefinedConstant();
275 Node* frame_state = graph()->start(); 314 Node* frame_state = graph()->start();
276 TRACED_FOREACH(Type*, t0, kNumberTypes) { 315 TRACED_FOREACH(Type*, t0, kNumberTypes) {
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 Reduction r = Reduce(call); 827 Reduction r = Reduce(call);
789 828
790 ASSERT_TRUE(r.Changed()); 829 ASSERT_TRUE(r.Changed());
791 EXPECT_THAT(r.replacement(), 830 EXPECT_THAT(r.replacement(),
792 IsStringFromCharCode(IsPlainPrimitiveToNumber(p0))); 831 IsStringFromCharCode(IsPlainPrimitiveToNumber(p0)));
793 } 832 }
794 833
795 } // namespace compiler 834 } // namespace compiler
796 } // namespace internal 835 } // namespace internal
797 } // namespace v8 836 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698