< prev index next >

src/jdk.internal.vm.compiler/share/classes/jdk.internal.vm.compiler.word/src/jdk/internal/vm/compiler/word/Pointer.java

Print this page
rev 52509 : [mq]: graal

@@ -1,29 +1,45 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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.
+ * The Universal Permissive License (UPL), Version 1.0
+ *
+ * Subject to the condition set forth below, permission is hereby granted to any
+ * person obtaining a copy of this software, associated documentation and/or
+ * data (collectively the "Software"), free of charge and under any and all
+ * copyright rights in the Software, and any and all patent rights owned or
+ * freely licensable by each licensor hereunder covering either (i) the
+ * unmodified Software as contributed to or provided by such licensor, or (ii)
+ * the Larger Works (as defined below), to deal in both
+ *
+ * (a) the Software, and
+ *
+ * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
+ * one is included with the Software each a "Larger Work" to which the Software
+ * is contributed by such licensors),
+ *
+ * without restriction, including without limitation the rights to copy, create
+ * derivative works of, display, perform, and distribute the Software and make,
+ * use, sell, offer for sale, import, export, have made, and have sold the
+ * Software and the Larger Work(s), and to sublicense the foregoing rights on
+ * either these or other terms.
+ *
+ * This license is subject to the following condition:
+ *
+ * The above copyright notice and either this complete permission notice or at a
+ * minimum a reference to the UPL must be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
  */
-
-
 package jdk.internal.vm.compiler.word;
 
 /**
  * Lowest-level memory access of native C memory.
  * <p>

@@ -957,149 +973,161 @@
      * @since 1.0
      */
     void writeObject(WordBase offset, Object val);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      * <p>
      * The offset is always treated as a {@link SignedWord} value. However, the static type is
      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
      * knows that the highest-order bit of the unsigned value is never used).
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
-     * @return The value after the atomic exchange
+     * @return The value that was read for comparison, which is {@code expectedValue} if the
+     *         exchange was performed.
      *
      * @since 1.0
      */
     int compareAndSwapInt(WordBase offset, int expectedValue, int newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      * <p>
      * The offset is always treated as a {@link SignedWord} value. However, the static type is
      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
      * knows that the highest-order bit of the unsigned value is never used).
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
-     * @return The value after the atomic exchange
+     * @return The value that was read for comparison, which is {@code expectedValue} if the
+     *         exchange was performed.
      *
      * @since 1.0
      */
     long compareAndSwapLong(WordBase offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      * <p>
      * The offset is always treated as a {@link SignedWord} value. However, the static type is
      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
      * knows that the highest-order bit of the unsigned value is never used).
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
-     * @return The value after the atomic exchange
+     * @return The value that was read for comparison, which is {@code expectedValue} if the
+     *         exchange was performed.
      *
      * @since 1.0
      */
     <T extends WordBase> T compareAndSwapWord(WordBase offset, T expectedValue, T newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      * <p>
      * The offset is always treated as a {@link SignedWord} value. However, the static type is
      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
      * knows that the highest-order bit of the unsigned value is never used).
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
-     * @return The value after the atomic exchange
+     * @return The value that was read for comparison, which is {@code expectedValue} if the
+     *         exchange was performed.
      *
      * @since 1.0
      */
     Object compareAndSwapObject(WordBase offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      * <p>
      * The offset is always treated as a {@link SignedWord} value. However, the static type is
      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
      * knows that the highest-order bit of the unsigned value is never used).
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
      * @return {@code true} if successful. False return indicates that the actual value was not
      *         equal to the expected value.
      *
      * @since 1.0
      */
     boolean logicCompareAndSwapInt(WordBase offset, int expectedValue, int newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      * <p>
      * The offset is always treated as a {@link SignedWord} value. However, the static type is
      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
      * knows that the highest-order bit of the unsigned value is never used).
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
      * @return {@code true} if successful. False return indicates that the actual value was not
      *         equal to the expected value.
      *
      * @since 1.0
      */
     boolean logicCompareAndSwapLong(WordBase offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      * <p>
      * The offset is always treated as a {@link SignedWord} value. However, the static type is
      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
      * knows that the highest-order bit of the unsigned value is never used).
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
      * @return {@code true} if successful. False return indicates that the actual value was not
      *         equal to the expected value.
      *
      * @since 1.0
      */
     boolean logicCompareAndSwapWord(WordBase offset, WordBase expectedValue, WordBase newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      * <p>
      * The offset is always treated as a {@link SignedWord} value. However, the static type is
      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
      * knows that the highest-order bit of the unsigned value is never used).
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
      * @return {@code true} if successful. False return indicates that the actual value was not
      *         equal to the expected value.
      *
      * @since 1.0

@@ -1204,117 +1232,129 @@
      * @since 1.0
      */
     void writeObject(int offset, Object val);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
-     * @return The value after the atomic exchange
+     * @return The value that was read for comparison, which is {@code expectedValue} if the
+     *         exchange was performed.
      *
      * @since 1.0
      */
     int compareAndSwapInt(int offset, int expectedValue, int newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
-     * @return The value after the atomic exchange
+     * @return The value that was read for comparison, which is {@code expectedValue} if the
+     *         exchange was performed.
      *
      * @since 1.0
      */
     long compareAndSwapLong(int offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
-     * @return The value after the atomic exchange
+     * @return The value that was read for comparison, which is {@code expectedValue} if the
+     *         exchange was performed.
      *
      * @since 1.0
      */
     <T extends WordBase> T compareAndSwapWord(int offset, T expectedValue, T newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
-     * @return The value after the atomic exchange
+     * @return The value that was read for comparison, which is {@code expectedValue} if the
+     *         exchange was performed.
      *
      * @since 1.0
      */
     Object compareAndSwapObject(int offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
      * @return {@code true} if successful. False return indicates that the actual value was not
      *         equal to the expected value.
      *
      * @since 1.0
      */
     boolean logicCompareAndSwapInt(int offset, int expectedValue, int newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
      * @return {@code true} if successful. False return indicates that the actual value was not
      *         equal to the expected value.
      *
      * @since 1.0
      */
     boolean logicCompareAndSwapLong(int offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
      * @return {@code true} if successful. False return indicates that the actual value was not
      *         equal to the expected value.
      *
      * @since 1.0
      */
     boolean logicCompareAndSwapWord(int offset, WordBase expectedValue, WordBase newValue, LocationIdentity locationIdentity);
 
     /**
-     * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and
+     * In a single atomic step, compares the memory at address {@code (this + offset)} to the
+     * expected value, and if equal, exchanges it for the new value. Both the base address and
      * offset are in bytes.
      *
      * @param offset the signed offset for the memory access
-     * @param expectedValue the expected value of the atomic exchange
-     * @param newValue the new value of the atomic exchange
+     * @param expectedValue the expected current value at the memory address
+     * @param newValue the new value for the atomic exchange
      * @param locationIdentity the identity of the memory location
      * @return {@code true} if successful. False return indicates that the actual value was not
      *         equal to the expected value.
      *
      * @since 1.0
< prev index next >