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

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

Issue 2083573002: [builtins] Unify Cosh, Sinh and Tanh as exports from flibm (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE and windows fix. Created 4 years, 5 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 Node* call = graph()->NewNode(javascript()->CallFunction(3), function, 335 Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
336 UndefinedConstant(), p0, context, frame_state, 336 UndefinedConstant(), p0, context, frame_state,
337 effect, control); 337 effect, control);
338 Reduction r = Reduce(call); 338 Reduction r = Reduce(call);
339 339
340 ASSERT_TRUE(r.Changed()); 340 ASSERT_TRUE(r.Changed());
341 EXPECT_THAT(r.replacement(), IsNumberCos(IsPlainPrimitiveToNumber(p0))); 341 EXPECT_THAT(r.replacement(), IsNumberCos(IsPlainPrimitiveToNumber(p0)));
342 } 342 }
343 343
344 // ----------------------------------------------------------------------------- 344 // -----------------------------------------------------------------------------
345 // Math.cosh
346
347 TEST_F(JSBuiltinReducerTest, MathCoshWithNumber) {
348 Node* function = MathFunction("cosh");
349
350 Node* effect = graph()->start();
351 Node* control = graph()->start();
352 Node* context = UndefinedConstant();
353 Node* frame_state = graph()->start();
354 TRACED_FOREACH(Type*, t0, kNumberTypes) {
355 Node* p0 = Parameter(t0, 0);
356 Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
357 UndefinedConstant(), p0, context, frame_state,
358 effect, control);
359 Reduction r = Reduce(call);
360
361 ASSERT_TRUE(r.Changed());
362 EXPECT_THAT(r.replacement(), IsNumberCosh(p0));
363 }
364 }
365
366 TEST_F(JSBuiltinReducerTest, MathCoshWithPlainPrimitive) {
367 Node* function = MathFunction("cosh");
368
369 Node* effect = graph()->start();
370 Node* control = graph()->start();
371 Node* context = UndefinedConstant();
372 Node* frame_state = graph()->start();
373 Node* p0 = Parameter(Type::PlainPrimitive(), 0);
374 Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
375 UndefinedConstant(), p0, context, frame_state,
376 effect, control);
377 Reduction r = Reduce(call);
378
379 ASSERT_TRUE(r.Changed());
380 EXPECT_THAT(r.replacement(), IsNumberCosh(IsPlainPrimitiveToNumber(p0)));
381 }
382
383 // -----------------------------------------------------------------------------
345 // Math.exp 384 // Math.exp
346 385
347 TEST_F(JSBuiltinReducerTest, MathExpWithNumber) { 386 TEST_F(JSBuiltinReducerTest, MathExpWithNumber) {
348 Node* function = MathFunction("exp"); 387 Node* function = MathFunction("exp");
349 388
350 Node* effect = graph()->start(); 389 Node* effect = graph()->start();
351 Node* control = graph()->start(); 390 Node* control = graph()->start();
352 Node* context = UndefinedConstant(); 391 Node* context = UndefinedConstant();
353 Node* frame_state = graph()->start(); 392 Node* frame_state = graph()->start();
354 TRACED_FOREACH(Type*, t0, kNumberTypes) { 393 TRACED_FOREACH(Type*, t0, kNumberTypes) {
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 Node* call = graph()->NewNode(javascript()->CallFunction(3), function, 907 Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
869 UndefinedConstant(), p0, context, frame_state, 908 UndefinedConstant(), p0, context, frame_state,
870 effect, control); 909 effect, control);
871 Reduction r = Reduce(call); 910 Reduction r = Reduce(call);
872 911
873 ASSERT_TRUE(r.Changed()); 912 ASSERT_TRUE(r.Changed());
874 EXPECT_THAT(r.replacement(), IsNumberSin(IsPlainPrimitiveToNumber(p0))); 913 EXPECT_THAT(r.replacement(), IsNumberSin(IsPlainPrimitiveToNumber(p0)));
875 } 914 }
876 915
877 // ----------------------------------------------------------------------------- 916 // -----------------------------------------------------------------------------
917 // Math.sinh
918
919 TEST_F(JSBuiltinReducerTest, MathSinhWithNumber) {
920 Node* function = MathFunction("sinh");
921
922 Node* effect = graph()->start();
923 Node* control = graph()->start();
924 Node* context = UndefinedConstant();
925 Node* frame_state = graph()->start();
926 TRACED_FOREACH(Type*, t0, kNumberTypes) {
927 Node* p0 = Parameter(t0, 0);
928 Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
929 UndefinedConstant(), p0, context, frame_state,
930 effect, control);
931 Reduction r = Reduce(call);
932
933 ASSERT_TRUE(r.Changed());
934 EXPECT_THAT(r.replacement(), IsNumberSinh(p0));
935 }
936 }
937
938 TEST_F(JSBuiltinReducerTest, MathSinhWithPlainPrimitive) {
939 Node* function = MathFunction("sinh");
940
941 Node* effect = graph()->start();
942 Node* control = graph()->start();
943 Node* context = UndefinedConstant();
944 Node* frame_state = graph()->start();
945 Node* p0 = Parameter(Type::PlainPrimitive(), 0);
946 Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
947 UndefinedConstant(), p0, context, frame_state,
948 effect, control);
949 Reduction r = Reduce(call);
950
951 ASSERT_TRUE(r.Changed());
952 EXPECT_THAT(r.replacement(), IsNumberSinh(IsPlainPrimitiveToNumber(p0)));
953 }
954
955 // -----------------------------------------------------------------------------
878 // Math.sqrt 956 // Math.sqrt
879 957
880 TEST_F(JSBuiltinReducerTest, MathSqrtWithNumber) { 958 TEST_F(JSBuiltinReducerTest, MathSqrtWithNumber) {
881 Node* function = MathFunction("sqrt"); 959 Node* function = MathFunction("sqrt");
882 960
883 Node* effect = graph()->start(); 961 Node* effect = graph()->start();
884 Node* control = graph()->start(); 962 Node* control = graph()->start();
885 Node* context = UndefinedConstant(); 963 Node* context = UndefinedConstant();
886 Node* frame_state = graph()->start(); 964 Node* frame_state = graph()->start();
887 TRACED_FOREACH(Type*, t0, kNumberTypes) { 965 TRACED_FOREACH(Type*, t0, kNumberTypes) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 Node* call = graph()->NewNode(javascript()->CallFunction(3), function, 1024 Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
947 UndefinedConstant(), p0, context, frame_state, 1025 UndefinedConstant(), p0, context, frame_state,
948 effect, control); 1026 effect, control);
949 Reduction r = Reduce(call); 1027 Reduction r = Reduce(call);
950 1028
951 ASSERT_TRUE(r.Changed()); 1029 ASSERT_TRUE(r.Changed());
952 EXPECT_THAT(r.replacement(), IsNumberTan(IsPlainPrimitiveToNumber(p0))); 1030 EXPECT_THAT(r.replacement(), IsNumberTan(IsPlainPrimitiveToNumber(p0)));
953 } 1031 }
954 1032
955 // ----------------------------------------------------------------------------- 1033 // -----------------------------------------------------------------------------
1034 // Math.tanh
1035
1036 TEST_F(JSBuiltinReducerTest, MathTanhWithNumber) {
1037 Node* function = MathFunction("tanh");
1038
1039 Node* effect = graph()->start();
1040 Node* control = graph()->start();
1041 Node* context = UndefinedConstant();
1042 Node* frame_state = graph()->start();
1043 TRACED_FOREACH(Type*, t0, kNumberTypes) {
1044 Node* p0 = Parameter(t0, 0);
1045 Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
1046 UndefinedConstant(), p0, context, frame_state,
1047 effect, control);
1048 Reduction r = Reduce(call);
1049
1050 ASSERT_TRUE(r.Changed());
1051 EXPECT_THAT(r.replacement(), IsNumberTanh(p0));
1052 }
1053 }
1054
1055 TEST_F(JSBuiltinReducerTest, MathTanhWithPlainPrimitive) {
1056 Node* function = MathFunction("tanh");
1057
1058 Node* effect = graph()->start();
1059 Node* control = graph()->start();
1060 Node* context = UndefinedConstant();
1061 Node* frame_state = graph()->start();
1062 Node* p0 = Parameter(Type::PlainPrimitive(), 0);
1063 Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
1064 UndefinedConstant(), p0, context, frame_state,
1065 effect, control);
1066 Reduction r = Reduce(call);
1067
1068 ASSERT_TRUE(r.Changed());
1069 EXPECT_THAT(r.replacement(), IsNumberTanh(IsPlainPrimitiveToNumber(p0)));
1070 }
1071
1072 // -----------------------------------------------------------------------------
956 // Math.trunc 1073 // Math.trunc
957 1074
958 TEST_F(JSBuiltinReducerTest, MathTruncWithNumber) { 1075 TEST_F(JSBuiltinReducerTest, MathTruncWithNumber) {
959 Node* function = MathFunction("trunc"); 1076 Node* function = MathFunction("trunc");
960 1077
961 Node* effect = graph()->start(); 1078 Node* effect = graph()->start();
962 Node* control = graph()->start(); 1079 Node* control = graph()->start();
963 Node* context = UndefinedConstant(); 1080 Node* context = UndefinedConstant();
964 Node* frame_state = graph()->start(); 1081 Node* frame_state = graph()->start();
965 TRACED_FOREACH(Type*, t0, kNumberTypes) { 1082 TRACED_FOREACH(Type*, t0, kNumberTypes) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 Reduction r = Reduce(call); 1144 Reduction r = Reduce(call);
1028 1145
1029 ASSERT_TRUE(r.Changed()); 1146 ASSERT_TRUE(r.Changed());
1030 EXPECT_THAT(r.replacement(), 1147 EXPECT_THAT(r.replacement(),
1031 IsStringFromCharCode(IsPlainPrimitiveToNumber(p0))); 1148 IsStringFromCharCode(IsPlainPrimitiveToNumber(p0)));
1032 } 1149 }
1033 1150
1034 } // namespace compiler 1151 } // namespace compiler
1035 } // namespace internal 1152 } // namespace internal
1036 } // namespace v8 1153 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/base/ieee754-unittest.cc ('k') | test/unittests/compiler/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698