Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/env/J9ObjectModel.cpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2022 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
#if defined(J9ZOS390)
24
//On zOS XLC linker can't handle files with same name at link time
25
//This workaround with pragma is needed. What this does is essentially
26
//give a different name to the codesection (csect) for this file. So it
27
//doesn't conflict with another file with same name.
28
#pragma csect(CODE,"J9ObjectModel#C")
29
#pragma csect(STATIC,"J9ObjectModel#S")
30
#pragma csect(TEST,"J9ObjectModel#T")
31
#endif
32
33
#include <algorithm>
34
#include <limits.h>
35
#include <stdint.h>
36
#include "j9.h"
37
#include "j9cfg.h"
38
#include "j9modron.h"
39
#include "codegen/CodeGenerator.hpp"
40
#include "env/CompilerEnv.hpp"
41
#include "env/ObjectModel.hpp"
42
#include "env/jittypes.h"
43
#include "env/VMAccessCriticalSection.hpp"
44
#include "il/DataTypes.hpp"
45
#include "il/Node.hpp"
46
#include "il/Node_inlines.hpp"
47
#include "env/VMJ9.h"
48
#if defined(J9VM_OPT_JITSERVER)
49
#include "control/CompilationThread.hpp"
50
#include "runtime/JITClientSession.hpp"
51
#endif /* defined(J9VM_OPT_JITSERVER) */
52
53
#define DEFAULT_OBJECT_ALIGNMENT (8)
54
55
56
void
57
J9::ObjectModel::initialize()
58
{
59
OMR::ObjectModelConnector::initialize();
60
61
J9JavaVM *vm = TR::Compiler->javaVM;
62
63
PORT_ACCESS_FROM_JAVAVM(vm);
64
J9MemoryManagerFunctions * mmf = vm->memoryManagerFunctions;
65
66
uintptr_t value;
67
68
// Compressed refs
69
uintptr_t result = mmf->j9gc_modron_getConfigurationValueForKey(vm,
70
j9gc_modron_configuration_compressObjectReferences,
71
&value);
72
if (result == 1 && value == 1)
73
_compressObjectReferences = true;
74
else
75
_compressObjectReferences = false;
76
77
// Discontiguous arraylets
78
//
79
result = mmf->j9gc_modron_getConfigurationValueForKey(vm,
80
j9gc_modron_configuration_discontiguousArraylets,
81
&value);
82
if (result == 1 && value == 1)
83
{
84
_usesDiscontiguousArraylets = true;
85
_arrayLetLeafSize = (int32_t)(vm->memoryManagerFunctions->j9gc_arraylet_getLeafSize(vm));
86
_arrayLetLeafLogSize = (int32_t)(vm->memoryManagerFunctions->j9gc_arraylet_getLeafLogSize(vm));
87
}
88
else
89
{
90
_usesDiscontiguousArraylets = false;
91
_arrayLetLeafSize = 0;
92
_arrayLetLeafLogSize = 0;
93
}
94
95
_readBarrierType = (MM_GCReadBarrierType) mmf->j9gc_modron_getReadBarrierType(vm);
96
_writeBarrierType = (MM_GCWriteBarrierType)mmf->j9gc_modron_getWriteBarrierType(vm);
97
if (_writeBarrierType == gc_modron_wrtbar_satb_and_oldcheck)
98
{
99
// JIT treats satb_and_oldcheck same as satb
100
_writeBarrierType = gc_modron_wrtbar_satb;
101
}
102
103
_objectAlignmentInBytes = objectAlignmentInBytes();
104
}
105
106
107
bool
108
J9::ObjectModel::areValueTypesEnabled()
109
{
110
#if defined(J9VM_OPT_JITSERVER)
111
if (auto stream = TR::CompilationInfo::getStream())
112
{
113
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
114
return true;
115
#else /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
116
return false;
117
#endif /* defined(J9VM_OPT_VALHALLA_VALUE_TYPES) */
118
}
119
#endif /* defined(J9VM_OPT_JITSERVER) */
120
121
J9JavaVM * javaVM = TR::Compiler->javaVM;
122
return javaVM->internalVMFunctions->areValueTypesEnabled(javaVM);
123
}
124
125
126
bool
127
J9::ObjectModel::areValueBasedMonitorChecksEnabled()
128
{
129
#if defined(J9VM_OPT_JITSERVER)
130
if (auto stream = TR::CompilationInfo::getStream())
131
{
132
auto *vmInfo = TR::compInfoPT->getClientData()->getOrCacheVMInfo(stream);
133
return J9_ARE_ANY_BITS_SET(vmInfo->_extendedRuntimeFlags2, J9_EXTENDED_RUNTIME2_VALUE_BASED_EXCEPTION | J9_EXTENDED_RUNTIME2_VALUE_BASED_WARNING);
134
}
135
#endif /* defined(J9VM_OPT_JITSERVER) */
136
137
J9JavaVM * javaVM = TR::Compiler->javaVM;
138
return javaVM->internalVMFunctions->areValueBasedMonitorChecksEnabled(javaVM);
139
}
140
141
142
int32_t
143
J9::ObjectModel::sizeofReferenceField()
144
{
145
if (compressObjectReferences())
146
return sizeof(uint32_t);
147
return sizeof(uintptr_t);
148
}
149
150
151
bool
152
J9::ObjectModel::isHotReferenceFieldRequired()
153
{
154
#if defined(J9VM_OPT_JITSERVER)
155
if (auto stream = TR::CompilationInfo::getStream())
156
{
157
auto *vmInfo = TR::compInfoPT->getClientData()->getOrCacheVMInfo(stream);
158
return vmInfo->_isHotReferenceFieldRequired;
159
}
160
#endif /* defined(J9VM_OPT_JITSERVER) */
161
return TR::Compiler->javaVM->memoryManagerFunctions->j9gc_hot_reference_field_required(TR::Compiler->javaVM);
162
}
163
164
165
UDATA
166
J9::ObjectModel::elementSizeOfBooleanArray()
167
{
168
return 1;
169
}
170
171
172
uint32_t
173
J9::ObjectModel::getSizeOfArrayElement(TR::Node * node)
174
{
175
TR_ASSERT(node->getOpCodeValue() == TR::newarray || node->getOpCodeValue() == TR::anewarray, "getSizeOfArrayElement expects either newarray or anewarray at [%p]", node);
176
177
if (node->getOpCodeValue() == TR::anewarray)
178
{
179
if (compressObjectReferences())
180
return sizeofReferenceField();
181
return TR::Symbol::convertTypeToSize(TR::Address);
182
}
183
184
TR_ASSERT(node->getSecondChild()->getOpCode().isLoadConst(), "Expecting const child \n");
185
switch (node->getSecondChild()->getInt())
186
{
187
case 4:
188
return (uint32_t) TR::Compiler->om.elementSizeOfBooleanArray();
189
case 8:
190
return 1;
191
case 5:
192
case 9:
193
return 2;
194
case 7:
195
case 11:
196
return 8;
197
}
198
return 4;
199
}
200
201
int64_t
202
J9::ObjectModel::maxArraySizeInElementsForAllocation(
203
TR::Node *newArray,
204
TR::Compilation *comp)
205
{
206
int64_t result = TR::getMaxSigned<TR::Int64>();
207
208
switch (newArray->getOpCodeValue())
209
{
210
case TR::newarray:
211
case TR::anewarray:
212
result = TR::Compiler->om.maxArraySizeInElements(TR::Compiler->om.getSizeOfArrayElement(newArray), comp);
213
break;
214
case TR::multianewarray:
215
result = TR::Compiler->om.maxArraySizeInElements(TR::Compiler->om.sizeofReferenceField(), comp);
216
break;
217
default:
218
TR_ASSERT(0, "Unexpected node %p in maxArraySizeInElementsForAllocation", newArray);
219
break;
220
}
221
222
return result;
223
}
224
225
226
int64_t
227
J9::ObjectModel::maxArraySizeInElements(
228
int32_t knownMinElementSize,
229
TR::Compilation *comp)
230
{
231
int64_t result = INT_MAX; // On Java, indexes are signed 32-bit ints
232
233
// An array can't be larger than the heap. Limit the index based on that.
234
//
235
int32_t minElementSize = std::max(1, knownMinElementSize);
236
int64_t maxHeapSizeInBytes;
237
238
if (comp->compileRelocatableCode())
239
{
240
maxHeapSizeInBytes = -1;
241
}
242
else
243
{
244
maxHeapSizeInBytes = TR::Compiler->vm.maxHeapSizeInBytes();
245
}
246
247
if (maxHeapSizeInBytes == -1)
248
{
249
// getMaximumHeapSize has an irritating habit of returning -1 sometimes,
250
// for some reason. Must compensate for this corner case here.
251
//
252
if (comp->target().is64Bit())
253
{
254
// Ok, in theory it could be TR::getMaxUnsigned<TR::Int64>(). This isn't worth the
255
// hassle of using uint64_t and worrying about signedness. When the
256
// day comes that a Java program needs an array larger than 8 billion
257
// gigabytes, our great-grandchildren can switch to int128_t, assuming
258
// Testarossa has not yet become self-aware and fixed this limitation
259
// by itself.
260
//
261
maxHeapSizeInBytes = TR::getMaxSigned<TR::Int64>();
262
}
263
else
264
{
265
maxHeapSizeInBytes = TR::getMaxUnsigned<TR::Int32>(); // Heap can't be larger than the address space
266
}
267
}
268
269
result = std::min(result, maxHeapSizeInBytes / minElementSize);
270
271
return result;
272
}
273
274
275
bool
276
J9::ObjectModel::nativeAddressesCanChangeSize()
277
{
278
#if defined(J9VM_OPT_SHARED_CLASSES) && defined(J9VM_INTERP_AOT_COMPILE_SUPPORT)
279
return true;
280
#else
281
return false;
282
#endif
283
}
284
285
286
bool
287
J9::ObjectModel::generateCompressedObjectHeaders()
288
{
289
return compressObjectReferences();
290
}
291
292
293
uintptr_t
294
J9::ObjectModel::contiguousArrayHeaderSizeInBytes()
295
{
296
return compressObjectReferences() ? sizeof(J9IndexableObjectContiguousCompressed) : sizeof(J9IndexableObjectContiguousFull);
297
}
298
299
300
uintptr_t
301
J9::ObjectModel::discontiguousArrayHeaderSizeInBytes()
302
{
303
return compressObjectReferences() ? sizeof(J9IndexableObjectDiscontiguousCompressed) : sizeof(J9IndexableObjectDiscontiguousFull);
304
}
305
306
307
// Returns the maximum contiguous arraylet size in bytes NOT including the header.
308
//
309
int32_t
310
J9::ObjectModel::maxContiguousArraySizeInBytes()
311
{
312
return TR::Compiler->om.arrayletLeafSize() - TR::Compiler->om.contiguousArrayHeaderSizeInBytes();
313
}
314
315
316
// 'sizeInBytes' should NOT include the header
317
//
318
bool
319
J9::ObjectModel::isDiscontiguousArray(int32_t sizeInBytes)
320
{
321
if (sizeInBytes > TR::Compiler->om.maxContiguousArraySizeInBytes())
322
return true;
323
else
324
{
325
if (TR::Compiler->om.useHybridArraylets() && sizeInBytes == 0)
326
return true;
327
else
328
return false;
329
}
330
}
331
332
333
// 'sizeInElements' should NOT include the header
334
//
335
bool
336
J9::ObjectModel::isDiscontiguousArray(int32_t sizeInElements, int32_t elementSize)
337
{
338
int32_t shift = trailingZeroes(elementSize);
339
int32_t maxContiguousArraySizeInElements = TR::Compiler->om.maxContiguousArraySizeInBytes() >> shift;
340
341
if (sizeInElements > maxContiguousArraySizeInElements)
342
return true;
343
else
344
{
345
if (TR::Compiler->om.useHybridArraylets() && sizeInElements == 0)
346
return true;
347
else
348
return false;
349
}
350
}
351
352
353
int32_t
354
J9::ObjectModel::compressedReferenceShiftOffset()
355
{
356
// FIXME: currently returns 0, has to be modified to
357
// return the shift offset
358
//
359
return TR::Compiler->om.compressedReferenceShift();
360
}
361
362
363
int32_t
364
J9::ObjectModel::compressedReferenceShift()
365
{
366
#if defined(J9VM_OPT_JITSERVER)
367
if (auto stream = TR::CompilationInfo::getStream())
368
{
369
auto *vmInfo = TR::compInfoPT->getClientData()->getOrCacheVMInfo(stream);
370
return vmInfo->_compressedReferenceShift;
371
}
372
#endif /* defined(J9VM_OPT_JITSERVER) */
373
374
if (compressObjectReferences())
375
{
376
J9JavaVM *javaVM = TR::Compiler->javaVM;
377
if (!javaVM)
378
return 0;
379
380
J9VMThread *vmThread = javaVM->internalVMFunctions->currentVMThread(javaVM);
381
J9MemoryManagerFunctions * mmf = javaVM->memoryManagerFunctions;
382
int32_t result = mmf->j9gc_objaccess_compressedPointersShift(vmThread);
383
return result;
384
}
385
return 0;
386
}
387
388
389
uintptr_t
390
J9::ObjectModel::offsetOfObjectVftField()
391
{
392
return TMP_OFFSETOF_J9OBJECT_CLAZZ;
393
}
394
395
396
uintptr_t
397
J9::ObjectModel::offsetOfHeaderFlags()
398
{
399
#if defined(J9VM_INTERP_FLAGS_IN_CLASS_SLOT)
400
return TR::Compiler->om.offsetOfObjectVftField();
401
#else
402
#if defined(TMP_OFFSETOF_J9OBJECT_FLAGS)
403
return TMP_OFFSETOF_J9OBJECT_FLAGS;
404
#else
405
return 0;
406
#endif
407
#endif
408
}
409
410
411
uintptr_t
412
J9::ObjectModel::maskOfObjectVftField()
413
{
414
if (TR::Compiler->om.offsetOfHeaderFlags() != TR::Compiler->om.offsetOfObjectVftField())
415
{
416
// Flags are not in the VFT field, so no need for a mask
417
//
418
if (TR::Options::getCmdLineOptions()->getOption(TR_DisableMaskVFTPointers))
419
return ~(uintptr_t)0;
420
}
421
422
return (uintptr_t)(-J9_REQUIRED_CLASS_ALIGNMENT);
423
}
424
425
426
// Answers whether this compilation may need spine checks. The FE will answer yes
427
// if true discontiguous arrays could appear at all with this GC policy, but its a
428
// conservative answer. The corresponding compilation query may know better for
429
// this compilation unit.
430
//
431
bool
432
J9::ObjectModel::mayRequireSpineChecks()
433
{
434
return TR::Compiler->om.useHybridArraylets();
435
}
436
437
438
int32_t
439
J9::ObjectModel::arraySpineShift(int32_t width)
440
{
441
TR_ASSERT(TR::Compiler->om.canGenerateArraylets(), "not supposed to be generating arraylets!");
442
TR_ASSERT(width >= 0, "unexpected arraylet datatype width");
443
444
// for elements larger than bytes, need to reduce the shift because fewer elements
445
// fit into each arraylet
446
447
int32_t shift=-1;
448
int32_t maxShift = TR::Compiler->om.arrayletLeafLogSize();
449
450
switch(width)
451
{
452
case 1 : shift = maxShift-0; break;
453
case 2 : shift = maxShift-1; break;
454
case 4 : shift = maxShift-2; break;
455
case 8 : shift = maxShift-3; break;
456
default: TR_ASSERT(0,"unexpected element width");
457
}
458
return shift;
459
}
460
461
462
int32_t
463
J9::ObjectModel::arrayletMask(int32_t width)
464
{
465
TR_ASSERT(TR::Compiler->om.canGenerateArraylets(), "not supposed to be generating arraylets!");
466
TR_ASSERT(width >= 0, "unexpected arraylet datatype width");
467
int32_t mask=(1 << TR::Compiler->om.arraySpineShift(width))-1;
468
return mask;
469
}
470
471
472
int32_t
473
J9::ObjectModel::arrayletLeafIndex(int32_t index, int32_t elementSize)
474
{
475
TR_ASSERT(TR::Compiler->om.canGenerateArraylets(), "not supposed to be generating arraylets!");
476
TR_ASSERT(elementSize >= 0, "unexpected arraylet datatype width");
477
478
if (index<0)
479
return -1;
480
481
int32_t arrayletIndex = (index >> TR::Compiler->om.arraySpineShift(elementSize));
482
return arrayletIndex;
483
}
484
485
486
int32_t
487
J9::ObjectModel::objectAlignmentInBytes()
488
{
489
J9JavaVM *javaVM = TR::Compiler->javaVM;
490
if (!javaVM)
491
return 0;
492
493
#if defined(J9VM_OPT_JITSERVER)
494
if (auto stream = TR::CompilationInfo::getStream())
495
{
496
auto *vmInfo = TR::compInfoPT->getClientData()->getOrCacheVMInfo(stream);
497
return vmInfo->_objectAlignmentInBytes;
498
}
499
#endif /* defined(J9VM_OPT_JITSERVER) */
500
501
J9MemoryManagerFunctions * mmf = javaVM->memoryManagerFunctions;
502
uintptr_t result = 0;
503
result = mmf->j9gc_modron_getConfigurationValueForKey(javaVM, j9gc_modron_configuration_objectAlignment, &result) ? result : 0;
504
return (int32_t)result;
505
}
506
507
uintptr_t
508
J9::ObjectModel::offsetOfContiguousArraySizeField()
509
{
510
return compressObjectReferences() ? offsetof(J9IndexableObjectContiguousCompressed, size) : offsetof(J9IndexableObjectContiguousFull, size);
511
}
512
513
514
uintptr_t
515
J9::ObjectModel::offsetOfDiscontiguousArraySizeField()
516
{
517
return compressObjectReferences() ? offsetof(J9IndexableObjectDiscontiguousCompressed, size) : offsetof(J9IndexableObjectDiscontiguousFull, size);
518
}
519
520
#if defined(TR_TARGET_64BIT)
521
uintptr_t
522
J9::ObjectModel::offsetOfContiguousDataAddrField()
523
{
524
return compressObjectReferences()
525
? offsetof(J9IndexableObjectContiguousCompressed, dataAddr)
526
: offsetof(J9IndexableObjectContiguousFull, dataAddr);
527
}
528
529
uintptr_t
530
J9::ObjectModel::offsetOfDiscontiguousDataAddrField()
531
{
532
return compressObjectReferences()
533
? offsetof(J9IndexableObjectDiscontiguousCompressed, dataAddr)
534
: offsetof(J9IndexableObjectDiscontiguousFull, dataAddr);
535
}
536
#endif /* TR_TARGET_64BIT */
537
538
539
uintptr_t
540
J9::ObjectModel::objectHeaderSizeInBytes()
541
{
542
return compressObjectReferences() ? sizeof(J9ObjectCompressed) : sizeof(J9ObjectFull);
543
}
544
545
546
uintptr_t
547
J9::ObjectModel::offsetOfIndexableSizeField()
548
{
549
return offsetof(J9ROMArrayClass, arrayShape);
550
}
551
552
553
bool
554
J9::ObjectModel::isDiscontiguousArray(TR::Compilation* comp, uintptr_t objectPointer)
555
{
556
TR_ASSERT(TR::Compiler->vm.hasAccess(comp), "isDicontiguousArray requires VM access");
557
TR_ASSERT(TR::Compiler->cls.isClassArray(comp, TR::Compiler->cls.objectClass(comp, (objectPointer))), "Object is not an array");
558
559
int32_t length = *(int32_t*)(objectPointer + TR::Compiler->om.offsetOfContiguousArraySizeField());
560
561
if (TR::Compiler->om.canGenerateArraylets()
562
&& length == 0)
563
return true;
564
565
return false;
566
}
567
568
/**
569
* \brief
570
* Get the address of an element given its offset into the array.
571
* \parm comp
572
* Current compilation.
573
*
574
* \parm objectPointer.
575
* Pointer to the array.
576
*
577
* \parm offset
578
* The offset of the element in bytes. It should contain the array header. If
579
* objectPointer is a discontiguous array, offset should be an integer that's
580
* calculated as if the array was a contiguous array.
581
*
582
* \return
583
* The address of the element.
584
*/
585
uintptr_t
586
J9::ObjectModel::getAddressOfElement(TR::Compilation* comp, uintptr_t objectPointer, int64_t offset)
587
{
588
TR_ASSERT(TR::Compiler->vm.hasAccess(comp), "getAddressOfElement requires VM access");
589
TR_ASSERT(TR::Compiler->cls.isClassArray(comp, TR::Compiler->cls.objectClass(comp, (objectPointer))), "Object is not an array");
590
TR_ASSERT(offset >= TR::Compiler->om.contiguousArrayHeaderSizeInBytes() &&
591
offset < TR::Compiler->om.getArrayLengthInBytes(comp, objectPointer) + TR::Compiler->om.contiguousArrayHeaderSizeInBytes(), "Array is out of bound");
592
593
// If the array is contiguous, return the addition of objectPointer and offset
594
if (!TR::Compiler->om.isDiscontiguousArray(comp, objectPointer))
595
return objectPointer + offset;
596
597
// The following code handles discontiguous array
598
//
599
// Treat the array as a byte array, so the element size is 1
600
uintptr_t elementSize = 1;
601
int64_t elementIndex = offset - TR::Compiler->om.contiguousArrayHeaderSizeInBytes();
602
603
uintptr_t leafIndex = comp->fej9()->getArrayletLeafIndex(elementIndex, elementSize);
604
uintptr_t elementIndexInLeaf = comp->fej9()->getLeafElementIndex(elementIndex, elementSize);
605
uintptr_t dataStart = objectPointer + TR::Compiler->om.discontiguousArrayHeaderSizeInBytes();
606
607
if (comp->useCompressedPointers())
608
{
609
uint32_t *spine = (uint32_t*)dataStart;
610
dataStart = spine[leafIndex];
611
dataStart = TR::Compiler->om.decompressReference(comp, dataStart);
612
}
613
else
614
{
615
uintptr_t *spine = (uintptr_t*)dataStart;
616
dataStart = spine[leafIndex];
617
}
618
619
return dataStart + elementIndexInLeaf * elementSize;
620
}
621
622
uintptr_t
623
J9::ObjectModel::getArrayElementWidthInBytes(TR::DataType type)
624
{
625
if (type == TR::Address)
626
return TR::Compiler->om.sizeofReferenceField();
627
else
628
return TR::Symbol::convertTypeToSize(type);
629
}
630
631
uintptr_t
632
J9::ObjectModel::getArrayElementWidthInBytes(TR::Compilation* comp, uintptr_t objectPointer)
633
{
634
TR_ASSERT(TR::Compiler->vm.hasAccess(comp), "Must haveAccess in getArrayElementWidthInBytes");
635
return TR::Compiler->cls.getArrayElementWidthInBytes(comp, TR::Compiler->cls.objectClass(comp, (objectPointer)));
636
}
637
638
uintptr_t
639
J9::ObjectModel::getArrayLengthInBytes(TR::Compilation* comp, uintptr_t objectPointer)
640
{
641
TR_ASSERT(TR::Compiler->vm.hasAccess(comp), "Must haveAccess in getArrayLengthInBytes");
642
return (uintptr_t)TR::Compiler->om.getArrayLengthInElements(comp, objectPointer) * TR::Compiler->om.getArrayElementWidthInBytes(comp, objectPointer);
643
}
644
645
intptr_t
646
J9::ObjectModel::getArrayLengthInElements(TR::Compilation* comp, uintptr_t objectPointer)
647
{
648
return comp->fej9()->getArrayLengthInElements(objectPointer);
649
}
650
651
uintptr_t
652
J9::ObjectModel::decompressReference(TR::Compilation* comp, uintptr_t compressedReference)
653
{
654
return (compressedReference << TR::Compiler->om.compressedReferenceShift());
655
}
656
657
bool
658
J9::ObjectModel::usesDiscontiguousArraylets()
659
{
660
#if defined(J9VM_OPT_JITSERVER)
661
if (auto stream = TR::CompilationInfo::getStream())
662
{
663
auto *vmInfo = TR::compInfoPT->getClientData()->getOrCacheVMInfo(stream);
664
return vmInfo->_usesDiscontiguousArraylets;
665
}
666
#endif /* defined(J9VM_OPT_JITSERVER) */
667
return _usesDiscontiguousArraylets;
668
}
669
670
int32_t
671
J9::ObjectModel::arrayletLeafSize()
672
{
673
#if defined(J9VM_OPT_JITSERVER)
674
if (auto stream = TR::CompilationInfo::getStream())
675
{
676
auto *vmInfo = TR::compInfoPT->getClientData()->getOrCacheVMInfo(stream);
677
return vmInfo->_arrayletLeafSize;
678
}
679
#endif /* defined(J9VM_OPT_JITSERVER) */
680
return _arrayLetLeafSize;
681
}
682
683
int32_t
684
J9::ObjectModel::arrayletLeafLogSize()
685
{
686
#if defined(J9VM_OPT_JITSERVER)
687
if (auto stream = TR::CompilationInfo::getStream())
688
{
689
auto *vmInfo = TR::compInfoPT->getClientData()->getOrCacheVMInfo(stream);
690
return vmInfo->_arrayletLeafLogSize;
691
}
692
#endif /* defined(J9VM_OPT_JITSERVER) */
693
return _arrayLetLeafLogSize;
694
}
695
696
MM_GCReadBarrierType
697
J9::ObjectModel::readBarrierType()
698
{
699
#if defined(J9VM_OPT_JITSERVER)
700
if (auto stream = TR::CompilationInfo::getStream())
701
{
702
auto *vmInfo = TR::compInfoPT->getClientData()->getOrCacheVMInfo(stream);
703
return vmInfo->_readBarrierType;
704
}
705
#endif /* defined(J9VM_OPT_JITSERVER) */
706
return _readBarrierType;
707
}
708
709
MM_GCWriteBarrierType
710
J9::ObjectModel::writeBarrierType()
711
{
712
#if defined(J9VM_OPT_JITSERVER)
713
if (auto stream = TR::CompilationInfo::getStream())
714
{
715
auto *vmInfo = TR::compInfoPT->getClientData()->getOrCacheVMInfo(stream);
716
return vmInfo->_writeBarrierType;
717
}
718
#endif /* defined(J9VM_OPT_JITSERVER) */
719
return _writeBarrierType;
720
}
721
722
bool
723
J9::ObjectModel::compressObjectReferences()
724
{
725
#if defined(J9VM_OPT_JITSERVER)
726
if (auto stream = TR::CompilationInfo::getStream())
727
{
728
auto *vmInfo = TR::compInfoPT->getClientData()->getOrCacheVMInfo(stream);
729
return vmInfo->_compressObjectReferences;
730
}
731
#endif /* defined(J9VM_OPT_JITSERVER) */
732
return _compressObjectReferences;
733
}
734
735
int32_t
736
J9::ObjectModel::getObjectAlignmentInBytes()
737
{
738
#if defined(J9VM_OPT_JITSERVER)
739
if (auto stream = TR::CompilationInfo::getStream())
740
{
741
auto *vmInfo = TR::compInfoPT->getClientData()->getOrCacheVMInfo(stream);
742
return vmInfo->_objectAlignmentInBytes;
743
}
744
#endif /* defined(J9VM_OPT_JITSERVER) */
745
return _objectAlignmentInBytes;
746
}
747
748