1 /*
   2  * Copyright (c) 2011, 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 package com.oracle.graal.hotspot;
  24 
  25 /**
  26  * Used to communicate configuration details, runtime offsets, etc. to Graal upon compileMethod.
  27  */
  28 public final class HotSpotVMConfig extends CompilerObject {
  29 
  30     private static final long serialVersionUID = -4744897993263044184L;
  31 
  32     HotSpotVMConfig() {
  33     }
  34 
  35     // os information, register layout, code generation, ...
  36     public boolean windowsOs;
  37     public int codeEntryAlignment;
  38     public boolean verifyOops;
  39     public boolean ciTime;
  40     public boolean useFastLocking;
  41     public boolean useTLAB;
  42     public boolean useBiasedLocking;
  43     public boolean usePopCountInstruction;
  44     public boolean useAESIntrinsics;
  45     public boolean useG1GC;
  46 
  47     // offsets, ...
  48     public int stackShadowPages;
  49 
  50     /**
  51      * The offset of the mark word in an object's header.
  52      */
  53     public int markOffset;
  54 
  55     /**
  56      * The offset of the hub (i.e. Klass*) in an object's header.
  57      */
  58     public int hubOffset;
  59 
  60     /**
  61      * The offset of the _prototype_header field in a Klass.
  62      */
  63     public int prototypeMarkWordOffset;
  64 
  65     /**
  66      * The offset of the _subklass field in a Klass.
  67      */
  68     public int subklassOffset;
  69 
  70     /**
  71      * The offset of the _next_sibling field in a Klass.
  72      */
  73     public int nextSiblingOffset;
  74 
  75     /**
  76      * The offset of the array length word in an array object's header.
  77      */
  78     public int arrayLengthOffset;
  79 
  80     /**
  81      * The offset of the _length field in an Array metaspace object (see array.hpp).
  82      */
  83     public int metaspaceArrayLengthOffset;
  84 
  85     /**
  86      * The offset of the _data field in an Array metaspace object (see array.hpp).
  87      */
  88     public int metaspaceArrayBaseOffset;
  89 
  90     /**
  91      * The offset of the _super_check_offset field in a Klass.
  92      */
  93     public int superCheckOffsetOffset;
  94 
  95     /**
  96      * The offset of the _secondary_super_cache field in a Klass.
  97      */
  98     public int secondarySuperCacheOffset;
  99 
 100     /**
 101      * The offset of the _secondary_supers field in a Klass.
 102      */
 103     public int secondarySupersOffset;
 104 
 105     /**
 106      * The offset of the _init_state field in an instanceKlass.
 107      */
 108     public int klassStateOffset;
 109 
 110     /**
 111      * The value of instanceKlass::fully_initialized.
 112      */
 113     public int klassStateFullyInitialized;
 114 
 115     /**
 116      * The value of objArrayKlass::element_klass_offset().
 117      */
 118     public int arrayClassElementOffset;
 119 
 120     /**
 121      * The value of JavaThread::tlab_top_offset().
 122      */
 123     public int threadTlabTopOffset;
 124 
 125     /**
 126      * The value of JavaThread::tlab_end_offset().
 127      */
 128     public int threadTlabEndOffset;
 129 
 130     public int threadObjectOffset;
 131 
 132     /**
 133      * The value of JavaThread::osthread_offset().
 134      */
 135     public int osThreadOffset;
 136 
 137     /**
 138      * The value of OSThread::interrupted_offset().
 139      */
 140     public int osThreadInterruptedOffset;
 141 
 142     /**
 143      * The value of markOopDesc::unlocked_value.
 144      */
 145     public int unlockedMask;
 146 
 147     /**
 148      * The value of markOopDesc::biased_lock_mask_in_place.
 149      */
 150     public int biasedLockMaskInPlace;
 151 
 152     /**
 153      * The value of markOopDesc::age_mask_in_place.
 154      */
 155     public int ageMaskInPlace;
 156 
 157     /**
 158      * The value of markOopDesc::epoch_mask_in_place.
 159      */
 160     public int epochMaskInPlace;
 161 
 162     /**
 163      * The value of markOopDesc::biased_lock_pattern.
 164      */
 165     public int biasedLockPattern;
 166 
 167     /**
 168      * Identity hash code value when uninitialized.
 169      */
 170     public int uninitializedIdentityHashCodeValue;
 171 
 172     /**
 173      * Offset of the pending deoptimization field.
 174      */
 175     public int pendingDeoptimizationOffset;
 176 
 177     /**
 178      * Mark word right shift to get identity hash code.
 179      */
 180     public int identityHashCodeShift;
 181 
 182     /**
 183      * Offset of _access_flags in a metaspace Method object.
 184      */
 185     public int methodAccessFlagsOffset;
 186 
 187     /**
 188      * Offset of _max_locals in a metaspace Method object.
 189      */
 190     public int methodMaxLocalsOffset;
 191 
 192     /**
 193      * Offset of _constMethod in a metaspace Method object.
 194      */
 195     public int methodConstMethodOffset;
 196 
 197     /**
 198      * Offset of _max_stack in a metaspace ConstMethod object.
 199      */
 200     public int constMethodMaxStackOffset;
 201 
 202     /**
 203      * Value of extra_stack_entries() in method.hpp.
 204      */
 205     public int extraStackEntries;
 206 
 207     /**
 208      * Value of JVM_ACC_HAS_FINALIZER in accessFlags.hpp.
 209      */
 210     public int klassHasFinalizerFlag;
 211 
 212     public int threadExceptionOopOffset;
 213     public int threadExceptionPcOffset;
 214     public long cardtableStartAddress;
 215     public int cardtableShift;
 216     public long safepointPollingAddress;
 217     public boolean isPollingPageFar;
 218 
 219     /**
 220      * G1 Collector Related Values.
 221      */
 222     public int g1CardQueueIndexOffset;
 223     public int g1CardQueueBufferOffset;
 224     public int logOfHRGrainBytes;
 225     public int g1SATBQueueMarkingOffset;
 226     public int g1SATBQueueIndexOffset;
 227     public int g1SATBQueueBufferOffset;
 228 
 229     /**
 230      * The offset of the _java_mirror field (of type {@link Class}) in a Klass.
 231      */
 232     public int classMirrorOffset;
 233 
 234     public int runtimeCallStackSize;
 235 
 236     /**
 237      * The offset of the _modifier_flags field in a Klass.
 238      */
 239     public int klassModifierFlagsOffset;
 240 
 241     /**
 242      * The offset of the _access_flags field in a Klass.
 243      */
 244     public int klassAccessFlagsOffset;
 245 
 246     /**
 247      * The offset of the _layout_helper field in a Klass.
 248      */
 249     public int klassLayoutHelperOffset;
 250 
 251     /**
 252      * Bit pattern in the klass layout helper that can be used to identify arrays.
 253      */
 254     public int arrayKlassLayoutHelperIdentifier;
 255 
 256     /**
 257      * The offset of the _componentMirror field in an ArrayKlass.
 258      */
 259     public int arrayKlassComponentMirrorOffset;
 260 
 261     /**
 262      * The offset of the _super field in a Klass.
 263      */
 264     public int klassSuperKlassOffset;
 265 
 266     /**
 267      * The offset of the injected klass field in a {@link Class}.
 268      */
 269     public int klassOffset;
 270 
 271     /**
 272      * The offset of the injected graal_mirror field in a {@link Class}.
 273      */
 274     public int graalMirrorInClassOffset;
 275 
 276     /**
 277      * The offset of the _method_data field in a metaspace Method.
 278      */
 279     public int methodDataOffset;
 280 
 281     public int nmethodEntryOffset;
 282     public int methodCompiledEntryOffset;
 283     public int basicLockSize;
 284     public int basicLockDisplacedHeaderOffset;
 285     public long tlabIntArrayMarkWord;
 286     public long heapEndAddress;
 287     public long heapTopAddress;
 288     public int threadTlabStartOffset;
 289     public int threadTlabSizeOffset;
 290     public int threadAllocatedBytesOffset;
 291     public int tlabRefillWasteLimitOffset;
 292     public int tlabRefillWasteIncrement;
 293     public int tlabAlignmentReserve;
 294     public int tlabSlowAllocationsOffset;
 295     public int tlabFastRefillWasteOffset;
 296     public int tlabNumberOfRefillsOffset;
 297     public boolean tlabStats;
 298     public int klassInstanceSizeOffset;
 299     public boolean inlineContiguousAllocationSupported;
 300     public long arrayPrototypeMarkWord;
 301     public int layoutHelperLog2ElementSizeShift;
 302     public int layoutHelperLog2ElementSizeMask;
 303     public int layoutHelperElementTypeShift;
 304     public int layoutHelperElementTypeMask;
 305     public int layoutHelperElementTypePrimitiveInPlace;
 306     public int layoutHelperHeaderSizeShift;
 307     public int layoutHelperHeaderSizeMask;
 308     public int layoutHelperOffset;
 309 
 310     // methodData information
 311     public int methodDataOopDataOffset;
 312     public int methodDataOopTrapHistoryOffset;
 313     public int dataLayoutHeaderSize;
 314     public int dataLayoutTagOffset;
 315     public int dataLayoutFlagsOffset;
 316     public int dataLayoutBCIOffset;
 317     public int dataLayoutCellsOffset;
 318     public int dataLayoutCellSize;
 319     public int bciProfileWidth;
 320     public int typeProfileWidth;
 321 
 322     // runtime stubs
 323     public long newInstanceStub;
 324     public long newArrayStub;
 325     public long newMultiArrayStub;
 326     public long inlineCacheMissStub;
 327     public long handleExceptionStub;
 328     public long handleDeoptStub;
 329     public long monitorEnterStub;
 330     public long monitorExitStub;
 331     public long wbPreCallStub;
 332     public long wbPostCallStub;
 333 
 334     public long verifyOopStub;
 335     public long vmErrorStub;
 336     public long deoptimizeStub;
 337     public long unwindExceptionStub;
 338     public long osrMigrationEndStub;
 339     public long registerFinalizerStub;
 340     public long createNullPointerExceptionStub;
 341     public long createOutOfBoundsExceptionStub;
 342     public long javaTimeMillisStub;
 343     public long javaTimeNanosStub;
 344     public long arithmeticFremStub;
 345     public long arithmeticDremStub;
 346     public long arithmeticSinStub;
 347     public long arithmeticCosStub;
 348     public long arithmeticTanStub;
 349     public long logPrimitiveStub;
 350     public long logObjectStub;
 351     public long logPrintfStub;
 352     public int deoptReasonNone;
 353     public long threadIsInterruptedStub;
 354     public long identityHashCodeStub;
 355     public long aescryptEncryptBlockStub;
 356     public long aescryptDecryptBlockStub;
 357     public long cipherBlockChainingEncryptAESCryptStub;
 358     public long cipherBlockChainingDecryptAESCryptStub;
 359 
 360     public int deoptReasonNullCheck;
 361     public int deoptReasonRangeCheck;
 362     public int deoptReasonClassCheck;
 363     public int deoptReasonArrayCheck;
 364     public int deoptReasonUnreached0;
 365     public int deoptReasonTypeCheckInlining;
 366     public int deoptReasonOptimizedTypeCheck;
 367     public int deoptReasonNotCompiledExceptionHandler;
 368     public int deoptReasonUnresolved;
 369     public int deoptReasonJsrMismatch;
 370     public int deoptReasonDiv0Check;
 371     public int deoptReasonConstraint;
 372 
 373     public int deoptActionNone;
 374     public int deoptActionMaybeRecompile;
 375     public int deoptActionReinterpret;
 376     public int deoptActionMakeNotEntrant;
 377     public int deoptActionMakeNotCompilable;
 378 
 379     public void check() {
 380         assert codeEntryAlignment > 0;
 381         assert stackShadowPages > 0;
 382     }
 383 }