1 /* 2 * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 package org.graalvm.compiler.hotspot; 26 27 import java.lang.reflect.Field; 28 import java.lang.reflect.Modifier; 29 import java.util.List; 30 31 import org.graalvm.compiler.api.replacements.Fold; 32 import org.graalvm.compiler.api.replacements.Fold.InjectedParameter; 33 import org.graalvm.compiler.core.common.CompressEncoding; 34 import org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext; 35 import org.graalvm.compiler.options.OptionValues; 36 37 import jdk.vm.ci.common.JVMCIError; 38 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; 39 import jdk.vm.ci.hotspot.HotSpotVMConfigStore; 40 import jdk.vm.ci.meta.MetaAccessProvider; 41 import jdk.vm.ci.meta.ResolvedJavaMethod; 42 43 /** 44 * Used to access native configuration details. 45 */ 46 public class GraalHotSpotVMConfig extends GraalHotSpotVMConfigAccess { 47 48 /** 49 * Sentinel value to use for an {@linkplain InjectedParameter injected} 50 * {@link GraalHotSpotVMConfig} parameter to a {@linkplain Fold foldable} method. 51 */ 52 public static final GraalHotSpotVMConfig INJECTED_VMCONFIG = null; 53 public static final MetaAccessProvider INJECTED_METAACCESS = null; 54 public static final OptionValues INJECTED_OPTIONVALUES = null; 55 public static final IntrinsicContext INJECTED_INTRINSIC_CONTEXT = null; 56 GraalHotSpotVMConfig(HotSpotVMConfigStore store)57 GraalHotSpotVMConfig(HotSpotVMConfigStore store) { 58 super(store); 59 60 assert narrowKlassShift <= logKlassAlignment; 61 assert narrowOopShift <= logMinObjAlignment(); 62 oopEncoding = new CompressEncoding(narrowOopBase, narrowOopShift); 63 klassEncoding = new CompressEncoding(narrowKlassBase, narrowKlassShift); 64 65 assert check(); 66 reportErrors(); 67 } 68 69 private final CompressEncoding oopEncoding; 70 private final CompressEncoding klassEncoding; 71 private final String markWord = JDK < 14 ? "markOop" : "markWord"; // JDK-8229258 72 73 public CompressEncoding getOopEncoding() { 74 return oopEncoding; 75 } 76 77 public CompressEncoding getKlassEncoding() { 78 return klassEncoding; 79 } 80 81 private final boolean isJDK11Plus = JDK >= 11; 82 private final boolean isJDK8OrJDK11Plus = JDK == 8 || isJDK11Plus; 83 84 // Certain values were accidentally omitted in JDK 9+ only VM values 85 // in vmStructs_jvmci.cpp are exposed to JVMCI. In JDK 8, values in any 86 // vmStructs*.[cpp|hpp] file are exposed to JVMCI. 87 private final boolean gr21761 = JDK == 8 || (JVMCI ? jvmciGE(JVMCI_20_0_b03) : JDK >= 15); 88 89 private final boolean jdk13Backport = JVMCI ? jvmciGE(JVMCI_19_3_b03) : JDK >= 13; 90 91 public final boolean cAssertions = getConstant("ASSERT", Boolean.class); 92 93 public final int codeEntryAlignment = getFlag("CodeEntryAlignment", Integer.class); 94 public final boolean enableContended = getFlag("EnableContended", Boolean.class); 95 public final boolean restrictContended = getFlag("RestrictContended", Boolean.class); 96 public final int contendedPaddingWidth = getFlag("ContendedPaddingWidth", Integer.class); 97 public final int fieldsAllocationStyle; 98 public final boolean compactFields; 99 { 100 // JDK-8236224 101 if (JDK >= 15) { 102 fieldsAllocationStyle = 1; 103 compactFields = true; 104 } else { 105 fieldsAllocationStyle = getFlag("FieldsAllocationStyle", Integer.class); 106 compactFields = getFlag("CompactFields", Boolean.class); 107 } 108 } 109 public final boolean verifyOops = getFlag("VerifyOops", Boolean.class); 110 public final boolean ciTime = getFlag("CITime", Boolean.class); 111 public final boolean ciTimeEach = getFlag("CITimeEach", Boolean.class); 112 public final boolean dontCompileHugeMethods = getFlag("DontCompileHugeMethods", Boolean.class); 113 public final int hugeMethodLimit = getFlag("HugeMethodLimit", Integer.class); 114 public final boolean printInlining = getFlag("PrintInlining", Boolean.class); 115 public final boolean inline = getFlag("Inline", Boolean.class); 116 public final boolean inlineNotify = JDK > 8; 117 public final boolean useFastLocking = getFlag("JVMCIUseFastLocking", Boolean.class); 118 public final boolean forceUnreachable = getFlag("ForceUnreachable", Boolean.class); 119 public final int codeSegmentSize = getFlag("CodeCacheSegmentSize", Integer.class); 120 public final boolean foldStableValues = getFlag("FoldStableValues", Boolean.class); 121 public final int maxVectorSize = getFlag("MaxVectorSize", Integer.class); 122 123 public final boolean verifyBeforeGC = getFlag("VerifyBeforeGC", Boolean.class); 124 public final boolean verifyAfterGC = getFlag("VerifyAfterGC", Boolean.class); 125 126 public final boolean useTLAB = getFlag("UseTLAB", Boolean.class); 127 public final boolean useBiasedLocking = getFlag("UseBiasedLocking", Boolean.class); 128 public final boolean usePopCountInstruction = getFlag("UsePopCountInstruction", Boolean.class); 129 public final boolean useAESIntrinsics = getFlag("UseAESIntrinsics", Boolean.class); 130 public final boolean useAESCTRIntrinsics = getFlag("UseAESCTRIntrinsics", Boolean.class, false, (JDK == 8 && !IS_OPENJDK) || JDK >= 9); 131 public final boolean useCRC32Intrinsics = getFlag("UseCRC32Intrinsics", Boolean.class); 132 public final boolean useCRC32CIntrinsics = getFlag("UseCRC32CIntrinsics", Boolean.class, false, JDK >= 9); // JDK-8073583 133 public final boolean useThreadLocalPolling; 134 { 135 if (JDK >= 14) { 136 // JDK-8220049, JDK-8220051 137 useThreadLocalPolling = true; 138 } else if (JDK >= 10) { 139 useThreadLocalPolling = getFlag("ThreadLocalHandshakes", Boolean.class); 140 } else { 141 useThreadLocalPolling = false; 142 } 143 } 144 private final boolean useMultiplyToLenIntrinsic = getFlag("UseMultiplyToLenIntrinsic", Boolean.class); 145 private final boolean useSHA1Intrinsics = getFlag("UseSHA1Intrinsics", Boolean.class); 146 private final boolean useSHA256Intrinsics = getFlag("UseSHA256Intrinsics", Boolean.class); 147 private final boolean useSHA512Intrinsics = getFlag("UseSHA512Intrinsics", Boolean.class); 148 private final boolean useGHASHIntrinsics = getFlag("UseGHASHIntrinsics", Boolean.class, false, isJDK8OrJDK11Plus); 149 private final boolean useBase64Intrinsics = getFlag("UseBASE64Intrinsics", Boolean.class, false, isJDK11Plus); 150 private final boolean useMontgomeryMultiplyIntrinsic = getFlag("UseMontgomeryMultiplyIntrinsic", Boolean.class, false, isJDK8OrJDK11Plus); 151 private final boolean useMontgomerySquareIntrinsic = getFlag("UseMontgomerySquareIntrinsic", Boolean.class, false, isJDK8OrJDK11Plus); 152 private final boolean useMulAddIntrinsic = getFlag("UseMulAddIntrinsic", Boolean.class, false, isJDK8OrJDK11Plus); 153 private final boolean useSquareToLenIntrinsic = getFlag("UseSquareToLenIntrinsic", Boolean.class, false, isJDK8OrJDK11Plus); 154 public final boolean useVectorizedMismatchIntrinsic = getFlag("UseVectorizedMismatchIntrinsic", Boolean.class, false, isJDK11Plus); 155 public final boolean useFMAIntrinsics = getFlag("UseFMA", Boolean.class, false, JDK >= 9); 156 public final int useAVX3Threshold = getFlag("AVX3Threshold", Integer.class, 4096, osArch.equals("amd64") && (JDK >= 14 || (JDK == 11 && JDK_UPDATE >= 6))); 157 158 public final boolean preserveFramePointer = getFlag("PreserveFramePointer", Boolean.class); 159 160 /* 161 * These are methods because in some JDKs the flags are visible but the stubs themselves haven't 162 * been exported so we have to check both if the flag is on and if we have the stub. 163 */ useMultiplyToLenIntrinsic()164 public boolean useMultiplyToLenIntrinsic() { 165 return useMultiplyToLenIntrinsic && multiplyToLen != 0; 166 } 167 useSHA1Intrinsics()168 public boolean useSHA1Intrinsics() { 169 return useSHA1Intrinsics && sha1ImplCompress != 0 && sha1ImplCompressMultiBlock != 0; 170 } 171 useSHA256Intrinsics()172 public boolean useSHA256Intrinsics() { 173 return useSHA256Intrinsics && sha256ImplCompress != 0 && sha256ImplCompressMultiBlock != 0; 174 } 175 useSHA512Intrinsics()176 public boolean useSHA512Intrinsics() { 177 return useSHA512Intrinsics && sha512ImplCompress != 0 && sha512ImplCompressMultiBlock != 0; 178 } 179 useGHASHIntrinsics()180 public boolean useGHASHIntrinsics() { 181 return useGHASHIntrinsics && ghashProcessBlocks != 0; 182 } 183 useBase64Intrinsics()184 public boolean useBase64Intrinsics() { 185 return useBase64Intrinsics && base64EncodeBlock != 0; 186 } 187 useMontgomeryMultiplyIntrinsic()188 public boolean useMontgomeryMultiplyIntrinsic() { 189 return useMontgomeryMultiplyIntrinsic && montgomeryMultiply != 0; 190 } 191 useMontgomerySquareIntrinsic()192 public boolean useMontgomerySquareIntrinsic() { 193 return useMontgomerySquareIntrinsic && montgomerySquare != 0; 194 } 195 useMulAddIntrinsic()196 public boolean useMulAddIntrinsic() { 197 return useMulAddIntrinsic && mulAdd != 0; 198 } 199 useSquareToLenIntrinsic()200 public boolean useSquareToLenIntrinsic() { 201 return useSquareToLenIntrinsic && squareToLen != 0; 202 } 203 inlineNotify()204 public boolean inlineNotify() { 205 return inlineNotify && notifyAddress != 0; 206 } 207 inlineNotifyAll()208 public boolean inlineNotifyAll() { 209 return inlineNotify && notifyAllAddress != 0; 210 } 211 212 public final boolean useG1GC = getFlag("UseG1GC", Boolean.class); 213 public final boolean useCMSGC = getFlag("UseConcMarkSweepGC", Boolean.class, false, JDK < 14); // JDK-8231559 214 215 public final int allocatePrefetchStyle = getFlag("AllocatePrefetchStyle", Integer.class); 216 public final int allocatePrefetchInstr = getFlag("AllocatePrefetchInstr", Integer.class); 217 public final int allocatePrefetchLines = getFlag("AllocatePrefetchLines", Integer.class); 218 public final int allocateInstancePrefetchLines = getFlag("AllocateInstancePrefetchLines", Integer.class); 219 public final int allocatePrefetchStepSize = getFlag("AllocatePrefetchStepSize", Integer.class); 220 public final int allocatePrefetchDistance = getFlag("AllocatePrefetchDistance", Integer.class); 221 222 private final long universeCollectedHeap = getFieldValue("CompilerToVM::Data::Universe_collectedHeap", Long.class, "CollectedHeap*"); 223 private final int collectedHeapTotalCollectionsOffset = getFieldOffset("CollectedHeap::_total_collections", Integer.class, "unsigned int"); 224 gcTotalCollectionsAddress()225 public long gcTotalCollectionsAddress() { 226 return universeCollectedHeap + collectedHeapTotalCollectionsOffset; 227 } 228 229 public final boolean useDeferredInitBarriers = getFlag("ReduceInitialCardMarks", Boolean.class); 230 231 // Compressed Oops related values. 232 public final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); 233 public final boolean useCompressedClassPointers = getFlag("UseCompressedClassPointers", Boolean.class); 234 235 public final long narrowOopBase = getFieldValue("CompilerToVM::Data::Universe_narrow_oop_base", Long.class, "address"); 236 public final int narrowOopShift = getFieldValue("CompilerToVM::Data::Universe_narrow_oop_shift", Integer.class, "int"); 237 public final int objectAlignment = getFlag("ObjectAlignmentInBytes", Integer.class); 238 minObjAlignment()239 public final int minObjAlignment() { 240 return objectAlignment / heapWordSize; 241 } 242 logMinObjAlignment()243 public final int logMinObjAlignment() { 244 return (int) (Math.log(objectAlignment) / Math.log(2)); 245 } 246 247 public final int narrowKlassSize = getFieldValue("CompilerToVM::Data::sizeof_narrowKlass", Integer.class, "int"); 248 public final long narrowKlassBase = getFieldValue("CompilerToVM::Data::Universe_narrow_klass_base", Long.class, "address"); 249 public final int narrowKlassShift = getFieldValue("CompilerToVM::Data::Universe_narrow_klass_shift", Integer.class, "int"); 250 public final int logKlassAlignment = getConstant("LogKlassAlignmentInBytes", Integer.class); 251 252 public final int stackShadowPages = getFlag("StackShadowPages", Integer.class); 253 public final int stackReservedPages = getFlag("StackReservedPages", Integer.class, 0, JDK >= 9); 254 public final boolean useStackBanging = getFlag("UseStackBanging", Boolean.class); 255 public final int stackBias = getConstant("STACK_BIAS", Integer.class, 0, JDK < 15); 256 public final int vmPageSize = getFieldValue("CompilerToVM::Data::vm_page_size", Integer.class, "int"); 257 258 public final int markOffset = getFieldOffset("oopDesc::_mark", Integer.class, markWord); 259 public final int hubOffset = getFieldOffset("oopDesc::_metadata._klass", Integer.class, "Klass*"); 260 261 public final int prototypeMarkWordOffset = getFieldOffset("Klass::_prototype_header", Integer.class, markWord); 262 public final int subklassOffset = getFieldOffset("Klass::_subklass", Integer.class, "Klass*"); 263 public final int nextSiblingOffset = getFieldOffset("Klass::_next_sibling", Integer.class, "Klass*"); 264 public final int superCheckOffsetOffset = getFieldOffset("Klass::_super_check_offset", Integer.class, "juint"); 265 public final int secondarySuperCacheOffset = getFieldOffset("Klass::_secondary_super_cache", Integer.class, "Klass*"); 266 public final int secondarySupersOffset = getFieldOffset("Klass::_secondary_supers", Integer.class, "Array<Klass*>*"); 267 268 public final boolean classMirrorIsHandle; 269 public final int classMirrorOffset; 270 { 271 // JDK-8186777 272 if (JDK <= 8) { 273 classMirrorIsHandle = false; 274 classMirrorOffset = getFieldOffset("Klass::_java_mirror", Integer.class, "oop"); 275 } else { 276 classMirrorIsHandle = true; 277 classMirrorOffset = getFieldOffset("Klass::_java_mirror", Integer.class, "OopHandle"); 278 } 279 } 280 281 public final int klassSuperKlassOffset = getFieldOffset("Klass::_super", Integer.class, "Klass*"); 282 public final int klassModifierFlagsOffset = getFieldOffset("Klass::_modifier_flags", Integer.class, "jint"); 283 public final int klassAccessFlagsOffset = getFieldOffset("Klass::_access_flags", Integer.class, "AccessFlags"); 284 public final int klassLayoutHelperOffset = getFieldOffset("Klass::_layout_helper", Integer.class, "jint"); 285 286 public final int klassLayoutHelperNeutralValue = getConstant("Klass::_lh_neutral_value", Integer.class); 287 public final int layoutHelperLog2ElementSizeShift = getConstant("Klass::_lh_log2_element_size_shift", Integer.class); 288 public final int layoutHelperLog2ElementSizeMask = getConstant("Klass::_lh_log2_element_size_mask", Integer.class); 289 public final int layoutHelperElementTypeShift = getConstant("Klass::_lh_element_type_shift", Integer.class); 290 public final int layoutHelperElementTypeMask = getConstant("Klass::_lh_element_type_mask", Integer.class); 291 public final int layoutHelperHeaderSizeShift = getConstant("Klass::_lh_header_size_shift", Integer.class); 292 public final int layoutHelperHeaderSizeMask = getConstant("Klass::_lh_header_size_mask", Integer.class); 293 public final int layoutHelperArrayTagShift = getConstant("Klass::_lh_array_tag_shift", Integer.class); 294 public final int layoutHelperArrayTagTypeValue = getConstant("Klass::_lh_array_tag_type_value", Integer.class); 295 public final int layoutHelperArrayTagObjectValue = getConstant("Klass::_lh_array_tag_obj_value", Integer.class); 296 297 /** 298 * This filters out the bit that differentiates a type array from an object array. 299 */ layoutHelperElementTypePrimitiveInPlace()300 public int layoutHelperElementTypePrimitiveInPlace() { 301 return (layoutHelperArrayTagTypeValue & ~layoutHelperArrayTagObjectValue) << layoutHelperArrayTagShift; 302 } 303 304 public final int vtableEntrySize = getFieldValue("CompilerToVM::Data::sizeof_vtableEntry", Integer.class, "int"); 305 public final int vtableEntryMethodOffset = getFieldOffset("vtableEntry::_method", Integer.class, "Method*"); 306 307 public final int instanceKlassInitStateOffset = getFieldOffset("InstanceKlass::_init_state", Integer.class, "u1"); 308 public final int instanceKlassInitThreadOffset = getFieldOffset("InstanceKlass::_init_thread", Integer.class, "Thread*", -1, JDK == 8 || JDK >= 15 || (JVMCI && jvmciGE(JVMCI_20_0_b03))); 309 public final int instanceKlassConstantsOffset = getFieldOffset("InstanceKlass::_constants", Integer.class, "ConstantPool*"); 310 public final int instanceKlassFieldsOffset = getFieldOffset("InstanceKlass::_fields", Integer.class, "Array<u2>*"); 311 public final int klassVtableStartOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_start_offset", Integer.class, "int"); 312 public final int klassVtableLengthOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_length_offset", Integer.class, "int"); 313 314 public final int instanceKlassStateLinked = getConstant("InstanceKlass::linked", Integer.class); 315 public final int instanceKlassStateBeingInitialized = getConstant("InstanceKlass::being_initialized", Integer.class, -1, JDK == 8 || (JVMCI ? jvmciGE(JVMCI_20_0_b03) : JDK >= 14)); 316 public final int instanceKlassStateFullyInitialized = getConstant("InstanceKlass::fully_initialized", Integer.class); 317 318 public final int arrayOopDescSize = getFieldValue("CompilerToVM::Data::sizeof_arrayOopDesc", Integer.class, "int"); 319 320 /** 321 * The offset of the array length word in an array object's header. 322 * 323 * See {@code arrayOopDesc::length_offset_in_bytes()}. 324 */ arrayOopDescLengthOffset()325 public final int arrayOopDescLengthOffset() { 326 return useCompressedClassPointers ? hubOffset + narrowKlassSize : arrayOopDescSize; 327 } 328 329 public final int arrayU1LengthOffset = getFieldOffset("Array<int>::_length", Integer.class, "int"); 330 public final int arrayU1DataOffset = getFieldOffset("Array<u1>::_data", Integer.class); 331 public final int arrayU2DataOffset = getFieldOffset("Array<u2>::_data", Integer.class); 332 public final int metaspaceArrayLengthOffset = getFieldOffset("Array<Klass*>::_length", Integer.class, "int"); 333 public final int metaspaceArrayBaseOffset = getFieldOffset("Array<Klass*>::_data[0]", Integer.class, "Klass*"); 334 335 public final int arrayClassElementOffset = getFieldOffset("ObjArrayKlass::_element_klass", Integer.class, "Klass*"); 336 337 public final int fieldInfoAccessFlagsOffset = getConstant("FieldInfo::access_flags_offset", Integer.class); 338 public final int fieldInfoNameIndexOffset = getConstant("FieldInfo::name_index_offset", Integer.class); 339 public final int fieldInfoSignatureIndexOffset = getConstant("FieldInfo::signature_index_offset", Integer.class); 340 public final int fieldInfoInitvalIndexOffset = getConstant("FieldInfo::initval_index_offset", Integer.class); 341 public final int fieldInfoLowPackedOffset = getConstant("FieldInfo::low_packed_offset", Integer.class); 342 public final int fieldInfoHighPackedOffset = getConstant("FieldInfo::high_packed_offset", Integer.class); 343 public final int fieldInfoFieldSlots = getConstant("FieldInfo::field_slots", Integer.class); 344 345 public final int fieldInfoTagSize = getConstant("FIELDINFO_TAG_SIZE", Integer.class); 346 347 public final int jvmAccMonitorMatch = getConstant("JVM_ACC_MONITOR_MATCH", Integer.class); 348 public final int jvmAccHasMonitorBytecodes = getConstant("JVM_ACC_HAS_MONITOR_BYTECODES", Integer.class); 349 public final int jvmAccHasFinalizer = getConstant("JVM_ACC_HAS_FINALIZER", Integer.class); 350 public final int jvmAccFieldInternal = getConstant("JVM_ACC_FIELD_INTERNAL", Integer.class); 351 public final int jvmAccFieldStable = getConstant("JVM_ACC_FIELD_STABLE", Integer.class); 352 public final int jvmAccFieldHasGenericSignature = getConstant("JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE", Integer.class); 353 public final int jvmAccWrittenFlags = getConstant("JVM_ACC_WRITTEN_FLAGS", Integer.class); 354 public final int jvmAccSynthetic = getConstant("JVM_ACC_SYNTHETIC", Integer.class); 355 public final int jvmAccIsHiddenClass = getConstant("JVM_ACC_IS_HIDDEN_CLASS", Integer.class, 0, JDK >= 15); // JDK-8219607 356 357 public final int jvmciCompileStateCanPostOnExceptionsOffset = getJvmciJvmtiCapabilityOffset("_jvmti_can_post_on_exceptions"); 358 public final int jvmciCompileStateCanPopFrameOffset = getJvmciJvmtiCapabilityOffset("_jvmti_can_pop_frame"); 359 public final int jvmciCompileStateCanAccessLocalVariablesOffset = getJvmciJvmtiCapabilityOffset("_jvmti_can_access_local_variables"); 360 361 // Integer.MIN_VALUE if not available getJvmciJvmtiCapabilityOffset(String name)362 private int getJvmciJvmtiCapabilityOffset(String name) { 363 if (JVMCI) { 364 return getFieldOffset("JVMCICompileState::" + name, Integer.class, "jbyte"); 365 } 366 if (JDK >= 13) { 367 return getFieldOffset("JVMCICompileState::" + name, Integer.class, "jbyte"); 368 } 369 if (JDK == 12) { 370 return getFieldOffset("JVMCIEnv::" + name, Integer.class, "jbyte"); 371 } 372 return Integer.MIN_VALUE; 373 } 374 375 public final int threadTlabOffset = getFieldOffset("Thread::_tlab", Integer.class, "ThreadLocalAllocBuffer"); 376 public final int javaThreadAnchorOffset = getFieldOffset("JavaThread::_anchor", Integer.class, "JavaFrameAnchor"); 377 public final int javaThreadShouldPostOnExceptionsFlagOffset = getFieldOffset("JavaThread::_should_post_on_exceptions_flag", Integer.class, "int", Integer.MIN_VALUE, JVMCI || JDK >= 12); 378 public final int threadObjectOffset = getFieldOffset("JavaThread::_threadObj", Integer.class, "oop"); 379 public final int osThreadOffset = getFieldOffset("JavaThread::_osthread", Integer.class, "OSThread*"); 380 public final int threadIsMethodHandleReturnOffset = getFieldOffset("JavaThread::_is_method_handle_return", Integer.class, "int"); 381 public final int threadObjectResultOffset = getFieldOffset("JavaThread::_vm_result", Integer.class, "oop"); 382 public final int jvmciCountersThreadOffset = getFieldOffset("JavaThread::_jvmci_counters", Integer.class, "jlong*"); 383 public final int doingUnsafeAccessOffset = getFieldOffset("JavaThread::_doing_unsafe_access", Integer.class, "bool", Integer.MAX_VALUE, JVMCI || JDK >= 14); 384 public final int javaThreadReservedStackActivationOffset = JDK <= 8 ? 0 : getFieldOffset("JavaThread::_reserved_stack_activation", Integer.class, "address"); // JDK-8046936 385 public final int jniEnvironmentOffset = getFieldOffset("JavaThread::_jni_environment", Integer.class, "JNIEnv", Integer.MIN_VALUE, JVMCI || JDK >= 14); 386 requiresReservedStackCheck(List<ResolvedJavaMethod> methods)387 public boolean requiresReservedStackCheck(List<ResolvedJavaMethod> methods) { 388 if (enableStackReservedZoneAddress != 0 && methods != null) { 389 for (ResolvedJavaMethod method : methods) { 390 if (((HotSpotResolvedJavaMethod) method).hasReservedStackAccess()) { 391 return true; 392 } 393 } 394 } 395 return false; 396 } 397 398 /** 399 * An invalid value for {@link #rtldDefault}. 400 */ 401 public static final long INVALID_RTLD_DEFAULT_HANDLE = 0xDEADFACE; 402 403 /** 404 * Address of the library lookup routine. The C signature of this routine is: 405 * 406 * <pre> 407 * void* (const char *filename, char *ebuf, int ebuflen) 408 * </pre> 409 */ 410 public final long dllLoad = getAddress("os::dll_load"); 411 412 /** 413 * Address of the library lookup routine. The C signature of this routine is: 414 * 415 * <pre> 416 * void* (void* handle, const char* name) 417 * </pre> 418 */ 419 public final long dllLookup = getAddress("os::dll_lookup"); 420 421 /** 422 * A pseudo-handle which when used as the first argument to {@link #dllLookup} means lookup will 423 * return the first occurrence of the desired symbol using the default library search order. If 424 * this field is {@value #INVALID_RTLD_DEFAULT_HANDLE}, then this capability is not supported on 425 * the current platform. 426 */ 427 public final long rtldDefault = getAddress("RTLD_DEFAULT", INVALID_RTLD_DEFAULT_HANDLE, osName.equals("darwin") || osName.equals("linux") || osName.equals("bsd")); 428 429 /** 430 * This field is used to pass exception objects into and out of the runtime system during 431 * exception handling for compiled code. 432 */ 433 public final int threadExceptionOopOffset = getFieldOffset("JavaThread::_exception_oop", Integer.class, "oop"); 434 public final int threadExceptionPcOffset = getFieldOffset("JavaThread::_exception_pc", Integer.class, "address"); 435 public final int pendingExceptionOffset = getFieldOffset("ThreadShadow::_pending_exception", Integer.class, "oop"); 436 437 public final int pendingDeoptimizationOffset = getFieldOffset("JavaThread::_pending_deoptimization", Integer.class, "int"); 438 public final int pendingTransferToInterpreterOffset = getFieldOffset("JavaThread::_pending_transfer_to_interpreter", Integer.class, "bool"); 439 440 private final int javaFrameAnchorLastJavaSpOffset = getFieldOffset("JavaFrameAnchor::_last_Java_sp", Integer.class, "intptr_t*"); 441 private final int javaFrameAnchorLastJavaPcOffset = getFieldOffset("JavaFrameAnchor::_last_Java_pc", Integer.class, "address"); 442 443 public final int pendingFailedSpeculationOffset; 444 { 445 String name = "JavaThread::_pending_failed_speculation"; 446 int offset = -1; 447 try { 448 offset = getFieldOffset(name, Integer.class, "jlong"); 449 } catch (JVMCIError e) { 450 try { 451 offset = getFieldOffset(name, Integer.class, "long"); 452 } catch (JVMCIError e2) { 453 } 454 } 455 if (offset == -1) { 456 throw new JVMCIError("cannot get offset of field " + name + " with type long or jlong"); 457 } 458 pendingFailedSpeculationOffset = offset; 459 } 460 threadLastJavaSpOffset()461 public int threadLastJavaSpOffset() { 462 return javaThreadAnchorOffset + javaFrameAnchorLastJavaSpOffset; 463 } 464 threadLastJavaPcOffset()465 public int threadLastJavaPcOffset() { 466 return javaThreadAnchorOffset + javaFrameAnchorLastJavaPcOffset; 467 } 468 threadLastJavaFpOffset()469 public int threadLastJavaFpOffset() { 470 assert osArch.equals("aarch64") || osArch.equals("amd64"); 471 return javaThreadAnchorOffset + getFieldOffset("JavaFrameAnchor::_last_Java_fp", Integer.class, "intptr_t*"); 472 } 473 threadJavaFrameAnchorFlagsOffset()474 public int threadJavaFrameAnchorFlagsOffset() { 475 assert osArch.equals("sparc"); 476 return javaThreadAnchorOffset + getFieldOffset("JavaFrameAnchor::_flags", Integer.class, "int"); 477 } 478 479 public final int runtimeCallStackSize = getConstant("frame::arg_reg_save_area_bytes", Integer.class, 0, osArch.equals("amd64")); 480 public final int frameInterpreterFrameSenderSpOffset = getConstant("frame::interpreter_frame_sender_sp_offset", Integer.class, 0, osArch.equals("amd64")); 481 public final int frameInterpreterFrameLastSpOffset = getConstant("frame::interpreter_frame_last_sp_offset", Integer.class, 0, osArch.equals("amd64")); 482 483 public final int osThreadInterruptedOffset = getFieldOffset("OSThread::_interrupted", Integer.class, "jint", Integer.MAX_VALUE, JDK < 14); 484 485 public final long markWordHashShift = getConstant(markWordField("hash_shift"), Long.class); 486 487 public final int biasedLockMaskInPlace = getConstant(markWordField("biased_lock_mask_in_place"), Integer.class); 488 public final int ageMaskInPlace = getConstant(markWordField("age_mask_in_place"), Integer.class); 489 public final int epochMaskInPlace = getConstant(markWordField("epoch_mask_in_place"), Integer.class); 490 public final long markWordHashMask = getConstant(markWordField("hash_mask"), Long.class); 491 public final long markWordHashMaskInPlace = getConstant(markWordField("hash_mask_in_place"), Long.class); 492 493 public final int unlockedMask = getConstant(markWordField("unlocked_value"), Integer.class); 494 public final int monitorMask = getConstant(markWordField("monitor_value"), Integer.class, -1, gr21761); 495 public final int biasedLockPattern = getConstant(markWordField("biased_lock_pattern"), Integer.class); 496 497 // This field has no type in vmStructs.cpp 498 public final int objectMonitorOwner = getFieldOffset("ObjectMonitor::_owner", Integer.class, null, -1, gr21761); 499 public final int objectMonitorRecursions = getFieldOffset("ObjectMonitor::_recursions", Integer.class, "intptr_t", -1, gr21761); 500 public final int objectMonitorCxq = getFieldOffset("ObjectMonitor::_cxq", Integer.class, "ObjectWaiter*", -1, jdk13Backport); 501 public final int objectMonitorEntryList = getFieldOffset("ObjectMonitor::_EntryList", Integer.class, "ObjectWaiter*", -1, jdk13Backport); 502 public final int objectMonitorSucc = getFieldOffset("ObjectMonitor::_succ", Integer.class, "Thread*", -1, jdk13Backport); 503 504 public final int markWordNoHashInPlace = getConstant(markWordField("no_hash_in_place"), Integer.class); 505 public final int markWordNoLockInPlace = getConstant(markWordField("no_lock_in_place"), Integer.class); 506 507 /** 508 * See {@code markOopDesc::prototype()}/{@code markWord::prototype()}. 509 */ arrayPrototypeMarkWord()510 public long arrayPrototypeMarkWord() { 511 return markWordNoHashInPlace | markWordNoLockInPlace; 512 } 513 514 /** 515 * See {@code markOopDesc::copy_set_hash()}/{@code markWord::copy_set_hash()}. 516 */ tlabIntArrayMarkWord()517 public long tlabIntArrayMarkWord() { 518 long tmp = arrayPrototypeMarkWord() & (~markWordHashMaskInPlace); 519 tmp |= ((0x2 & markWordHashMask) << markWordHashShift); 520 return tmp; 521 } 522 markWordField(String simpleName)523 private static String markWordField(String simpleName) { 524 return (JDK < 14 ? "markOopDesc::" : "markWord::") + simpleName; 525 } 526 527 /** 528 * Mark word right shift to get identity hash code. 529 */ 530 public final int identityHashCodeShift = getConstant(markWordField("hash_shift"), Integer.class); 531 532 /** 533 * Identity hash code value when uninitialized. 534 */ 535 public final int uninitializedIdentityHashCodeValue = getConstant(markWordField("no_hash"), Integer.class); 536 537 public final int methodAccessFlagsOffset = getFieldOffset("Method::_access_flags", Integer.class, "AccessFlags"); 538 public final int methodConstMethodOffset = getFieldOffset("Method::_constMethod", Integer.class, "ConstMethod*"); 539 public final int methodIntrinsicIdOffset = getFieldOffset("Method::_intrinsic_id", Integer.class, JDK <= 8 ? "u1" : "u2"); 540 public final int methodFlagsOffset = getFieldOffset("Method::_flags", Integer.class, JDK <= 8 ? "u1" : "u2"); 541 public final int methodVtableIndexOffset = getFieldOffset("Method::_vtable_index", Integer.class, "int"); 542 543 public final int methodCountersOffset = getFieldOffset("Method::_method_counters", Integer.class, "MethodCounters*"); 544 public final int methodDataOffset = getFieldOffset("Method::_method_data", Integer.class, "MethodData*"); 545 public final int methodCompiledEntryOffset = getFieldOffset("Method::_from_compiled_entry", Integer.class, "address"); 546 public final int methodCodeOffset = getFieldOffset("Method::_code", Integer.class, JDK <= 8 ? "nmethod*" : "CompiledMethod*"); 547 548 public final int methodFlagsCallerSensitive = getConstant("Method::_caller_sensitive", Integer.class); 549 public final int methodFlagsForceInline = getConstant("Method::_force_inline", Integer.class); 550 public final int methodFlagsDontInline = getConstant("Method::_dont_inline", Integer.class); 551 public final int methodFlagsHidden = getConstant("Method::_hidden", Integer.class); 552 public final int nonvirtualVtableIndex = getConstant("Method::nonvirtual_vtable_index", Integer.class); 553 public final int invalidVtableIndex = getConstant("Method::invalid_vtable_index", Integer.class); 554 555 public final int invocationCounterOffset = getFieldOffset("MethodCounters::_invocation_counter", Integer.class, "InvocationCounter"); 556 public final int backedgeCounterOffset = getFieldOffset("MethodCounters::_backedge_counter", Integer.class, "InvocationCounter"); 557 public final int invocationCounterIncrement = JDK <= 8 ? 0 : getConstant("InvocationCounter::count_increment", Integer.class); 558 public final int invocationCounterShift = JDK <= 8 ? 0 : getConstant("InvocationCounter::count_shift", Integer.class); 559 560 public final int nmethodEntryOffset = getFieldOffset("nmethod::_verified_entry_point", Integer.class, "address"); 561 public final int compilationLevelFullOptimization = getConstant("CompLevel_full_optimization", Integer.class); 562 563 public final int constantPoolSize = getFieldValue("CompilerToVM::Data::sizeof_ConstantPool", Integer.class, "int"); 564 public final int constantPoolLengthOffset = getFieldOffset("ConstantPool::_length", Integer.class, "int"); 565 566 public final int heapWordSize = getConstant("HeapWordSize", Integer.class); 567 568 /** 569 * Bit pattern that represents a non-oop. Neither the high bits nor the low bits of this value 570 * are allowed to look like (respectively) the high or low bits of a real oop. 571 */ 572 public final long nonOopBits = getFieldValue("CompilerToVM::Data::Universe_non_oop_bits", Long.class, "void*"); 573 574 public final long verifyOopCounterAddress = getFieldAddress("StubRoutines::_verify_oop_count", "jint"); 575 public final long verifyOopMask = getFieldValue("CompilerToVM::Data::Universe_verify_oop_mask", Long.class, "uintptr_t"); 576 public final long verifyOopBits = getFieldValue("CompilerToVM::Data::Universe_verify_oop_bits", Long.class, "uintptr_t"); 577 578 public final int logOfHRGrainBytes = getFieldValue("HeapRegion::LogOfHRGrainBytes", Integer.class, "int"); 579 580 public final int cardtableShift = getFieldValue("CompilerToVM::Data::cardtable_shift", Integer.class, "int"); 581 public final long cardtableStartAddress; 582 { 583 // JDK-8237497 584 if (JDK < 15) { 585 cardtableStartAddress = getFieldValue("CompilerToVM::Data::cardtable_start_address", Long.class, "jbyte*"); 586 } else { 587 cardtableStartAddress = getFieldValue("CompilerToVM::Data::cardtable_start_address", Long.class, "CardTable::CardValue*"); 588 } 589 } 590 591 /** 592 * This is the largest stack offset encodeable in an OopMapValue. Offsets larger than this will 593 * throw an exception during code installation. 594 */ 595 public final int maxOopMapStackOffset = getFieldValue("CompilerToVM::Data::_max_oop_map_stack_offset", Integer.class, "int"); 596 597 public final long safepointPollingAddress = getFieldValue("os::_polling_page", Long.class, "address"); 598 599 // G1 Collector Related Values. 600 public final byte dirtyCardValue; 601 public final byte g1YoungCardValue; 602 public final int g1SATBQueueMarkingOffset; 603 public final int g1SATBQueueIndexOffset; 604 public final int g1SATBQueueBufferOffset; 605 public final int g1CardQueueIndexOffset; 606 public final int g1CardQueueBufferOffset; 607 { 608 if (JDK <= 8) { 609 int dirtyCardQueueBufferOffset = getFieldOffset("PtrQueue::_buf", Integer.class, "void**"); 610 int dirtyCardQueueIndexOffset = getFieldOffset("PtrQueue::_index", Integer.class, "size_t"); 611 int satbMarkQueueBufferOffset = dirtyCardQueueBufferOffset; 612 int satbMarkQueueIndexOffset = dirtyCardQueueIndexOffset; 613 int satbMarkQueueActiveOffset = getFieldOffset("PtrQueue::_active", Integer.class, "bool"); 614 int javaThreadSatbMarkQueueOffset = getFieldOffset("JavaThread::_satb_mark_queue", Integer.class); 615 int javaThreadDirtyCardQueueOffset = getFieldOffset("JavaThread::_dirty_card_queue", Integer.class, "DirtyCardQueue"); 616 617 dirtyCardValue = getFieldValue("CompilerToVM::Data::dirty_card", Byte.class, "int"); 618 g1YoungCardValue = getFieldValue("CompilerToVM::Data::g1_young_card", Byte.class, "int"); 619 g1CardQueueIndexOffset = javaThreadDirtyCardQueueOffset + dirtyCardQueueIndexOffset; 620 g1CardQueueBufferOffset = javaThreadDirtyCardQueueOffset + dirtyCardQueueBufferOffset; 621 g1SATBQueueMarkingOffset = javaThreadSatbMarkQueueOffset + satbMarkQueueActiveOffset; 622 g1SATBQueueIndexOffset = javaThreadSatbMarkQueueOffset + satbMarkQueueIndexOffset; 623 g1SATBQueueBufferOffset = javaThreadSatbMarkQueueOffset + satbMarkQueueBufferOffset; 624 } else { 625 dirtyCardValue = getConstant("CardTable::dirty_card", Byte.class); 626 g1YoungCardValue = getConstant("G1CardTable::g1_young_gen", Byte.class); 627 g1SATBQueueMarkingOffset = getConstant("G1ThreadLocalData::satb_mark_queue_active_offset", Integer.class); 628 g1SATBQueueIndexOffset = getConstant("G1ThreadLocalData::satb_mark_queue_index_offset", Integer.class); 629 g1SATBQueueBufferOffset = getConstant("G1ThreadLocalData::satb_mark_queue_buffer_offset", Integer.class); 630 g1CardQueueIndexOffset = getConstant("G1ThreadLocalData::dirty_card_queue_index_offset", Integer.class); 631 g1CardQueueBufferOffset = getConstant("G1ThreadLocalData::dirty_card_queue_buffer_offset", Integer.class); 632 } 633 } 634 635 public final int klassOffset = getFieldValue("java_lang_Class::_klass_offset", Integer.class, "int"); 636 public final int arrayKlassOffset = getFieldValue("java_lang_Class::_array_klass_offset", Integer.class, "int"); 637 638 public final int basicLockSize = getFieldValue("CompilerToVM::Data::sizeof_BasicLock", Integer.class, "int"); 639 public final int basicLockDisplacedHeaderOffset = getFieldOffset("BasicLock::_displaced_header", Integer.class, markWord); 640 641 public final int threadAllocatedBytesOffset = getFieldOffset("Thread::_allocated_bytes", Integer.class, "jlong"); 642 public final int threadPollingPageOffset; 643 { 644 // JDK-8237497 645 if (JDK < 15) { 646 threadPollingPageOffset = getFieldOffset("Thread::_polling_page", Integer.class, "address", -1, JDK >= 10); 647 } else { 648 threadPollingPageOffset = getFieldOffset("Thread::_polling_page", Integer.class, "volatile void*"); 649 } 650 } 651 652 public final int tlabRefillWasteIncrement = getFlag("TLABWasteIncrement", Integer.class); 653 654 private final int threadLocalAllocBufferStartOffset = getFieldOffset("ThreadLocalAllocBuffer::_start", Integer.class, "HeapWord*"); 655 private final int threadLocalAllocBufferEndOffset = getFieldOffset("ThreadLocalAllocBuffer::_end", Integer.class, "HeapWord*"); 656 private final int threadLocalAllocBufferTopOffset = getFieldOffset("ThreadLocalAllocBuffer::_top", Integer.class, "HeapWord*"); 657 private final int threadLocalAllocBufferPfTopOffset = getFieldOffset("ThreadLocalAllocBuffer::_pf_top", Integer.class, "HeapWord*"); 658 private final int threadLocalAllocBufferSlowAllocationsOffset = getFieldOffset("ThreadLocalAllocBuffer::_slow_allocations", Integer.class, "unsigned"); 659 private final int threadLocalAllocBufferFastRefillWasteOffset = getFieldOffset("ThreadLocalAllocBuffer::_fast_refill_waste", Integer.class, "unsigned"); 660 private final int threadLocalAllocBufferNumberOfRefillsOffset = getFieldOffset("ThreadLocalAllocBuffer::_number_of_refills", Integer.class, "unsigned"); 661 private final int threadLocalAllocBufferRefillWasteLimitOffset = getFieldOffset("ThreadLocalAllocBuffer::_refill_waste_limit", Integer.class, "size_t"); 662 private final int threadLocalAllocBufferDesiredSizeOffset = getFieldOffset("ThreadLocalAllocBuffer::_desired_size", Integer.class, "size_t"); 663 tlabSlowAllocationsOffset()664 public int tlabSlowAllocationsOffset() { 665 return threadTlabOffset + threadLocalAllocBufferSlowAllocationsOffset; 666 } 667 tlabFastRefillWasteOffset()668 public int tlabFastRefillWasteOffset() { 669 return threadTlabOffset + threadLocalAllocBufferFastRefillWasteOffset; 670 } 671 tlabNumberOfRefillsOffset()672 public int tlabNumberOfRefillsOffset() { 673 return threadTlabOffset + threadLocalAllocBufferNumberOfRefillsOffset; 674 } 675 tlabRefillWasteLimitOffset()676 public int tlabRefillWasteLimitOffset() { 677 return threadTlabOffset + threadLocalAllocBufferRefillWasteLimitOffset; 678 } 679 threadTlabSizeOffset()680 public int threadTlabSizeOffset() { 681 return threadTlabOffset + threadLocalAllocBufferDesiredSizeOffset; 682 } 683 threadTlabStartOffset()684 public int threadTlabStartOffset() { 685 return threadTlabOffset + threadLocalAllocBufferStartOffset; 686 } 687 threadTlabEndOffset()688 public int threadTlabEndOffset() { 689 return threadTlabOffset + threadLocalAllocBufferEndOffset; 690 } 691 threadTlabTopOffset()692 public int threadTlabTopOffset() { 693 return threadTlabOffset + threadLocalAllocBufferTopOffset; 694 } 695 threadTlabPfTopOffset()696 public int threadTlabPfTopOffset() { 697 return threadTlabOffset + threadLocalAllocBufferPfTopOffset; 698 } 699 700 public final int tlabAlignmentReserve = getFieldValue("CompilerToVM::Data::ThreadLocalAllocBuffer_alignment_reserve", Integer.class, "size_t"); 701 702 public final boolean tlabStats = getFlag("TLABStats", Boolean.class); 703 704 // We set 0x10 as default value to disable DC ZVA if this field is not present in HotSpot. 705 // ARMv8-A architecture reference manual D12.2.35 Data Cache Zero ID register says: 706 // * BS, bits [3:0] indicate log2 of the DC ZVA block size in (4-byte) words. 707 // * DZP, bit [4] of indicates whether use of DC ZVA instruction is prohibited. 708 public final int psrInfoDczidValue = getFieldValue("VM_Version::_psr_info.dczid_el0", Integer.class, "uint32_t", 0x10, (JVMCI ? jvmciGE(JVMCI_19_3_b04) : JDK >= 14) && osArch.equals("aarch64")); 709 710 // FIXME This is only temporary until the GC code is changed. 711 public final boolean inlineContiguousAllocationSupported = getFieldValue("CompilerToVM::Data::_supports_inline_contig_alloc", Boolean.class); 712 public final long heapEndAddress = getFieldValue("CompilerToVM::Data::_heap_end_addr", Long.class, "HeapWord**"); 713 public final long heapTopAddress = getFieldValue("CompilerToVM::Data::_heap_top_addr", Long.class, JDK <= 8 ? "HeapWord**" : "HeapWord* volatile*"); 714 715 public final boolean cmsIncrementalMode = getFlag("CMSIncrementalMode", Boolean.class, false, JDK <= 8); 716 717 public final long inlineCacheMissStub = getFieldValue("CompilerToVM::Data::SharedRuntime_ic_miss_stub", Long.class, "address"); 718 public final long handleWrongMethodStub = getFieldValue("CompilerToVM::Data::SharedRuntime_handle_wrong_method_stub", Long.class, "address"); 719 720 public final long deoptBlobUnpack = getFieldValue("CompilerToVM::Data::SharedRuntime_deopt_blob_unpack", Long.class, "address"); 721 public final long deoptBlobUnpackWithExceptionInTLS = getFieldValue("CompilerToVM::Data::SharedRuntime_deopt_blob_unpack_with_exception_in_tls", Long.class, "address", 0L, 722 JVMCI ? jvmciGE(JVMCI_19_3_b07) : JDK >= 14); 723 public final long deoptBlobUncommonTrap = getFieldValue("CompilerToVM::Data::SharedRuntime_deopt_blob_uncommon_trap", Long.class, "address"); 724 725 public final long codeCacheLowBound = getFieldValue(JDK == 8 ? "CompilerToVM::Data::CodeCache_low_bound" : "CodeCache::_low_bound", Long.class, "address"); 726 public final long codeCacheHighBound = getFieldValue(JDK == 8 ? "CompilerToVM::Data::CodeCache_high_bound" : "CodeCache::_high_bound", Long.class, "address"); 727 728 public final long aescryptEncryptBlockStub = getFieldValue("StubRoutines::_aescrypt_encryptBlock", Long.class, "address"); 729 public final long aescryptDecryptBlockStub = getFieldValue("StubRoutines::_aescrypt_decryptBlock", Long.class, "address"); 730 public final long cipherBlockChainingEncryptAESCryptStub = getFieldValue("StubRoutines::_cipherBlockChaining_encryptAESCrypt", Long.class, "address"); 731 public final long cipherBlockChainingDecryptAESCryptStub = getFieldValue("StubRoutines::_cipherBlockChaining_decryptAESCrypt", Long.class, "address"); 732 public final long updateBytesCRC32Stub = getFieldValue("StubRoutines::_updateBytesCRC32", Long.class, "address"); 733 public final long crcTableAddress = getFieldValue("StubRoutines::_crc_table_adr", Long.class, "address"); 734 735 public final long sha1ImplCompress = getFieldValue("StubRoutines::_sha1_implCompress", Long.class, "address"); 736 public final long sha1ImplCompressMultiBlock = getFieldValue("StubRoutines::_sha1_implCompressMB", Long.class, "address"); 737 public final long sha256ImplCompress = getFieldValue("StubRoutines::_sha256_implCompress", Long.class, "address"); 738 public final long sha256ImplCompressMultiBlock = getFieldValue("StubRoutines::_sha256_implCompressMB", Long.class, "address"); 739 public final long sha512ImplCompress = getFieldValue("StubRoutines::_sha512_implCompress", Long.class, "address"); 740 public final long sha512ImplCompressMultiBlock = getFieldValue("StubRoutines::_sha512_implCompressMB", Long.class, "address"); 741 public final long multiplyToLen = getFieldValue("StubRoutines::_multiplyToLen", Long.class, "address"); 742 743 public final long counterModeAESCrypt = getFieldValue("StubRoutines::_counterMode_AESCrypt", Long.class, "address", 0L, (JDK == 8 && !IS_OPENJDK) || JDK >= 9); 744 public final long ghashProcessBlocks = getFieldValue("StubRoutines::_ghash_processBlocks", Long.class, "address", 0L, isJDK8OrJDK11Plus); 745 public final long base64EncodeBlock = getFieldValue("StubRoutines::_base64_encodeBlock", Long.class, "address", 0L, isJDK11Plus); 746 public final long crc32cTableTddr = getFieldValue("StubRoutines::_crc32c_table_addr", Long.class, "address", 0L, isJDK11Plus); 747 public final long updateBytesCRC32C = getFieldValue("StubRoutines::_updateBytesCRC32C", Long.class, "address", 0L, isJDK11Plus); 748 public final long updateBytesAdler32 = getFieldValue("StubRoutines::_updateBytesAdler32", Long.class, "address", 0L, isJDK11Plus); 749 public final long squareToLen = getFieldValue("StubRoutines::_squareToLen", Long.class, "address"); 750 public final long mulAdd = getFieldValue("StubRoutines::_mulAdd", Long.class, "address"); 751 public final long montgomeryMultiply = getFieldValue("StubRoutines::_montgomeryMultiply", Long.class, "address"); 752 public final long montgomerySquare = getFieldValue("StubRoutines::_montgomerySquare", Long.class, "address"); 753 public final long vectorizedMismatch = getFieldValue("StubRoutines::_vectorizedMismatch", Long.class, "address", 0L, isJDK11Plus); 754 755 public final long throwDelayedStackOverflowErrorEntry = JDK <= 8 ? 0 : getFieldValue("StubRoutines::_throw_delayed_StackOverflowError_entry", Long.class, "address"); 756 757 public final long jbyteArraycopy = getFieldValue("StubRoutines::_jbyte_arraycopy", Long.class, "address"); 758 public final long jshortArraycopy = getFieldValue("StubRoutines::_jshort_arraycopy", Long.class, "address"); 759 public final long jintArraycopy = getFieldValue("StubRoutines::_jint_arraycopy", Long.class, "address"); 760 public final long jlongArraycopy = getFieldValue("StubRoutines::_jlong_arraycopy", Long.class, "address"); 761 public final long oopArraycopy = getFieldValue("StubRoutines::_oop_arraycopy", Long.class, "address"); 762 public final long oopArraycopyUninit = getFieldValue("StubRoutines::_oop_arraycopy_uninit", Long.class, "address"); 763 public final long jbyteDisjointArraycopy = getFieldValue("StubRoutines::_jbyte_disjoint_arraycopy", Long.class, "address"); 764 public final long jshortDisjointArraycopy = getFieldValue("StubRoutines::_jshort_disjoint_arraycopy", Long.class, "address"); 765 public final long jintDisjointArraycopy = getFieldValue("StubRoutines::_jint_disjoint_arraycopy", Long.class, "address"); 766 public final long jlongDisjointArraycopy = getFieldValue("StubRoutines::_jlong_disjoint_arraycopy", Long.class, "address"); 767 public final long oopDisjointArraycopy = getFieldValue("StubRoutines::_oop_disjoint_arraycopy", Long.class, "address"); 768 public final long oopDisjointArraycopyUninit = getFieldValue("StubRoutines::_oop_disjoint_arraycopy_uninit", Long.class, "address"); 769 public final long jbyteAlignedArraycopy = getFieldValue("StubRoutines::_arrayof_jbyte_arraycopy", Long.class, "address"); 770 public final long jshortAlignedArraycopy = getFieldValue("StubRoutines::_arrayof_jshort_arraycopy", Long.class, "address"); 771 public final long jintAlignedArraycopy = getFieldValue("StubRoutines::_arrayof_jint_arraycopy", Long.class, "address"); 772 public final long jlongAlignedArraycopy = getFieldValue("StubRoutines::_arrayof_jlong_arraycopy", Long.class, "address"); 773 public final long oopAlignedArraycopy = getFieldValue("StubRoutines::_arrayof_oop_arraycopy", Long.class, "address"); 774 public final long oopAlignedArraycopyUninit = getFieldValue("StubRoutines::_arrayof_oop_arraycopy_uninit", Long.class, "address"); 775 public final long jbyteAlignedDisjointArraycopy = getFieldValue("StubRoutines::_arrayof_jbyte_disjoint_arraycopy", Long.class, "address"); 776 public final long jshortAlignedDisjointArraycopy = getFieldValue("StubRoutines::_arrayof_jshort_disjoint_arraycopy", Long.class, "address"); 777 public final long jintAlignedDisjointArraycopy = getFieldValue("StubRoutines::_arrayof_jint_disjoint_arraycopy", Long.class, "address"); 778 public final long jlongAlignedDisjointArraycopy = getFieldValue("StubRoutines::_arrayof_jlong_disjoint_arraycopy", Long.class, "address"); 779 public final long oopAlignedDisjointArraycopy = getFieldValue("StubRoutines::_arrayof_oop_disjoint_arraycopy", Long.class, "address"); 780 public final long oopAlignedDisjointArraycopyUninit = getFieldValue("StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit", Long.class, "address"); 781 public final long checkcastArraycopy = getFieldValue("StubRoutines::_checkcast_arraycopy", Long.class, "address"); 782 public final long checkcastArraycopyUninit = getFieldValue("StubRoutines::_checkcast_arraycopy_uninit", Long.class, "address"); 783 public final long unsafeArraycopy = getFieldValue("StubRoutines::_unsafe_arraycopy", Long.class, "address"); 784 public final long genericArraycopy = getFieldValue("StubRoutines::_generic_arraycopy", Long.class, "address"); 785 786 // Allocation stubs that throw an exception when allocation fails 787 public final long newInstanceAddress = getAddress("JVMCIRuntime::new_instance"); 788 public final long newArrayAddress = getAddress("JVMCIRuntime::new_array"); 789 public final long newMultiArrayAddress = getAddress("JVMCIRuntime::new_multi_array"); 790 public final long dynamicNewInstanceAddress = getAddress("JVMCIRuntime::dynamic_new_instance"); 791 792 // Allocation stubs that return null when allocation fails 793 public final long newInstanceOrNullAddress = getAddress("JVMCIRuntime::new_instance_or_null", 0L, JVMCI || JDK >= 12 || (!IS_OPENJDK && JDK == 11 && JDK_UPDATE >= 7)); 794 public final long newArrayOrNullAddress = getAddress("JVMCIRuntime::new_array_or_null", 0L, JVMCI || JDK >= 12 || (!IS_OPENJDK && JDK == 11 && JDK_UPDATE >= 7)); 795 public final long newMultiArrayOrNullAddress = getAddress("JVMCIRuntime::new_multi_array_or_null", 0L, JVMCI || JDK >= 12 || (!IS_OPENJDK && JDK == 11 && JDK_UPDATE >= 7)); 796 public final long dynamicNewInstanceOrNullAddress = getAddress("JVMCIRuntime::dynamic_new_instance_or_null", 0L, JVMCI || JDK >= 12 || (!IS_OPENJDK && JDK == 11 && JDK_UPDATE >= 7)); 797 areNullAllocationStubsAvailable()798 public boolean areNullAllocationStubsAvailable() { 799 return newInstanceOrNullAddress != 0L; 800 } 801 802 /** 803 * Checks that HotSpot implements all or none of the allocate-or-null stubs. 804 */ checkNullAllocationStubs()805 private boolean checkNullAllocationStubs() { 806 if (newInstanceOrNullAddress == 0L) { 807 assert newArrayOrNullAddress == 0L; 808 assert newMultiArrayOrNullAddress == 0L; 809 assert dynamicNewInstanceOrNullAddress == 0L; 810 } else { 811 assert newArrayOrNullAddress != 0L; 812 assert newMultiArrayOrNullAddress != 0L; 813 assert dynamicNewInstanceOrNullAddress != 0L; 814 } 815 return true; 816 } 817 818 public final long vmMessageAddress = getAddress("JVMCIRuntime::vm_message"); 819 public final long identityHashCodeAddress = getAddress("JVMCIRuntime::identity_hash_code"); 820 public final long exceptionHandlerForPcAddress = getAddress("JVMCIRuntime::exception_handler_for_pc"); 821 public final long monitorenterAddress = getAddress("JVMCIRuntime::monitorenter"); 822 public final long monitorexitAddress = getAddress("JVMCIRuntime::monitorexit"); 823 public final long notifyAddress = getAddress("JVMCIRuntime::object_notify", 0L, JDK >= 11); 824 public final long notifyAllAddress = getAddress("JVMCIRuntime::object_notifyAll", 0L, JDK >= 11); 825 public final long throwAndPostJvmtiExceptionAddress = getAddress("JVMCIRuntime::throw_and_post_jvmti_exception"); 826 public final long throwKlassExternalNameExceptionAddress = getAddress("JVMCIRuntime::throw_klass_external_name_exception"); 827 public final long throwClassCastExceptionAddress = getAddress("JVMCIRuntime::throw_class_cast_exception"); 828 public final long logPrimitiveAddress = getAddress("JVMCIRuntime::log_primitive"); 829 public final long logObjectAddress = getAddress("JVMCIRuntime::log_object"); 830 public final long logPrintfAddress = getAddress("JVMCIRuntime::log_printf"); 831 public final long vmErrorAddress = getAddress("JVMCIRuntime::vm_error"); 832 public final long loadAndClearExceptionAddress = getAddress("JVMCIRuntime::load_and_clear_exception"); 833 public final long writeBarrierPreAddress = getAddress("JVMCIRuntime::write_barrier_pre"); 834 public final long writeBarrierPostAddress = getAddress("JVMCIRuntime::write_barrier_post"); 835 public final long validateObject = getAddress("JVMCIRuntime::validate_object"); 836 837 public final long testDeoptimizeCallInt = getAddress("JVMCIRuntime::test_deoptimize_call_int"); 838 839 public final long registerFinalizerAddress = getAddress("SharedRuntime::register_finalizer"); 840 public final long exceptionHandlerForReturnAddressAddress = getAddress("SharedRuntime::exception_handler_for_return_address"); 841 public final long osrMigrationEndAddress = getAddress("SharedRuntime::OSR_migration_end"); 842 public final long enableStackReservedZoneAddress = JDK <= 8 ? 0 : getAddress("SharedRuntime::enable_stack_reserved_zone"); 843 844 public final long javaTimeMillisAddress = getAddress("os::javaTimeMillis"); 845 public final long javaTimeNanosAddress = getAddress("os::javaTimeNanos"); 846 public final long arithmeticSinAddress = getFieldValue("CompilerToVM::Data::dsin", Long.class, "address"); 847 public final long arithmeticCosAddress = getFieldValue("CompilerToVM::Data::dcos", Long.class, "address"); 848 public final long arithmeticTanAddress = getFieldValue("CompilerToVM::Data::dtan", Long.class, "address"); 849 public final long arithmeticExpAddress = getFieldValue("CompilerToVM::Data::dexp", Long.class, "address"); 850 public final long arithmeticLogAddress = getFieldValue("CompilerToVM::Data::dlog", Long.class, "address"); 851 public final long arithmeticLog10Address = getFieldValue("CompilerToVM::Data::dlog10", Long.class, "address"); 852 public final long arithmeticPowAddress = getFieldValue("CompilerToVM::Data::dpow", Long.class, "address"); 853 854 public final long fremAddress = getAddress("SharedRuntime::frem"); 855 public final long dremAddress = getAddress("SharedRuntime::drem"); 856 857 public final int jvmciCountersSize = getFlag("JVMCICounterSize", Integer.class); 858 859 public final long deoptimizationFetchUnrollInfo = getAddress("Deoptimization::fetch_unroll_info"); 860 public final long deoptimizationUncommonTrap = getAddress("Deoptimization::uncommon_trap"); 861 public final long deoptimizationUnpackFrames = getAddress("Deoptimization::unpack_frames"); 862 863 public final int deoptimizationUnpackDeopt = getConstant("Deoptimization::Unpack_deopt", Integer.class); 864 public final int deoptimizationUnpackException = getConstant("Deoptimization::Unpack_exception", Integer.class); 865 public final int deoptimizationUnpackUncommonTrap = getConstant("Deoptimization::Unpack_uncommon_trap", Integer.class); 866 public final int deoptimizationUnpackReexecute = getConstant("Deoptimization::Unpack_reexecute", Integer.class); 867 868 public final int deoptimizationUnrollBlockSizeOfDeoptimizedFrameOffset = getFieldOffset("Deoptimization::UnrollBlock::_size_of_deoptimized_frame", Integer.class, "int"); 869 public final int deoptimizationUnrollBlockCallerAdjustmentOffset = getFieldOffset("Deoptimization::UnrollBlock::_caller_adjustment", Integer.class, "int"); 870 public final int deoptimizationUnrollBlockNumberOfFramesOffset = getFieldOffset("Deoptimization::UnrollBlock::_number_of_frames", Integer.class, "int"); 871 public final int deoptimizationUnrollBlockTotalFrameSizesOffset = getFieldOffset("Deoptimization::UnrollBlock::_total_frame_sizes", Integer.class, "int"); 872 public final int deoptimizationUnrollBlockUnpackKindOffset = getFieldOffset("Deoptimization::UnrollBlock::_unpack_kind", Integer.class, "int"); 873 public final int deoptimizationUnrollBlockFrameSizesOffset = getFieldOffset("Deoptimization::UnrollBlock::_frame_sizes", Integer.class, "intptr_t*"); 874 public final int deoptimizationUnrollBlockFramePcsOffset = getFieldOffset("Deoptimization::UnrollBlock::_frame_pcs", Integer.class, "address*"); 875 public final int deoptimizationUnrollBlockInitialInfoOffset = getFieldOffset("Deoptimization::UnrollBlock::_initial_info", Integer.class, "intptr_t"); 876 877 // JDK-8231756, GR-16685 878 public final boolean deoptimizationSupportLargeAccessByteArrayVirtualization = // 879 getConstant("Deoptimization::_support_large_access_byte_array_virtualization", Boolean.class, false, JVMCI || JDK >= 15); 880 881 private static final boolean JDK_8245443 = ((JDK == 11 && JDK_UPDATE >= 8) || JDK >= 15); 882 883 // Checkstyle: stop 884 public final int VERIFIED_ENTRY = getConstant("CodeInstaller::VERIFIED_ENTRY", Integer.class); 885 public final int UNVERIFIED_ENTRY = getConstant("CodeInstaller::UNVERIFIED_ENTRY", Integer.class); 886 public final int OSR_ENTRY = getConstant("CodeInstaller::OSR_ENTRY", Integer.class); 887 public final int EXCEPTION_HANDLER_ENTRY = getConstant("CodeInstaller::EXCEPTION_HANDLER_ENTRY", Integer.class); 888 public final int DEOPT_HANDLER_ENTRY = getConstant("CodeInstaller::DEOPT_HANDLER_ENTRY", Integer.class); 889 public final int FRAME_COMPLETE = getConstant("CodeInstaller::FRAME_COMPLETE", Integer.class, -1, (JVMCI ? jvmciGE(JVMCI_20_1_b01) : JDK_8245443)); 890 public final int INVOKEINTERFACE = getConstant("CodeInstaller::INVOKEINTERFACE", Integer.class); 891 public final int INVOKEVIRTUAL = getConstant("CodeInstaller::INVOKEVIRTUAL", Integer.class); 892 public final int INVOKESTATIC = getConstant("CodeInstaller::INVOKESTATIC", Integer.class); 893 public final int INVOKESPECIAL = getConstant("CodeInstaller::INVOKESPECIAL", Integer.class); 894 public final int INLINE_INVOKE = getConstant("CodeInstaller::INLINE_INVOKE", Integer.class); 895 public final int POLL_NEAR = getConstant("CodeInstaller::POLL_NEAR", Integer.class); 896 public final int POLL_RETURN_NEAR = getConstant("CodeInstaller::POLL_RETURN_NEAR", Integer.class); 897 public final int POLL_FAR = getConstant("CodeInstaller::POLL_FAR", Integer.class); 898 public final int POLL_RETURN_FAR = getConstant("CodeInstaller::POLL_RETURN_FAR", Integer.class); 899 public final int CARD_TABLE_SHIFT = getConstant("CodeInstaller::CARD_TABLE_SHIFT", Integer.class); 900 public final int CARD_TABLE_ADDRESS = getConstant("CodeInstaller::CARD_TABLE_ADDRESS", Integer.class); 901 public final int INVOKE_INVALID = getConstant("CodeInstaller::INVOKE_INVALID", Integer.class); 902 903 public final boolean CPU_HAS_INTEL_JCC_ERRATUM = getFieldValue("VM_Version::_has_intel_jcc_erratum", Boolean.class, "bool", 904 true, "amd64".equals(osArch) && (JVMCI ? jvmciGE(JVMCI_20_1_b01) : JDK >= 15)); 905 906 /** 907 * The following constants are given default values here since they are missing in the native 908 * JVMCI-8 code but are still required for {@link HotSpotMarkId} to work in a JDK8 environment. 909 */ 910 public final int NARROW_KLASS_BASE_ADDRESS = getConstant("CodeInstaller::NARROW_KLASS_BASE_ADDRESS", Integer.class, 19, JDK > 9); 911 public final int NARROW_OOP_BASE_ADDRESS = getConstant("CodeInstaller::NARROW_OOP_BASE_ADDRESS", Integer.class, 20, JDK > 9); 912 public final int CRC_TABLE_ADDRESS = getConstant("CodeInstaller::CRC_TABLE_ADDRESS", Integer.class, 21, JDK > 9); 913 public final int LOG_OF_HEAP_REGION_GRAIN_BYTES = getConstant("CodeInstaller::LOG_OF_HEAP_REGION_GRAIN_BYTES", Integer.class, 22, JDK > 9); 914 915 // Checkstyle: resume 916 check()917 protected boolean check() { 918 for (Field f : getClass().getDeclaredFields()) { 919 int modifiers = f.getModifiers(); 920 if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers)) { 921 assert Modifier.isFinal(modifiers) : "field should be final: " + f; 922 } 923 } 924 925 assert codeEntryAlignment > 0 : codeEntryAlignment; 926 assert checkNullAllocationStubs(); 927 return true; 928 } 929 } 930