104 public static boolean unsafeCompareAndSetInt() { 105 Container container = new Container(); 106 return unsafe.compareAndSetInt(container, intOffset, 0xcafebabe, 0xbabefafa); 107 } 108 109 public static boolean unsafeCompareAndSetLong() { 110 Container container = new Container(); 111 return unsafe.compareAndSetLong(container, longOffset, 0xdedababafafaL, 0xfafacecafafadedaL); 112 } 113 114 public static boolean unsafeCompareAndSetFloat() { 115 Container container = new Container(); 116 return unsafe.compareAndSetFloat(container, floatOffset, 0.125f, 0.25f); 117 } 118 119 public static boolean unsafeCompareAndSetDouble() { 120 Container container = new Container(); 121 return unsafe.compareAndSetDouble(container, doubleOffset, 0.125, 0.25); 122 } 123 124 public static boolean unsafeCompareAndSetObject() { 125 Container container = new Container(); 126 return unsafe.compareAndSetObject(container, objectOffset, dummyValue, newDummyValue); 127 } 128 129 public static boolean unsafeCompareAndExchangeBoolean() { 130 Container container = new Container(); 131 return unsafe.compareAndExchangeBoolean(container, booleanOffset, false, true); 132 } 133 134 public static byte unsafeCompareAndExchangeByte() { 135 Container container = new Container(); 136 return unsafe.compareAndExchangeByte(container, byteOffset, (byte) 17, (byte) 31); 137 } 138 139 public static char unsafeCompareAndExchangeChar() { 140 Container container = new Container(); 141 return unsafe.compareAndExchangeChar(container, charOffset, (char) 1025, (char) 4502); 142 } 143 144 public static short unsafeCompareAndExchangeShort() { 145 Container container = new Container(); 146 return unsafe.compareAndExchangeShort(container, shortOffset, (short) 2232, (short) 8121); 149 public static int unsafeCompareAndExchangeInt() { 150 Container container = new Container(); 151 return unsafe.compareAndExchangeInt(container, intOffset, 0xcafebabe, 0xbabefafa); 152 } 153 154 public static long unsafeCompareAndExchangeLong() { 155 Container container = new Container(); 156 return unsafe.compareAndExchangeLong(container, longOffset, 0xdedababafafaL, 0xfafacecafafadedaL); 157 } 158 159 public static float unsafeCompareAndExchangeFloat() { 160 Container container = new Container(); 161 return unsafe.compareAndExchangeFloat(container, floatOffset, 0.125f, 0.25f); 162 } 163 164 public static double unsafeCompareAndExchangeDouble() { 165 Container container = new Container(); 166 return unsafe.compareAndExchangeDouble(container, doubleOffset, 0.125, 0.25); 167 } 168 169 public static Object unsafeCompareAndExchangeObject() { 170 Container container = new Container(); 171 return unsafe.compareAndExchangeObject(container, objectOffset, dummyValue, newDummyValue); 172 } 173 174 @Test 175 public void testCompareAndSet() { 176 TargetDescription target = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getTarget(); 177 if (target.arch instanceof AMD64) { 178 testGraph("unsafeCompareAndSetBoolean"); 179 testGraph("unsafeCompareAndSetByte"); 180 testGraph("unsafeCompareAndSetChar"); 181 testGraph("unsafeCompareAndSetShort"); 182 testGraph("unsafeCompareAndSetInt"); 183 testGraph("unsafeCompareAndSetLong"); 184 testGraph("unsafeCompareAndSetFloat"); 185 testGraph("unsafeCompareAndSetDouble"); 186 testGraph("unsafeCompareAndSetObject"); 187 testGraph("unsafeCompareAndExchangeBoolean"); 188 testGraph("unsafeCompareAndExchangeByte"); 189 testGraph("unsafeCompareAndExchangeChar"); 190 testGraph("unsafeCompareAndExchangeShort"); 191 testGraph("unsafeCompareAndExchangeInt"); 192 testGraph("unsafeCompareAndExchangeLong"); 193 testGraph("unsafeCompareAndExchangeFloat"); 194 testGraph("unsafeCompareAndExchangeDouble"); 195 testGraph("unsafeCompareAndExchangeObject"); 196 } 197 test("unsafeCompareAndSetBoolean"); 198 test("unsafeCompareAndSetByte"); 199 test("unsafeCompareAndSetChar"); 200 test("unsafeCompareAndSetShort"); 201 test("unsafeCompareAndSetInt"); 202 test("unsafeCompareAndSetLong"); 203 test("unsafeCompareAndSetFloat"); 204 test("unsafeCompareAndSetDouble"); 205 test("unsafeCompareAndSetObject"); 206 test("unsafeCompareAndExchangeBoolean"); 207 test("unsafeCompareAndExchangeByte"); 208 test("unsafeCompareAndExchangeChar"); 209 test("unsafeCompareAndExchangeShort"); 210 test("unsafeCompareAndExchangeInt"); 211 test("unsafeCompareAndExchangeLong"); 212 test("unsafeCompareAndExchangeFloat"); 213 test("unsafeCompareAndExchangeDouble"); 214 test("unsafeCompareAndExchangeObject"); 215 } 216 217 public static int unsafeGetAndAddByte() { 218 Container container = new Container(); 219 return unsafe.getAndAddByte(container, byteOffset, (byte) 2); 220 } 221 222 public static int unsafeGetAndAddChar() { 223 Container container = new Container(); 224 return unsafe.getAndAddChar(container, charOffset, (char) 250); 225 } 226 227 public static int unsafeGetAndAddShort() { 228 Container container = new Container(); 229 return unsafe.getAndAddShort(container, shortOffset, (short) 1250); 230 } 231 232 public static int unsafeGetAndAddInt() { 233 Container container = new Container(); 234 return unsafe.getAndAddInt(container, intOffset, 104501); 271 public static char unsafeGetAndSetChar() { 272 Container container = new Container(); 273 return unsafe.getAndSetChar(container, charOffset, (char) 21111); 274 } 275 276 public static short unsafeGetAndSetShort() { 277 Container container = new Container(); 278 return unsafe.getAndSetShort(container, shortOffset, (short) 21111); 279 } 280 281 public static int unsafeGetAndSetInt() { 282 Container container = new Container(); 283 return unsafe.getAndSetInt(container, intOffset, 0x1234af); 284 } 285 286 public static long unsafeGetAndSetLong() { 287 Container container = new Container(); 288 return unsafe.getAndSetLong(container, longOffset, 0x12345678abL); 289 } 290 291 public static Object unsafeGetAndSetObject() { 292 Container container = new Container(); 293 container.objectField = null; 294 Container other = new Container(); 295 return unsafe.getAndSetObject(container, objectOffset, other); 296 } 297 298 @Test 299 public void testGetAndSet() { 300 TargetDescription target = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getTarget(); 301 if (target.arch instanceof AMD64) { 302 testGraph("unsafeGetAndSetBoolean"); 303 testGraph("unsafeGetAndSetByte"); 304 testGraph("unsafeGetAndSetChar"); 305 testGraph("unsafeGetAndSetShort"); 306 } 307 if (target.arch instanceof AMD64 || target.arch instanceof AArch64) { 308 testGraph("unsafeGetAndSetInt"); 309 testGraph("unsafeGetAndSetLong"); 310 testGraph("unsafeGetAndSetObject"); 311 } 312 test("unsafeGetAndSetBoolean"); 313 test("unsafeGetAndSetByte"); 314 test("unsafeGetAndSetChar"); 315 test("unsafeGetAndSetShort"); 316 test("unsafeGetAndSetInt"); 317 test("unsafeGetAndSetLong"); 318 test("unsafeGetAndSetObject"); 319 } 320 321 public static void fieldInstance() { 322 JdkInternalMiscUnsafeAccessTestBoolean.testFieldInstance(); 323 } 324 325 @Test 326 public void testFieldInstance() { 327 test(new OptionValues(getInitialOptions(), HighTier.Options.Inline, false), "fieldInstance"); 328 } 329 330 public static void array() { 331 JdkInternalMiscUnsafeAccessTestBoolean.testArray(); 332 } 333 334 @Test 335 public void testArray() { 336 test(new OptionValues(getInitialOptions(), HighTier.Options.Inline, false), "array"); 337 } 338 545 } 546 547 public static long unsafeGetPutLong() { 548 Container container = new Container(); 549 unsafe.putLong(container, longOffset, 0x01234567890ABCDEFL); 550 return unsafe.getLong(container, longOffset); 551 } 552 553 public static float unsafeGetPutFloat() { 554 Container container = new Container(); 555 unsafe.putFloat(container, floatOffset, 1.234F); 556 return unsafe.getFloat(container, floatOffset); 557 } 558 559 public static double unsafeGetPutDouble() { 560 Container container = new Container(); 561 unsafe.putDouble(container, doubleOffset, 1.23456789); 562 return unsafe.getDouble(container, doubleOffset); 563 } 564 565 public static Object unsafeGetPutObject() { 566 Container container = new Container(); 567 unsafe.putObject(container, objectOffset, "Hello there"); 568 return unsafe.getObject(container, objectOffset); 569 } 570 571 public static boolean unsafeGetPutBooleanOpaque() { 572 Container container = new Container(); 573 unsafe.putBooleanOpaque(container, booleanOffset, true); 574 return unsafe.getBooleanOpaque(container, booleanOffset); 575 } 576 577 public static byte unsafeGetPutByteOpaque() { 578 Container container = new Container(); 579 unsafe.putByteOpaque(container, byteOffset, (byte) 0x12); 580 return unsafe.getByteOpaque(container, byteOffset); 581 } 582 583 public static short unsafeGetPutShortOpaque() { 584 Container container = new Container(); 585 unsafe.putShortOpaque(container, shortOffset, (short) 0x1234); 586 return unsafe.getShortOpaque(container, shortOffset); 587 } 588 599 } 600 601 public static long unsafeGetPutLongOpaque() { 602 Container container = new Container(); 603 unsafe.putLongOpaque(container, longOffset, 0x01234567890ABCDEFL); 604 return unsafe.getLongOpaque(container, longOffset); 605 } 606 607 public static float unsafeGetPutFloatOpaque() { 608 Container container = new Container(); 609 unsafe.putFloatOpaque(container, floatOffset, 1.234F); 610 return unsafe.getFloatOpaque(container, floatOffset); 611 } 612 613 public static double unsafeGetPutDoubleOpaque() { 614 Container container = new Container(); 615 unsafe.putDoubleOpaque(container, doubleOffset, 1.23456789); 616 return unsafe.getDoubleOpaque(container, doubleOffset); 617 } 618 619 public static Object unsafeGetPutObjectOpaque() { 620 Container container = new Container(); 621 unsafe.putObjectOpaque(container, objectOffset, "Hello there"); 622 return unsafe.getObjectOpaque(container, objectOffset); 623 } 624 625 public static boolean unsafeGetPutBooleanRA() { 626 Container container = new Container(); 627 unsafe.putBooleanRelease(container, booleanOffset, true); 628 return unsafe.getBooleanAcquire(container, booleanOffset); 629 } 630 631 public static byte unsafeGetPutByteRA() { 632 Container container = new Container(); 633 unsafe.putByteRelease(container, byteOffset, (byte) 0x12); 634 return unsafe.getByteAcquire(container, byteOffset); 635 } 636 637 public static short unsafeGetPutShortRA() { 638 Container container = new Container(); 639 unsafe.putShortRelease(container, shortOffset, (short) 0x1234); 640 return unsafe.getShortAcquire(container, shortOffset); 641 } 642 653 } 654 655 public static long unsafeGetPutLongRA() { 656 Container container = new Container(); 657 unsafe.putLongRelease(container, longOffset, 0x01234567890ABCDEFL); 658 return unsafe.getLongAcquire(container, longOffset); 659 } 660 661 public static float unsafeGetPutFloatRA() { 662 Container container = new Container(); 663 unsafe.putFloatRelease(container, floatOffset, 1.234F); 664 return unsafe.getFloatAcquire(container, floatOffset); 665 } 666 667 public static double unsafeGetPutDoubleRA() { 668 Container container = new Container(); 669 unsafe.putDoubleRelease(container, doubleOffset, 1.23456789); 670 return unsafe.getDoubleAcquire(container, doubleOffset); 671 } 672 673 public static Object unsafeGetPutObjectRA() { 674 Container container = new Container(); 675 unsafe.putObjectRelease(container, objectOffset, "Hello there"); 676 return unsafe.getObjectAcquire(container, objectOffset); 677 } 678 679 public static boolean unsafeGetPutBooleanVolatile() { 680 Container container = new Container(); 681 unsafe.putBooleanVolatile(container, booleanOffset, true); 682 return unsafe.getBooleanVolatile(container, booleanOffset); 683 } 684 685 public static byte unsafeGetPutByteVolatile() { 686 Container container = new Container(); 687 unsafe.putByteVolatile(container, byteOffset, (byte) 0x12); 688 return unsafe.getByteVolatile(container, byteOffset); 689 } 690 691 public static short unsafeGetPutShortVolatile() { 692 Container container = new Container(); 693 unsafe.putShortVolatile(container, shortOffset, (short) 0x1234); 694 return unsafe.getShortVolatile(container, shortOffset); 695 } 696 707 } 708 709 public static long unsafeGetPutLongVolatile() { 710 Container container = new Container(); 711 unsafe.putLongVolatile(container, longOffset, 0x01234567890ABCDEFL); 712 return unsafe.getLongVolatile(container, longOffset); 713 } 714 715 public static float unsafeGetPutFloatVolatile() { 716 Container container = new Container(); 717 unsafe.putFloatVolatile(container, floatOffset, 1.234F); 718 return unsafe.getFloatVolatile(container, floatOffset); 719 } 720 721 public static double unsafeGetPutDoubleVolatile() { 722 Container container = new Container(); 723 unsafe.putDoubleVolatile(container, doubleOffset, 1.23456789); 724 return unsafe.getDoubleVolatile(container, doubleOffset); 725 } 726 727 public static Object unsafeGetPutObjectVolatile() { 728 Container container = new Container(); 729 unsafe.putObjectVolatile(container, objectOffset, "Hello there"); 730 return unsafe.getObjectVolatile(container, objectOffset); 731 } 732 733 @Test 734 public void testUnsafeGetPutPlain() { 735 testGraph("unsafeGetPutBoolean"); 736 testGraph("unsafeGetPutByte"); 737 testGraph("unsafeGetPutShort"); 738 testGraph("unsafeGetPutChar"); 739 testGraph("unsafeGetPutInt"); 740 testGraph("unsafeGetPutLong"); 741 testGraph("unsafeGetPutFloat"); 742 testGraph("unsafeGetPutDouble"); 743 testGraph("unsafeGetPutObject"); 744 745 test("unsafeGetPutBoolean"); 746 test("unsafeGetPutByte"); 747 test("unsafeGetPutShort"); 748 test("unsafeGetPutChar"); 749 test("unsafeGetPutInt"); 750 test("unsafeGetPutLong"); 769 test("unsafeGetPutByteOpaque"); 770 test("unsafeGetPutShortOpaque"); 771 test("unsafeGetPutCharOpaque"); 772 test("unsafeGetPutIntOpaque"); 773 test("unsafeGetPutLongOpaque"); 774 test("unsafeGetPutFloatOpaque"); 775 test("unsafeGetPutDoubleOpaque"); 776 test("unsafeGetPutObjectOpaque"); 777 } 778 779 @Test 780 public void testUnsafeGetPutReleaseAcquire() { 781 testGraph("unsafeGetPutBooleanRA"); 782 testGraph("unsafeGetPutByteRA"); 783 testGraph("unsafeGetPutShortRA"); 784 testGraph("unsafeGetPutCharRA"); 785 testGraph("unsafeGetPutIntRA"); 786 testGraph("unsafeGetPutLongRA"); 787 testGraph("unsafeGetPutFloatRA"); 788 testGraph("unsafeGetPutDoubleRA"); 789 testGraph("unsafeGetPutObjectRA"); 790 791 test("unsafeGetPutBooleanRA"); 792 test("unsafeGetPutByteRA"); 793 test("unsafeGetPutShortRA"); 794 test("unsafeGetPutCharRA"); 795 test("unsafeGetPutIntRA"); 796 test("unsafeGetPutLongRA"); 797 test("unsafeGetPutFloatRA"); 798 test("unsafeGetPutDoubleRA"); 799 test("unsafeGetPutObjectRA"); 800 } 801 802 @Test 803 public void testUnsafeGetPutVolatile() { 804 testGraph("unsafeGetPutBooleanVolatile"); 805 testGraph("unsafeGetPutByteVolatile"); 806 testGraph("unsafeGetPutShortVolatile"); 807 testGraph("unsafeGetPutCharVolatile"); 808 testGraph("unsafeGetPutIntVolatile"); 809 testGraph("unsafeGetPutLongVolatile"); 810 testGraph("unsafeGetPutFloatVolatile"); 811 testGraph("unsafeGetPutDoubleVolatile"); 812 testGraph("unsafeGetPutObjectVolatile"); 813 814 test("unsafeGetPutBooleanVolatile"); 815 test("unsafeGetPutByteVolatile"); 816 test("unsafeGetPutShortVolatile"); 817 test("unsafeGetPutCharVolatile"); 818 test("unsafeGetPutIntVolatile"); 819 test("unsafeGetPutLongVolatile"); 820 test("unsafeGetPutFloatVolatile"); 821 test("unsafeGetPutDoubleVolatile"); 822 test("unsafeGetPutObjectVolatile"); 823 } 824 } | 104 public static boolean unsafeCompareAndSetInt() { 105 Container container = new Container(); 106 return unsafe.compareAndSetInt(container, intOffset, 0xcafebabe, 0xbabefafa); 107 } 108 109 public static boolean unsafeCompareAndSetLong() { 110 Container container = new Container(); 111 return unsafe.compareAndSetLong(container, longOffset, 0xdedababafafaL, 0xfafacecafafadedaL); 112 } 113 114 public static boolean unsafeCompareAndSetFloat() { 115 Container container = new Container(); 116 return unsafe.compareAndSetFloat(container, floatOffset, 0.125f, 0.25f); 117 } 118 119 public static boolean unsafeCompareAndSetDouble() { 120 Container container = new Container(); 121 return unsafe.compareAndSetDouble(container, doubleOffset, 0.125, 0.25); 122 } 123 124 public static boolean unsafeCompareAndSetReference() { 125 Container container = new Container(); 126 return unsafe.compareAndSetReference(container, objectOffset, dummyValue, newDummyValue); 127 } 128 129 public static boolean unsafeCompareAndExchangeBoolean() { 130 Container container = new Container(); 131 return unsafe.compareAndExchangeBoolean(container, booleanOffset, false, true); 132 } 133 134 public static byte unsafeCompareAndExchangeByte() { 135 Container container = new Container(); 136 return unsafe.compareAndExchangeByte(container, byteOffset, (byte) 17, (byte) 31); 137 } 138 139 public static char unsafeCompareAndExchangeChar() { 140 Container container = new Container(); 141 return unsafe.compareAndExchangeChar(container, charOffset, (char) 1025, (char) 4502); 142 } 143 144 public static short unsafeCompareAndExchangeShort() { 145 Container container = new Container(); 146 return unsafe.compareAndExchangeShort(container, shortOffset, (short) 2232, (short) 8121); 149 public static int unsafeCompareAndExchangeInt() { 150 Container container = new Container(); 151 return unsafe.compareAndExchangeInt(container, intOffset, 0xcafebabe, 0xbabefafa); 152 } 153 154 public static long unsafeCompareAndExchangeLong() { 155 Container container = new Container(); 156 return unsafe.compareAndExchangeLong(container, longOffset, 0xdedababafafaL, 0xfafacecafafadedaL); 157 } 158 159 public static float unsafeCompareAndExchangeFloat() { 160 Container container = new Container(); 161 return unsafe.compareAndExchangeFloat(container, floatOffset, 0.125f, 0.25f); 162 } 163 164 public static double unsafeCompareAndExchangeDouble() { 165 Container container = new Container(); 166 return unsafe.compareAndExchangeDouble(container, doubleOffset, 0.125, 0.25); 167 } 168 169 public static Object unsafeCompareAndExchangeReference() { 170 Container container = new Container(); 171 return unsafe.compareAndExchangeReference(container, objectOffset, dummyValue, newDummyValue); 172 } 173 174 @Test 175 public void testCompareAndSet() { 176 TargetDescription target = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getTarget(); 177 if (target.arch instanceof AMD64) { 178 testGraph("unsafeCompareAndSetBoolean"); 179 testGraph("unsafeCompareAndSetByte"); 180 testGraph("unsafeCompareAndSetChar"); 181 testGraph("unsafeCompareAndSetShort"); 182 testGraph("unsafeCompareAndSetInt"); 183 testGraph("unsafeCompareAndSetLong"); 184 testGraph("unsafeCompareAndSetFloat"); 185 testGraph("unsafeCompareAndSetDouble"); 186 testGraph("unsafeCompareAndSetReference"); 187 testGraph("unsafeCompareAndExchangeBoolean"); 188 testGraph("unsafeCompareAndExchangeByte"); 189 testGraph("unsafeCompareAndExchangeChar"); 190 testGraph("unsafeCompareAndExchangeShort"); 191 testGraph("unsafeCompareAndExchangeInt"); 192 testGraph("unsafeCompareAndExchangeLong"); 193 testGraph("unsafeCompareAndExchangeFloat"); 194 testGraph("unsafeCompareAndExchangeDouble"); 195 testGraph("unsafeCompareAndExchangeReference"); 196 } 197 test("unsafeCompareAndSetBoolean"); 198 test("unsafeCompareAndSetByte"); 199 test("unsafeCompareAndSetChar"); 200 test("unsafeCompareAndSetShort"); 201 test("unsafeCompareAndSetInt"); 202 test("unsafeCompareAndSetLong"); 203 test("unsafeCompareAndSetFloat"); 204 test("unsafeCompareAndSetDouble"); 205 test("unsafeCompareAndSetReference"); 206 test("unsafeCompareAndExchangeBoolean"); 207 test("unsafeCompareAndExchangeByte"); 208 test("unsafeCompareAndExchangeChar"); 209 test("unsafeCompareAndExchangeShort"); 210 test("unsafeCompareAndExchangeInt"); 211 test("unsafeCompareAndExchangeLong"); 212 test("unsafeCompareAndExchangeFloat"); 213 test("unsafeCompareAndExchangeDouble"); 214 test("unsafeCompareAndExchangeReference"); 215 } 216 217 public static int unsafeGetAndAddByte() { 218 Container container = new Container(); 219 return unsafe.getAndAddByte(container, byteOffset, (byte) 2); 220 } 221 222 public static int unsafeGetAndAddChar() { 223 Container container = new Container(); 224 return unsafe.getAndAddChar(container, charOffset, (char) 250); 225 } 226 227 public static int unsafeGetAndAddShort() { 228 Container container = new Container(); 229 return unsafe.getAndAddShort(container, shortOffset, (short) 1250); 230 } 231 232 public static int unsafeGetAndAddInt() { 233 Container container = new Container(); 234 return unsafe.getAndAddInt(container, intOffset, 104501); 271 public static char unsafeGetAndSetChar() { 272 Container container = new Container(); 273 return unsafe.getAndSetChar(container, charOffset, (char) 21111); 274 } 275 276 public static short unsafeGetAndSetShort() { 277 Container container = new Container(); 278 return unsafe.getAndSetShort(container, shortOffset, (short) 21111); 279 } 280 281 public static int unsafeGetAndSetInt() { 282 Container container = new Container(); 283 return unsafe.getAndSetInt(container, intOffset, 0x1234af); 284 } 285 286 public static long unsafeGetAndSetLong() { 287 Container container = new Container(); 288 return unsafe.getAndSetLong(container, longOffset, 0x12345678abL); 289 } 290 291 public static Object unsafeGetAndSetReference() { 292 Container container = new Container(); 293 container.objectField = null; 294 Container other = new Container(); 295 return unsafe.getAndSetReference(container, objectOffset, other); 296 } 297 298 @Test 299 public void testGetAndSet() { 300 TargetDescription target = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getTarget(); 301 if (target.arch instanceof AMD64) { 302 testGraph("unsafeGetAndSetBoolean"); 303 testGraph("unsafeGetAndSetByte"); 304 testGraph("unsafeGetAndSetChar"); 305 testGraph("unsafeGetAndSetShort"); 306 } 307 if (target.arch instanceof AMD64 || target.arch instanceof AArch64) { 308 testGraph("unsafeGetAndSetInt"); 309 testGraph("unsafeGetAndSetLong"); 310 testGraph("unsafeGetAndSetReference"); 311 } 312 test("unsafeGetAndSetBoolean"); 313 test("unsafeGetAndSetByte"); 314 test("unsafeGetAndSetChar"); 315 test("unsafeGetAndSetShort"); 316 test("unsafeGetAndSetInt"); 317 test("unsafeGetAndSetLong"); 318 test("unsafeGetAndSetReference"); 319 } 320 321 public static void fieldInstance() { 322 JdkInternalMiscUnsafeAccessTestBoolean.testFieldInstance(); 323 } 324 325 @Test 326 public void testFieldInstance() { 327 test(new OptionValues(getInitialOptions(), HighTier.Options.Inline, false), "fieldInstance"); 328 } 329 330 public static void array() { 331 JdkInternalMiscUnsafeAccessTestBoolean.testArray(); 332 } 333 334 @Test 335 public void testArray() { 336 test(new OptionValues(getInitialOptions(), HighTier.Options.Inline, false), "array"); 337 } 338 545 } 546 547 public static long unsafeGetPutLong() { 548 Container container = new Container(); 549 unsafe.putLong(container, longOffset, 0x01234567890ABCDEFL); 550 return unsafe.getLong(container, longOffset); 551 } 552 553 public static float unsafeGetPutFloat() { 554 Container container = new Container(); 555 unsafe.putFloat(container, floatOffset, 1.234F); 556 return unsafe.getFloat(container, floatOffset); 557 } 558 559 public static double unsafeGetPutDouble() { 560 Container container = new Container(); 561 unsafe.putDouble(container, doubleOffset, 1.23456789); 562 return unsafe.getDouble(container, doubleOffset); 563 } 564 565 public static Object unsafeGetPutReference() { 566 Container container = new Container(); 567 unsafe.putReference(container, objectOffset, "Hello there"); 568 return unsafe.getReference(container, objectOffset); 569 } 570 571 public static boolean unsafeGetPutBooleanOpaque() { 572 Container container = new Container(); 573 unsafe.putBooleanOpaque(container, booleanOffset, true); 574 return unsafe.getBooleanOpaque(container, booleanOffset); 575 } 576 577 public static byte unsafeGetPutByteOpaque() { 578 Container container = new Container(); 579 unsafe.putByteOpaque(container, byteOffset, (byte) 0x12); 580 return unsafe.getByteOpaque(container, byteOffset); 581 } 582 583 public static short unsafeGetPutShortOpaque() { 584 Container container = new Container(); 585 unsafe.putShortOpaque(container, shortOffset, (short) 0x1234); 586 return unsafe.getShortOpaque(container, shortOffset); 587 } 588 599 } 600 601 public static long unsafeGetPutLongOpaque() { 602 Container container = new Container(); 603 unsafe.putLongOpaque(container, longOffset, 0x01234567890ABCDEFL); 604 return unsafe.getLongOpaque(container, longOffset); 605 } 606 607 public static float unsafeGetPutFloatOpaque() { 608 Container container = new Container(); 609 unsafe.putFloatOpaque(container, floatOffset, 1.234F); 610 return unsafe.getFloatOpaque(container, floatOffset); 611 } 612 613 public static double unsafeGetPutDoubleOpaque() { 614 Container container = new Container(); 615 unsafe.putDoubleOpaque(container, doubleOffset, 1.23456789); 616 return unsafe.getDoubleOpaque(container, doubleOffset); 617 } 618 619 public static Object unsafeGetPutReferenceOpaque() { 620 Container container = new Container(); 621 unsafe.putReferenceOpaque(container, objectOffset, "Hello there"); 622 return unsafe.getReferenceOpaque(container, objectOffset); 623 } 624 625 public static boolean unsafeGetPutBooleanRA() { 626 Container container = new Container(); 627 unsafe.putBooleanRelease(container, booleanOffset, true); 628 return unsafe.getBooleanAcquire(container, booleanOffset); 629 } 630 631 public static byte unsafeGetPutByteRA() { 632 Container container = new Container(); 633 unsafe.putByteRelease(container, byteOffset, (byte) 0x12); 634 return unsafe.getByteAcquire(container, byteOffset); 635 } 636 637 public static short unsafeGetPutShortRA() { 638 Container container = new Container(); 639 unsafe.putShortRelease(container, shortOffset, (short) 0x1234); 640 return unsafe.getShortAcquire(container, shortOffset); 641 } 642 653 } 654 655 public static long unsafeGetPutLongRA() { 656 Container container = new Container(); 657 unsafe.putLongRelease(container, longOffset, 0x01234567890ABCDEFL); 658 return unsafe.getLongAcquire(container, longOffset); 659 } 660 661 public static float unsafeGetPutFloatRA() { 662 Container container = new Container(); 663 unsafe.putFloatRelease(container, floatOffset, 1.234F); 664 return unsafe.getFloatAcquire(container, floatOffset); 665 } 666 667 public static double unsafeGetPutDoubleRA() { 668 Container container = new Container(); 669 unsafe.putDoubleRelease(container, doubleOffset, 1.23456789); 670 return unsafe.getDoubleAcquire(container, doubleOffset); 671 } 672 673 public static Object unsafeGetPutReferenceRA() { 674 Container container = new Container(); 675 unsafe.putReferenceRelease(container, objectOffset, "Hello there"); 676 return unsafe.getReferenceAcquire(container, objectOffset); 677 } 678 679 public static boolean unsafeGetPutBooleanVolatile() { 680 Container container = new Container(); 681 unsafe.putBooleanVolatile(container, booleanOffset, true); 682 return unsafe.getBooleanVolatile(container, booleanOffset); 683 } 684 685 public static byte unsafeGetPutByteVolatile() { 686 Container container = new Container(); 687 unsafe.putByteVolatile(container, byteOffset, (byte) 0x12); 688 return unsafe.getByteVolatile(container, byteOffset); 689 } 690 691 public static short unsafeGetPutShortVolatile() { 692 Container container = new Container(); 693 unsafe.putShortVolatile(container, shortOffset, (short) 0x1234); 694 return unsafe.getShortVolatile(container, shortOffset); 695 } 696 707 } 708 709 public static long unsafeGetPutLongVolatile() { 710 Container container = new Container(); 711 unsafe.putLongVolatile(container, longOffset, 0x01234567890ABCDEFL); 712 return unsafe.getLongVolatile(container, longOffset); 713 } 714 715 public static float unsafeGetPutFloatVolatile() { 716 Container container = new Container(); 717 unsafe.putFloatVolatile(container, floatOffset, 1.234F); 718 return unsafe.getFloatVolatile(container, floatOffset); 719 } 720 721 public static double unsafeGetPutDoubleVolatile() { 722 Container container = new Container(); 723 unsafe.putDoubleVolatile(container, doubleOffset, 1.23456789); 724 return unsafe.getDoubleVolatile(container, doubleOffset); 725 } 726 727 public static Object unsafeGetPutReferenceVolatile() { 728 Container container = new Container(); 729 unsafe.putReferenceVolatile(container, objectOffset, "Hello there"); 730 return unsafe.getReferenceVolatile(container, objectOffset); 731 } 732 733 @Test 734 public void testUnsafeGetPutPlain() { 735 testGraph("unsafeGetPutBoolean"); 736 testGraph("unsafeGetPutByte"); 737 testGraph("unsafeGetPutShort"); 738 testGraph("unsafeGetPutChar"); 739 testGraph("unsafeGetPutInt"); 740 testGraph("unsafeGetPutLong"); 741 testGraph("unsafeGetPutFloat"); 742 testGraph("unsafeGetPutDouble"); 743 testGraph("unsafeGetPutObject"); 744 745 test("unsafeGetPutBoolean"); 746 test("unsafeGetPutByte"); 747 test("unsafeGetPutShort"); 748 test("unsafeGetPutChar"); 749 test("unsafeGetPutInt"); 750 test("unsafeGetPutLong"); 769 test("unsafeGetPutByteOpaque"); 770 test("unsafeGetPutShortOpaque"); 771 test("unsafeGetPutCharOpaque"); 772 test("unsafeGetPutIntOpaque"); 773 test("unsafeGetPutLongOpaque"); 774 test("unsafeGetPutFloatOpaque"); 775 test("unsafeGetPutDoubleOpaque"); 776 test("unsafeGetPutObjectOpaque"); 777 } 778 779 @Test 780 public void testUnsafeGetPutReleaseAcquire() { 781 testGraph("unsafeGetPutBooleanRA"); 782 testGraph("unsafeGetPutByteRA"); 783 testGraph("unsafeGetPutShortRA"); 784 testGraph("unsafeGetPutCharRA"); 785 testGraph("unsafeGetPutIntRA"); 786 testGraph("unsafeGetPutLongRA"); 787 testGraph("unsafeGetPutFloatRA"); 788 testGraph("unsafeGetPutDoubleRA"); 789 testGraph("unsafeGetPutReferenceRA"); 790 791 test("unsafeGetPutBooleanRA"); 792 test("unsafeGetPutByteRA"); 793 test("unsafeGetPutShortRA"); 794 test("unsafeGetPutCharRA"); 795 test("unsafeGetPutIntRA"); 796 test("unsafeGetPutLongRA"); 797 test("unsafeGetPutFloatRA"); 798 test("unsafeGetPutDoubleRA"); 799 test("unsafeGetPutReferenceRA"); 800 } 801 802 @Test 803 public void testUnsafeGetPutVolatile() { 804 testGraph("unsafeGetPutBooleanVolatile"); 805 testGraph("unsafeGetPutByteVolatile"); 806 testGraph("unsafeGetPutShortVolatile"); 807 testGraph("unsafeGetPutCharVolatile"); 808 testGraph("unsafeGetPutIntVolatile"); 809 testGraph("unsafeGetPutLongVolatile"); 810 testGraph("unsafeGetPutFloatVolatile"); 811 testGraph("unsafeGetPutDoubleVolatile"); 812 testGraph("unsafeGetPutReferenceVolatile"); 813 814 test("unsafeGetPutBooleanVolatile"); 815 test("unsafeGetPutByteVolatile"); 816 test("unsafeGetPutShortVolatile"); 817 test("unsafeGetPutCharVolatile"); 818 test("unsafeGetPutIntVolatile"); 819 test("unsafeGetPutLongVolatile"); 820 test("unsafeGetPutFloatVolatile"); 821 test("unsafeGetPutDoubleVolatile"); 822 test("unsafeGetPutReferenceVolatile"); 823 } 824 } |