< 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 /*
   2  * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.


















  22  */
  23 
  24 
  25 package jdk.internal.vm.compiler.word;
  26 
  27 /**
  28  * Lowest-level memory access of native C memory.
  29  * <p>
  30  * Do not use these methods to access Java objects. These methods access the raw memory without any
  31  * null checks, read- or write barriers. Even when the VM uses compressed pointers, then readObject
  32  * and writeObject methods access uncompressed pointers.
  33  *
  34  * @since 1.0
  35  */
  36 public interface Pointer extends UnsignedWord, PointerBase {
  37 
  38     /**
  39      * Unsafe conversion of this Pointer to a Java language object. No correctness checks or type
  40      * checks are performed. The caller must ensure that the Pointer contains a valid Java object
  41      * that can i.e., processed by the garbage collector.
  42      *
  43      * @return this Pointer cast to Object.
  44      *


 942      * @since 1.0
 943      */
 944     void writeWord(WordBase offset, WordBase val);
 945 
 946     /**
 947      * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
 948      * bytes.
 949      * <p>
 950      * The offset is always treated as a {@link SignedWord} value. However, the static type is
 951      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
 952      * knows that the highest-order bit of the unsigned value is never used).
 953      *
 954      * @param offset the signed offset for the memory access
 955      * @param val the value to be written to memory
 956      *
 957      * @since 1.0
 958      */
 959     void writeObject(WordBase offset, Object val);
 960 
 961     /**
 962      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

 963      * offset are in bytes.
 964      * <p>
 965      * The offset is always treated as a {@link SignedWord} value. However, the static type is
 966      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
 967      * knows that the highest-order bit of the unsigned value is never used).
 968      *
 969      * @param offset the signed offset for the memory access
 970      * @param expectedValue the expected value of the atomic exchange
 971      * @param newValue the new value of the atomic exchange
 972      * @param locationIdentity the identity of the memory location
 973      * @return The value after the atomic exchange

 974      *
 975      * @since 1.0
 976      */
 977     int compareAndSwapInt(WordBase offset, int expectedValue, int newValue, LocationIdentity locationIdentity);
 978 
 979     /**
 980      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

 981      * offset are in bytes.
 982      * <p>
 983      * The offset is always treated as a {@link SignedWord} value. However, the static type is
 984      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
 985      * knows that the highest-order bit of the unsigned value is never used).
 986      *
 987      * @param offset the signed offset for the memory access
 988      * @param expectedValue the expected value of the atomic exchange
 989      * @param newValue the new value of the atomic exchange
 990      * @param locationIdentity the identity of the memory location
 991      * @return The value after the atomic exchange

 992      *
 993      * @since 1.0
 994      */
 995     long compareAndSwapLong(WordBase offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
 996 
 997     /**
 998      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

 999      * offset are in bytes.
1000      * <p>
1001      * The offset is always treated as a {@link SignedWord} value. However, the static type is
1002      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
1003      * knows that the highest-order bit of the unsigned value is never used).
1004      *
1005      * @param offset the signed offset for the memory access
1006      * @param expectedValue the expected value of the atomic exchange
1007      * @param newValue the new value of the atomic exchange
1008      * @param locationIdentity the identity of the memory location
1009      * @return The value after the atomic exchange

1010      *
1011      * @since 1.0
1012      */
1013     <T extends WordBase> T compareAndSwapWord(WordBase offset, T expectedValue, T newValue, LocationIdentity locationIdentity);
1014 
1015     /**
1016      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

1017      * offset are in bytes.
1018      * <p>
1019      * The offset is always treated as a {@link SignedWord} value. However, the static type is
1020      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
1021      * knows that the highest-order bit of the unsigned value is never used).
1022      *
1023      * @param offset the signed offset for the memory access
1024      * @param expectedValue the expected value of the atomic exchange
1025      * @param newValue the new value of the atomic exchange
1026      * @param locationIdentity the identity of the memory location
1027      * @return The value after the atomic exchange

1028      *
1029      * @since 1.0
1030      */
1031     Object compareAndSwapObject(WordBase offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity);
1032 
1033     /**
1034      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

1035      * offset are in bytes.
1036      * <p>
1037      * The offset is always treated as a {@link SignedWord} value. However, the static type is
1038      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
1039      * knows that the highest-order bit of the unsigned value is never used).
1040      *
1041      * @param offset the signed offset for the memory access
1042      * @param expectedValue the expected value of the atomic exchange
1043      * @param newValue the new value of the atomic exchange
1044      * @param locationIdentity the identity of the memory location
1045      * @return {@code true} if successful. False return indicates that the actual value was not
1046      *         equal to the expected value.
1047      *
1048      * @since 1.0
1049      */
1050     boolean logicCompareAndSwapInt(WordBase offset, int expectedValue, int newValue, LocationIdentity locationIdentity);
1051 
1052     /**
1053      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

1054      * offset are in bytes.
1055      * <p>
1056      * The offset is always treated as a {@link SignedWord} value. However, the static type is
1057      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
1058      * knows that the highest-order bit of the unsigned value is never used).
1059      *
1060      * @param offset the signed offset for the memory access
1061      * @param expectedValue the expected value of the atomic exchange
1062      * @param newValue the new value of the atomic exchange
1063      * @param locationIdentity the identity of the memory location
1064      * @return {@code true} if successful. False return indicates that the actual value was not
1065      *         equal to the expected value.
1066      *
1067      * @since 1.0
1068      */
1069     boolean logicCompareAndSwapLong(WordBase offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
1070 
1071     /**
1072      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

1073      * offset are in bytes.
1074      * <p>
1075      * The offset is always treated as a {@link SignedWord} value. However, the static type is
1076      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
1077      * knows that the highest-order bit of the unsigned value is never used).
1078      *
1079      * @param offset the signed offset for the memory access
1080      * @param expectedValue the expected value of the atomic exchange
1081      * @param newValue the new value of the atomic exchange
1082      * @param locationIdentity the identity of the memory location
1083      * @return {@code true} if successful. False return indicates that the actual value was not
1084      *         equal to the expected value.
1085      *
1086      * @since 1.0
1087      */
1088     boolean logicCompareAndSwapWord(WordBase offset, WordBase expectedValue, WordBase newValue, LocationIdentity locationIdentity);
1089 
1090     /**
1091      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

1092      * offset are in bytes.
1093      * <p>
1094      * The offset is always treated as a {@link SignedWord} value. However, the static type is
1095      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
1096      * knows that the highest-order bit of the unsigned value is never used).
1097      *
1098      * @param offset the signed offset for the memory access
1099      * @param expectedValue the expected value of the atomic exchange
1100      * @param newValue the new value of the atomic exchange
1101      * @param locationIdentity the identity of the memory location
1102      * @return {@code true} if successful. False return indicates that the actual value was not
1103      *         equal to the expected value.
1104      *
1105      * @since 1.0
1106      */
1107     boolean logicCompareAndSwapObject(WordBase offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity);
1108 
1109     /**
1110      * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
1111      * bytes.
1112      *
1113      * @param offset the signed offset for the memory access
1114      * @param val the value to be written to memory
1115      *
1116      * @since 1.0
1117      */
1118     void writeByte(int offset, byte val);
1119 
1120     /**


1189      *
1190      * @param offset the signed offset for the memory access
1191      * @param val the value to be written to memory
1192      *
1193      * @since 1.0
1194      */
1195     void writeWord(int offset, WordBase val);
1196 
1197     /**
1198      * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
1199      * bytes.
1200      *
1201      * @param offset the signed offset for the memory access
1202      * @param val the value to be written to memory
1203      *
1204      * @since 1.0
1205      */
1206     void writeObject(int offset, Object val);
1207 
1208     /**
1209      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

1210      * offset are in bytes.
1211      *
1212      * @param offset the signed offset for the memory access
1213      * @param expectedValue the expected value of the atomic exchange
1214      * @param newValue the new value of the atomic exchange
1215      * @param locationIdentity the identity of the memory location
1216      * @return The value after the atomic exchange

1217      *
1218      * @since 1.0
1219      */
1220     int compareAndSwapInt(int offset, int expectedValue, int newValue, LocationIdentity locationIdentity);
1221 
1222     /**
1223      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

1224      * offset are in bytes.
1225      *
1226      * @param offset the signed offset for the memory access
1227      * @param expectedValue the expected value of the atomic exchange
1228      * @param newValue the new value of the atomic exchange
1229      * @param locationIdentity the identity of the memory location
1230      * @return The value after the atomic exchange

1231      *
1232      * @since 1.0
1233      */
1234     long compareAndSwapLong(int offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
1235 
1236     /**
1237      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

1238      * offset are in bytes.
1239      *
1240      * @param offset the signed offset for the memory access
1241      * @param expectedValue the expected value of the atomic exchange
1242      * @param newValue the new value of the atomic exchange
1243      * @param locationIdentity the identity of the memory location
1244      * @return The value after the atomic exchange

1245      *
1246      * @since 1.0
1247      */
1248     <T extends WordBase> T compareAndSwapWord(int offset, T expectedValue, T newValue, LocationIdentity locationIdentity);
1249 
1250     /**
1251      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

1252      * offset are in bytes.
1253      *
1254      * @param offset the signed offset for the memory access
1255      * @param expectedValue the expected value of the atomic exchange
1256      * @param newValue the new value of the atomic exchange
1257      * @param locationIdentity the identity of the memory location
1258      * @return The value after the atomic exchange

1259      *
1260      * @since 1.0
1261      */
1262     Object compareAndSwapObject(int offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity);
1263 
1264     /**
1265      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

1266      * offset are in bytes.
1267      *
1268      * @param offset the signed offset for the memory access
1269      * @param expectedValue the expected value of the atomic exchange
1270      * @param newValue the new value of the atomic exchange
1271      * @param locationIdentity the identity of the memory location
1272      * @return {@code true} if successful. False return indicates that the actual value was not
1273      *         equal to the expected value.
1274      *
1275      * @since 1.0
1276      */
1277     boolean logicCompareAndSwapInt(int offset, int expectedValue, int newValue, LocationIdentity locationIdentity);
1278 
1279     /**
1280      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

1281      * offset are in bytes.
1282      *
1283      * @param offset the signed offset for the memory access
1284      * @param expectedValue the expected value of the atomic exchange
1285      * @param newValue the new value of the atomic exchange
1286      * @param locationIdentity the identity of the memory location
1287      * @return {@code true} if successful. False return indicates that the actual value was not
1288      *         equal to the expected value.
1289      *
1290      * @since 1.0
1291      */
1292     boolean logicCompareAndSwapLong(int offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
1293 
1294     /**
1295      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

1296      * offset are in bytes.
1297      *
1298      * @param offset the signed offset for the memory access
1299      * @param expectedValue the expected value of the atomic exchange
1300      * @param newValue the new value of the atomic exchange
1301      * @param locationIdentity the identity of the memory location
1302      * @return {@code true} if successful. False return indicates that the actual value was not
1303      *         equal to the expected value.
1304      *
1305      * @since 1.0
1306      */
1307     boolean logicCompareAndSwapWord(int offset, WordBase expectedValue, WordBase newValue, LocationIdentity locationIdentity);
1308 
1309     /**
1310      * Atomically exchanges memory at address {@code (this + offset)}. Both the base address and

1311      * offset are in bytes.
1312      *
1313      * @param offset the signed offset for the memory access
1314      * @param expectedValue the expected value of the atomic exchange
1315      * @param newValue the new value of the atomic exchange
1316      * @param locationIdentity the identity of the memory location
1317      * @return {@code true} if successful. False return indicates that the actual value was not
1318      *         equal to the expected value.
1319      *
1320      * @since 1.0
1321      */
1322     boolean logicCompareAndSwapObject(int offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity);
1323 
1324     // Math functions that are defined in Unsigned, but known to preserve the
1325     // pointer-characteristics.
1326     // It is therefore safe that they return a static type of Pointer instead of Unsigned.
1327 
1328     /**
1329      * Returns a Pointer whose value is {@code (this + val)}.
1330      *
1331      * @param val value to be added to this Pointer.
1332      * @return {@code this + val}
1333      *
1334      * @since 1.0
1335      */


   1 /*
   2  * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * The Universal Permissive License (UPL), Version 1.0
   6  *
   7  * Subject to the condition set forth below, permission is hereby granted to any
   8  * person obtaining a copy of this software, associated documentation and/or
   9  * data (collectively the "Software"), free of charge and under any and all
  10  * copyright rights in the Software, and any and all patent rights owned or
  11  * freely licensable by each licensor hereunder covering either (i) the
  12  * unmodified Software as contributed to or provided by such licensor, or (ii)
  13  * the Larger Works (as defined below), to deal in both
  14  *
  15  * (a) the Software, and
  16  *
  17  * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
  18  * one is included with the Software each a "Larger Work" to which the Software
  19  * is contributed by such licensors),
  20  *
  21  * without restriction, including without limitation the rights to copy, create
  22  * derivative works of, display, perform, and distribute the Software and make,
  23  * use, sell, offer for sale, import, export, have made, and have sold the
  24  * Software and the Larger Work(s), and to sublicense the foregoing rights on
  25  * either these or other terms.
  26  *
  27  * This license is subject to the following condition:
  28  *
  29  * The above copyright notice and either this complete permission notice or at a
  30  * minimum a reference to the UPL must be included in all copies or substantial
  31  * portions of the Software.
  32  *
  33  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  34  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  35  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  36  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  37  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  38  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  39  * SOFTWARE.
  40  */


  41 package jdk.internal.vm.compiler.word;
  42 
  43 /**
  44  * Lowest-level memory access of native C memory.
  45  * <p>
  46  * Do not use these methods to access Java objects. These methods access the raw memory without any
  47  * null checks, read- or write barriers. Even when the VM uses compressed pointers, then readObject
  48  * and writeObject methods access uncompressed pointers.
  49  *
  50  * @since 1.0
  51  */
  52 public interface Pointer extends UnsignedWord, PointerBase {
  53 
  54     /**
  55      * Unsafe conversion of this Pointer to a Java language object. No correctness checks or type
  56      * checks are performed. The caller must ensure that the Pointer contains a valid Java object
  57      * that can i.e., processed by the garbage collector.
  58      *
  59      * @return this Pointer cast to Object.
  60      *


 958      * @since 1.0
 959      */
 960     void writeWord(WordBase offset, WordBase val);
 961 
 962     /**
 963      * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
 964      * bytes.
 965      * <p>
 966      * The offset is always treated as a {@link SignedWord} value. However, the static type is
 967      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
 968      * knows that the highest-order bit of the unsigned value is never used).
 969      *
 970      * @param offset the signed offset for the memory access
 971      * @param val the value to be written to memory
 972      *
 973      * @since 1.0
 974      */
 975     void writeObject(WordBase offset, Object val);
 976 
 977     /**
 978      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
 979      * expected value, and if equal, exchanges it for the new value. Both the base address and
 980      * offset are in bytes.
 981      * <p>
 982      * The offset is always treated as a {@link SignedWord} value. However, the static type is
 983      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
 984      * knows that the highest-order bit of the unsigned value is never used).
 985      *
 986      * @param offset the signed offset for the memory access
 987      * @param expectedValue the expected current value at the memory address
 988      * @param newValue the new value for the atomic exchange
 989      * @param locationIdentity the identity of the memory location
 990      * @return The value that was read for comparison, which is {@code expectedValue} if the
 991      *         exchange was performed.
 992      *
 993      * @since 1.0
 994      */
 995     int compareAndSwapInt(WordBase offset, int expectedValue, int newValue, LocationIdentity locationIdentity);
 996 
 997     /**
 998      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
 999      * expected value, and if equal, exchanges it for the new value. Both the base address and
1000      * offset are in bytes.
1001      * <p>
1002      * The offset is always treated as a {@link SignedWord} value. However, the static type is
1003      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
1004      * knows that the highest-order bit of the unsigned value is never used).
1005      *
1006      * @param offset the signed offset for the memory access
1007      * @param expectedValue the expected current value at the memory address
1008      * @param newValue the new value for the atomic exchange
1009      * @param locationIdentity the identity of the memory location
1010      * @return The value that was read for comparison, which is {@code expectedValue} if the
1011      *         exchange was performed.
1012      *
1013      * @since 1.0
1014      */
1015     long compareAndSwapLong(WordBase offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
1016 
1017     /**
1018      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1019      * expected value, and if equal, exchanges it for the new value. Both the base address and
1020      * offset are in bytes.
1021      * <p>
1022      * The offset is always treated as a {@link SignedWord} value. However, the static type is
1023      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
1024      * knows that the highest-order bit of the unsigned value is never used).
1025      *
1026      * @param offset the signed offset for the memory access
1027      * @param expectedValue the expected current value at the memory address
1028      * @param newValue the new value for the atomic exchange
1029      * @param locationIdentity the identity of the memory location
1030      * @return The value that was read for comparison, which is {@code expectedValue} if the
1031      *         exchange was performed.
1032      *
1033      * @since 1.0
1034      */
1035     <T extends WordBase> T compareAndSwapWord(WordBase offset, T expectedValue, T newValue, LocationIdentity locationIdentity);
1036 
1037     /**
1038      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1039      * expected value, and if equal, exchanges it for the new value. Both the base address and
1040      * offset are in bytes.
1041      * <p>
1042      * The offset is always treated as a {@link SignedWord} value. However, the static type is
1043      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
1044      * knows that the highest-order bit of the unsigned value is never used).
1045      *
1046      * @param offset the signed offset for the memory access
1047      * @param expectedValue the expected current value at the memory address
1048      * @param newValue the new value for the atomic exchange
1049      * @param locationIdentity the identity of the memory location
1050      * @return The value that was read for comparison, which is {@code expectedValue} if the
1051      *         exchange was performed.
1052      *
1053      * @since 1.0
1054      */
1055     Object compareAndSwapObject(WordBase offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity);
1056 
1057     /**
1058      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1059      * expected value, and if equal, exchanges it for the new value. Both the base address and
1060      * offset are in bytes.
1061      * <p>
1062      * The offset is always treated as a {@link SignedWord} value. However, the static type is
1063      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
1064      * knows that the highest-order bit of the unsigned value is never used).
1065      *
1066      * @param offset the signed offset for the memory access
1067      * @param expectedValue the expected current value at the memory address
1068      * @param newValue the new value for the atomic exchange
1069      * @param locationIdentity the identity of the memory location
1070      * @return {@code true} if successful. False return indicates that the actual value was not
1071      *         equal to the expected value.
1072      *
1073      * @since 1.0
1074      */
1075     boolean logicCompareAndSwapInt(WordBase offset, int expectedValue, int newValue, LocationIdentity locationIdentity);
1076 
1077     /**
1078      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1079      * expected value, and if equal, exchanges it for the new value. Both the base address and
1080      * offset are in bytes.
1081      * <p>
1082      * The offset is always treated as a {@link SignedWord} value. However, the static type is
1083      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
1084      * knows that the highest-order bit of the unsigned value is never used).
1085      *
1086      * @param offset the signed offset for the memory access
1087      * @param expectedValue the expected current value at the memory address
1088      * @param newValue the new value for the atomic exchange
1089      * @param locationIdentity the identity of the memory location
1090      * @return {@code true} if successful. False return indicates that the actual value was not
1091      *         equal to the expected value.
1092      *
1093      * @since 1.0
1094      */
1095     boolean logicCompareAndSwapLong(WordBase offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
1096 
1097     /**
1098      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1099      * expected value, and if equal, exchanges it for the new value. Both the base address and
1100      * offset are in bytes.
1101      * <p>
1102      * The offset is always treated as a {@link SignedWord} value. However, the static type is
1103      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
1104      * knows that the highest-order bit of the unsigned value is never used).
1105      *
1106      * @param offset the signed offset for the memory access
1107      * @param expectedValue the expected current value at the memory address
1108      * @param newValue the new value for the atomic exchange
1109      * @param locationIdentity the identity of the memory location
1110      * @return {@code true} if successful. False return indicates that the actual value was not
1111      *         equal to the expected value.
1112      *
1113      * @since 1.0
1114      */
1115     boolean logicCompareAndSwapWord(WordBase offset, WordBase expectedValue, WordBase newValue, LocationIdentity locationIdentity);
1116 
1117     /**
1118      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1119      * expected value, and if equal, exchanges it for the new value. Both the base address and
1120      * offset are in bytes.
1121      * <p>
1122      * The offset is always treated as a {@link SignedWord} value. However, the static type is
1123      * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
1124      * knows that the highest-order bit of the unsigned value is never used).
1125      *
1126      * @param offset the signed offset for the memory access
1127      * @param expectedValue the expected current value at the memory address
1128      * @param newValue the new value for the atomic exchange
1129      * @param locationIdentity the identity of the memory location
1130      * @return {@code true} if successful. False return indicates that the actual value was not
1131      *         equal to the expected value.
1132      *
1133      * @since 1.0
1134      */
1135     boolean logicCompareAndSwapObject(WordBase offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity);
1136 
1137     /**
1138      * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
1139      * bytes.
1140      *
1141      * @param offset the signed offset for the memory access
1142      * @param val the value to be written to memory
1143      *
1144      * @since 1.0
1145      */
1146     void writeByte(int offset, byte val);
1147 
1148     /**


1217      *
1218      * @param offset the signed offset for the memory access
1219      * @param val the value to be written to memory
1220      *
1221      * @since 1.0
1222      */
1223     void writeWord(int offset, WordBase val);
1224 
1225     /**
1226      * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
1227      * bytes.
1228      *
1229      * @param offset the signed offset for the memory access
1230      * @param val the value to be written to memory
1231      *
1232      * @since 1.0
1233      */
1234     void writeObject(int offset, Object val);
1235 
1236     /**
1237      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1238      * expected value, and if equal, exchanges it for the new value. Both the base address and
1239      * offset are in bytes.
1240      *
1241      * @param offset the signed offset for the memory access
1242      * @param expectedValue the expected current value at the memory address
1243      * @param newValue the new value for the atomic exchange
1244      * @param locationIdentity the identity of the memory location
1245      * @return The value that was read for comparison, which is {@code expectedValue} if the
1246      *         exchange was performed.
1247      *
1248      * @since 1.0
1249      */
1250     int compareAndSwapInt(int offset, int expectedValue, int newValue, LocationIdentity locationIdentity);
1251 
1252     /**
1253      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1254      * expected value, and if equal, exchanges it for the new value. Both the base address and
1255      * offset are in bytes.
1256      *
1257      * @param offset the signed offset for the memory access
1258      * @param expectedValue the expected current value at the memory address
1259      * @param newValue the new value for the atomic exchange
1260      * @param locationIdentity the identity of the memory location
1261      * @return The value that was read for comparison, which is {@code expectedValue} if the
1262      *         exchange was performed.
1263      *
1264      * @since 1.0
1265      */
1266     long compareAndSwapLong(int offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
1267 
1268     /**
1269      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1270      * expected value, and if equal, exchanges it for the new value. Both the base address and
1271      * offset are in bytes.
1272      *
1273      * @param offset the signed offset for the memory access
1274      * @param expectedValue the expected current value at the memory address
1275      * @param newValue the new value for the atomic exchange
1276      * @param locationIdentity the identity of the memory location
1277      * @return The value that was read for comparison, which is {@code expectedValue} if the
1278      *         exchange was performed.
1279      *
1280      * @since 1.0
1281      */
1282     <T extends WordBase> T compareAndSwapWord(int offset, T expectedValue, T newValue, LocationIdentity locationIdentity);
1283 
1284     /**
1285      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1286      * expected value, and if equal, exchanges it for the new value. Both the base address and
1287      * offset are in bytes.
1288      *
1289      * @param offset the signed offset for the memory access
1290      * @param expectedValue the expected current value at the memory address
1291      * @param newValue the new value for the atomic exchange
1292      * @param locationIdentity the identity of the memory location
1293      * @return The value that was read for comparison, which is {@code expectedValue} if the
1294      *         exchange was performed.
1295      *
1296      * @since 1.0
1297      */
1298     Object compareAndSwapObject(int offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity);
1299 
1300     /**
1301      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1302      * expected value, and if equal, exchanges it for the new value. Both the base address and
1303      * offset are in bytes.
1304      *
1305      * @param offset the signed offset for the memory access
1306      * @param expectedValue the expected current value at the memory address
1307      * @param newValue the new value for the atomic exchange
1308      * @param locationIdentity the identity of the memory location
1309      * @return {@code true} if successful. False return indicates that the actual value was not
1310      *         equal to the expected value.
1311      *
1312      * @since 1.0
1313      */
1314     boolean logicCompareAndSwapInt(int offset, int expectedValue, int newValue, LocationIdentity locationIdentity);
1315 
1316     /**
1317      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1318      * expected value, and if equal, exchanges it for the new value. Both the base address and
1319      * offset are in bytes.
1320      *
1321      * @param offset the signed offset for the memory access
1322      * @param expectedValue the expected current value at the memory address
1323      * @param newValue the new value for the atomic exchange
1324      * @param locationIdentity the identity of the memory location
1325      * @return {@code true} if successful. False return indicates that the actual value was not
1326      *         equal to the expected value.
1327      *
1328      * @since 1.0
1329      */
1330     boolean logicCompareAndSwapLong(int offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
1331 
1332     /**
1333      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1334      * expected value, and if equal, exchanges it for the new value. Both the base address and
1335      * offset are in bytes.
1336      *
1337      * @param offset the signed offset for the memory access
1338      * @param expectedValue the expected current value at the memory address
1339      * @param newValue the new value for the atomic exchange
1340      * @param locationIdentity the identity of the memory location
1341      * @return {@code true} if successful. False return indicates that the actual value was not
1342      *         equal to the expected value.
1343      *
1344      * @since 1.0
1345      */
1346     boolean logicCompareAndSwapWord(int offset, WordBase expectedValue, WordBase newValue, LocationIdentity locationIdentity);
1347 
1348     /**
1349      * In a single atomic step, compares the memory at address {@code (this + offset)} to the
1350      * expected value, and if equal, exchanges it for the new value. Both the base address and
1351      * offset are in bytes.
1352      *
1353      * @param offset the signed offset for the memory access
1354      * @param expectedValue the expected current value at the memory address
1355      * @param newValue the new value for the atomic exchange
1356      * @param locationIdentity the identity of the memory location
1357      * @return {@code true} if successful. False return indicates that the actual value was not
1358      *         equal to the expected value.
1359      *
1360      * @since 1.0
1361      */
1362     boolean logicCompareAndSwapObject(int offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity);
1363 
1364     // Math functions that are defined in Unsigned, but known to preserve the
1365     // pointer-characteristics.
1366     // It is therefore safe that they return a static type of Pointer instead of Unsigned.
1367 
1368     /**
1369      * Returns a Pointer whose value is {@code (this + val)}.
1370      *
1371      * @param val value to be added to this Pointer.
1372      * @return {@code this + val}
1373      *
1374      * @since 1.0
1375      */


< prev index next >