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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 ASSERT_TRUE(r.Changed()); | 165 ASSERT_TRUE(r.Changed()); |
166 EXPECT_THAT(r.replacement(), IsInt32Mul(p0, p1)); | 166 EXPECT_THAT(r.replacement(), IsInt32Mul(p0, p1)); |
167 } else { | 167 } else { |
168 ASSERT_FALSE(r.Changed()); | 168 ASSERT_FALSE(r.Changed()); |
169 EXPECT_EQ(IrOpcode::kJSCallFunction, call->opcode()); | 169 EXPECT_EQ(IrOpcode::kJSCallFunction, call->opcode()); |
170 } | 170 } |
171 } | 171 } |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 | |
176 // ----------------------------------------------------------------------------- | |
177 // Math.fround | |
178 | |
179 | |
180 TEST_F(JSBuiltinReducerTest, MathFround) { | |
181 Handle<Object> m = | |
182 JSObject::GetProperty(isolate()->global_object(), | |
183 isolate()->factory()->NewStringFromAsciiChecked( | |
184 "Math")).ToHandleChecked(); | |
185 Handle<JSFunction> f = Handle<JSFunction>::cast( | |
186 JSObject::GetProperty(m, isolate()->factory()->NewStringFromAsciiChecked( | |
187 "fround")).ToHandleChecked()); | |
188 | |
189 TRACED_FOREACH(Type*, t0, kNumberTypes) { | |
190 Node* p0 = Parameter(t0, 0); | |
191 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f)); | |
192 Node* call = graph()->NewNode(javascript()->Call(3, NO_CALL_FUNCTION_FLAGS), | |
193 fun, UndefinedConstant(), p0); | |
194 Reduction r = Reduce(call); | |
195 | |
196 EXPECT_TRUE(r.Changed()); | |
Benedikt Meurer
2014/09/24 11:37:51
Nit: ASSERT_TRUE
Michael Starzinger
2014/09/24 13:12:25
Done.
| |
197 EXPECT_THAT(r.replacement(), IsTruncateFloat64ToFloat32(p0)); | |
198 } | |
199 } | |
200 | |
175 } // namespace compiler | 201 } // namespace compiler |
176 } // namespace internal | 202 } // namespace internal |
177 } // namespace v8 | 203 } // namespace v8 |
OLD | NEW |