Chromium Code Reviews| 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/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 Loading... | |
| 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.sqrt | |
| 64 | |
| 65 | |
| 66 TEST_F(JSBuiltinReducerTest, MathSqrt) { | |
| 67 Handle<JSFunction> f(isolate()->context()->math_sqrt_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 EXPECT_TRUE(r.Changed()); | |
|
Benedikt Meurer
2014/09/24 06:34:43
Nit: use ASSERT_TRUE, doesn't make sense to do the
Michael Starzinger
2014/09/24 08:20:51
Done, here and at all occurrences below.
| |
| 77 EXPECT_THAT(r.replacement(), IsFloat64Sqrt(p0)); | |
| 78 } | |
| 79 } | |
| 80 | |
| 81 | |
| 82 // ----------------------------------------------------------------------------- | |
| 63 // Math.max | 83 // Math.max |
| 64 | 84 |
| 65 | 85 |
| 66 TEST_F(JSBuiltinReducerTest, MathMax0) { | 86 TEST_F(JSBuiltinReducerTest, MathMax0) { |
| 67 Handle<JSFunction> f(isolate()->context()->math_max_fun()); | 87 Handle<JSFunction> f(isolate()->context()->math_max_fun()); |
| 68 | 88 |
| 69 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f)); | 89 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f)); |
| 70 Node* call = graph()->NewNode(javascript()->Call(2, NO_CALL_FUNCTION_FLAGS), | 90 Node* call = graph()->NewNode(javascript()->Call(2, NO_CALL_FUNCTION_FLAGS), |
| 71 fun, UndefinedConstant()); | 91 fun, UndefinedConstant()); |
| 72 Reduction r = Reduce(call); | 92 Reduction r = Reduce(call); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 EXPECT_FALSE(r.Changed()); | 168 EXPECT_FALSE(r.Changed()); |
| 149 EXPECT_EQ(IrOpcode::kJSCallFunction, call->opcode()); | 169 EXPECT_EQ(IrOpcode::kJSCallFunction, call->opcode()); |
| 150 } | 170 } |
| 151 } | 171 } |
| 152 } | 172 } |
| 153 } | 173 } |
| 154 | 174 |
| 155 } // namespace compiler | 175 } // namespace compiler |
| 156 } // namespace internal | 176 } // namespace internal |
| 157 } // namespace v8 | 177 } // namespace v8 |
| OLD | NEW |