changeset 7224:fb16d8681ddc

bugfixes for compiler intrinsics added more unsafe intrinsics
author Christian Haeubl <haeubl@ssw.jku.at>
date Wed, 12 Dec 2012 15:05:21 +0100
parents e2ea829fafd9
children 31c4d9f9e922
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DirectStoreNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotCurrentRawThreadNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ThreadIsInterruptedStubCall.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ThreadSnippets.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/UnsafeSnippets.java graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64MathIntrinsicOp.java graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/IntrinsificationTest.java graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/nodes/MathIntrinsicNode.java src/share/vm/runtime/compilationPolicy.cpp
diffstat 11 files changed, 129 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Tue Dec 11 16:38:27 2012 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Wed Dec 12 15:05:21 2012 +0100
@@ -173,7 +173,7 @@
                (isConstant(operand) && x.kind() == operand.getKind().getStackKind()) : operand.getKind() + " for node " + x;
         assert operand(x) == null : "operand cannot be set twice";
         assert operand != null && isLegal(operand) : "operand must be legal";
-        assert operand.getKind().getStackKind() == x.kind();
+        assert operand.getKind().getStackKind() == x.kind() : operand.getKind().getStackKind() + " must match " + x.kind();
         assert !(x instanceof VirtualObjectNode);
         nodeOperands.set(x, operand);
         return operand;
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Tue Dec 11 16:38:27 2012 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Wed Dec 12 15:05:21 2012 +0100
@@ -135,9 +135,9 @@
 
         addRuntimeCall(THREAD_IS_INTERRUPTED, config.threadIsInterruptedStub,
                 /*        temps */ null,
-                /*          ret */ rax.asValue(Kind.Boolean),
-                /* arg0: thread */ rdx.asValue(Kind.Object),
-      /* arg1: clearInterrupted */ rdx.asValue(Kind.Boolean));
+                /*          ret */ rax.asValue(Kind.Int),
+                /* arg0: thread */ arg(0, Kind.Object),
+      /* arg1: clearInterrupted */ arg(1, Kind.Boolean));
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DirectStoreNode.java	Tue Dec 11 16:38:27 2012 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DirectStoreNode.java	Wed Dec 12 15:05:21 2012 +0100
@@ -44,13 +44,28 @@
     }
 
     @NodeIntrinsic
-    public static native void store(long address, long value);
+    public static native void store(long address, boolean value);
+
+    @NodeIntrinsic
+    public static native void store(long address, byte value);
+
+    @NodeIntrinsic
+    public static native void store(long address, short value);
+
+    @NodeIntrinsic
+    public static native void store(long address, char value);
 
     @NodeIntrinsic
     public static native void store(long address, int value);
 
     @NodeIntrinsic
-    public static native void store(long address, boolean value);
+    public static native void store(long address, long value);
+
+    @NodeIntrinsic
+    public static native void store(long address, float value);
+
+    @NodeIntrinsic
+    public static native void store(long address, double value);
 
     @Override
     public void generate(LIRGeneratorTool gen) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotCurrentRawThreadNode.java	Wed Dec 12 15:05:21 2012 +0100
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.nodes;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.nodes.calc.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+import com.oracle.graal.snippets.*;
+
+
+public class HotSpotCurrentRawThreadNode extends FloatingNode implements LIRLowerable {
+    public HotSpotCurrentRawThreadNode() {
+        super(StampFactory.forWord());
+    }
+
+    @Override
+    public void generate(LIRGeneratorTool gen) {
+        Register rawThread = HotSpotGraalRuntime.getInstance().getRuntime().threadRegister();
+        gen.setResult(this, rawThread.asValue(this.kind()));
+    }
+
+    @NodeIntrinsic
+    public static native Word get();
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ThreadIsInterruptedStubCall.java	Tue Dec 11 16:38:27 2012 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ThreadIsInterruptedStubCall.java	Wed Dec 12 15:05:21 2012 +0100
@@ -36,20 +36,22 @@
  */
 public class ThreadIsInterruptedStubCall extends FixedWithNextNode implements LIRGenLowerable {
     @Input private final ValueNode thread;
-    public static final Descriptor THREAD_IS_INTERRUPTED = new Descriptor("thread_is_interrupted", false, Kind.Boolean, Kind.Object, Kind.Boolean);
+    @Input private final ValueNode clearIsInterrupted;
+    public static final Descriptor THREAD_IS_INTERRUPTED = new Descriptor("thread_is_interrupted", false, Kind.Int, Kind.Object, Kind.Boolean);
 
-    public ThreadIsInterruptedStubCall(ValueNode thread) {
-        super(StampFactory.forKind(Kind.Boolean));
+    public ThreadIsInterruptedStubCall(ValueNode thread, ValueNode clearIsInterrupted) {
+        super(StampFactory.forInteger(Kind.Int, 0, 1));
         this.thread = thread;
+        this.clearIsInterrupted = clearIsInterrupted;
     }
 
     @Override
     public void generate(LIRGenerator gen) {
         RuntimeCallTarget stub = gen.getRuntime().lookupRuntimeCall(ThreadIsInterruptedStubCall.THREAD_IS_INTERRUPTED);
-        Variable result = gen.emitCall(stub, stub.getCallingConvention(), true, gen.operand(thread));
+        Variable result = gen.emitCall(stub, stub.getCallingConvention(), true, gen.operand(thread), gen.operand(clearIsInterrupted));
         gen.setResult(this, result);
     }
 
     @NodeIntrinsic
-    public static native boolean call(Thread thread);
+    public static native int call(Thread thread, boolean clearIsInterrupted);
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ThreadSnippets.java	Tue Dec 11 16:38:27 2012 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ThreadSnippets.java	Wed Dec 12 15:05:21 2012 +0100
@@ -37,15 +37,16 @@
     @InstanceMethodSubstitution
     @SuppressWarnings("unused")
     private static boolean isInterrupted(final Thread thisObject, boolean clearInterrupted) {
-        Thread thread = CurrentThread.get(threadObjectOffset());
+        Word rawThread = HotSpotCurrentRawThreadNode.get();
+        Thread thread = (Thread) loadObjectFromWord(rawThread, threadObjectOffset());
         if (thisObject == thread) {
-            Word osThread = loadWordFromObject(thisObject, osThreadOffset());
-            boolean interrupted = loadIntFromWord(osThread, osThreadInterruptedOffset()) == 1;
+            Word osThread = loadWordFromWord(rawThread, osThreadOffset());
+            boolean interrupted = loadIntFromWord(osThread, osThreadInterruptedOffset()) != 0;
             if (!interrupted || !clearInterrupted) {
                 return interrupted;
             }
         }
 
-        return ThreadIsInterruptedStubCall.call(thisObject);
+        return ThreadIsInterruptedStubCall.call(thisObject, clearInterrupted) != 0;
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/UnsafeSnippets.java	Tue Dec 11 16:38:27 2012 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/UnsafeSnippets.java	Wed Dec 12 15:05:21 2012 +0100
@@ -269,6 +269,18 @@
         MembarNode.memoryBarrier(MemoryBarriers.JMM_POST_VOLATILE_WRITE);
     }
 
+    public void putByte(long address, byte value) {
+        DirectStoreNode.store(address, value);
+    }
+
+    public void putShort(long address, short value) {
+        DirectStoreNode.store(address, value);
+    }
+
+    public void putChar(long address, char value) {
+        DirectStoreNode.store(address, value);
+    }
+
     public void putInt(long address, int value) {
         DirectStoreNode.store(address, value);
     }
@@ -277,6 +289,26 @@
         DirectStoreNode.store(address, value);
     }
 
+    public void putFloat(long address, float value) {
+        DirectStoreNode.store(address, value);
+    }
+
+    public void putDouble(long address, double value) {
+        DirectStoreNode.store(address, value);
+    }
+
+    public byte getByte(long address) {
+        return DirectReadNode.read(address, Kind.Byte);
+    }
+
+    public short getShort(long address) {
+        return DirectReadNode.read(address, Kind.Short);
+    }
+
+    public char getChar(long address) {
+        return DirectReadNode.read(address, Kind.Char);
+    }
+
     public int getInt(long address) {
         return DirectReadNode.read(address, Kind.Int);
     }
@@ -284,4 +316,12 @@
     public long getLong(long address) {
         return DirectReadNode.read(address, Kind.Long);
     }
+
+    public float getFloat(long address) {
+        return DirectReadNode.read(address, Kind.Float);
+    }
+
+    public double getDouble(long address) {
+        return DirectReadNode.read(address, Kind.Double);
+    }
 }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64MathIntrinsicOp.java	Tue Dec 11 16:38:27 2012 +0100
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64MathIntrinsicOp.java	Wed Dec 12 15:05:21 2012 +0100
@@ -33,7 +33,7 @@
     public enum IntrinsicOpcode  {
         SQRT,
         SIN, COS, TAN,
-        LOG, LOG10;
+        LOG, LOG10
     }
 
     @Opcode private final IntrinsicOpcode opcode;
--- a/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/IntrinsificationTest.java	Tue Dec 11 16:38:27 2012 +0100
+++ b/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/IntrinsificationTest.java	Wed Dec 12 15:05:21 2012 +0100
@@ -162,8 +162,8 @@
         test("unsafePutDoubleSnippet");
         test("unsafePutObjectSnippet");
 
-        // test("unsafeDirectMemoryReadSnippet");
-        // test("unsafeDirectMemoryWriteSnippet");
+        test("unsafeDirectMemoryReadSnippet");
+        test("unsafeDirectMemoryWriteSnippet");
     }
 
     @SuppressWarnings("all")
--- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/nodes/MathIntrinsicNode.java	Tue Dec 11 16:38:27 2012 +0100
+++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/nodes/MathIntrinsicNode.java	Wed Dec 12 15:05:21 2012 +0100
@@ -38,7 +38,7 @@
     private final Operation operation;
 
     public enum Operation {
-        ABS, SQRT, LOG, LOG10, SIN, COS, TAN,
+        ABS, SQRT, LOG, LOG10, SIN, COS, TAN
     }
 
     public ValueNode x() {
--- a/src/share/vm/runtime/compilationPolicy.cpp	Tue Dec 11 16:38:27 2012 +0100
+++ b/src/share/vm/runtime/compilationPolicy.cpp	Wed Dec 12 15:05:21 2012 +0100
@@ -493,6 +493,12 @@
   const char* comment = "backedge_count";
 
   if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) {
+    if (TraceCompilationPolicy) {
+      tty->print("backedge invocation trigger: ");
+      m->print_short_name(tty);
+      tty->print_cr(" ( interpreted " INTPTR_FORMAT ", size=%d, hotCount=%d ) ", (address)m(), m->code_size(), hot_count);
+    }
+
     CompileBroker::compile_method(m, bci, CompLevel_highest_tier,
                                   m, hot_count, comment, thread);
     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));)