hotspot/src/share/vm/c1/c1_Canonicalizer.cpp
changeset 12949 e125ba4c16bd
parent 12947 ba8ba6c2dd83
child 12950 ab4f4afb3988
--- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp	Fri Jun 01 11:25:12 2012 -0700
+++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp	Tue Jun 05 10:15:27 2012 +0200
@@ -456,6 +456,28 @@
     }
     break;
   }
+  case vmIntrinsics::_isInstance          : {
+    assert(x->number_of_arguments() == 2, "wrong type");
+
+    InstanceConstant* c = x->argument_at(0)->type()->as_InstanceConstant();
+    if (c != NULL && !c->value()->is_null_object()) {
+      // ciInstance::java_mirror_type() returns non-NULL only for Java mirrors
+      ciType* t = c->value()->as_instance()->java_mirror_type();
+      if (t->is_klass()) {
+        // substitute cls.isInstance(obj) of a constant Class into
+        // an InstantOf instruction
+        InstanceOf* i = new InstanceOf(t->as_klass(), x->argument_at(1), x->state());
+        set_canonical(i);
+        // and try to canonicalize even further
+        do_InstanceOf(i);
+      } else {
+        assert(t->is_primitive_type(), "should be a primitive type");
+        // cls.isInstance(obj) always returns false for primitive classes
+        set_constant(0);
+      }
+    }
+    break;
+  }
   }
 }