changeset 2543:c58a301eb2d7

Clean up on canTrap.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Apr 2011 21:22:10 +0200
parents 0f9eeb15e636
children 84a2012f8cd1
files graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java graal/GraalCompiler/src/com/sun/c1x/ir/AccessIndexed.java graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java graal/GraalCompiler/src/com/sun/c1x/ir/MonitorEnter.java graal/GraalCompiler/src/com/sun/c1x/ir/MonitorExit.java graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java graal/GraalCompiler/src/com/sun/c1x/ir/NewInstance.java graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java graal/GraalCompiler/src/com/sun/c1x/ir/RegisterFinalizer.java graal/GraalCompiler/src/com/sun/c1x/ir/ResolveClass.java graal/GraalCompiler/src/com/sun/c1x/ir/StateSplit.java graal/GraalCompiler/src/com/sun/c1x/ir/StoreIndexed.java graal/GraalCompiler/src/com/sun/c1x/ir/TypeCheck.java graal/GraalRuntime/src/com/oracle/graal/runtime/HotSpotXirGenerator.java
diffstat 17 files changed, 8 insertions(+), 125 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Wed Apr 27 21:22:10 2011 +0200
@@ -1597,7 +1597,7 @@
         }
 
         public boolean requiresNullCheck() {
-            return current == null || current.canTrap();
+            return current == null || current instanceof InstanceOf || current instanceof CheckCast;//current.canTrap();
         }
 
         public boolean requiresBoundsCheck() {
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed Apr 27 21:22:10 2011 +0200
@@ -1272,7 +1272,7 @@
 
         if (x instanceof StateSplit) {
             StateSplit stateSplit = (StateSplit) x;
-            if (!stateSplit.isStateCleared() && stateSplit.stateBefore() == null) {
+            if (stateSplit.stateBefore() == null) {
                 stateSplit.setStateBefore(curState.immutableCopy(bci));
             }
         }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java	Wed Apr 27 21:22:10 2011 +0200
@@ -93,16 +93,6 @@
         return isLoaded() && Modifier.isVolatile(field.accessFlags());
     }
 
-    /**
-     * Checks whether this field access may cause a trap or an exception, which
-     * is if it either requires a null check or needs patching.
-     * @return {@code true} if this field access can cause a trap
-     */
-    @Override
-    public boolean canTrap() {
-        return true;
-    }
-
     @Override
     public void inputValuesDo(ValueClosure closure) {
         object = closure.apply(object);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/AccessIndexed.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/AccessIndexed.java	Wed Apr 27 21:22:10 2011 +0200
@@ -77,15 +77,6 @@
         return elementType;
     }
 
-    /**
-     * Checks whether this instruction can cause a trap.
-     * @return {@code true} if this instruction can cause a trap
-     */
-    @Override
-    public boolean canTrap() {
-        return true;
-    }
-
     @Override
     public void inputValuesDo(ValueClosure closure) {
         super.inputValuesDo(closure);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java	Wed Apr 27 21:22:10 2011 +0200
@@ -44,15 +44,6 @@
         super(CiKind.Int, array, newFrameState);
     }
 
-    /**
-     * Checks whether this instruction can cause a trap.
-     * @return {@code true} if this instruction can cause a trap
-     */
-    @Override
-    public boolean canTrap() {
-        return true;
-    }
-
     @Override
     public void accept(ValueVisitor v) {
         v.visitArrayLength(this);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java	Wed Apr 27 21:22:10 2011 +0200
@@ -105,15 +105,6 @@
     }
 
     /**
-     * Checks whether this instruction can trap.
-     * @return {@code true}, conservatively assuming the called method may throw an exception
-     */
-    @Override
-    public boolean canTrap() {
-        return true;
-    }
-
-    /**
      * Checks whether this invocation has a receiver object.
      * @return {@code true} if this invocation has a receiver object; {@code false} otherwise, if this is a
      *         static call
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorEnter.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorEnter.java	Wed Apr 27 21:22:10 2011 +0200
@@ -46,15 +46,6 @@
         super(object, lockAddress, stateBefore, lockNumber);
     }
 
-    /**
-     * Checks whether this instruction can trap.
-     * @return {@code true} if this instruction may raise a {@link NullPointerException}
-     */
-    @Override
-    public boolean canTrap() {
-        return true;
-    }
-
     @Override
     public void accept(ValueVisitor v) {
         v.visitMonitorEnter(this);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorExit.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorExit.java	Wed Apr 27 21:22:10 2011 +0200
@@ -45,11 +45,6 @@
     }
 
     @Override
-    public boolean canTrap() {
-        return true;
-    }
-
-    @Override
     public void accept(ValueVisitor v) {
         v.visitMonitorExit(this);
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java	Wed Apr 27 21:22:10 2011 +0200
@@ -54,16 +54,6 @@
     }
 
     /**
-     * Checks whether this instruction can trap.
-     * @return <code>true</code>, conservatively assuming that this instruction can throw such
-     * exceptions as {@code OutOfMemoryError}
-     */
-    @Override
-    public boolean canTrap() {
-        return true;
-    }
-
-    /**
      * Applies the specified closure to all input values of this instruction.
      * @param closure the closure to apply
      */
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/NewInstance.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NewInstance.java	Wed Apr 27 21:22:10 2011 +0200
@@ -61,15 +61,6 @@
     }
 
     /**
-     * Checks whether this instruction can trap.
-     * @return {@code true}, assuming that allocation can cause OutOfMemory or other exceptions
-     */
-    @Override
-    public boolean canTrap() {
-        return true;
-    }
-
-    /**
      * Gets the exact type produced by this instruction. For allocations of instance classes, this is
      * always the class allocated.
      * @return the exact type produced by this instruction
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java	Wed Apr 27 21:22:10 2011 +0200
@@ -54,15 +54,6 @@
         return object;
     }
 
-    /**
-     * Checks whether this instruction can cause a trap.
-     * @return {@code true} if this instruction can cause a trap
-     */
-    @Override
-    public boolean canTrap() {
-        return true;
-    }
-
     @Override
     public void inputValuesDo(ValueClosure closure) {
         object = closure.apply(object);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/RegisterFinalizer.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/RegisterFinalizer.java	Wed Apr 27 21:22:10 2011 +0200
@@ -51,11 +51,6 @@
     }
 
     @Override
-    public boolean canTrap() {
-        return true;
-    }
-
-    @Override
     public void print(LogStream out) {
         out.print("register finalizer ").print(object);
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ResolveClass.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ResolveClass.java	Wed Apr 27 21:22:10 2011 +0200
@@ -52,11 +52,6 @@
     }
 
     @Override
-    public boolean canTrap() {
-        return true;
-    }
-
-    @Override
     public int valueNumber() {
         return 0x50000000 | type.hashCode();
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/StateSplit.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/StateSplit.java	Wed Apr 27 21:22:10 2011 +0200
@@ -49,21 +49,9 @@
         this.stateBefore = stateBefore;
     }
 
-    /**
-     * Determines if the state for this instruction has explicitly
-     * been cleared (as opposed to never initialized). Once explicitly
-     * cleared, an instruction must not have it state (re)set.
-     */
-    public boolean isStateCleared() {
-        return stateBefore == CLEARED_STATE;
-    }
-
-    /**
-     * Clears the state for this instruction. Once explicitly
-     * cleared, an instruction must not have it state (re)set.
-     */
-    protected void clearState() {
-        stateBefore = CLEARED_STATE;
+    @Override
+    public boolean canTrap() {
+        return stateBefore != null;
     }
 
     /**
@@ -82,6 +70,6 @@
      */
     @Override
     public final FrameState stateBefore() {
-        return stateBefore == CLEARED_STATE ? null : stateBefore;
+        return stateBefore;
     }
 }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/StoreIndexed.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/StoreIndexed.java	Wed Apr 27 21:22:10 2011 +0200
@@ -61,15 +61,6 @@
         return value;
     }
 
-    /**
-     * Checks whether this instruction can cause a trap.
-     * @return {@code true} if this instruction can cause a trap
-     */
-    @Override
-    public boolean canTrap() {
-        return true;
-    }
-
     @Override
     public void inputValuesDo(ValueClosure closure) {
         super.inputValuesDo(closure);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/TypeCheck.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/TypeCheck.java	Wed Apr 27 21:22:10 2011 +0200
@@ -84,15 +84,6 @@
     }
 
     /**
-     * Checks whether this instruction can trap.
-     * @return {@code true}, conservatively assuming the cast may fail
-     */
-    @Override
-    public boolean canTrap() {
-        return true;
-    }
-
-    /**
      * Iterates over the input values to this instruction.
      * @param closure the closure to apply
      */
--- a/graal/GraalRuntime/src/com/oracle/graal/runtime/HotSpotXirGenerator.java	Wed Apr 27 20:58:01 2011 +0200
+++ b/graal/GraalRuntime/src/com/oracle/graal/runtime/HotSpotXirGenerator.java	Wed Apr 27 21:22:10 2011 +0200
@@ -1056,6 +1056,7 @@
                 valueHub = asm.createTemp("valueHub", CiKind.Object);
                 compHub = asm.createTemp("compHub", CiKind.Object);
                 if (implicitNullException) {
+                    asm.nop(1);
                     asm.mark(MARK_IMPLICIT_NULL);
                 }
                 asm.pload(CiKind.Object, compHub, array, asm.i(config.hubOffset), implicitNullException);
@@ -1069,6 +1070,7 @@
             int elemSize = target.sizeInBytes(kind);
 
             if (implicitNullException) {
+                asm.nop(1);
                 asm.mark(MARK_IMPLICIT_NULL);
             }
             int disp = config.getArrayOffset(kind);