-
Notifications
You must be signed in to change notification settings - Fork 746
/
Copy pathObjectAccessBarrierAPI.hpp
3027 lines (2758 loc) · 114 KB
/
ObjectAccessBarrierAPI.hpp
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
/*******************************************************************************
* Copyright IBM Corp. and others 1991
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] https://openjdk.org/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
*******************************************************************************/
#if !defined(OBJECTACCESSBARRIERAPI_HPP_)
#define OBJECTACCESSBARRIERAPI_HPP_
#include "j9cfg.h"
#if defined(OMR_OVERRIDE_COMPRESS_OBJECT_REFERENCES)
#if OMR_OVERRIDE_COMPRESS_OBJECT_REFERENCES
#define MM_ObjectAccessBarrierAPI MM_ObjectAccessBarrierAPICompressed
#else /* OMR_OVERRIDE_COMPRESS_OBJECT_REFERENCES */
#define MM_ObjectAccessBarrierAPI MM_ObjectAccessBarrierAPIFull
#endif /* OMR_OVERRIDE_COMPRESS_OBJECT_REFERENCES */
#endif /* OMR_OVERRIDE_COMPRESS_OBJECT_REFERENCES */
#include "j9.h"
#include "j9modron.h"
#include "omrmodroncore.h"
#include "omr.h"
#include "AtomicSupport.hpp"
#include "ArrayCopyHelpers.hpp"
#include "ObjectMonitor.hpp"
#include "j9nongenerated.h"
#define J9OAB_MIXEDOBJECT_EA(object, offset, type) (type *)(((U_8 *)(object)) + offset)
class MM_ObjectAccessBarrierAPI
{
friend class MM_ObjectAccessBarrier;
friend class MM_RealtimeAccessBarrier;
/* Data members & types */
public:
private:
const UDATA _writeBarrierType;
const UDATA _readBarrierType;
#if defined(OMR_GC_COMPRESSED_POINTERS)
const UDATA _compressedPointersShift;
#endif /* defined(OMR_GC_COMPRESSED_POINTERS) */
protected:
#if defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS)
bool const _compressObjectReferences;
#endif /* defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS) */
/* Methods */
public:
/**
* Create an instance.
*/
MM_ObjectAccessBarrierAPI(J9VMThread *currentThread)
: _writeBarrierType(currentThread->javaVM->gcWriteBarrierType)
, _readBarrierType(currentThread->javaVM->gcReadBarrierType)
#if defined(OMR_GC_COMPRESSED_POINTERS)
, _compressedPointersShift(currentThread->javaVM->compressedPointersShift)
#endif /* defined(OMR_GC_COMPRESSED_POINTERS) */
#if defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS)
, _compressObjectReferences(J9VMTHREAD_COMPRESS_OBJECT_REFERENCES(currentThread))
#endif /* defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS) */
{}
/**
* Return back true if object references are compressed
* @return true, if object references are compressed
*/
MMINLINE bool compressObjectReferences() {
return OMR_COMPRESS_OBJECT_REFERENCES(_compressObjectReferences);
}
static VMINLINE void
internalPostBatchStoreObjectCardTableAndGenerational(J9VMThread *vmThread, j9object_t object)
{
/* Check to see if object is old. If object is not old neither barrier is required
* if ((object - vmThread->omrVMThread->heapBaseForBarrierRange0) < vmThread->omrVMThread->heapSizeForBarrierRange0) then old
*
* Since card dirtying also requires this calculation remember these values
*/
UDATA base = (UDATA)vmThread->omrVMThread->heapBaseForBarrierRange0;
UDATA objectDelta = (UDATA)object - base;
UDATA size = vmThread->omrVMThread->heapSizeForBarrierRange0;
if (objectDelta < size) {
/* object is old so check for concurrent barrier */
if (0 != (vmThread->privateFlags & J9_PRIVATE_FLAGS_CONCURRENT_MARK_ACTIVE)) {
/* concurrent barrier is enabled so dirty the card for object */
dirtyCard(vmThread, objectDelta);
}
/* generational barrier is required if object is old*/
rememberObject(vmThread, object);
}
}
static VMINLINE void
internalPostBatchStoreObjectGenerational(J9VMThread *vmThread, j9object_t object)
{
/* Check to see if object is old. If object is not old neither barrier is required
* if ((object - vmThread->omrVMThread->heapBaseForBarrierRange0) < vmThread->omrVMThread->heapSizeForBarrierRange0) then old
*
* Since card dirtying also requires this calculation remember these values
*/
UDATA base = (UDATA)vmThread->omrVMThread->heapBaseForBarrierRange0;
UDATA objectDelta = (UDATA)object - base;
UDATA size = vmThread->omrVMThread->heapSizeForBarrierRange0;
if (objectDelta < size) {
/* generational barrier is required if object is old*/
rememberObject(vmThread, object);
}
}
static VMINLINE void
internalPostBatchStoreObjectCardTableIncremental(J9VMThread *vmThread, j9object_t object)
{
/* Check to see if object is within the barrier range.
* if ((object - vmThread->omrVMThread->heapBaseForBarrierRange0) < vmThread->omrVMThread->heapSizeForBarrierRange0)
*
* Since card dirtying also requires this calculation remember these values
*/
UDATA base = (UDATA)vmThread->omrVMThread->heapBaseForBarrierRange0;
UDATA objectDelta = (UDATA)object - base;
UDATA size = vmThread->omrVMThread->heapSizeForBarrierRange0;
if (objectDelta < size) {
/* Object is within the barrier range. Dirty the card */
dirtyCard(vmThread, objectDelta);
}
}
static VMINLINE void
internalPostBatchStoreObjectCardTable(J9VMThread *vmThread, j9object_t object)
{
/* Check to see if object is old. If object is not old neither barrier is required
* if ((object - vmThread->omrVMThread->heapBaseForBarrierRange0) < vmThread->omrVMThread->heapSizeForBarrierRange0) then old
*
* Since card dirtying also requires this calculation remember these values
*/
UDATA base = (UDATA)vmThread->omrVMThread->heapBaseForBarrierRange0;
UDATA objectDelta = (UDATA)object - base;
UDATA size = vmThread->omrVMThread->heapSizeForBarrierRange0;
if (objectDelta < size) {
/* object is old so check for concurrent barrier */
if (0 != (vmThread->privateFlags & J9_PRIVATE_FLAGS_CONCURRENT_MARK_ACTIVE)) {
/* concurrent barrier is enabled so dirty the card for object */
dirtyCard(vmThread, objectDelta);
}
}
}
/**
* Call after storing an object reference for barrier type
* j9gc_modron_wrtbar_cardmark_and_oldcheck
*
* @param object the object being stored into
* @param value the object reference being stored
*
*/
static VMINLINE void
internalPostObjectStoreCardTableAndGenerational(J9VMThread *vmThread, j9object_t object, j9object_t value)
{
/* if value is NULL neither barrier is required */
if (NULL != value) {
/* Check to see if object is old. If object is not old neither barrier is required
* if ((object - vmThread->omrVMThread->heapBaseForBarrierRange0) < vmThread->omrVMThread->heapSizeForBarrierRange0) then old
*
* Since card dirtying also requires this calculation remember these values
*/
UDATA base = (UDATA)vmThread->omrVMThread->heapBaseForBarrierRange0;
UDATA objectDelta = (UDATA)object - base;
UDATA size = vmThread->omrVMThread->heapSizeForBarrierRange0;
if (objectDelta < size) {
/* object is old so check for concurrent barrier */
if (0 != (vmThread->privateFlags & J9_PRIVATE_FLAGS_CONCURRENT_MARK_ACTIVE)) {
/* concurrent barrier is enabled so dirty the card for object */
dirtyCard(vmThread, objectDelta);
}
/* generational barrier is required if object is old and value is new */
/* Check to see if value is new using the same optimization as above */
UDATA valueDelta = (UDATA)value - base;
if (valueDelta >= size) {
/* value is in new space so do generational barrier */
rememberObject(vmThread, object);
}
}
}
}
/**
* Call after storing an object reference for barrier type
* j9gc_modron_wrtbar_cardmark
*
* @param object the object being stored into
* @param value the object reference being stored
*
*/
static VMINLINE void
internalPostObjectStoreCardTable(J9VMThread *vmThread, j9object_t object, j9object_t value)
{
/* if value is NULL neither barrier is required */
if (NULL != value) {
/* Check to see if object is old.
* if ((object - vmThread->omrVMThread->heapBaseForBarrierRange0) < vmThread->omrVMThread->heapSizeForBarrierRange0) then old
*
* Since card dirtying also requires this calculation remember these values
*/
UDATA base = (UDATA)vmThread->omrVMThread->heapBaseForBarrierRange0;
UDATA objectDelta = (UDATA)object - base;
UDATA size = vmThread->omrVMThread->heapSizeForBarrierRange0;
if (objectDelta < size) {
/* object is old so check for concurrent barrier */
if (0 != (vmThread->privateFlags & J9_PRIVATE_FLAGS_CONCURRENT_MARK_ACTIVE)) {
/* concurrent barrier is enabled so dirty the card for object */
dirtyCard(vmThread, objectDelta);
}
}
}
}
/**
* Call after storing an object reference for barrier type
* j9gc_modron_wrtbar_cardmark_incremental
*
* @param object the object being stored into
* @param value the object reference being stored
*
*/
static VMINLINE void
internalPostObjectStoreCardTableIncremental(J9VMThread *vmThread, j9object_t object, j9object_t value)
{
/* if value is NULL neither barrier is required */
if (NULL != value) {
/* Check to see if object is within the barrier range.
* if ((object - vmThread->omrVMThread->heapBaseForBarrierRange0) < vmThread->omrVMThread->heapSizeForBarrierRange0)
*
* Since card dirtying also requires this calculation remember these values
*/
UDATA base = (UDATA)vmThread->omrVMThread->heapBaseForBarrierRange0;
UDATA objectDelta = (UDATA)object - base;
UDATA size = vmThread->omrVMThread->heapSizeForBarrierRange0;
if (objectDelta < size) {
/* Object is within the barrier range. Dirty the card */
dirtyCard(vmThread, objectDelta);
}
}
}
/**
* Call after storing an object reference for barrier type
* j9gc_modron_wrtbar_oldcheck
*
* @param object the object being stored into
* @param value the object reference being stored
*
*/
static VMINLINE void
internalPostObjectStoreGenerational(J9VMThread *vmThread, j9object_t object, j9object_t value)
{
/* if value is NULL neither barrier is required */
if (NULL != value) {
/* Check to see if object is old.
* if ((object - vmThread->omrVMThread->heapBaseForBarrierRange0) < vmThread->omrVMThread->heapSizeForBarrierRange0) then old
*
* Since card dirtying also requires this calculation remember these values
*/
UDATA base = (UDATA)vmThread->omrVMThread->heapBaseForBarrierRange0;
UDATA objectDelta = (UDATA)object - base;
UDATA size = vmThread->omrVMThread->heapSizeForBarrierRange0;
if (objectDelta < size) {
/* generational barrier is required if object is old and value is new */
/* Check to see if value is new using the same optimization as above */
UDATA valueDelta = (UDATA)value - base;
if (valueDelta >= size) {
/* value is in new space so do generational barrier */
rememberObject(vmThread, object);
}
}
}
}
/**
* Call after storing an object reference for barrier type
* j9gc_modron_wrtbar_oldcheck
*
* @param object the object being stored into
* @param value the object reference being stored
*
*/
static VMINLINE void
internalPostObjectStoreGenerationalNoValueCheck(J9VMThread *vmThread, j9object_t object)
{
/* Check to see if object is old.
* if ((object - vmThread->omrVMThread->heapBaseForBarrierRange0) < vmThread->omrVMThread->heapSizeForBarrierRange0) then old
*
* Since card dirtying also requires this calculation remember these values
*/
UDATA base = (UDATA)vmThread->omrVMThread->heapBaseForBarrierRange0;
UDATA objectDelta = (UDATA)object - base;
UDATA size = vmThread->omrVMThread->heapSizeForBarrierRange0;
if (objectDelta < size) {
rememberObject(vmThread, object);
}
}
/**
* Return the address of the lockword for the given object, or NULL if it
* does not have an inline lockword.
*/
VMINLINE j9objectmonitor_t *
getLockwordAddress(J9VMThread *currentThread, J9Object *object)
{
j9objectmonitor_t *lockwordAddress = NULL;
J9Class *clazz = J9OBJECT_CLAZZ(currentThread, object);
if (!J9_IS_J9CLASS_VALUETYPE(clazz)) {
UDATA lockOffset = clazz->lockOffset;
if ((IDATA) lockOffset >= 0) {
lockwordAddress = (j9objectmonitor_t *)(((U_8 *)object) + lockOffset);
}
}
return lockwordAddress;
}
VMINLINE void
cloneArray(J9VMThread *currentThread, j9object_t original, j9object_t copy, J9Class *objectClass, U_32 size, MM_objectMapFunction objectMapFunction = NULL, void *objectMapData = NULL, bool initializeLockWord = true)
{
/* Note: initializeLockWord is ignored as arrays never have inline lockwords */
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
currentThread->javaVM->memoryManagerFunctions->j9gc_objaccess_cloneIndexableObject(currentThread, (J9IndexableObject*)original, (J9IndexableObject*)copy), objectMapFunction, objectMapData;
#else /* defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER) */
if (OBJECT_HEADER_SHAPE_POINTERS == J9CLASS_SHAPE(objectClass)) {
if (NULL != objectMapFunction) {
currentThread->javaVM->memoryManagerFunctions->j9gc_objaccess_cloneIndexableObject(currentThread, (J9IndexableObject*)original, (J9IndexableObject*)copy, objectMapFunction, objectMapData);
} else {
VM_ArrayCopyHelpers::referenceArrayCopy(currentThread, original, 0, copy, 0, size);
}
} else {
VM_ArrayCopyHelpers::primitiveArrayCopy(currentThread, original, 0, copy, 0, size, (((J9ROMArrayClass*)objectClass->romClass)->arrayShape & 0x0000FFFF));
}
#endif /* defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER) */
}
VMINLINE UDATA
mixedObjectGetHeaderSize(J9Class *objectClass)
{
return (compressObjectReferences() ? sizeof(J9ObjectCompressed) : sizeof(J9ObjectFull)) + J9CLASS_PREPADDING_SIZE(objectClass);
}
VMINLINE UDATA
mixedObjectGetDataSize(J9Class *objectClass)
{
return J9CLASS_UNPADDED_INSTANCE_SIZE(objectClass);
}
VMINLINE void
cloneObject(J9VMThread *currentThread, j9object_t original, j9object_t copy, J9Class *objectClass, MM_objectMapFunction objectMapFunction = NULL, void *objectMapData = NULL, bool initializeLockWord = true)
{
UDATA offset = mixedObjectGetHeaderSize(objectClass);
copyObjectFields(currentThread, objectClass, original, offset, copy, offset, objectMapFunction, objectMapData, initializeLockWord);
}
VMINLINE void
copyObjectFieldsToFlattenedArrayElement(J9VMThread *vmThread, J9ArrayClass *arrayClazz, j9object_t srcObject, J9IndexableObject *arrayRef, UDATA index)
{
/* TODO optimizations for non-arraylet path will be added in the future */
vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_copyObjectFieldsToFlattenedArrayElement(vmThread, arrayClazz, srcObject, arrayRef, (I_32)index);
}
VMINLINE void
copyObjectFieldsFromFlattenedArrayElement(J9VMThread *vmThread, J9ArrayClass *arrayClazz, j9object_t destObject, J9IndexableObject *arrayRef, UDATA index)
{
/* TODO optimizations for non-arraylet path will be added in the future */
vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_copyObjectFieldsFromFlattenedArrayElement(vmThread, arrayClazz, destObject, arrayRef, (I_32)index);
}
VMINLINE BOOLEAN
structuralFlattenedCompareObjects(J9VMThread *vmThread, J9Class *valueClass, j9object_t lhsObject, j9object_t rhsObject, UDATA startOffset)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
return vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_structuralCompareFlattenedObjects(vmThread, valueClass, lhsObject, rhsObject, startOffset);
#else /* defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER) */
bool hasReferences = J9CLASS_HAS_REFERENCES(valueClass);
if (hasReferences && (j9gc_modron_readbar_none != _readBarrierType)) {
return vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_structuralCompareFlattenedObjects(vmThread, valueClass, lhsObject, rhsObject, startOffset);
} else {
UDATA compareSize = mixedObjectGetDataSize(valueClass);
startOffset += J9CLASS_PREPADDING_SIZE(valueClass);
return (0 == memcmp((void*)((UDATA)lhsObject + startOffset), (void*)((UDATA)rhsObject + startOffset), (size_t)compareSize));
}
#endif /* defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER) */
}
/**
* Copy valueType from sourceObject to destObject
* See MM_ObjectAccessBarrier::copyObjectFields for detailed description
*
* @param vmThread vmthread token
* @param objectClass The class of the objects being copied
* @param srcObject The object being used.
* @param srcOffset The offset of the field.
* @param destObject The object being used.
* @param destOffset The offset of the field.
* @param objectMapFunction Function to allow replacement of object fields, default NULL
* @param objectMapData Data to pass to objectMapFunction, default NULL
* @param initializeLockWord true to initialize inline lockword, false to copy it, default true
*/
VMINLINE void
copyObjectFields(J9VMThread *vmThread, J9Class *objectClass, j9object_t srcObject, UDATA srcOffset, j9object_t destObject, UDATA destOffset, MM_objectMapFunction objectMapFunction = NULL, void *objectMapData = NULL, bool initializeLockWord = true)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_copyObjectFields(vmThread, objectClass, srcObject, srcOffset, destObject, destOffset, objectMapFunction, objectMapData, initializeLockWord);
#else /* defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER) */
bool hasReferences = J9CLASS_HAS_REFERENCES(objectClass);
if (hasReferences && ((NULL != objectMapFunction) || (j9gc_modron_readbar_none != _readBarrierType) || (j9gc_modron_wrtbar_always == _writeBarrierType))) {
vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_copyObjectFields(vmThread, objectClass, srcObject, srcOffset, destObject, destOffset, objectMapFunction, objectMapData, initializeLockWord);
} else {
UDATA offset = 0;
UDATA limit = mixedObjectGetDataSize(objectClass);
if (J9VMTHREAD_COMPRESS_OBJECT_REFERENCES(vmThread)) {
while (offset < limit) {
*(uint32_t*)((UDATA)destObject + offset + destOffset) = *(uint32_t*)((UDATA)srcObject + offset + srcOffset);
offset += sizeof(uint32_t);
}
} else {
while (offset < limit) {
*(uintptr_t*)((UDATA)destObject + offset + destOffset) = *(uintptr_t*)((UDATA)srcObject + offset + srcOffset);
offset += sizeof(uintptr_t);
}
}
if (!J9_IS_J9CLASS_VALUETYPE(objectClass)) {
if (initializeLockWord) {
/* zero lockword, if present */
j9objectmonitor_t *lockwordAddress = getLockwordAddress(vmThread, destObject);
if (NULL != lockwordAddress) {
j9objectmonitor_t lwValue = VM_ObjectMonitor::getInitialLockword(vmThread->javaVM, objectClass);
J9_STORE_LOCKWORD(vmThread, lockwordAddress, lwValue);
}
}
}
if (hasReferences) {
postBatchStoreObject(vmThread, destObject);
}
}
#endif /* defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER) */
}
/**
* Read an object field: perform any pre-use barriers, calculate an effective address
* and perform the work.
*
* @param srcObject The object being used.
* @param srcOffset The offset of the field.
* @param isVolatile non-zero if the field is volatile.
* @return result The object stored at srcOffset in srcObject
*/
VMINLINE j9object_t
inlineMixedObjectReadObject(J9VMThread *vmThread, j9object_t srcObject, UDATA srcOffset, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
return vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectReadObject(vmThread, srcObject, srcOffset, isVolatile);
#elif defined(J9VM_GC_COMBINATION_SPEC)
fj9object_t *actualAddress = J9OAB_MIXEDOBJECT_EA(srcObject, srcOffset, fj9object_t);
preMixedObjectReadObject(vmThread, srcObject, actualAddress);
protectIfVolatileBefore(isVolatile, true);
j9object_t result = readObjectImpl(vmThread, actualAddress, isVolatile);
protectIfVolatileAfter(isVolatile, true);
return result;
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Store an object pointer into an object.
*
* This function performs all of the necessary barriers and calls OOL when it can not handle
* the barrier itself.
*
* @param srcObject the object being stored into
* @param srcOffset the offset with in srcObject to store value
* @param value the value to be stored
* @param isVolatile non-zero if the field is volatile, zero otherwise
*/
VMINLINE void
inlineMixedObjectStoreObject(J9VMThread *vmThread, j9object_t srcObject, UDATA srcOffset, j9object_t value, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectStoreObject(vmThread, srcObject, srcOffset, value, isVolatile);
#elif defined(J9VM_GC_COMBINATION_SPEC)
if (j9gc_modron_wrtbar_always == _writeBarrierType) {
vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectStoreObject(vmThread, srcObject, srcOffset, value, isVolatile);
} else {
fj9object_t *actualAddress = J9OAB_MIXEDOBJECT_EA(srcObject, srcOffset, fj9object_t);
preMixedObjectStoreObject(vmThread, srcObject, actualAddress, value);
protectIfVolatileBefore(isVolatile, false);
storeObjectImpl(vmThread, actualAddress, value, isVolatile);
protectIfVolatileAfter(isVolatile, false);
postMixedObjectStoreObject(vmThread, srcObject, actualAddress, value);
}
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Store an object pointer into an object atomically.
*
* This function performs all of the necessary barriers and calls OOL when it can not handle
* the barrier itself.
*
* @param destObject the object being stored into
* @param destOffset the offset with in srcObject to store value
* @param compareObject the object to compare with
* @param swapObject the value to be swapped in
* @param isVolatile non-zero if the field is volatile, zero otherwise
*
* @return true on success, false otherwise
*/
VMINLINE bool
inlineMixedObjectCompareAndSwapObject(J9VMThread *vmThread, j9object_t destObject, UDATA destOffset, j9object_t compareObject, j9object_t swapObject, bool isVolatile = false)
{
fj9object_t *destAddress = J9OAB_MIXEDOBJECT_EA(destObject, destOffset, fj9object_t);
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
return (1 == vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_compareAndSwapObject(vmThread, destObject, (J9Object **)destAddress, compareObject, swapObject));
#elif defined(J9VM_GC_COMBINATION_SPEC)
if (j9gc_modron_wrtbar_always == _writeBarrierType) {
return (1 == vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_compareAndSwapObject(vmThread, destObject, (J9Object **)destAddress, compareObject, swapObject));
} else {
preMixedObjectReadObject(vmThread, destObject, destAddress);
preMixedObjectStoreObject(vmThread, destObject, destAddress, swapObject);
protectIfVolatileBefore(isVolatile, false);
bool result = compareAndSwapObjectImpl(vmThread, destAddress, compareObject, swapObject, isVolatile);
protectIfVolatileAfter(isVolatile, false);
if (result) {
postMixedObjectStoreObject(vmThread, destObject, destAddress, swapObject);
}
return result;
}
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Conditionally store an object pointer into an object atomically.
*
* This function performs all of the necessary barriers and calls OOL when it can not handle
* the barrier itself.
*
* @param destObject the object being stored into
* @param destOffset the offset with in srcObject to store value
* @param compareObject the object to compare with
* @param swapObject the value to be swapped in
* @param isVolatile non-zero if the field is volatile, zero otherwise
*
* @return the object stored in the object field before the update
*/
VMINLINE j9object_t
inlineMixedObjectCompareAndExchangeObject(J9VMThread *vmThread, j9object_t destObject, UDATA destOffset, j9object_t compareObject, j9object_t swapObject, bool isVolatile = false)
{
fj9object_t *destAddress = J9OAB_MIXEDOBJECT_EA(destObject, destOffset, fj9object_t);
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
return vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_compareAndExchangeObject(vmThread, destObject, (J9Object **)destAddress, compareObject, swapObject);
#elif defined(J9VM_GC_COMBINATION_SPEC)
if (j9gc_modron_wrtbar_always == _writeBarrierType) {
return vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_compareAndExchangeObject(vmThread, destObject, (J9Object **)destAddress, compareObject, swapObject);
} else {
preMixedObjectReadObject(vmThread, destObject, destAddress);
preMixedObjectStoreObject(vmThread, destObject, destAddress, swapObject);
protectIfVolatileBefore(isVolatile, false);
fj9object_t resultToken = compareAndExchangeObjectImpl(vmThread, destAddress, compareObject, swapObject, isVolatile);
protectIfVolatileAfter(isVolatile, false);
j9object_t result = internalConvertPointerFromToken(resultToken);
if (result == compareObject) {
postMixedObjectStoreObject(vmThread, destObject, destAddress, swapObject);
}
return result;
}
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Read an I_32 field: perform any pre-use barriers, calculate an effective address
* and perform the work.
*
* @param srcObject The object being used.
* @param srcOffset The offset of the field.
* @param isVolatile non-zero if the field is volatile.
*/
VMINLINE I_32
inlineMixedObjectReadI32(J9VMThread *vmThread, j9object_t srcObject, UDATA srcOffset, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
return (I_32)vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectReadI32(vmThread, srcObject, srcOffset, isVolatile);
#elif defined(J9VM_GC_COMBINATION_SPEC)
I_32 *actualAddress = J9OAB_MIXEDOBJECT_EA(srcObject, srcOffset, I_32);
protectIfVolatileBefore(isVolatile, true);
I_32 result = readI32Impl(vmThread, actualAddress, isVolatile);
protectIfVolatileAfter(isVolatile, true);
return result;
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Store an I_32 value into an object.
*
* This function performs all of the necessary barriers and calls OOL when it can not handle
* the barrier itself.
*
* @param srcObject the object being stored into
* @param srcOffset the offset with in srcObject to store value
* @param value the value to be stored
* @param isVolatile non-zero if the field is volatile, zero otherwise
*/
VMINLINE void
inlineMixedObjectStoreI32(J9VMThread *vmThread, j9object_t srcObject, UDATA srcOffset, I_32 value, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectStoreI32(vmThread, srcObject, srcOffset, value, isVolatile);
#elif defined(J9VM_GC_COMBINATION_SPEC)
I_32 *actualAddress = J9OAB_MIXEDOBJECT_EA(srcObject, srcOffset, I_32);
protectIfVolatileBefore(isVolatile, false);
storeI32Impl(vmThread, actualAddress, value, isVolatile);
protectIfVolatileAfter(isVolatile, false);
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Read a U_32 field: perform any pre-use barriers, calculate an effective address
* and perform the work.
*
* @param srcObject The object being used.
* @param srcOffset The offset of the field.
* @param isVolatile non-zero if the field is volatile.
*/
VMINLINE U_32
inlineMixedObjectReadU32(J9VMThread *vmThread, j9object_t srcObject, UDATA srcOffset, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
return (U_32)vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectReadU32(vmThread, srcObject, srcOffset, isVolatile);
#elif defined(J9VM_GC_COMBINATION_SPEC)
U_32 *actualAddress = J9OAB_MIXEDOBJECT_EA(srcObject, srcOffset, U_32);
protectIfVolatileBefore(isVolatile, true);
U_32 result = readU32Impl(vmThread, actualAddress, isVolatile);
protectIfVolatileAfter(isVolatile, true);
return result;
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Store an U_32 value into an object.
*
* This function performs all of the necessary barriers and calls OOL when it can not handle
* the barrier itself.
*
* @param srcObject the object being stored into
* @param srcOffset the offset with in srcObject to store value
* @param value the value to be stored
* @param isVolatile non-zero if the field is volatile, zero otherwise
*/
VMINLINE void
inlineMixedObjectStoreU32(J9VMThread *vmThread, j9object_t srcObject, UDATA srcOffset, U_32 value, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectStoreU32(vmThread, srcObject, srcOffset, value, isVolatile);
#elif defined(J9VM_GC_COMBINATION_SPEC)
U_32 *actualAddress = J9OAB_MIXEDOBJECT_EA(srcObject, srcOffset, U_32);
protectIfVolatileBefore(isVolatile, false);
storeU32Impl(vmThread, actualAddress, value, isVolatile);
protectIfVolatileAfter(isVolatile, false);
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Store an U_32 value into an object atomically
*
* This function performs all of the necessary barriers and calls OOL when it can not handle
* the barrier itself.
*
* @param destObject the object being stored into
* @param destOffset the offset with in srcObject to store value
* @param compareObject the object to compare with
* @param swapObject the value to be swapped in
* @param isVolatile non-zero if the field is volatile, zero otherwise
*
* @return true on success, false otherwise
*/
VMINLINE bool
inlineMixedObjectCompareAndSwapU32(J9VMThread *vmThread, j9object_t destObject, UDATA destOffset, U_32 compareValue, U_32 swapValue, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
return (1 == vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectCompareAndSwapInt(vmThread, destObject, destOffset, compareValue, swapValue));
#elif defined(J9VM_GC_COMBINATION_SPEC)
U_32 *actualAddress = J9OAB_MIXEDOBJECT_EA(destObject, destOffset, U_32);
protectIfVolatileBefore(isVolatile, false);
bool result = compareAndSwapU32Impl(vmThread, actualAddress, compareValue, swapValue, isVolatile);
protectIfVolatileAfter(isVolatile, false);
return result;
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Conditionally store a U_32 value into an object atomically
*
* This function performs all of the necessary barriers and calls OOL when it can not handle
* the barrier itself.
*
* @param destObject the object being stored into
* @param destOffset the offset with in srcObject to store value
* @param compareObject the object to compare with
* @param swapObject the value to be swapped in
* @param isVolatile non-zero if the field is volatile, zero otherwise
*
* @return the value stored in the object field before the update
*/
VMINLINE U_32
inlineMixedObjectCompareAndExchangeU32(J9VMThread *vmThread, j9object_t destObject, UDATA destOffset, U_32 compareValue, U_32 swapValue, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
return vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectCompareAndExchangeInt(vmThread, destObject, destOffset, compareValue, swapValue);
#elif defined(J9VM_GC_COMBINATION_SPEC)
U_32 *actualAddress = J9OAB_MIXEDOBJECT_EA(destObject, destOffset, U_32);
protectIfVolatileBefore(isVolatile, false);
U_32 result = compareAndExchangeU32Impl(vmThread, actualAddress, compareValue, swapValue, isVolatile);
protectIfVolatileAfter(isVolatile, false);
return result;
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Read an I_64 field: perform any pre-use barriers, calculate an effective address
* and perform the work.
*
* @param srcObject The object being used.
* @param srcOffset The offset of the field.
* @param isVolatile non-zero if the field is volatile.
*/
VMINLINE I_64
inlineMixedObjectReadI64(J9VMThread *vmThread, j9object_t srcObject, UDATA srcOffset, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
return vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectReadI64(vmThread, srcObject, srcOffset, isVolatile);
#elif defined(J9VM_GC_COMBINATION_SPEC)
I_64 *actualAddress = J9OAB_MIXEDOBJECT_EA(srcObject, srcOffset, I_64);
protectIfVolatileBefore(isVolatile, true);
I_64 result = readI64Impl(vmThread, actualAddress, isVolatile);
protectIfVolatileAfter(isVolatile, true);
return result;
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Store an I_64 value into an object.
*
* This function performs all of the necessary barriers and calls OOL when it can not handle
* the barrier itself.
*
* @param srcObject the object being stored into
* @param srcOffset the offset with in srcObject to store value
* @param value the value to be stored
* @param isVolatile non-zero if the field is volatile, zero otherwise
*/
VMINLINE void
inlineMixedObjectStoreI64(J9VMThread *vmThread, j9object_t srcObject, UDATA srcOffset, I_64 value, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectStoreI64(vmThread, srcObject, srcOffset, value, isVolatile);
#elif defined(J9VM_GC_COMBINATION_SPEC)
I_64 *actualAddress = J9OAB_MIXEDOBJECT_EA(srcObject, srcOffset, I_64);
protectIfVolatileBefore(isVolatile, false);
storeI64Impl(vmThread, actualAddress, value, isVolatile);
protectIfVolatileAfter(isVolatile, false);
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Read a U_64 field: perform any pre-use barriers, calculate an effective address
* and perform the work.
*
* @param srcObject The object being used.
* @param srcOffset The offset of the field.
* @param isVolatile non-zero if the field is volatile.
*/
VMINLINE U_64
inlineMixedObjectReadU64(J9VMThread *vmThread, j9object_t srcObject, UDATA srcOffset, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
return vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectReadU64(vmThread, srcObject, srcOffset, isVolatile);
#elif defined(J9VM_GC_COMBINATION_SPEC)
U_64 *actualAddress = J9OAB_MIXEDOBJECT_EA(srcObject, srcOffset, U_64);
protectIfVolatileBefore(isVolatile, true);
U_64 result = readU64Impl(vmThread, actualAddress, isVolatile);
protectIfVolatileAfter(isVolatile, true);
return result;
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Store an U_64 value into an object.
*
* This function performs all of the necessary barriers and calls OOL when it can not handle
* the barrier itself.
*
* @param srcObject the object being stored into
* @param srcOffset the offset with in srcObject to store value
* @param value the value to be stored
* @param isVolatile non-zero if the field is volatile, zero otherwise
*/
VMINLINE void
inlineMixedObjectStoreU64(J9VMThread *vmThread, j9object_t srcObject, UDATA srcOffset, U_64 value, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectStoreU64(vmThread, srcObject, srcOffset, value, isVolatile);
#elif defined(J9VM_GC_COMBINATION_SPEC)
U_64 *actualAddress = J9OAB_MIXEDOBJECT_EA(srcObject, srcOffset, U_64);
protectIfVolatileBefore(isVolatile, false);
storeU64Impl(vmThread, actualAddress, value, isVolatile);
protectIfVolatileAfter(isVolatile, false);
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Store an U_64 value into an object atomically
*
* This function performs all of the necessary barriers and calls OOL when it can not handle
* the barrier itself.
*
* @param destObject the object being stored into
* @param destOffset the offset with in srcObject to store value
* @param compareObject the object to compare with
* @param swapObject the value to be swapped in
* @param isVolatile non-zero if the field is volatile, zero otherwise
*
* @return true on success, false otherwise
*/
VMINLINE bool
inlineMixedObjectCompareAndSwapU64(J9VMThread *vmThread, j9object_t destObject, UDATA destOffset, U_64 compareValue, U_64 swapValue, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
return (1 == vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectCompareAndSwapLong(vmThread, destObject, destOffset, compareValue, swapValue));
#elif defined(J9VM_GC_COMBINATION_SPEC)
U_64 *actualAddress = J9OAB_MIXEDOBJECT_EA(destObject, destOffset, U_64);
protectIfVolatileBefore(isVolatile, false);
bool result = compareAndSwapU64Impl(vmThread, actualAddress, compareValue, swapValue, isVolatile);
protectIfVolatileAfter(isVolatile, false);
return result;
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Conditionally store a U_64 value into an object atomically
*
* This function performs all of the necessary barriers and calls OOL when it can not handle
* the barrier itself.
*
* @param destObject the object being stored into
* @param destOffset the offset with in srcObject to store value
* @param compareObject the object to compare with
* @param swapObject the value to be swapped in
* @param isVolatile non-zero if the field is volatile, zero otherwise
*
* @return the value stored in the object field before the update
*/
VMINLINE U_64
inlineMixedObjectCompareAndExchangeU64(J9VMThread *vmThread, j9object_t destObject, UDATA destOffset, U_64 compareValue, U_64 swapValue, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
return vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_mixedObjectCompareAndExchangeLong(vmThread, destObject, destOffset, compareValue, swapValue);
#elif defined(J9VM_GC_COMBINATION_SPEC)
U_64 *actualAddress = J9OAB_MIXEDOBJECT_EA(destObject, destOffset, U_64);
protectIfVolatileBefore(isVolatile, false);
U_64 result = compareAndExchangeU64Impl(vmThread, actualAddress, compareValue, swapValue, isVolatile);
protectIfVolatileAfter(isVolatile, false);
return result;
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Read a static object field: perform any pre-use barriers, calculate an effective address
* and perform the work.
*
* @param clazz The J9Class being written to.
* @param srcAddress The offset of the field.
* @param isVolatile non-zero if the field is volatile.
*/
VMINLINE j9object_t
inlineStaticReadObject(J9VMThread *vmThread, J9Class *clazz, j9object_t *srcAddress, bool isVolatile = false)
{
#if defined(J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER)
return vmThread->javaVM->memoryManagerFunctions->j9gc_objaccess_staticReadObject(vmThread, clazz, srcAddress, isVolatile);
#elif defined(J9VM_GC_COMBINATION_SPEC)
preStaticReadObject(vmThread, clazz, srcAddress);
protectIfVolatileBefore(isVolatile, true);
j9object_t result = staticReadObjectImpl(vmThread, srcAddress, isVolatile);
protectIfVolatileAfter(isVolatile, true);
/* TODO handle postReadBarrier if RTJ every becomes combo */
return result;
#else /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
#error unsupported barrier
#endif /* J9VM_GC_ALWAYS_CALL_OBJECT_ACCESS_BARRIER */
}
/**
* Store an object value into a static.
*
* This function performs all of the necessary barriers and calls OOL when it can not handle
* the barrier itself.
*
* @param clazz the clazz whose static being stored into
* @param srcAddress the address of the static to store value
* @param value the value to be stored
* @param isVolatile non-zero if the field is volatile, zero otherwise
*/
VMINLINE void