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

Unified Diff: test/unittests/compiler/js-typed-lowering-unittest.cc

Issue 2365223003: Revert of [compiler] Properly guard the speculative optimizations for instanceof. (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/compiler/deopt-instanceof-proxy.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « test/mjsunit/compiler/deopt-instanceof-proxy.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698