# HG changeset patch # User Doug Simon # Date 1340885700 -7200 # Node ID 956217932b8c00ed7a177e17aaa13564c9c8260e # Parent 42f3dac334f9c2f30db483cebb88db3f7108014c moved classes from com.oracle.max.cri.util to com.oracle.max.crituils diff -r 42f3dac334f9 -r 956217932b8c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Jun 28 14:10:30 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Jun 28 14:15:00 2012 +0200 @@ -22,7 +22,7 @@ */ package com.oracle.graal.hotspot.meta; -import static com.oracle.max.cri.util.MemoryBarriers.*; +import static com.oracle.max.criutils.MemoryBarriers.*; import java.lang.reflect.*; import java.util.*; diff -r 42f3dac334f9 -r 956217932b8c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/UnsafeSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/UnsafeSnippets.java Thu Jun 28 14:10:30 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/UnsafeSnippets.java Thu Jun 28 14:15:00 2012 +0200 @@ -22,11 +22,11 @@ */ package com.oracle.graal.hotspot.snippets; -import com.oracle.max.cri.util.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.snippets.*; +import com.oracle.max.criutils.*; /** * Snippets for {@link sun.misc.Unsafe} methods. diff -r 42f3dac334f9 -r 956217932b8c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java Thu Jun 28 14:10:30 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java Thu Jun 28 14:15:00 2012 +0200 @@ -25,7 +25,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; -import com.oracle.max.cri.util.*; +import com.oracle.max.criutils.*; /** * Condition codes used in conditionals. diff -r 42f3dac334f9 -r 956217932b8c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/MembarNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/MembarNode.java Thu Jun 28 14:10:30 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/MembarNode.java Thu Jun 28 14:15:00 2012 +0200 @@ -25,7 +25,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; -import com.oracle.max.cri.util.*; +import com.oracle.max.criutils.*; /** * Creates a memory barrier. diff -r 42f3dac334f9 -r 956217932b8c graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64.java --- a/graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64.java Thu Jun 28 14:10:30 2012 +0200 +++ b/graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64.java Thu Jun 28 14:15:00 2012 +0200 @@ -24,7 +24,7 @@ import static com.oracle.graal.api.code.Register.RegisterFlag.*; import static com.oracle.graal.api.meta.Kind.*; -import static com.oracle.max.cri.util.MemoryBarriers.*; +import static com.oracle.max.criutils.MemoryBarriers.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.Register.*; diff -r 42f3dac334f9 -r 956217932b8c graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64Assembler.java --- a/graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64Assembler.java Thu Jun 28 14:10:30 2012 +0200 +++ b/graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64Assembler.java Thu Jun 28 14:15:00 2012 +0200 @@ -25,7 +25,7 @@ import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.max.asm.NumUtil.*; import static com.oracle.max.asm.target.amd64.AMD64.*; -import static com.oracle.max.cri.util.MemoryBarriers.*; +import static com.oracle.max.criutils.MemoryBarriers.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; diff -r 42f3dac334f9 -r 956217932b8c graal/com.oracle.max.cri/src/com/oracle/max/cri/util/MemoryBarriers.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/util/MemoryBarriers.java Thu Jun 28 14:10:30 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2011, 2011, 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.max.cri.util; - -/** - * Constants and intrinsic definition for memory barriers. - * - * The documentation for each constant is taken from Doug Lea's - * The JSR-133 Cookbook for Compiler Writers. - *

- * The {@code JMM_*} constants capture the memory barriers necessary to implement the Java Memory Model - * with respect to volatile field accesses. Their values are explained by this - * comment from templateTable_i486.cpp in the HotSpot source code: - *

- * Volatile variables demand their effects be made known to all CPU's in
- * order.  Store buffers on most chips allow reads & writes to reorder; the
- * JMM's ReadAfterWrite.java test fails in -Xint mode without some kind of
- * memory barrier (i.e., it's not sufficient that the interpreter does not
- * reorder volatile references, the hardware also must not reorder them).
- *
- * According to the new Java Memory Model (JMM):
- * (1) All volatiles are serialized wrt to each other.
- * ALSO reads & writes act as acquire & release, so:
- * (2) A read cannot let unrelated NON-volatile memory refs that happen after
- * the read float up to before the read.  It's OK for non-volatile memory refs
- * that happen before the volatile read to float down below it.
- * (3) Similarly, a volatile write cannot let unrelated NON-volatile memory refs
- * that happen BEFORE the write float down to after the write.  It's OK for
- * non-volatile memory refs that happen after the volatile write to float up
- * before it.
- *
- * We only put in barriers around volatile refs (they are expensive), not
- * _between_ memory refs (which would require us to track the flavor of the
- * previous memory refs).  Requirements (2) and (3) require some barriers
- * before volatile stores and after volatile loads.  These nearly cover
- * requirement (1) but miss the volatile-store-volatile-load case.  This final
- * case is placed after volatile-stores although it could just as well go
- * before volatile-loads.
- * 
- */ -public class MemoryBarriers { - - /** - * The sequence {@code Load1; LoadLoad; Load2} ensures that {@code Load1}'s data are loaded before data accessed - * by {@code Load2} and all subsequent load instructions are loaded. In general, explicit {@code LoadLoad} - * barriers are needed on processors that perform speculative loads and/or out-of-order processing in which - * waiting load instructions can bypass waiting stores. On processors that guarantee to always preserve load - * ordering, these barriers amount to no-ops. - */ - public static final int LOAD_LOAD = 0x0001; - - /** - * The sequence {@code Load1; LoadStore; Store2} ensures that {@code Load1}'s data are loaded before all data - * associated with {@code Store2} and subsequent store instructions are flushed. {@code LoadStore} barriers are - * needed only on those out-of-order processors in which waiting store instructions can bypass loads. - */ - public static final int LOAD_STORE = 0x0002; - - /** - * The sequence {@code Store1; StoreLoad; Load2} ensures that {@code Store1}'s data are made visible to other - * processors (i.e., flushed to main memory) before data accessed by {@code Load2} and all subsequent load - * instructions are loaded. {@code StoreLoad} barriers protect against a subsequent load incorrectly using - * {@code Store1}'s data value rather than that from a more recent store to the same location performed by a - * different processor. Because of this, on the processors discussed below, a {@code StoreLoad} is strictly - * necessary only for separating stores from subsequent loads of the same location(s) as were stored before the - * barrier. {@code StoreLoad} barriers are needed on nearly all recent multiprocessors, and are usually the most - * expensive kind. Part of the reason they are expensive is that they must disable mechanisms that ordinarily - * bypass cache to satisfy loads from write-buffers. This might be implemented by letting the buffer fully - * flush, among other possible stalls. - */ - public static final int STORE_LOAD = 0x0004; - - /** - * The sequence {@code Store1; StoreStore; Store2} ensures that {@code Store1}'s data are visible to other - * processors (i.e., flushed to memory) before the data associated with {@code Store2} and all subsequent store - * instructions. In general, {@code StoreStore} barriers are needed on processors that do not otherwise - * guarantee strict ordering of flushes from write buffers and/or caches to other processors or main memory. - */ - public static final int STORE_STORE = 0x0008; - - public static final int JMM_PRE_VOLATILE_WRITE = LOAD_STORE | STORE_STORE; - public static final int JMM_POST_VOLATILE_WRITE = STORE_LOAD | STORE_STORE; - public static final int JMM_PRE_VOLATILE_READ = 0; - public static final int JMM_POST_VOLATILE_READ = LOAD_LOAD | LOAD_STORE; - - public static String barriersString(int barriers) { - StringBuilder sb = new StringBuilder(); - sb.append((barriers & LOAD_LOAD) != 0 ? "LOAD_LOAD " : ""); - sb.append((barriers & LOAD_STORE) != 0 ? "LOAD_STORE " : ""); - sb.append((barriers & STORE_LOAD) != 0 ? "STORE_LOAD " : ""); - sb.append((barriers & STORE_STORE) != 0 ? "STORE_STORE " : ""); - return sb.toString().trim(); - } -} diff -r 42f3dac334f9 -r 956217932b8c graal/com.oracle.max.cri/src/com/oracle/max/cri/util/UnsignedMath.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/util/UnsignedMath.java Thu Jun 28 14:10:30 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2011, 2011, 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.max.cri.util; - -/** - * Utilities for unsigned comparisons. - * All methods have correct, but slow, standard Java implementations so that - * they can be used with compilers not supporting the intrinsics. - */ -public class UnsignedMath { - private static final long MASK = 0xffffffffL; - - /** - * Unsigned comparison aboveThan for two numbers. - */ - public static boolean aboveThan(int a, int b) { - return (a & MASK) > (b & MASK); - } - - /** - * Unsigned comparison aboveOrEqual for two numbers. - */ - public static boolean aboveOrEqual(int a, int b) { - return (a & MASK) >= (b & MASK); - } - - /** - * Unsigned comparison belowThan for two numbers. - */ - public static boolean belowThan(int a, int b) { - return (a & MASK) < (b & MASK); - } - - /** - * Unsigned comparison belowOrEqual for two numbers. - */ - public static boolean belowOrEqual(int a, int b) { - return (a & MASK) <= (b & MASK); - } - - /** - * Unsigned comparison aboveThan for two numbers. - */ - public static boolean aboveThan(long a, long b) { - return (a > b) ^ ((a < 0) != (b < 0)); - } - - /** - * Unsigned comparison aboveOrEqual for two numbers. - */ - public static boolean aboveOrEqual(long a, long b) { - return (a >= b) ^ ((a < 0) != (b < 0)); - } - - /** - * Unsigned comparison belowThan for two numbers. - */ - public static boolean belowThan(long a, long b) { - return (a < b) ^ ((a < 0) != (b < 0)); - } - - /** - * Unsigned comparison belowOrEqual for two numbers. - */ - public static boolean belowOrEqual(long a, long b) { - return (a <= b) ^ ((a < 0) != (b < 0)); - } -} - diff -r 42f3dac334f9 -r 956217932b8c graal/com.oracle.max.criutils/src/com/oracle/max/criutils/MemoryBarriers.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.criutils/src/com/oracle/max/criutils/MemoryBarriers.java Thu Jun 28 14:15:00 2012 +0200 @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2011, 2011, 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.max.criutils; + +/** + * Constants and intrinsic definition for memory barriers. + * + * The documentation for each constant is taken from Doug Lea's + * The JSR-133 Cookbook for Compiler Writers. + *

+ * The {@code JMM_*} constants capture the memory barriers necessary to implement the Java Memory Model + * with respect to volatile field accesses. Their values are explained by this + * comment from templateTable_i486.cpp in the HotSpot source code: + *

+ * Volatile variables demand their effects be made known to all CPU's in
+ * order.  Store buffers on most chips allow reads & writes to reorder; the
+ * JMM's ReadAfterWrite.java test fails in -Xint mode without some kind of
+ * memory barrier (i.e., it's not sufficient that the interpreter does not
+ * reorder volatile references, the hardware also must not reorder them).
+ *
+ * According to the new Java Memory Model (JMM):
+ * (1) All volatiles are serialized wrt to each other.
+ * ALSO reads & writes act as acquire & release, so:
+ * (2) A read cannot let unrelated NON-volatile memory refs that happen after
+ * the read float up to before the read.  It's OK for non-volatile memory refs
+ * that happen before the volatile read to float down below it.
+ * (3) Similarly, a volatile write cannot let unrelated NON-volatile memory refs
+ * that happen BEFORE the write float down to after the write.  It's OK for
+ * non-volatile memory refs that happen after the volatile write to float up
+ * before it.
+ *
+ * We only put in barriers around volatile refs (they are expensive), not
+ * _between_ memory refs (which would require us to track the flavor of the
+ * previous memory refs).  Requirements (2) and (3) require some barriers
+ * before volatile stores and after volatile loads.  These nearly cover
+ * requirement (1) but miss the volatile-store-volatile-load case.  This final
+ * case is placed after volatile-stores although it could just as well go
+ * before volatile-loads.
+ * 
+ */ +public class MemoryBarriers { + + /** + * The sequence {@code Load1; LoadLoad; Load2} ensures that {@code Load1}'s data are loaded before data accessed + * by {@code Load2} and all subsequent load instructions are loaded. In general, explicit {@code LoadLoad} + * barriers are needed on processors that perform speculative loads and/or out-of-order processing in which + * waiting load instructions can bypass waiting stores. On processors that guarantee to always preserve load + * ordering, these barriers amount to no-ops. + */ + public static final int LOAD_LOAD = 0x0001; + + /** + * The sequence {@code Load1; LoadStore; Store2} ensures that {@code Load1}'s data are loaded before all data + * associated with {@code Store2} and subsequent store instructions are flushed. {@code LoadStore} barriers are + * needed only on those out-of-order processors in which waiting store instructions can bypass loads. + */ + public static final int LOAD_STORE = 0x0002; + + /** + * The sequence {@code Store1; StoreLoad; Load2} ensures that {@code Store1}'s data are made visible to other + * processors (i.e., flushed to main memory) before data accessed by {@code Load2} and all subsequent load + * instructions are loaded. {@code StoreLoad} barriers protect against a subsequent load incorrectly using + * {@code Store1}'s data value rather than that from a more recent store to the same location performed by a + * different processor. Because of this, on the processors discussed below, a {@code StoreLoad} is strictly + * necessary only for separating stores from subsequent loads of the same location(s) as were stored before the + * barrier. {@code StoreLoad} barriers are needed on nearly all recent multiprocessors, and are usually the most + * expensive kind. Part of the reason they are expensive is that they must disable mechanisms that ordinarily + * bypass cache to satisfy loads from write-buffers. This might be implemented by letting the buffer fully + * flush, among other possible stalls. + */ + public static final int STORE_LOAD = 0x0004; + + /** + * The sequence {@code Store1; StoreStore; Store2} ensures that {@code Store1}'s data are visible to other + * processors (i.e., flushed to memory) before the data associated with {@code Store2} and all subsequent store + * instructions. In general, {@code StoreStore} barriers are needed on processors that do not otherwise + * guarantee strict ordering of flushes from write buffers and/or caches to other processors or main memory. + */ + public static final int STORE_STORE = 0x0008; + + public static final int JMM_PRE_VOLATILE_WRITE = LOAD_STORE | STORE_STORE; + public static final int JMM_POST_VOLATILE_WRITE = STORE_LOAD | STORE_STORE; + public static final int JMM_PRE_VOLATILE_READ = 0; + public static final int JMM_POST_VOLATILE_READ = LOAD_LOAD | LOAD_STORE; + + public static String barriersString(int barriers) { + StringBuilder sb = new StringBuilder(); + sb.append((barriers & LOAD_LOAD) != 0 ? "LOAD_LOAD " : ""); + sb.append((barriers & LOAD_STORE) != 0 ? "LOAD_STORE " : ""); + sb.append((barriers & STORE_LOAD) != 0 ? "STORE_LOAD " : ""); + sb.append((barriers & STORE_STORE) != 0 ? "STORE_STORE " : ""); + return sb.toString().trim(); + } +} diff -r 42f3dac334f9 -r 956217932b8c graal/com.oracle.max.criutils/src/com/oracle/max/criutils/UnsignedMath.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.criutils/src/com/oracle/max/criutils/UnsignedMath.java Thu Jun 28 14:15:00 2012 +0200 @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2011, 2011, 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.max.criutils; + +/** + * Utilities for unsigned comparisons. + * All methods have correct, but slow, standard Java implementations so that + * they can be used with compilers not supporting the intrinsics. + */ +public class UnsignedMath { + private static final long MASK = 0xffffffffL; + + /** + * Unsigned comparison aboveThan for two numbers. + */ + public static boolean aboveThan(int a, int b) { + return (a & MASK) > (b & MASK); + } + + /** + * Unsigned comparison aboveOrEqual for two numbers. + */ + public static boolean aboveOrEqual(int a, int b) { + return (a & MASK) >= (b & MASK); + } + + /** + * Unsigned comparison belowThan for two numbers. + */ + public static boolean belowThan(int a, int b) { + return (a & MASK) < (b & MASK); + } + + /** + * Unsigned comparison belowOrEqual for two numbers. + */ + public static boolean belowOrEqual(int a, int b) { + return (a & MASK) <= (b & MASK); + } + + /** + * Unsigned comparison aboveThan for two numbers. + */ + public static boolean aboveThan(long a, long b) { + return (a > b) ^ ((a < 0) != (b < 0)); + } + + /** + * Unsigned comparison aboveOrEqual for two numbers. + */ + public static boolean aboveOrEqual(long a, long b) { + return (a >= b) ^ ((a < 0) != (b < 0)); + } + + /** + * Unsigned comparison belowThan for two numbers. + */ + public static boolean belowThan(long a, long b) { + return (a < b) ^ ((a < 0) != (b < 0)); + } + + /** + * Unsigned comparison belowOrEqual for two numbers. + */ + public static boolean belowOrEqual(long a, long b) { + return (a <= b) ^ ((a < 0) != (b < 0)); + } +} + diff -r 42f3dac334f9 -r 956217932b8c mx/projects --- a/mx/projects Thu Jun 28 14:10:30 2012 +0200 +++ b/mx/projects Thu Jun 28 14:15:00 2012 +0200 @@ -127,7 +127,7 @@ # graal.nodes project@com.oracle.graal.nodes@subDir=graal project@com.oracle.graal.nodes@sourceDirs=src,test -project@com.oracle.graal.nodes@dependencies=com.oracle.max.cri,com.oracle.graal.graph +project@com.oracle.graal.nodes@dependencies=com.oracle.max.criutils,com.oracle.graal.graph project@com.oracle.graal.nodes@checkstyle=com.oracle.graal.graph project@com.oracle.graal.nodes@javaCompliance=1.7