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

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

Issue 605123004: Extend JSBuiltinReducer to cover Math.abs as well. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments. Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/js-builtin-reducer.cc ('k') | test/mjsunit/asm/math-abs.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/graph-unittest.h" 5 #include "src/compiler/graph-unittest.h"
6 #include "src/compiler/js-builtin-reducer.h" 6 #include "src/compiler/js-builtin-reducer.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/node-properties-inl.h" 8 #include "src/compiler/node-properties-inl.h"
9 #include "src/compiler/typer.h" 9 #include "src/compiler/typer.h"
10 #include "testing/gmock-support.h" 10 #include "testing/gmock-support.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 Type::UnsignedSmall(), Type::OtherSignedSmall(), Type::OtherUnsigned31(), 53 Type::UnsignedSmall(), Type::OtherSignedSmall(), Type::OtherUnsigned31(),
54 Type::OtherUnsigned32(), Type::OtherSigned32(), Type::SignedSmall(), 54 Type::OtherUnsigned32(), Type::OtherSigned32(), Type::SignedSmall(),
55 Type::Signed32(), Type::Unsigned32(), Type::Integral32(), 55 Type::Signed32(), Type::Unsigned32(), Type::Integral32(),
56 Type::MinusZero(), Type::NaN(), Type::OtherNumber(), 56 Type::MinusZero(), Type::NaN(), Type::OtherNumber(),
57 Type::OrderedNumber(), Type::Number()}; 57 Type::OrderedNumber(), Type::Number()};
58 58
59 } // namespace 59 } // namespace
60 60
61 61
62 // ----------------------------------------------------------------------------- 62 // -----------------------------------------------------------------------------
63 // Math.abs
64
65
66 TEST_F(JSBuiltinReducerTest, MathAbs) {
67 Handle<JSFunction> f(isolate()->context()->math_abs_fun());
68
69 TRACED_FOREACH(Type*, t0, kNumberTypes) {
70 Node* p0 = Parameter(t0, 0);
71 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f));
72 Node* call = graph()->NewNode(javascript()->Call(3, NO_CALL_FUNCTION_FLAGS),
73 fun, UndefinedConstant(), p0);
74 Reduction r = Reduce(call);
75
76 if (t0->Is(Type::Unsigned32())) {
77 ASSERT_TRUE(r.Changed());
78 EXPECT_THAT(r.replacement(), p0);
79 } else {
80 Capture<Node*> branch;
81 ASSERT_TRUE(r.Changed());
82 EXPECT_THAT(
83 r.replacement(),
84 IsPhi(kMachNone, p0, IsNumberSubtract(IsNumberConstant(0), p0),
85 IsMerge(IsIfTrue(CaptureEq(&branch)),
86 IsIfFalse(AllOf(
87 CaptureEq(&branch),
88 IsBranch(IsNumberLessThan(IsNumberConstant(0), p0),
89 graph()->start()))))));
90 }
91 }
92 }
93
94
95 // -----------------------------------------------------------------------------
63 // Math.sqrt 96 // Math.sqrt
64 97
65 98
66 TEST_F(JSBuiltinReducerTest, MathSqrt) { 99 TEST_F(JSBuiltinReducerTest, MathSqrt) {
67 Handle<JSFunction> f(isolate()->context()->math_sqrt_fun()); 100 Handle<JSFunction> f(isolate()->context()->math_sqrt_fun());
68 101
69 TRACED_FOREACH(Type*, t0, kNumberTypes) { 102 TRACED_FOREACH(Type*, t0, kNumberTypes) {
70 Node* p0 = Parameter(t0, 0); 103 Node* p0 = Parameter(t0, 0);
71 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f)); 104 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f));
72 Node* call = graph()->NewNode(javascript()->Call(3, NO_CALL_FUNCTION_FLAGS), 105 Node* call = graph()->NewNode(javascript()->Call(3, NO_CALL_FUNCTION_FLAGS),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 Reduction r = Reduce(call); 227 Reduction r = Reduce(call);
195 228
196 ASSERT_TRUE(r.Changed()); 229 ASSERT_TRUE(r.Changed());
197 EXPECT_THAT(r.replacement(), IsTruncateFloat64ToFloat32(p0)); 230 EXPECT_THAT(r.replacement(), IsTruncateFloat64ToFloat32(p0));
198 } 231 }
199 } 232 }
200 233
201 } // namespace compiler 234 } // namespace compiler
202 } // namespace internal 235 } // namespace internal
203 } // namespace v8 236 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-builtin-reducer.cc ('k') | test/mjsunit/asm/math-abs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698