src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java
Index Unified diffs Context diffs Sdiffs Frames Patch New Old Previous File Next File open Sdiff src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot

src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java

Print this page


   1 /*
   2  * Copyright (c) 2011, 2018, 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 jdk.vm.ci.hotspot;
  24 
  25 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
  26 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
  27 

  28 import jdk.internal.misc.Unsafe;
  29 
  30 /**
  31  * Used to access native configuration details.
  32  *
  33  * All non-static, public fields in this class are so that they can be compiled as constants.
  34  */
  35 class HotSpotVMConfig extends HotSpotVMConfigAccess {
  36 
  37     /**
  38      * Gets the configuration associated with the singleton {@link HotSpotJVMCIRuntime}.
  39      */
  40     static HotSpotVMConfig config() {
  41         return runtime().getConfig();
  42     }
  43 
  44     private final String osArch = getHostArchitectureName();
  45 
  46     HotSpotVMConfig(HotSpotVMConfigStore store) {
  47         super(store);
  48     }
  49 
  50     /**
  51      * Gets the host architecture name for the purpose of finding the corresponding
  52      * {@linkplain HotSpotJVMCIBackendFactory backend}.
  53      */
  54     String getHostArchitectureName() {
  55         String arch = System.getProperty("os.arch");
  56         switch (arch) {
  57             case "x86_64":
  58                 return "amd64";
  59 
  60             case "sparcv9":
  61                 return "sparc";
  62             default:
  63                 return arch;
  64         }
  65     }
  66 
  67     final boolean useDeferredInitBarriers = getFlag("ReduceInitialCardMarks", Boolean.class);
  68 
  69     final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class);
  70 
  71     final int objectAlignment = getFlag("ObjectAlignmentInBytes", Integer.class);
  72 


  73     final int prototypeMarkWordOffset = getFieldOffset("Klass::_prototype_header", Integer.class, "markOop");
  74     final int subklassOffset = getFieldOffset("Klass::_subklass", Integer.class, "Klass*");

  75     final int nextSiblingOffset = getFieldOffset("Klass::_next_sibling", Integer.class, "Klass*");
  76     final int superCheckOffsetOffset = getFieldOffset("Klass::_super_check_offset", Integer.class, "juint");
  77     final int secondarySuperCacheOffset = getFieldOffset("Klass::_secondary_super_cache", Integer.class, "Klass*");
  78 


  79     /**
  80      * The offset of the _java_mirror field (of type {@link Class}) in a Klass.
  81      */
  82     final int classMirrorHandleOffset = getFieldOffset("Klass::_java_mirror", Integer.class, "OopHandle");
  83 
  84     final int klassAccessFlagsOffset = getFieldOffset("Klass::_access_flags", Integer.class, "AccessFlags");
  85     final int klassLayoutHelperOffset = getFieldOffset("Klass::_layout_helper", Integer.class, "jint");
  86 
  87     final int klassLayoutHelperNeutralValue = getConstant("Klass::_lh_neutral_value", Integer.class);
  88     final int klassLayoutHelperInstanceSlowPathBit = getConstant("Klass::_lh_instance_slow_path_bit", Integer.class);
  89 
  90     final int vtableEntrySize = getFieldValue("CompilerToVM::Data::sizeof_vtableEntry", Integer.class, "int");
  91     final int vtableEntryMethodOffset = getFieldOffset("vtableEntry::_method", Integer.class, "Method*");
  92 
  93     final int instanceKlassSourceFileNameIndexOffset = getFieldOffset("InstanceKlass::_source_file_name_index", Integer.class, "u2");
  94     final int instanceKlassInitStateOffset = getFieldOffset("InstanceKlass::_init_state", Integer.class, "u1");
  95     final int instanceKlassConstantsOffset = getFieldOffset("InstanceKlass::_constants", Integer.class, "ConstantPool*");
  96     final int instanceKlassFieldsOffset = getFieldOffset("InstanceKlass::_fields", Integer.class, "Array<u2>*");
  97     final int instanceKlassAnnotationsOffset = getFieldOffset("InstanceKlass::_annotations", Integer.class, "Annotations*");
  98     final int instanceKlassMiscFlagsOffset = getFieldOffset("InstanceKlass::_misc_flags", Integer.class, "u2");
  99     final int klassVtableStartOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_start_offset", Integer.class, "int");
 100     final int klassVtableLengthOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_length_offset", Integer.class, "int");
 101 
 102     final int instanceKlassStateLinked = getConstant("InstanceKlass::linked", Integer.class);


 114     final int fieldInfoNameIndexOffset = getConstant("FieldInfo::name_index_offset", Integer.class);
 115     final int fieldInfoSignatureIndexOffset = getConstant("FieldInfo::signature_index_offset", Integer.class);
 116     final int fieldInfoLowPackedOffset = getConstant("FieldInfo::low_packed_offset", Integer.class);
 117     final int fieldInfoHighPackedOffset = getConstant("FieldInfo::high_packed_offset", Integer.class);
 118     final int fieldInfoFieldSlots = getConstant("FieldInfo::field_slots", Integer.class);
 119 
 120     final int fieldInfoTagSize = getConstant("FIELDINFO_TAG_SIZE", Integer.class);
 121 
 122     final int jvmAccHasFinalizer = getConstant("JVM_ACC_HAS_FINALIZER", Integer.class);
 123     final int jvmAccFieldInternal = getConstant("JVM_ACC_FIELD_INTERNAL", Integer.class);
 124     final int jvmAccFieldStable = getConstant("JVM_ACC_FIELD_STABLE", Integer.class);
 125     final int jvmAccFieldHasGenericSignature = getConstant("JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE", Integer.class);
 126     final int jvmAccIsCloneableFast = getConstant("JVM_ACC_IS_CLONEABLE_FAST", Integer.class);
 127 
 128     // These modifiers are not public in Modifier so we get them via vmStructs.
 129     final int jvmAccSynthetic = getConstant("JVM_ACC_SYNTHETIC", Integer.class);
 130     final int jvmAccAnnotation = getConstant("JVM_ACC_ANNOTATION", Integer.class);
 131     final int jvmAccBridge = getConstant("JVM_ACC_BRIDGE", Integer.class);
 132     final int jvmAccVarargs = getConstant("JVM_ACC_VARARGS", Integer.class);
 133     final int jvmAccEnum = getConstant("JVM_ACC_ENUM", Integer.class);

 134 
 135     // This is only valid on AMD64.
 136     final int runtimeCallStackSize = getConstant("frame::arg_reg_save_area_bytes", Integer.class, osArch.equals("amd64") ? null : 0);
 137 
 138     private final int markWordNoHashInPlace = getConstant("markOopDesc::no_hash_in_place", Integer.class);
 139     private final int markWordNoLockInPlace = getConstant("markOopDesc::no_lock_in_place", Integer.class);
 140 
 141     /**
 142      * See {@code markOopDesc::prototype()}.
 143      */
 144     long arrayPrototypeMarkWord() {
 145         return markWordNoHashInPlace | markWordNoLockInPlace;
 146     }
 147 
 148     final int methodAccessFlagsOffset = getFieldOffset("Method::_access_flags", Integer.class, "AccessFlags");
 149     final int methodConstMethodOffset = getFieldOffset("Method::_constMethod", Integer.class, "ConstMethod*");
 150     final int methodIntrinsicIdOffset = getFieldOffset("Method::_intrinsic_id", Integer.class, "u2");
 151     final int methodFlagsOffset = getFieldOffset("Method::_flags", Integer.class, "u2");
 152     final int methodVtableIndexOffset = getFieldOffset("Method::_vtable_index", Integer.class, "int");
 153 


   1 /*
   2  * Copyright (c) 2011, 2019, 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 jdk.vm.ci.hotspot;
  24 
  25 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
  26 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
  27 
  28 import jdk.vm.ci.services.Services;
  29 import jdk.internal.misc.Unsafe;
  30 
  31 /**
  32  * Used to access native configuration details.
  33  *
  34  * All non-static, public fields in this class are so that they can be compiled as constants.
  35  */
  36 class HotSpotVMConfig extends HotSpotVMConfigAccess {
  37 
  38     /**
  39      * Gets the configuration associated with the singleton {@link HotSpotJVMCIRuntime}.
  40      */
  41     static HotSpotVMConfig config() {
  42         return runtime().getConfig();
  43     }
  44 
  45     private final String osArch = getHostArchitectureName();
  46 
  47     HotSpotVMConfig(HotSpotVMConfigStore store) {
  48         super(store);
  49     }
  50 
  51     /**
  52      * Gets the host architecture name for the purpose of finding the corresponding
  53      * {@linkplain HotSpotJVMCIBackendFactory backend}.
  54      */
  55     String getHostArchitectureName() {
  56         String arch = Services.getSavedProperty("os.arch");
  57         switch (arch) {
  58             case "x86_64":
  59                 return "amd64";
  60 
  61             case "sparcv9":
  62                 return "sparc";
  63             default:
  64                 return arch;
  65         }
  66     }
  67 
  68     final boolean useDeferredInitBarriers = getFlag("ReduceInitialCardMarks", Boolean.class);
  69 
  70     final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class);
  71 
  72     final int objectAlignment = getFlag("ObjectAlignmentInBytes", Integer.class);
  73 
  74     final int hubOffset = getFieldOffset("oopDesc::_metadata._klass", Integer.class, "Klass*");
  75 
  76     final int prototypeMarkWordOffset = getFieldOffset("Klass::_prototype_header", Integer.class, "markOop");
  77     final int subklassOffset = getFieldOffset("Klass::_subklass", Integer.class, "Klass*");
  78     final int superOffset = getFieldOffset("Klass::_super", Integer.class, "Klass*");
  79     final int nextSiblingOffset = getFieldOffset("Klass::_next_sibling", Integer.class, "Klass*");
  80     final int superCheckOffsetOffset = getFieldOffset("Klass::_super_check_offset", Integer.class, "juint");
  81     final int secondarySuperCacheOffset = getFieldOffset("Klass::_secondary_super_cache", Integer.class, "Klass*");
  82 
  83     final int classLoaderDataOffset = getFieldOffset("Klass::_class_loader_data", Integer.class, "ClassLoaderData*");
  84 
  85     /**
  86      * The offset of the _java_mirror field (of type {@link Class}) in a Klass.
  87      */
  88     final int javaMirrorOffset = getFieldOffset("Klass::_java_mirror", Integer.class, "OopHandle");
  89 
  90     final int klassAccessFlagsOffset = getFieldOffset("Klass::_access_flags", Integer.class, "AccessFlags");
  91     final int klassLayoutHelperOffset = getFieldOffset("Klass::_layout_helper", Integer.class, "jint");
  92 
  93     final int klassLayoutHelperNeutralValue = getConstant("Klass::_lh_neutral_value", Integer.class);
  94     final int klassLayoutHelperInstanceSlowPathBit = getConstant("Klass::_lh_instance_slow_path_bit", Integer.class);
  95 
  96     final int vtableEntrySize = getFieldValue("CompilerToVM::Data::sizeof_vtableEntry", Integer.class, "int");
  97     final int vtableEntryMethodOffset = getFieldOffset("vtableEntry::_method", Integer.class, "Method*");
  98 
  99     final int instanceKlassSourceFileNameIndexOffset = getFieldOffset("InstanceKlass::_source_file_name_index", Integer.class, "u2");
 100     final int instanceKlassInitStateOffset = getFieldOffset("InstanceKlass::_init_state", Integer.class, "u1");
 101     final int instanceKlassConstantsOffset = getFieldOffset("InstanceKlass::_constants", Integer.class, "ConstantPool*");
 102     final int instanceKlassFieldsOffset = getFieldOffset("InstanceKlass::_fields", Integer.class, "Array<u2>*");
 103     final int instanceKlassAnnotationsOffset = getFieldOffset("InstanceKlass::_annotations", Integer.class, "Annotations*");
 104     final int instanceKlassMiscFlagsOffset = getFieldOffset("InstanceKlass::_misc_flags", Integer.class, "u2");
 105     final int klassVtableStartOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_start_offset", Integer.class, "int");
 106     final int klassVtableLengthOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_length_offset", Integer.class, "int");
 107 
 108     final int instanceKlassStateLinked = getConstant("InstanceKlass::linked", Integer.class);


 120     final int fieldInfoNameIndexOffset = getConstant("FieldInfo::name_index_offset", Integer.class);
 121     final int fieldInfoSignatureIndexOffset = getConstant("FieldInfo::signature_index_offset", Integer.class);
 122     final int fieldInfoLowPackedOffset = getConstant("FieldInfo::low_packed_offset", Integer.class);
 123     final int fieldInfoHighPackedOffset = getConstant("FieldInfo::high_packed_offset", Integer.class);
 124     final int fieldInfoFieldSlots = getConstant("FieldInfo::field_slots", Integer.class);
 125 
 126     final int fieldInfoTagSize = getConstant("FIELDINFO_TAG_SIZE", Integer.class);
 127 
 128     final int jvmAccHasFinalizer = getConstant("JVM_ACC_HAS_FINALIZER", Integer.class);
 129     final int jvmAccFieldInternal = getConstant("JVM_ACC_FIELD_INTERNAL", Integer.class);
 130     final int jvmAccFieldStable = getConstant("JVM_ACC_FIELD_STABLE", Integer.class);
 131     final int jvmAccFieldHasGenericSignature = getConstant("JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE", Integer.class);
 132     final int jvmAccIsCloneableFast = getConstant("JVM_ACC_IS_CLONEABLE_FAST", Integer.class);
 133 
 134     // These modifiers are not public in Modifier so we get them via vmStructs.
 135     final int jvmAccSynthetic = getConstant("JVM_ACC_SYNTHETIC", Integer.class);
 136     final int jvmAccAnnotation = getConstant("JVM_ACC_ANNOTATION", Integer.class);
 137     final int jvmAccBridge = getConstant("JVM_ACC_BRIDGE", Integer.class);
 138     final int jvmAccVarargs = getConstant("JVM_ACC_VARARGS", Integer.class);
 139     final int jvmAccEnum = getConstant("JVM_ACC_ENUM", Integer.class);
 140     final int jvmAccInterface = getConstant("JVM_ACC_INTERFACE", Integer.class);
 141 
 142     // This is only valid on AMD64.
 143     final int runtimeCallStackSize = getConstant("frame::arg_reg_save_area_bytes", Integer.class, osArch.equals("amd64") ? null : 0);
 144 
 145     private final int markWordNoHashInPlace = getConstant("markOopDesc::no_hash_in_place", Integer.class);
 146     private final int markWordNoLockInPlace = getConstant("markOopDesc::no_lock_in_place", Integer.class);
 147 
 148     /**
 149      * See {@code markOopDesc::prototype()}.
 150      */
 151     long arrayPrototypeMarkWord() {
 152         return markWordNoHashInPlace | markWordNoLockInPlace;
 153     }
 154 
 155     final int methodAccessFlagsOffset = getFieldOffset("Method::_access_flags", Integer.class, "AccessFlags");
 156     final int methodConstMethodOffset = getFieldOffset("Method::_constMethod", Integer.class, "ConstMethod*");
 157     final int methodIntrinsicIdOffset = getFieldOffset("Method::_intrinsic_id", Integer.class, "u2");
 158     final int methodFlagsOffset = getFieldOffset("Method::_flags", Integer.class, "u2");
 159     final int methodVtableIndexOffset = getFieldOffset("Method::_vtable_index", Integer.class, "int");
 160 


src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java
Index Unified diffs Context diffs Sdiffs Frames Patch New Old Previous File Next File