/
Address.java
1003 lines (906 loc) · 26.3 KB
/
Address.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This file is part of the Jikes RVM project (http://jikesrvm.org).
*
* This file is licensed to You under the Common Public License (CPL);
* You may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.opensource.org/licenses/cpl1.0.php
*
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership.
*/
package org.vmmagic.unboxed;
import org.vmmagic.Unboxed;
import org.vmmagic.pragma.RawStorage;
/**
* <b>Stub</b> implementation of an Address type, intended only to
* allow the core of MMTk to be compiled. This <b>must</b> be
* replaced with a concrete implementation appropriate to a specific
* VM.
*
* The address type is used by the runtime system and collector to
* denote machine addresses. We use a separate type instead of the
* Java int type for coding clarity, machine-portability (it can map
* to 32 bit and 64 bit integral types), and access to unsigned
* operations (Java does not have unsigned int types).
*/
@Unboxed
@RawStorage(lengthInWords = true, length = 1)
public final class Address {
/****************************************************************************
*
* Special values
*/
private final ArchitecturalWord value;
Address(ArchitecturalWord value) {
this.value = value;
}
/**
* Return an <code>Address</code> instance that reflects the value
* zero.
*
* @return An address instance that reflects the value zero.
*/
public static Address zero() {
return new Address(ArchitecturalWord.fromLong(0));
}
/**
* Return <code>true</code> if this instance is zero.
*
* @return <code>true</code> if this instance is zero.
*/
public boolean isZero() {
return value.isZero();
}
/**
* Return an <code>Address</code> instance that reflects the maximum
* allowable <code>Address</code> value.
*
* @return An <code>Address</code> instance that reflects the
* maximum allowable <code>Address</code> value.
*/
public static Address max() {
return new Address(ArchitecturalWord.fromLong(0xFFFFFFFF));
}
/**
* Return <code>true</code> if this instance is the maximum
* allowable <code>Address</code> value.
*
* @return <code>true</code> if this instance is the maximum
* allowable <code>Address</code> valu.
*/
public boolean isMax() {
return value.isMax();
}
/****************************************************************************
*
* Conversions
*/
/**
* Fabricate an <code>Address</code> instance from an integer, after
* sign extending the integer.
*
* @param address the integer from which to create an <code>Address</code>
* instance
* @return An address instance
*/
public static Address fromIntSignExtend(int address) {
return new Address(ArchitecturalWord.fromIntSignExtend(address));
}
/**
* Fabricate an <code>Address</code> instance from an integer, after
* zero extending the integer.
*
* @param address the integer from which to create an <code>Address</code>
* instance
* @return An address instance
*/
public static Address fromIntZeroExtend(int address) {
return new Address(ArchitecturalWord.fromIntZeroExtend(address));
}
/**
* Fabricate an <code>Address</code> instance from an integer
*
* @param address the integer from which to create an <code>Address</code>
* instance
* @return An address instance
*/
public static Address fromLong(long address) {
return new Address(ArchitecturalWord.fromLong(address));
}
/**
* Fabricate an <code>ObjectReference</code> instance from an
* <code>Address</code> instance. It is the user's responsibility
* to ensure that the <code>Address</code> is suitable (i.e. it
* points to the object header, or satisfies any other VM-specific
* requirement for such a conversion).
*
* @return An <code>ObjectReference</code> instance.
*/
public ObjectReference toObjectReference() {
return new ObjectReference(value);
}
/**
* Return an integer that reflects the value of this
* <code>Address</code> instance.
*
* @return An integer that reflects the value of this
* <code>Address</code> instance.
*/
public int toInt() {
return value.toInt();
}
/**
* Return an long that reflects the value of this
* <code>Address</code> instance.
*
* @return An long that reflects the value of this
* <code>Address</code> instance.
*/
public long toLong() {
return value.toLongZeroExtend();
}
/**
* Return a <code>Word</code> instance that reflects the value of
* this <code>Address</code> instance.
*
* @return A <code>Word</code> instance that reflects the value of
* this <code>Address</code> instance.
*/
public Word toWord() {
return new Word(value);
}
/****************************************************************************
*
* Arithmetic operators
*/
/**
* Add an integer to this <code>Address</code>, and return the sum.
*
* @param v the value to be added to this <code>Address</code>
* @return An <code>Address</code> instance that reflects the result
* of the addition.
*/
public Address plus(int v) {
return new Address(value.plus(v));
}
/**
* Add an <code>Offset</code> to this <code>Address</code>, and
* return the sum.
*
* @param offset the <code>Offset</code> to be added to the address
* @return An <code>Address</code> instance that reflects the result
* of the addition.
*/
public Address plus(Offset offset) {
return new Address(value.plus(offset.toLong()));
}
/**
* Add an <code>Extent</code> to this <code>Address</code>, and
* return the sum.
*
* @param extent the <code>Extent</code> to be added to this
* <code>Address</code>
* @return An <code>Address</code> instance that reflects the result
* of the addition.
*/
public Address plus(Extent extent) {
return new Address(value.plus(extent.toLong()));
}
/**
* Subtract an integer from this <code>Address</code>, and return
* the result.
*
* @param v the integer to be subtracted from this
* <code>Address</code>.
* @return An <code>Address</code> instance that reflects the result
* of the subtraction.
*/
public Address minus(int v) {
return new Address(value.minus(v));// TODO 64-bit
}
/**
* Subtract an <code>Offset</code> from this <code>Address</code>, and
* return the result.
*
* @param offset the <code>Offset</code> to be subtracted from this
* <code>Address</code>.
* @return An <code>Address</code> instance that reflects the result
* of the subtraction.
*/
public Address minus(Offset offset) {
return new Address(value.minus(offset.toLong()));// TODO 64-bit
}
/**
* Subtract an <code>Extent</code> from this <code>Address</code>, and
* return the result.
*
* @param extent the <code>Extent</code> to be subtracted from this
* <code>Address</code>.
* @return An <code>Address</code> instance that reflects the result
* of the subtraction.
*/
public Address minus(Extent extent) {
return new Address(value.minus(extent.toLong()));
}
/**
* Compute the difference between two <code>Address</code>es and
* return the result.
*
* @param addr2 the <code>Address</code> to be subtracted from this
* <code>Address</code>.
* @return An <code>Offset</code> instance that reflects the result
* of the subtraction.
*/
public Offset diff(Address addr2) {
return new Offset(value.diff(addr2.value));
}
/****************************************************************************
*
* Boolean operators
*/
/**
* Return true if this <code>Address</code> instance is <i>less
* than</i> <code>addr2</code>.
*
* @param addr2 the <code>Address</code> to be compared to this
* <code>Address</code>.
* @return true if this <code>Address</code> instance is <i>less
* than</i> <code>addr2</code>.
*/
public boolean LT(Address addr2) {
return value.LT(addr2.value);
}
/**
* Return true if this <code>Address</code> instance is <i>less
* than or equal to</i> <code>addr2</code>.
*
* @param addr2 the <code>Address</code> to be compared to this
* <code>Address</code>.
* @return true if this <code>Address</code> instance is <i>less
* than or equal to</i> <code>addr2</code>.
*/
public boolean LE(Address addr2) {
return value.LE(addr2.value);
}
/**
* Return true if this <code>Address</code> instance is <i>greater
* than</i> <code>addr2</code>.
*
* @param addr2 the <code>Address</code> to be compared to this
* <code>Address</code>.
* @return true if this <code>Address</code> instance is <i>greater
* than</i> <code>addr2</code>.
*/
public boolean GT(Address addr2) {
return value.GT(addr2.value);
}
/**
* Return true if this <code>Address</code> instance is <i>greater
* than or equal to</i> <code>addr2</code>.
*
* @param addr2 the <code>Address</code> to be compared to this
* <code>Address</code>.
* @return true if this <code>Address</code> instance is <i>greater
* than or equal to</i> <code>addr2</code>.
*/
public boolean GE(Address addr2) {
return value.GE(addr2.value);
}
/**
* Return true if this <code>Address</code> instance is <i>equal
* to</i> <code>addr2</code>.
*
* @param addr2 the <code>Address</code> to be compared to this
* <code>Address</code>.
* @return true if this <code>Address</code> instance is <i>equal
* to</i> <code>addr2</code>.
*/
public boolean EQ(Address addr2) {
return value.EQ(addr2.value);
}
/**
* Return true if this <code>Address</code> instance is <i>not equal
* to</i> <code>addr2</code>.
*
* @param addr2 the <code>Address</code> to be compared to this
* <code>Address</code>.
* @return true if this <code>Address</code> instance is <i>not
* equal to</i> <code>addr2</code>.
*/
public boolean NE(Address addr2) {
return value.NE(addr2.value);
}
/****************************************************************************
*
* Software prefetch operators etc
*/
/**
* Prefetch a cache-line, architecture-independent
*/
public void prefetch() {
}
/****************************************************************************
*
* Memory access operators
*/
/**
* Loads a reference from the memory location pointed to by the
* current instance.
*
* @return the read value
*/
public ObjectReference loadObjectReference() {
return new ObjectReference(loadArchitecturalWord());
}
/**
* Loads a reference from the memory location pointed to by the
* current instance.
*
* @param offset the offset to the value.
* @return the read value
*/
public ObjectReference loadObjectReference(Offset offset) {
return new ObjectReference(loadArchitecturalWord(offset));
}
/**
* Loads a byte from the memory location pointed to by the
* current instance.
*
* @return the read value
*/
public byte loadByte() {
return SimulatedMemory.getByte(this);
}
/**
* Loads a byte from the memory location pointed to by the
* current instance.
*
* @param offset the offset to the value.
* @return the read value
*/
public byte loadByte(Offset offset) {
return this.plus(offset).loadByte();
}
/**
* Loads a char from the memory location pointed to by the
* current instance.
*
* @return the read value
*/
public char loadChar() {
return SimulatedMemory.getChar(this);
}
/**
* Loads a char from the memory location pointed to by the
* current instance.
*
* @param offset the offset to the value.
* @return the read value
*/
public char loadChar(Offset offset) {
return this.plus(offset).loadChar();
}
/**
* Loads a short from the memory location pointed to by the
* current instance.
*
* @return the read value
*/
public short loadShort() {
return SimulatedMemory.getShort(this);
}
/**
* Loads a short from the memory location pointed to by the
* current instance.
*
* @param offset the offset to the value.
* @return the read value
*/
public short loadShort(Offset offset) {
return this.plus(offset).loadShort();
}
/**
* Loads a float from the memory location pointed to by the
* current instance.
*
* @return the read value
*/
public float loadFloat() {
return SimulatedMemory.getFloat(this);
}
/**
* Loads a float from the memory location pointed to by the
* current instance.
*
* @param offset the offset to the value.
* @return the read value
*/
public float loadFloat(Offset offset) {
return this.plus(offset).loadFloat();
}
/**
* Loads an int from the memory location pointed to by the
* current instance.
*
* @return the read value
*/
public int loadInt() {
return SimulatedMemory.getInt(this);
}
/**
* Loads an int from the memory location pointed to by the
* current instance.
*
* @param offset the offset to the value.
* @return the read value
*/
public int loadInt(Offset offset) {
return this.plus(offset).loadInt();
}
/**
* Loads a long from the memory location pointed to by the
* current instance.
*
* @return the read value
*/
public long loadLong() {
return SimulatedMemory.getLong(this);
}
/**
* Loads a long from the memory location pointed to by the
* current instance.
*
* @param offset the offset to the value.
* @return the read value
*/
public long loadLong(Offset offset) {
return this.plus(offset).loadLong();
}
/**
* Loads a double from the memory location pointed to by the
* current instance.
*
* @return the read value
*/
public double loadDouble() {
return SimulatedMemory.getDouble(this);
}
/**
* Loads a double from the memory location pointed to by the
* current instance.
*
* @param offset the offset to the value.
* @return the read value
*/
public double loadDouble(Offset offset) {
return this.plus(offset).loadDouble();
}
/**
* Loads a word value from the memory location pointed to by the
* current instance.
*
* @param offset the offset to the value.
* @return the read word value.
*/
private ArchitecturalWord loadArchitecturalWord() {
return SimulatedMemory.getWord(this);
}
/**
* Loads a word value from the memory location pointed to by the
* current instance.
*
* @param offset the offset to the value.
* @return the read word value.
*/
private ArchitecturalWord loadArchitecturalWord(Offset offset) {
return SimulatedMemory.getWord(this.plus(offset));
}
/**
* Loads an address value from the memory location pointed to by the
* current instance.
*
* @return the read address value.
*/
public Address loadAddress() {
return new Address(loadArchitecturalWord());
}
/**
* Loads an address value from the memory location pointed to by the
* current instance.
*
* @param offset the offset to the value.
* @return the read address value.
*/
public Address loadAddress(Offset offset) {
return new Address(loadArchitecturalWord(offset));
}
/**
* Loads a word value from the memory location pointed to by the
* current instance.
*
* @return the read word value.
*/
public Word loadWord() {
return new Word(loadArchitecturalWord());
}
/**
* Loads a word value from the memory location pointed to by the
* current instance.
*
* @param offset the offset to the value.
* @return the read word value.
*/
public Word loadWord(Offset offset) {
return new Word(loadArchitecturalWord(offset));
}
/**
* Stores the address value in the memory location pointed to by the
* current instance.
*
* @param value The address value to store.
*/
public void store(ObjectReference value) {
SimulatedMemory.setWord(this, value.value);
}
/**
* Stores the object reference value in the memory location pointed
* to by the current instance.
*
* @param value The object reference value to store.
* @param offset the offset to the value.
*/
public void store(ObjectReference value, Offset offset) {
this.plus(offset).store(value);
}
/**
* Stores the address value in the memory location pointed to by the
* current instance.
*
* @param value The address value to store.
*/
public void store(Address value) {
SimulatedMemory.setWord(this, value.value);
}
/**
* Stores the address value in the memory location pointed to by the
* current instance.
*
* @param value The address value to store.
* @param offset the offset to the value.
*/
public void store(Address value, Offset offset) {
this.plus(offset).store(value);
}
/**
* Stores the float value in the memory location pointed to by the
* current instance.
*
* @param value The float value to store.
*/
public void store(float value) {
SimulatedMemory.setFloat(this, value);
}
/**
* Stores the float value in the memory location pointed to by the
* current instance.
*
* @param value The float value to store.
* @param offset the offset to the value.
*/
public void store(float value, Offset offset) {
this.plus(offset).store(value);
}
/**
* Stores the word value in the memory location pointed to by the
* current instance.
*
* @param value The word value to store.
*/
public void store(Word value) {
SimulatedMemory.setWord(this, value.value);
}
/**
* Stores the word value in the memory location pointed to by the
* current instance.
*
* @param value The word value to store.
* @param offset the offset to the value.
*/
public void store(Word value, Offset offset) {
this.plus(offset).store(value);
}
/**
* Stores the byte value in the memory location pointed to by the
* current instance.
*
* @param value The byte value to store.
*/
public void store(byte value) {
SimulatedMemory.setByte(this, value);
}
/**
* Stores the byte value in the memory location pointed to by the
* current instance.
*
* @param value The byte value to store.
* @param offset the offset to the value.
*/
public void store(byte value, Offset offset) {
this.plus(offset).store(value);
}
/**
* Stores an int value in memory location pointed to by the
* current instance.
*
* @param value The int value to store.
*/
public void store(int value) {
SimulatedMemory.setInt(this, value);
}
/**
* Stores an int value in memory location pointed to by the
* current instance.
*
* @param value The int value to store.
* @param offset the offset to the value.
*/
public void store(int value, Offset offset) {
this.plus(offset).store(value);
}
/**
* Stores a double value in memory location pointed to by the
* current instance.
*
* @param value The double value to store.
*/
public void store(double value) {
SimulatedMemory.setDouble(this, value);
}
/**
* Stores a double value in memory location pointed to by the
* current instance.
*
* @param value The double value to store.
* @param offset the offset to the value.
*/
public void store(double value, Offset offset) {
this.plus(offset).store(value);
}
/**
* Stores a double value in memory location pointed to by the
* current instance.
*
* @param value The double value to store.
*/
public void store(long value) {
SimulatedMemory.setLong(this, value);
}
/**
* Stores a double value in memory location pointed to by the
* current instance.
*
* @param value The double value to store.
* @param offset the offset to the value.
*/
public void store(long value, Offset offset) {
this.plus(offset).store(value);
}
/**
* Stores a char value in the memory location pointed to by the
* current instance.
*
* @param value the char value to store.
*/
public void store(char value) {
SimulatedMemory.setChar(this, value);
}
/**
* Stores a char value in the memory location pointed to by the
* current instance.
*
* @param value the char value to store.
* @param offset the offset to the value.
*/
public void store(char value, Offset offset) {
this.plus(offset).store(value);
}
/**
* Stores a short value in the memory location pointed to by the
* current instance.
*
* @param value the short value to store.
*/
public void store(short value) {
SimulatedMemory.setShort(this, value);
}
/**
* Stores a short value in the memory location pointed to by the
* current instance.
*
* @param value the short value to store.
* @param offset the offset to the value.
*/
public void store(short value, Offset offset) {
this.plus(offset).store(value);
}
/****************************************************************************
*
* Atomic memory access operators (compare and swap)
*/
/**
* Prepare for an atomic store operation. This must be associated with
* a related call to attempt.
*
* @return the old value to be passed to an attempt call.
*/
public Word prepareWord() {
return loadWord();
}
/**
* Prepare for an atomic store operation. This must be associated with
* a related call to attempt.
*
* @param offset the offset to the value.
* @return the old value to be passed to an attempt call.
*/
public Word prepareWord(Offset offset) {
return loadWord(offset);
}
/**
* Prepare for an atomic store operation. This must be associated with
* a related call to attempt.
*
* @return the old value to be passed to an attempt call.
*/
public ObjectReference prepareObjectReference() {
return loadObjectReference();
}
/**
* Prepare for an atomic store operation. This must be associated with
* a related call to attempt.
*
* @param offset the offset to the value.
* @return the old value to be passed to an attempt call.
*/
public ObjectReference prepareObjectReference(Offset offset) {
return loadObjectReference(offset);
}
/**
* Prepare for an atomic store operation. This must be associated with
* a related call to attempt.
*
* @return the old value to be passed to an attempt call.
*/
public Address prepareAddress() {
return loadAddress();
}
/**
* Prepare for an atomic store operation. This must be associated with
* a related call to attempt.
*
* @param offset the offset to the value.
* @return the old value to be passed to an attempt call.
*/
public Address prepareAddress(Offset offset) {
return loadAddress(offset);
}
/**
* Prepare for an atomic store operation. This must be associated with
* a related call to attempt.
*
* @return the old value to be passed to an attempt call.
*/
public int prepareInt() {
return loadInt();
}
/**
* Prepare for an atomic store operation. This must be associated with
* a related call to attempt.
*
* @param offset the offset to the value.
* @return the old value to be passed to an attempt call.
*/
public int prepareInt(Offset offset) {
return loadInt(offset);
}
/**
* Attempt an atomic store operation. This must be associated with a
* related call to prepare.
*
* @param old the old value.
* @param value the new value.
* @return true if the attempt was successful.
*/
public boolean attempt(int old, int value) {
return SimulatedMemory.exchangeInt(this, old, value);
}
/**
* Attempt an atomic store operation. This must be associated with a
* related call to prepare.
*
* @param old the old value.
* @param value the new value.
* @param offset the offset to the value.
* @return true if the attempt was successful.
*/
public boolean attempt(int old, int value, Offset offset) {
return this.plus(offset).attempt(old,value);
}
/**
* Attempt an atomic store operation. This must be associated with a
* related call to prepare.
*
* @param old the old value.
* @param value the new value.
* @return true if the attempt was successful.
*/
public boolean attempt(Word old, Word value) {
return SimulatedMemory.exchangeWord(this, old.value, value.value);
}
/**
* Attempt an atomic store operation. This must be associated with a
* related call to prepare.
*
* @param old the old value.
* @param value the new value.
* @param offset the offset to the value.
* @return true if the attempt was successful.
*/
public boolean attempt(Word old, Word value, Offset offset) {
return this.plus(offset).attempt(old,value);
}
/**
* Attempt an atomic store operation. This must be associated with a
* related call to prepare.
*
* @param old the old value.
* @param value the new value.
* @return true if the attempt was successful.
*/
public boolean attempt(ObjectReference old, ObjectReference value) {
return SimulatedMemory.exchangeWord(this, old.value, value.value);
}
/**
* Attempt an atomic store operation. This must be associated with a
* related call to prepare.
*
* @param old the old value.
* @param value the new value.
* @param offset the offset to the value.
* @return true if the attempt was successful.
*/
public boolean attempt(ObjectReference old, ObjectReference value, Offset offset) {
return this.plus(offset).attempt(old,value);
}
/**
* Attempt an atomic store operation. This must be associated with a
* related call to prepare.
*
* @param old the old value.
* @param value the new value.
* @return true if the attempt was successful.
*/
public boolean attempt(Address old, Address value) {
return SimulatedMemory.exchangeWord(this, old.value, value.value);
}
/**
* Attempt an atomic store operation. This must be associated with a
* related call to prepare.
*
* @param old the old value.
* @param value the new value.
* @param offset the offset to the value.
* @return true if the attempt was successful.
*/
public boolean attempt(Address old, Address value, Offset offset) {
return this.plus(offset).attempt(old,value);
}
/**
* Return a string representation of this address.
*/
public String toString() {