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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25package org.graalvm.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 */ 34public interface Pointer extends UnsignedWord, PointerBase { 35 36 /** 37 * Unsafe conversion of this Pointer to a Java language object. No correctness checks or type 38 * checks are performed. The caller must ensure that the Pointer contains a valid Java object 39 * that can i.e., processed by the garbage collector. 40 * 41 * @return this Pointer cast to Object. 42 */ 43 Object toObject(); 44 45 /** 46 * Unsafe conversion of this Pointer to a Java language object. No correctness checks or type 47 * checks are performed. The caller must ensure that the Pointer contains a valid Java object 48 * that can i.e., processed by the garbage collector and the Pointer does not contain 0. 49 * 50 * @return this Pointer cast to non-null Object. 51 */ 52 Object toObjectNonNull(); 53 54 /** 55 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 56 * bytes. 57 * <p> 58 * The offset is always treated as a {@link SignedWord} value. However, the static type is 59 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 60 * knows that the highest-order bit of the unsigned value is never used). 61 * 62 * @param offset the signed offset for the memory access 63 * @param locationIdentity the identity of the read 64 * @return the result of the memory access 65 */ 66 byte readByte(WordBase offset, LocationIdentity locationIdentity); 67 68 /** 69 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 70 * bytes. 71 * <p> 72 * The offset is always treated as a {@link SignedWord} value. However, the static type is 73 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 74 * knows that the highest-order bit of the unsigned value is never used). 75 * 76 * @param offset the signed offset for the memory access 77 * @param locationIdentity the identity of the read 78 * @return the result of the memory access 79 */ 80 char readChar(WordBase offset, LocationIdentity locationIdentity); 81 82 /** 83 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 84 * bytes. 85 * <p> 86 * The offset is always treated as a {@link SignedWord} value. However, the static type is 87 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 88 * knows that the highest-order bit of the unsigned value is never used). 89 * 90 * @param offset the signed offset for the memory access 91 * @param locationIdentity the identity of the read 92 * @return the result of the memory access 93 */ 94 short readShort(WordBase offset, LocationIdentity locationIdentity); 95 96 /** 97 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 98 * bytes. 99 * <p> 100 * The offset is always treated as a {@link SignedWord} value. However, the static type is 101 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 102 * knows that the highest-order bit of the unsigned value is never used). 103 * 104 * @param offset the signed offset for the memory access 105 * @param locationIdentity the identity of the read 106 * @return the result of the memory access 107 */ 108 int readInt(WordBase offset, LocationIdentity locationIdentity); 109 110 /** 111 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 112 * bytes. 113 * <p> 114 * The offset is always treated as a {@link SignedWord} value. However, the static type is 115 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 116 * knows that the highest-order bit of the unsigned value is never used). 117 * 118 * @param offset the signed offset for the memory access 119 * @param locationIdentity the identity of the read 120 * @return the result of the memory access 121 */ 122 long readLong(WordBase offset, LocationIdentity locationIdentity); 123 124 /** 125 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 126 * bytes. 127 * <p> 128 * The offset is always treated as a {@link SignedWord} value. However, the static type is 129 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 130 * knows that the highest-order bit of the unsigned value is never used). 131 * 132 * @param offset the signed offset for the memory access 133 * @param locationIdentity the identity of the read 134 * @return the result of the memory access 135 */ 136 float readFloat(WordBase offset, LocationIdentity locationIdentity); 137 138 /** 139 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 140 * bytes. 141 * <p> 142 * The offset is always treated as a {@link SignedWord} value. However, the static type is 143 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 144 * knows that the highest-order bit of the unsigned value is never used). 145 * 146 * @param offset the signed offset for the memory access 147 * @param locationIdentity the identity of the read 148 * @return the result of the memory access 149 */ 150 double readDouble(WordBase offset, LocationIdentity locationIdentity); 151 152 /** 153 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 154 * bytes. 155 * <p> 156 * The offset is always treated as a {@link SignedWord} value. However, the static type is 157 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 158 * knows that the highest-order bit of the unsigned value is never used). 159 * 160 * @param offset the signed offset for the memory access 161 * @param locationIdentity the identity of the read 162 * @return the result of the memory access 163 */ 164 <T extends WordBase> T readWord(WordBase offset, LocationIdentity locationIdentity); 165 166 /** 167 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 168 * bytes. 169 * <p> 170 * The offset is always treated as a {@link SignedWord} value. However, the static type is 171 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 172 * knows that the highest-order bit of the unsigned value is never used). 173 * 174 * @param offset the signed offset for the memory access 175 * @param locationIdentity the identity of the read 176 * @return the result of the memory access 177 */ 178 Object readObject(WordBase offset, LocationIdentity locationIdentity); 179 180 /** 181 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 182 * bytes. 183 * 184 * @param offset the signed offset for the memory access 185 * @param locationIdentity the identity of the read 186 * @return the result of the memory access 187 */ 188 byte readByte(int offset, LocationIdentity locationIdentity); 189 190 /** 191 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 192 * bytes. 193 * 194 * @param offset the signed offset for the memory access 195 * @param locationIdentity the identity of the read 196 * @return the result of the memory access 197 */ 198 char readChar(int offset, LocationIdentity locationIdentity); 199 200 /** 201 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 202 * bytes. 203 * 204 * @param offset the signed offset for the memory access 205 * @param locationIdentity the identity of the read 206 * @return the result of the memory access 207 */ 208 short readShort(int offset, LocationIdentity locationIdentity); 209 210 /** 211 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 212 * bytes. 213 * 214 * @param offset the signed offset for the memory access 215 * @param locationIdentity the identity of the read 216 * @return the result of the memory access 217 */ 218 int readInt(int offset, LocationIdentity locationIdentity); 219 220 /** 221 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 222 * bytes. 223 * 224 * @param offset the signed offset for the memory access 225 * @param locationIdentity the identity of the read 226 * @return the result of the memory access 227 */ 228 long readLong(int offset, LocationIdentity locationIdentity); 229 230 /** 231 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 232 * bytes. 233 * 234 * @param offset the signed offset for the memory access 235 * @param locationIdentity the identity of the read 236 * @return the result of the memory access 237 */ 238 float readFloat(int offset, LocationIdentity locationIdentity); 239 240 /** 241 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 242 * bytes. 243 * 244 * @param offset the signed offset for the memory access 245 * @param locationIdentity the identity of the read 246 * @return the result of the memory access 247 */ 248 double readDouble(int offset, LocationIdentity locationIdentity); 249 250 /** 251 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 252 * bytes. 253 * 254 * @param offset the signed offset for the memory access 255 * @param locationIdentity the identity of the read 256 * @return the result of the memory access 257 */ 258 <T extends WordBase> T readWord(int offset, LocationIdentity locationIdentity); 259 260 /** 261 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 262 * bytes. 263 * 264 * @param offset the signed offset for the memory access 265 * @param locationIdentity the identity of the read 266 * @return the result of the memory access 267 */ 268 Object readObject(int offset, LocationIdentity locationIdentity); 269 270 /** 271 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 272 * bytes. 273 * <p> 274 * The offset is always treated as a {@link SignedWord} value. However, the static type is 275 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 276 * knows that the highest-order bit of the unsigned value is never used). 277 * 278 * @param offset the signed offset for the memory access 279 * @param locationIdentity the identity of the write 280 * @param val the value to be written to memory 281 */ 282 void writeByte(WordBase offset, byte val, LocationIdentity locationIdentity); 283 284 /** 285 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 286 * bytes. 287 * <p> 288 * The offset is always treated as a {@link SignedWord} value. However, the static type is 289 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 290 * knows that the highest-order bit of the unsigned value is never used). 291 * 292 * @param offset the signed offset for the memory access 293 * @param locationIdentity the identity of the write 294 * @param val the value to be written to memory 295 */ 296 void writeChar(WordBase offset, char val, LocationIdentity locationIdentity); 297 298 /** 299 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 300 * bytes. 301 * <p> 302 * The offset is always treated as a {@link SignedWord} value. However, the static type is 303 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 304 * knows that the highest-order bit of the unsigned value is never used). 305 * 306 * @param offset the signed offset for the memory access 307 * @param locationIdentity the identity of the write 308 * @param val the value to be written to memory 309 */ 310 void writeShort(WordBase offset, short val, LocationIdentity locationIdentity); 311 312 /** 313 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 314 * bytes. 315 * <p> 316 * The offset is always treated as a {@link SignedWord} value. However, the static type is 317 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 318 * knows that the highest-order bit of the unsigned value is never used). 319 * 320 * @param offset the signed offset for the memory access 321 * @param locationIdentity the identity of the write 322 * @param val the value to be written to memory 323 */ 324 void writeInt(WordBase offset, int val, LocationIdentity locationIdentity); 325 326 /** 327 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 328 * bytes. 329 * <p> 330 * The offset is always treated as a {@link SignedWord} value. However, the static type is 331 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 332 * knows that the highest-order bit of the unsigned value is never used). 333 * 334 * @param offset the signed offset for the memory access 335 * @param locationIdentity the identity of the write 336 * @param val the value to be written to memory 337 */ 338 void writeLong(WordBase offset, long val, LocationIdentity locationIdentity); 339 340 /** 341 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 342 * bytes. 343 * <p> 344 * The offset is always treated as a {@link SignedWord} value. However, the static type is 345 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 346 * knows that the highest-order bit of the unsigned value is never used). 347 * 348 * @param offset the signed offset for the memory access 349 * @param locationIdentity the identity of the write 350 * @param val the value to be written to memory 351 */ 352 void writeFloat(WordBase offset, float val, LocationIdentity locationIdentity); 353 354 /** 355 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 356 * bytes. 357 * <p> 358 * The offset is always treated as a {@link SignedWord} value. However, the static type is 359 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 360 * knows that the highest-order bit of the unsigned value is never used). 361 * 362 * @param offset the signed offset for the memory access 363 * @param locationIdentity the identity of the write 364 * @param val the value to be written to memory 365 */ 366 void writeDouble(WordBase offset, double val, LocationIdentity locationIdentity); 367 368 /** 369 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 370 * bytes. 371 * <p> 372 * The offset is always treated as a {@link SignedWord} value. However, the static type is 373 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 374 * knows that the highest-order bit of the unsigned value is never used). 375 * 376 * @param offset the signed offset for the memory access 377 * @param locationIdentity the identity of the write 378 * @param val the value to be written to memory 379 */ 380 void writeWord(WordBase offset, WordBase val, LocationIdentity locationIdentity); 381 382 /** 383 * Initializes the memory at address {@code (this + offset)}. Both the base address and offset 384 * are in bytes. The memory must be uninitialized or zero prior to this operation. 385 * <p> 386 * The offset is always treated as a {@link SignedWord} value. However, the static type is 387 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 388 * knows that the highest-order bit of the unsigned value is never used). 389 * 390 * @param offset the signed offset for the memory access 391 * @param locationIdentity the identity of the write 392 * @param val the value to be written to memory 393 */ 394 void initializeLong(WordBase offset, long val, LocationIdentity locationIdentity); 395 396 /** 397 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 398 * bytes. 399 * <p> 400 * The offset is always treated as a {@link SignedWord} value. However, the static type is 401 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 402 * knows that the highest-order bit of the unsigned value is never used). 403 * 404 * @param offset the signed offset for the memory access 405 * @param locationIdentity the identity of the write 406 * @param val the value to be written to memory 407 */ 408 void writeObject(WordBase offset, Object val, LocationIdentity locationIdentity); 409 410 /** 411 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 412 * bytes. 413 * 414 * @param offset the signed offset for the memory access 415 * @param locationIdentity the identity of the write 416 * @param val the value to be written to memory 417 */ 418 void writeByte(int offset, byte val, LocationIdentity locationIdentity); 419 420 /** 421 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 422 * bytes. 423 * 424 * @param offset the signed offset for the memory access 425 * @param locationIdentity the identity of the write 426 * @param val the value to be written to memory 427 */ 428 void writeChar(int offset, char val, LocationIdentity locationIdentity); 429 430 /** 431 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 432 * bytes. 433 * 434 * @param offset the signed offset for the memory access 435 * @param locationIdentity the identity of the write 436 * @param val the value to be written to memory 437 */ 438 void writeShort(int offset, short val, LocationIdentity locationIdentity); 439 440 /** 441 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 442 * bytes. 443 * 444 * @param offset the signed offset for the memory access 445 * @param locationIdentity the identity of the write 446 * @param val the value to be written to memory 447 */ 448 void writeInt(int offset, int val, LocationIdentity locationIdentity); 449 450 /** 451 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 452 * bytes. 453 * 454 * @param offset the signed offset for the memory access 455 * @param locationIdentity the identity of the write 456 * @param val the value to be written to memory 457 */ 458 void writeLong(int offset, long val, LocationIdentity locationIdentity); 459 460 /** 461 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 462 * bytes. 463 * 464 * @param offset the signed offset for the memory access 465 * @param locationIdentity the identity of the write 466 * @param val the value to be written to memory 467 */ 468 void writeFloat(int offset, float val, LocationIdentity locationIdentity); 469 470 /** 471 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 472 * bytes. 473 * 474 * @param offset the signed offset for the memory access 475 * @param locationIdentity the identity of the write 476 * @param val the value to be written to memory 477 */ 478 void writeDouble(int offset, double val, LocationIdentity locationIdentity); 479 480 /** 481 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 482 * bytes. 483 * 484 * @param offset the signed offset for the memory access 485 * @param locationIdentity the identity of the write 486 * @param val the value to be written to memory 487 */ 488 void writeWord(int offset, WordBase val, LocationIdentity locationIdentity); 489 490 /** 491 * Initializes the memory at address {@code (this + offset)}. Both the base address and offset 492 * are in bytes. The memory must be uninitialized or zero prior to this operation. 493 * 494 * @param offset the signed offset for the memory access 495 * @param locationIdentity the identity of the write 496 * @param val the value to be written to memory 497 */ 498 void initializeLong(int offset, long val, LocationIdentity locationIdentity); 499 500 /** 501 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 502 * bytes. 503 * 504 * @param offset the signed offset for the memory access 505 * @param locationIdentity the identity of the write 506 * @param val the value to be written to memory 507 */ 508 void writeObject(int offset, Object val, LocationIdentity locationIdentity); 509 510 /** 511 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 512 * bytes. 513 * <p> 514 * The offset is always treated as a {@link SignedWord} value. However, the static type is 515 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 516 * knows that the highest-order bit of the unsigned value is never used). 517 * 518 * @param offset the signed offset for the memory access 519 * @return the result of the memory access 520 */ 521 byte readByte(WordBase offset); 522 523 /** 524 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 525 * bytes. 526 * <p> 527 * The offset is always treated as a {@link SignedWord} value. However, the static type is 528 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 529 * knows that the highest-order bit of the unsigned value is never used). 530 * 531 * @param offset the signed offset for the memory access 532 * @return the result of the memory access 533 */ 534 char readChar(WordBase offset); 535 536 /** 537 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 538 * bytes. 539 * <p> 540 * The offset is always treated as a {@link SignedWord} value. However, the static type is 541 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 542 * knows that the highest-order bit of the unsigned value is never used). 543 * 544 * @param offset the signed offset for the memory access 545 * @return the result of the memory access 546 */ 547 short readShort(WordBase offset); 548 549 /** 550 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 551 * bytes. 552 * <p> 553 * The offset is always treated as a {@link SignedWord} value. However, the static type is 554 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 555 * knows that the highest-order bit of the unsigned value is never used). 556 * 557 * @param offset the signed offset for the memory access 558 * @return the result of the memory access 559 */ 560 int readInt(WordBase offset); 561 562 /** 563 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 564 * bytes. 565 * <p> 566 * The offset is always treated as a {@link SignedWord} value. However, the static type is 567 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 568 * knows that the highest-order bit of the unsigned value is never used). 569 * 570 * @param offset the signed offset for the memory access 571 * @return the result of the memory access 572 */ 573 long readLong(WordBase offset); 574 575 /** 576 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 577 * bytes. 578 * <p> 579 * The offset is always treated as a {@link SignedWord} value. However, the static type is 580 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 581 * knows that the highest-order bit of the unsigned value is never used). 582 * 583 * @param offset the signed offset for the memory access 584 * @return the result of the memory access 585 */ 586 float readFloat(WordBase offset); 587 588 /** 589 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 590 * bytes. 591 * <p> 592 * The offset is always treated as a {@link SignedWord} value. However, the static type is 593 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 594 * knows that the highest-order bit of the unsigned value is never used). 595 * 596 * @param offset the signed offset for the memory access 597 * @return the result of the memory access 598 */ 599 double readDouble(WordBase offset); 600 601 /** 602 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 603 * bytes. 604 * <p> 605 * The offset is always treated as a {@link SignedWord} value. However, the static type is 606 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 607 * knows that the highest-order bit of the unsigned value is never used). 608 * 609 * @param offset the signed offset for the memory access 610 * @return the result of the memory access 611 */ 612 <T extends WordBase> T readWord(WordBase offset); 613 614 /** 615 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 616 * bytes. 617 * <p> 618 * The offset is always treated as a {@link SignedWord} value. However, the static type is 619 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 620 * knows that the highest-order bit of the unsigned value is never used). 621 * 622 * @param offset the signed offset for the memory access 623 * @return the result of the memory access 624 */ 625 Object readObject(WordBase offset); 626 627 /** 628 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 629 * bytes. 630 * 631 * @param offset the signed offset for the memory access 632 * @return the result of the memory access 633 */ 634 byte readByte(int offset); 635 636 /** 637 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 638 * bytes. 639 * 640 * @param offset the signed offset for the memory access 641 * @return the result of the memory access 642 */ 643 char readChar(int offset); 644 645 /** 646 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 647 * bytes. 648 * 649 * @param offset the signed offset for the memory access 650 * @return the result of the memory access 651 */ 652 short readShort(int offset); 653 654 /** 655 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 656 * bytes. 657 * 658 * @param offset the signed offset for the memory access 659 * @return the result of the memory access 660 */ 661 int readInt(int offset); 662 663 /** 664 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 665 * bytes. 666 * 667 * @param offset the signed offset for the memory access 668 * @return the result of the memory access 669 */ 670 long readLong(int offset); 671 672 /** 673 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 674 * bytes. 675 * 676 * @param offset the signed offset for the memory access 677 * @return the result of the memory access 678 */ 679 float readFloat(int offset); 680 681 /** 682 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 683 * bytes. 684 * 685 * @param offset the signed offset for the memory access 686 * @return the result of the memory access 687 */ 688 double readDouble(int offset); 689 690 /** 691 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 692 * bytes. 693 * 694 * @param offset the signed offset for the memory access 695 * @return the result of the memory access 696 */ 697 <T extends WordBase> T readWord(int offset); 698 699 /** 700 * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in 701 * bytes. 702 * 703 * @param offset the signed offset for the memory access 704 * @return the result of the memory access 705 */ 706 Object readObject(int offset); 707 708 /** 709 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 710 * bytes. 711 * <p> 712 * The offset is always treated as a {@link SignedWord} value. However, the static type is 713 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 714 * knows that the highest-order bit of the unsigned value is never used). 715 * 716 * @param offset the signed offset for the memory access 717 * @param val the value to be written to memory 718 */ 719 void writeByte(WordBase offset, byte val); 720 721 /** 722 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 723 * bytes. 724 * <p> 725 * The offset is always treated as a {@link SignedWord} value. However, the static type is 726 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 727 * knows that the highest-order bit of the unsigned value is never used). 728 * 729 * @param offset the signed offset for the memory access 730 * @param val the value to be written to memory 731 */ 732 void writeChar(WordBase offset, char val); 733 734 /** 735 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 736 * bytes. 737 * <p> 738 * The offset is always treated as a {@link SignedWord} value. However, the static type is 739 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 740 * knows that the highest-order bit of the unsigned value is never used). 741 * 742 * @param offset the signed offset for the memory access 743 * @param val the value to be written to memory 744 */ 745 void writeShort(WordBase offset, short val); 746 747 /** 748 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 749 * bytes. 750 * <p> 751 * The offset is always treated as a {@link SignedWord} value. However, the static type is 752 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 753 * knows that the highest-order bit of the unsigned value is never used). 754 * 755 * @param offset the signed offset for the memory access 756 * @param val the value to be written to memory 757 */ 758 void writeInt(WordBase offset, int val); 759 760 /** 761 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 762 * bytes. 763 * <p> 764 * The offset is always treated as a {@link SignedWord} value. However, the static type is 765 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 766 * knows that the highest-order bit of the unsigned value is never used). 767 * 768 * @param offset the signed offset for the memory access 769 * @param val the value to be written to memory 770 */ 771 void writeLong(WordBase offset, long val); 772 773 /** 774 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 775 * bytes. 776 * <p> 777 * The offset is always treated as a {@link SignedWord} value. However, the static type is 778 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 779 * knows that the highest-order bit of the unsigned value is never used). 780 * 781 * @param offset the signed offset for the memory access 782 * @param val the value to be written to memory 783 */ 784 void writeFloat(WordBase offset, float val); 785 786 /** 787 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 788 * bytes. 789 * <p> 790 * The offset is always treated as a {@link SignedWord} value. However, the static type is 791 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 792 * knows that the highest-order bit of the unsigned value is never used). 793 * 794 * @param offset the signed offset for the memory access 795 * @param val the value to be written to memory 796 */ 797 void writeDouble(WordBase offset, double val); 798 799 /** 800 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 801 * bytes. 802 * <p> 803 * The offset is always treated as a {@link SignedWord} value. However, the static type is 804 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 805 * knows that the highest-order bit of the unsigned value is never used). 806 * 807 * @param offset the signed offset for the memory access 808 * @param val the value to be written to memory 809 */ 810 void writeWord(WordBase offset, WordBase val); 811 812 /** 813 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 814 * bytes. 815 * <p> 816 * The offset is always treated as a {@link SignedWord} value. However, the static type is 817 * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller 818 * knows that the highest-order bit of the unsigned value is never used). 819 * 820 * @param offset the signed offset for the memory access 821 * @param val the value to be written to memory 822 */ 823 void writeObject(WordBase offset, Object val); 824 825 int compareAndSwapInt(WordBase offset, int expectedValue, int newValue, LocationIdentity locationIdentity); 826 827 long compareAndSwapLong(WordBase offset, long expectedValue, long newValue, LocationIdentity locationIdentity); 828 829 <T extends WordBase> T compareAndSwapWord(WordBase offset, T expectedValue, T newValue, LocationIdentity locationIdentity); 830 831 Object compareAndSwapObject(WordBase offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity); 832 833 boolean logicCompareAndSwapInt(WordBase offset, int expectedValue, int newValue, LocationIdentity locationIdentity); 834 835 boolean logicCompareAndSwapLong(WordBase offset, long expectedValue, long newValue, LocationIdentity locationIdentity); 836 837 boolean logicCompareAndSwapWord(WordBase offset, WordBase expectedValue, WordBase newValue, LocationIdentity locationIdentity); 838 839 boolean logicCompareAndSwapObject(WordBase offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity); 840 841 /** 842 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 843 * bytes. 844 * 845 * @param offset the signed offset for the memory access 846 * @param val the value to be written to memory 847 */ 848 void writeByte(int offset, byte val); 849 850 /** 851 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 852 * bytes. 853 * 854 * @param offset the signed offset for the memory access 855 * @param val the value to be written to memory 856 */ 857 void writeChar(int offset, char val); 858 859 /** 860 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 861 * bytes. 862 * 863 * @param offset the signed offset for the memory access 864 * @param val the value to be written to memory 865 */ 866 void writeShort(int offset, short val); 867 868 /** 869 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 870 * bytes. 871 * 872 * @param offset the signed offset for the memory access 873 * @param val the value to be written to memory 874 */ 875 void writeInt(int offset, int val); 876 877 /** 878 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 879 * bytes. 880 * 881 * @param offset the signed offset for the memory access 882 * @param val the value to be written to memory 883 */ 884 void writeLong(int offset, long val); 885 886 /** 887 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 888 * bytes. 889 * 890 * @param offset the signed offset for the memory access 891 * @param val the value to be written to memory 892 */ 893 void writeFloat(int offset, float val); 894 895 /** 896 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 897 * bytes. 898 * 899 * @param offset the signed offset for the memory access 900 * @param val the value to be written to memory 901 */ 902 void writeDouble(int offset, double val); 903 904 /** 905 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 906 * bytes. 907 * 908 * @param offset the signed offset for the memory access 909 * @param val the value to be written to memory 910 */ 911 void writeWord(int offset, WordBase val); 912 913 /** 914 * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in 915 * bytes. 916 * 917 * @param offset the signed offset for the memory access 918 * @param val the value to be written to memory 919 */ 920 void writeObject(int offset, Object val); 921 922 int compareAndSwapInt(int offset, int expectedValue, int newValue, LocationIdentity locationIdentity); 923 924 long compareAndSwapLong(int offset, long expectedValue, long newValue, LocationIdentity locationIdentity); 925 926 <T extends WordBase> T compareAndSwapWord(int offset, T expectedValue, T newValue, LocationIdentity locationIdentity); 927 928 Object compareAndSwapObject(int offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity); 929 930 boolean logicCompareAndSwapInt(int offset, int expectedValue, int newValue, LocationIdentity locationIdentity); 931 932 boolean logicCompareAndSwapLong(int offset, long expectedValue, long newValue, LocationIdentity locationIdentity); 933 934 boolean logicCompareAndSwapWord(int offset, WordBase expectedValue, WordBase newValue, LocationIdentity locationIdentity); 935 936 boolean logicCompareAndSwapObject(int offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity); 937 938 // Math functions that are defined in Unsigned, but known to preserve the 939 // pointer-characteristics. 940 // It is therefore safe that they return a static type of Pointer instead of Unsigned. 941 942 @Override 943 Pointer add(UnsignedWord val); 944 945 @Override 946 Pointer add(int val); 947 948 @Override 949 Pointer subtract(UnsignedWord val); 950 951 @Override 952 Pointer subtract(int val); 953 954 @Override 955 Pointer and(UnsignedWord val); 956 957 @Override 958 Pointer and(int val); 959 960 @Override 961 Pointer or(UnsignedWord val); 962 963 @Override 964 Pointer or(int val); 965} 966