| Index: test/unittests/compiler/js-typed-lowering-unittest.cc
|
| diff --git a/test/unittests/compiler/js-typed-lowering-unittest.cc b/test/unittests/compiler/js-typed-lowering-unittest.cc
|
| index 8748bebd6d8c01d657cb2931fc57fe4961e7fb15..765f18fbc3f994d093421b3e6d6441c60cc47fe9 100644
|
| --- a/test/unittests/compiler/js-typed-lowering-unittest.cc
|
| +++ b/test/unittests/compiler/js-typed-lowering-unittest.cc
|
| @@ -845,6 +845,43 @@
|
| }
|
|
|
| // -----------------------------------------------------------------------------
|
| +// JSInstanceOf
|
| +// Test that instanceOf is reduced if and only if the right-hand side is a
|
| +// function constant. Functional correctness is ensured elsewhere.
|
| +
|
| +TEST_F(JSTypedLoweringTest, JSInstanceOfSpecialization) {
|
| + Node* const context = Parameter(Type::Any());
|
| + Node* const frame_state = EmptyFrameState();
|
| + Node* const effect = graph()->start();
|
| + Node* const control = graph()->start();
|
| +
|
| + Node* instanceOf =
|
| + graph()->NewNode(javascript()->InstanceOf(), Parameter(Type::Any(), 0),
|
| + HeapConstant(isolate()->object_function()), context,
|
| + frame_state, effect, control);
|
| + Reduction r = Reduce(instanceOf);
|
| + ASSERT_TRUE(r.Changed());
|
| +}
|
| +
|
| +
|
| +TEST_F(JSTypedLoweringTest, JSInstanceOfNoSpecialization) {
|
| + Node* const context = Parameter(Type::Any());
|
| + Node* const frame_state = EmptyFrameState();
|
| + Node* const effect = graph()->start();
|
| + Node* const control = graph()->start();
|
| +
|
| + // Do not reduce if right-hand side is not a function constant.
|
| + Node* instanceOf = graph()->NewNode(
|
| + javascript()->InstanceOf(), Parameter(Type::Any(), 0),
|
| + Parameter(Type::Any()), context, frame_state, effect, control);
|
| + Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context,
|
| + frame_state, effect, control);
|
| + Reduction r = Reduce(instanceOf);
|
| + ASSERT_FALSE(r.Changed());
|
| + ASSERT_EQ(instanceOf, dummy->InputAt(0));
|
| +}
|
| +
|
| +// -----------------------------------------------------------------------------
|
| // JSBitwiseAnd
|
|
|
| TEST_F(JSTypedLoweringTest, JSBitwiseAndWithSignedSmallHint) {
|
|
|