Request for review (M): 7171890: C1: add Class.isInstance intrinsic

John Rose john.r.rose at oracle.com
Thu May 31 17:20:18 PDT 2012


On May 31, 2012, at 3:05 PM, Christian Thalinger wrote:

> The problem why we don't see a much bigger improvement is that most of the time (I'd say 99% of the time) Class.cast isn't inlined in C1 because it's too big, e.g.:

That looks like a marginal effect, where Class::cast is just slightly too large.

We should remove the effect of NestedInliningSizeRatio on our inlining adapters.

We could also clean up Class::cast to take it down to about 20 bytecodes; see below.

Still, it's amazing that a JNI call taking 80% of execution time disappears, but takes away only 9% of the runtime.

— John

diff --git a/src/share/classes/java/lang/Class.java b/src/share/classes/java/lang/Class.java
--- a/src/share/classes/java/lang/Class.java
+++ b/src/share/classes/java/lang/Class.java
@@ -3004,12 +3004,12 @@
     @SuppressWarnings("unchecked")
     public T cast(Object obj) {
         if (obj != null && !isInstance(obj))
-            throw new ClassCastException(cannotCastMsg(obj));
+            throw cannotCastException(obj);
         return (T) obj;
     }
 
-    private String cannotCastMsg(Object obj) {
-        return "Cannot cast " + obj.getClass().getName() + " to " + getName();
+    private ClassCastException cannotCastException(Object obj) {
+        return new ClassCastException("Cannot cast " + obj.getClass().getName() + " to " + getName());
     }
 
     /**

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20120531/1a196c2b/attachment.html 


More information about the hotspot-compiler-dev mailing list