1 /*
   2  * Copyright (c) 2011, 2016, 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 #ifndef SHARE_VM_JVMCI_JVMCIJAVACLASSES_HPP
  25 #define SHARE_VM_JVMCI_JVMCIJAVACLASSES_HPP
  26 
  27 #include "classfile/systemDictionary.hpp"
  28 #include "oops/instanceMirrorKlass.hpp"
  29 #include "oops/oop.inline.hpp"
  30 
  31 class JVMCIJavaClasses : AllStatic {
  32  public:
  33   static void compute_offsets(TRAPS);
  34 };
  35 
  36 /* This macro defines the structure of the JVMCI classes accessed from VM code.
  37  * It will generate classes with accessors similar to javaClasses.hpp, but with specializations for oops, Handles and jni handles.
  38  *
  39  * The public interface of these classes will look like this:
  40 
  41  * class StackSlot : AllStatic {
  42  * public:
  43  *   static Klass* klass();
  44  *   static jint  index(oop obj);
  45  *   static jint  index(Handle obj);
  46  *   static jint  index(jobject obj);
  47  *   static void set_index(oop obj, jint x);
  48  *   static void set_index(Handle obj, jint x);
  49  *   static void set_index(jobject obj, jint x);
  50  * };
  51  *
  52  */
  53 
  54 #define COMPILER_CLASSES_DO(start_class, end_class, char_field, int_field, boolean_field, long_field, float_field, oop_field, typeArrayOop_field, objArrayOop_field, static_oop_field, static_objArrayOop_field, static_int_field, static_boolean_field) \
  55   start_class(Architecture)                                                                                                                                    \
  56     oop_field(Architecture, wordKind, "Ljdk/vm/ci/meta/PlatformKind;")                                                                                         \
  57   end_class                                                                                                                                                    \
  58   start_class(TargetDescription)                                                                                                                               \
  59     oop_field(TargetDescription, arch, "Ljdk/vm/ci/code/Architecture;")                                                                                        \
  60   end_class                                                                                                                                                    \
  61   start_class(HotSpotResolvedObjectTypeImpl)                                                                                                                   \
  62     oop_field(HotSpotResolvedObjectTypeImpl, javaClass, "Ljava/lang/Class;")                                                                                   \
  63   end_class                                                                                                                                                    \
  64   start_class(HotSpotResolvedJavaMethodImpl)                                                                                                                   \
  65     long_field(HotSpotResolvedJavaMethodImpl, metaspaceMethod)                                                                                                 \
  66   end_class                                                                                                                                                    \
  67   start_class(HotSpotSymbol)                                                                                                                                   \
  68     long_field(HotSpotSymbol, pointer)                                                                                                                         \
  69   end_class                                                                                                                                                    \
  70   start_class(InstalledCode)                                                                                                                                   \
  71     long_field(InstalledCode, address)                                                                                                                         \
  72     long_field(InstalledCode, entryPoint)                                                                                                                      \
  73     long_field(InstalledCode, version)                                                                                                                         \
  74     oop_field(InstalledCode, name, "Ljava/lang/String;")                                                                                                       \
  75   end_class                                                                                                                                                    \
  76   start_class(HotSpotInstalledCode)                                                                                                                            \
  77     int_field(HotSpotInstalledCode, size)                                                                                                                      \
  78     long_field(HotSpotInstalledCode, codeStart)                                                                                                                \
  79     int_field(HotSpotInstalledCode, codeSize)                                                                                                                  \
  80   end_class                                                                                                                                                    \
  81   start_class(HotSpotNmethod)                                                                                                                                  \
  82     boolean_field(HotSpotNmethod, isDefault)                                                                                                                   \
  83   end_class                                                                                                                                                    \
  84   start_class(HotSpotCompiledCode)                                                                                                                             \
  85     oop_field(HotSpotCompiledCode, name, "Ljava/lang/String;")                                                                                                 \
  86     typeArrayOop_field(HotSpotCompiledCode, targetCode, "[B")                                                                                                  \
  87     int_field(HotSpotCompiledCode, targetCodeSize)                                                                                                             \
  88     objArrayOop_field(HotSpotCompiledCode, sites, "[Ljdk/vm/ci/code/site/Site;")                                                                               \
  89     objArrayOop_field(HotSpotCompiledCode, assumptions, "[Ljdk/vm/ci/meta/Assumptions$Assumption;")                                                            \
  90     objArrayOop_field(HotSpotCompiledCode, methods, "[Ljdk/vm/ci/meta/ResolvedJavaMethod;")                                                                    \
  91     objArrayOop_field(HotSpotCompiledCode, comments, "[Ljdk/vm/ci/hotspot/HotSpotCompiledCode$Comment;")                                                       \
  92     typeArrayOop_field(HotSpotCompiledCode, dataSection, "[B")                                                                                                 \
  93     int_field(HotSpotCompiledCode, dataSectionAlignment)                                                                                                       \
  94     objArrayOop_field(HotSpotCompiledCode, dataSectionPatches, "[Ljdk/vm/ci/code/site/DataPatch;")                                                             \
  95     boolean_field(HotSpotCompiledCode, isImmutablePIC)                                                                                                         \
  96     int_field(HotSpotCompiledCode, totalFrameSize)                                                                                                             \
  97     oop_field(HotSpotCompiledCode, deoptRescueSlot, "Ljdk/vm/ci/code/StackSlot;")                                                                              \
  98   end_class                                                                                                                                                    \
  99   start_class(HotSpotCompiledCode_Comment)                                                                                                                     \
 100     oop_field(HotSpotCompiledCode_Comment, text, "Ljava/lang/String;")                                                                                         \
 101     int_field(HotSpotCompiledCode_Comment, pcOffset)                                                                                                           \
 102   end_class                                                                                                                                                    \
 103   start_class(HotSpotCompiledNmethod)                                                                                                                          \
 104     oop_field(HotSpotCompiledNmethod, method, "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;")                                                                 \
 105     oop_field(HotSpotCompiledNmethod, installationFailureMessage, "Ljava/lang/String;")                                                                        \
 106     int_field(HotSpotCompiledNmethod, entryBCI)                                                                                                                \
 107     int_field(HotSpotCompiledNmethod, id)                                                                                                                      \
 108     long_field(HotSpotCompiledNmethod, jvmciEnv)                                                                                                               \
 109     boolean_field(HotSpotCompiledNmethod, hasUnsafeAccess)                                                                                                     \
 110   end_class                                                                                                                                                    \
 111   start_class(HotSpotJVMCIMetaAccessContext)                                                                                                                   \
 112     static_objArrayOop_field(HotSpotJVMCIMetaAccessContext, allContexts, "[Ljava/lang/ref/WeakReference;")                                                     \
 113     objArrayOop_field(HotSpotJVMCIMetaAccessContext, metadataRoots, "[Ljava/lang/Object;")                                                                     \
 114   end_class                                                                                                                                                    \
 115   start_class(HotSpotForeignCallTarget)                                                                                                                        \
 116     long_field(HotSpotForeignCallTarget, address)                                                                                                              \
 117   end_class                                                                                                                                                    \
 118   start_class(Assumptions_NoFinalizableSubclass)                                                                                                               \
 119     oop_field(Assumptions_NoFinalizableSubclass, receiverType, "Ljdk/vm/ci/meta/ResolvedJavaType;")                                                            \
 120   end_class                                                                                                                                                    \
 121   start_class(Assumptions_ConcreteSubtype)                                                                                                                     \
 122     oop_field(Assumptions_ConcreteSubtype, context, "Ljdk/vm/ci/meta/ResolvedJavaType;")                                                                       \
 123     oop_field(Assumptions_ConcreteSubtype, subtype, "Ljdk/vm/ci/meta/ResolvedJavaType;")                                                                       \
 124   end_class                                                                                                                                                    \
 125   start_class(Assumptions_LeafType)                                                                                                                            \
 126     oop_field(Assumptions_LeafType, context, "Ljdk/vm/ci/meta/ResolvedJavaType;")                                                                              \
 127   end_class                                                                                                                                                    \
 128   start_class(Assumptions_ConcreteMethod)                                                                                                                      \
 129     oop_field(Assumptions_ConcreteMethod, method, "Ljdk/vm/ci/meta/ResolvedJavaMethod;")                                                                       \
 130     oop_field(Assumptions_ConcreteMethod, context, "Ljdk/vm/ci/meta/ResolvedJavaType;")                                                                        \
 131     oop_field(Assumptions_ConcreteMethod, impl, "Ljdk/vm/ci/meta/ResolvedJavaMethod;")                                                                         \
 132   end_class                                                                                                                                                    \
 133   start_class(Assumptions_CallSiteTargetValue)                                                                                                                 \
 134     oop_field(Assumptions_CallSiteTargetValue, callSite, "Ljava/lang/invoke/CallSite;")                                                                        \
 135     oop_field(Assumptions_CallSiteTargetValue, methodHandle, "Ljava/lang/invoke/MethodHandle;")                                                                \
 136   end_class                                                                                                                                                    \
 137   start_class(site_Site)                                                                                                                                       \
 138     int_field(site_Site, pcOffset)                                                                                                                             \
 139   end_class                                                                                                                                                    \
 140   start_class(site_Call)                                                                                                                                       \
 141     oop_field(site_Call, target, "Ljdk/vm/ci/meta/InvokeTarget;")                                                                                              \
 142     oop_field(site_Call, debugInfo, "Ljdk/vm/ci/code/DebugInfo;")                                                                                              \
 143   end_class                                                                                                                                                    \
 144   start_class(site_DataPatch)                                                                                                                                  \
 145     oop_field(site_DataPatch, reference, "Ljdk/vm/ci/code/site/Reference;")                                                                                    \
 146   end_class                                                                                                                                                    \
 147   start_class(site_ConstantReference)                                                                                                                          \
 148     oop_field(site_ConstantReference, constant, "Ljdk/vm/ci/meta/VMConstant;")                                                                                 \
 149   end_class                                                                                                                                                    \
 150   start_class(site_DataSectionReference)                                                                                                                       \
 151     int_field(site_DataSectionReference, offset)                                                                                                               \
 152   end_class                                                                                                                                                    \
 153   start_class(site_InfopointReason)                                                                                                                            \
 154     static_oop_field(site_InfopointReason, SAFEPOINT, "Ljdk/vm/ci/code/site/InfopointReason;")                                                                 \
 155     static_oop_field(site_InfopointReason, CALL, "Ljdk/vm/ci/code/site/InfopointReason;")                                                                      \
 156     static_oop_field(site_InfopointReason, IMPLICIT_EXCEPTION, "Ljdk/vm/ci/code/site/InfopointReason;")                                                        \
 157   end_class                                                                                                                                                    \
 158   start_class(site_Infopoint)                                                                                                                                  \
 159     oop_field(site_Infopoint, debugInfo, "Ljdk/vm/ci/code/DebugInfo;")                                                                                         \
 160     oop_field(site_Infopoint, reason, "Ljdk/vm/ci/code/site/InfopointReason;")                                                                                 \
 161   end_class                                                                                                                                                    \
 162   start_class(site_ExceptionHandler)                                                                                                                           \
 163     int_field(site_ExceptionHandler, handlerPos)                                                                                                               \
 164   end_class                                                                                                                                                    \
 165   start_class(site_Mark)                                                                                                                                       \
 166     oop_field(site_Mark, id, "Ljava/lang/Object;")                                                                                                             \
 167   end_class                                                                                                                                                    \
 168   start_class(CompilationRequestResult)                                                                                                                        \
 169     oop_field(CompilationRequestResult, failureMessage, "Ljava/lang/String;")                                                                                  \
 170     boolean_field(CompilationRequestResult, retry)                                                                                                             \
 171     int_field(CompilationRequestResult, inlinedBytecodes)                                                                                                      \
 172   end_class                                                                                                                                                    \
 173   start_class(DebugInfo)                                                                                                                                       \
 174     oop_field(DebugInfo, bytecodePosition, "Ljdk/vm/ci/code/BytecodePosition;")                                                                                \
 175     oop_field(DebugInfo, referenceMap, "Ljdk/vm/ci/code/ReferenceMap;")                                                                                        \
 176     oop_field(DebugInfo, calleeSaveInfo, "Ljdk/vm/ci/code/RegisterSaveLayout;")                                                                                \
 177     objArrayOop_field(DebugInfo, virtualObjectMapping, "[Ljdk/vm/ci/code/VirtualObject;")                                                                      \
 178   end_class                                                                                                                                                    \
 179   start_class(HotSpotReferenceMap)                                                                                                                             \
 180     objArrayOop_field(HotSpotReferenceMap, objects, "[Ljdk/vm/ci/code/Location;")                                                                              \
 181     objArrayOop_field(HotSpotReferenceMap, derivedBase, "[Ljdk/vm/ci/code/Location;")                                                                          \
 182     typeArrayOop_field(HotSpotReferenceMap, sizeInBytes, "[I")                                                                                                 \
 183     int_field(HotSpotReferenceMap, maxRegisterSize)                                                                                                            \
 184   end_class                                                                                                                                                    \
 185   start_class(RegisterSaveLayout)                                                                                                                              \
 186     objArrayOop_field(RegisterSaveLayout, registers, "[Ljdk/vm/ci/code/Register;")                                                                             \
 187     typeArrayOop_field(RegisterSaveLayout, slots, "[I")                                                                                                        \
 188   end_class                                                                                                                                                    \
 189   start_class(BytecodeFrame)                                                                                                                                   \
 190     objArrayOop_field(BytecodeFrame, values, "[Ljdk/vm/ci/meta/JavaValue;")                                                                                    \
 191     objArrayOop_field(BytecodeFrame, slotKinds, "[Ljdk/vm/ci/meta/JavaKind;")                                                                                  \
 192     int_field(BytecodeFrame, numLocals)                                                                                                                        \
 193     int_field(BytecodeFrame, numStack)                                                                                                                         \
 194     int_field(BytecodeFrame, numLocks)                                                                                                                         \
 195     boolean_field(BytecodeFrame, rethrowException)                                                                                                             \
 196     boolean_field(BytecodeFrame, duringCall)                                                                                                                   \
 197     static_int_field(BytecodeFrame, BEFORE_BCI)                                                                                                                \
 198   end_class                                                                                                                                                    \
 199   start_class(BytecodePosition)                                                                                                                                \
 200     oop_field(BytecodePosition, caller, "Ljdk/vm/ci/code/BytecodePosition;")                                                                                   \
 201     oop_field(BytecodePosition, method, "Ljdk/vm/ci/meta/ResolvedJavaMethod;")                                                                                 \
 202     int_field(BytecodePosition, bci)                                                                                                                           \
 203   end_class                                                                                                                                                    \
 204   start_class(JavaConstant)                                                                                                                                    \
 205   end_class                                                                                                                                                    \
 206   start_class(PrimitiveConstant)                                                                                                                               \
 207     oop_field(PrimitiveConstant, kind, "Ljdk/vm/ci/meta/JavaKind;")                                                                                            \
 208     long_field(PrimitiveConstant, primitive)                                                                                                                   \
 209   end_class                                                                                                                                                    \
 210   start_class(RawConstant)                                                                                                                                     \
 211     long_field(RawConstant, primitive)                                                                                                                         \
 212   end_class                                                                                                                                                    \
 213   start_class(NullConstant)                                                                                                                                    \
 214   end_class                                                                                                                                                    \
 215   start_class(HotSpotCompressedNullConstant)                                                                                                                   \
 216   end_class                                                                                                                                                    \
 217   start_class(HotSpotObjectConstantImpl)                                                                                                                       \
 218     oop_field(HotSpotObjectConstantImpl, object, "Ljava/lang/Object;")                                                                                         \
 219     boolean_field(HotSpotObjectConstantImpl, compressed)                                                                                                       \
 220   end_class                                                                                                                                                    \
 221   start_class(HotSpotMetaspaceConstantImpl)                                                                                                                    \
 222     oop_field(HotSpotMetaspaceConstantImpl, metaspaceObject, "Ljdk/vm/ci/hotspot/MetaspaceWrapperObject;")                                                     \
 223     boolean_field(HotSpotMetaspaceConstantImpl, compressed)                                                                                                    \
 224   end_class                                                                                                                                                    \
 225   start_class(HotSpotSentinelConstant)                                                                                                                         \
 226   end_class                                                                                                                                                    \
 227   start_class(JavaKind)                                                                                                                                        \
 228     char_field(JavaKind, typeChar)                                                                                                                             \
 229     static_oop_field(JavaKind, Boolean, "Ljdk/vm/ci/meta/JavaKind;");                                                                                          \
 230     static_oop_field(JavaKind, Byte, "Ljdk/vm/ci/meta/JavaKind;");                                                                                             \
 231     static_oop_field(JavaKind, Char, "Ljdk/vm/ci/meta/JavaKind;");                                                                                             \
 232     static_oop_field(JavaKind, Short, "Ljdk/vm/ci/meta/JavaKind;");                                                                                            \
 233     static_oop_field(JavaKind, Int, "Ljdk/vm/ci/meta/JavaKind;");                                                                                              \
 234     static_oop_field(JavaKind, Long, "Ljdk/vm/ci/meta/JavaKind;");                                                                                             \
 235   end_class                                                                                                                                                    \
 236   start_class(LIRKind)                                                                                                                                         \
 237     oop_field(LIRKind, platformKind, "Ljdk/vm/ci/meta/PlatformKind;")                                                                                          \
 238     int_field(LIRKind, referenceMask)                                                                                                                          \
 239   end_class                                                                                                                                                    \
 240   start_class(Value)                                                                                                                                           \
 241     oop_field(Value, lirKind, "Ljdk/vm/ci/meta/LIRKind;")                                                                                                      \
 242     static_oop_field(Value, ILLEGAL, "Ljdk/vm/ci/meta/AllocatableValue;");                                                                                     \
 243   end_class                                                                                                                                                    \
 244   start_class(RegisterValue)                                                                                                                                   \
 245     oop_field(RegisterValue, reg, "Ljdk/vm/ci/code/Register;")                                                                                                 \
 246   end_class                                                                                                                                                    \
 247   start_class(code_Location)                                                                                                                                   \
 248     oop_field(code_Location, reg, "Ljdk/vm/ci/code/Register;")                                                                                                 \
 249     int_field(code_Location, offset)                                                                                                                           \
 250   end_class                                                                                                                                                    \
 251   start_class(code_Register)                                                                                                                                   \
 252     int_field(code_Register, number)                                                                                                                           \
 253     int_field(code_Register, encoding)                                                                                                                         \
 254   end_class                                                                                                                                                    \
 255   start_class(StackSlot)                                                                                                                                       \
 256     int_field(StackSlot, offset)                                                                                                                               \
 257     boolean_field(StackSlot, addFrameSize)                                                                                                                     \
 258   end_class                                                                                                                                                    \
 259   start_class(VirtualObject)                                                                                                                                   \
 260     int_field(VirtualObject, id)                                                                                                                               \
 261     oop_field(VirtualObject, type, "Ljdk/vm/ci/meta/ResolvedJavaType;")                                                                                        \
 262     objArrayOop_field(VirtualObject, values, "[Ljdk/vm/ci/meta/JavaValue;")                                                                                    \
 263     objArrayOop_field(VirtualObject, slotKinds, "[Ljdk/vm/ci/meta/JavaKind;")                                                                                  \
 264   end_class                                                                                                                                                    \
 265   start_class(StackLockValue)                                                                                                                                  \
 266     oop_field(StackLockValue, owner, "Ljdk/vm/ci/meta/JavaValue;")                                                                                             \
 267     oop_field(StackLockValue, slot, "Ljdk/vm/ci/meta/AllocatableValue;")                                                                                       \
 268     boolean_field(StackLockValue, eliminated)                                                                                                                  \
 269   end_class                                                                                                                                                    \
 270   start_class(HotSpotSpeculationLog)                                                                                                                           \
 271     oop_field(HotSpotSpeculationLog, lastFailed, "Ljava/lang/Object;")                                                                                         \
 272   end_class                                                                                                                                                    \
 273   start_class(HotSpotStackFrameReference)                                                                                                                      \
 274     oop_field(HotSpotStackFrameReference, compilerToVM, "Ljdk/vm/ci/hotspot/CompilerToVM;")                                                                    \
 275     long_field(HotSpotStackFrameReference, stackPointer)                                                                                                       \
 276     int_field(HotSpotStackFrameReference, frameNumber)                                                                                                         \
 277     int_field(HotSpotStackFrameReference, bci)                                                                                                                 \
 278     oop_field(HotSpotStackFrameReference, method, "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;")                                                             \
 279     objArrayOop_field(HotSpotStackFrameReference, locals, "[Ljava/lang/Object;")                                                                               \
 280     typeArrayOop_field(HotSpotStackFrameReference, localIsVirtual, "[Z")                                                                                       \
 281   end_class                                                                                                                                                    \
 282   start_class(HotSpotMetaData)                                                                                                                                 \
 283     typeArrayOop_field(HotSpotMetaData, pcDescBytes, "[B")                                                                                                     \
 284     typeArrayOop_field(HotSpotMetaData, scopesDescBytes, "[B")                                                                                                 \
 285     typeArrayOop_field(HotSpotMetaData, relocBytes, "[B")                                                                                                      \
 286     typeArrayOop_field(HotSpotMetaData, exceptionBytes, "[B")                                                                                                  \
 287     typeArrayOop_field(HotSpotMetaData, oopMaps, "[B")                                                                                                         \
 288     objArrayOop_field(HotSpotMetaData, metadata, "[Ljava/lang/String;")                                                                                        \
 289   end_class                                                                                                                                                    \
 290   start_class(HotSpotOopMap)                                                                                                                                   \
 291     int_field(HotSpotOopMap, offset)                                                                                                                           \
 292     int_field(HotSpotOopMap, count)                                                                                                                            \
 293     typeArrayOop_field(HotSpotOopMap, data, "[B")                                                                                                              \
 294   end_class                                                                                                                                                    \
 295   start_class(HotSpotConstantPool)                                                                                                                             \
 296     long_field(HotSpotConstantPool, metaspaceConstantPool)                                                                                                     \
 297   end_class                                                                                                                                                    \
 298   start_class(HotSpotJVMCIRuntime)                                                                                                                             \
 299     objArrayOop_field(HotSpotJVMCIRuntime, trivialPrefixes, "[Ljava/lang/String;")                                                                             \
 300     int_field(HotSpotJVMCIRuntime, compilationLevelAdjustment)                                                                                                 \
 301   end_class                                                                                                                                                    \
 302   /* end*/
 303 
 304 #define START_CLASS(name)                                                                                                                                      \
 305 class name : AllStatic {                                                                                                                                       \
 306   private:                                                                                                                                                     \
 307     friend class JVMCICompiler;                                                                                                                                \
 308     static void check(oop obj, const char* field_name, int offset) {                                                                                           \
 309         assert(obj != NULL, "NULL field access of %s.%s", #name, field_name);                                                                                  \
 310         assert(obj->is_a(SystemDictionary::name##_klass()), "wrong class, " #name " expected, found %s", obj->klass()->external_name());                       \
 311         assert(offset != 0, "must be valid offset");                                                                                                           \
 312     }                                                                                                                                                          \
 313     static void compute_offsets(TRAPS);                                                                                                                        \
 314   public:                                                                                                                                                      \
 315     static InstanceKlass* klass() { return SystemDictionary::name##_klass(); }
 316 
 317 #define END_CLASS };
 318 
 319 #define FIELD(name, type, accessor, cast)                                                                                                                         \
 320     static int _##name##_offset;                                                                                                                                  \
 321     static type name(oop obj)                   { check(obj, #name, _##name##_offset); return cast obj->accessor(_##name##_offset); }                                               \
 322     static type name(Handle obj)                { check(obj(), #name, _##name##_offset); return cast obj->accessor(_##name##_offset); }                                             \
 323     static type name(jobject obj)               { check(JNIHandles::resolve(obj), #name, _##name##_offset); return cast JNIHandles::resolve(obj)->accessor(_##name##_offset); }     \
 324     static void set_##name(oop obj, type x)     { check(obj, #name, _##name##_offset); obj->accessor##_put(_##name##_offset, x); }                                                  \
 325     static void set_##name(Handle obj, type x)  { check(obj(), #name, _##name##_offset); obj->accessor##_put(_##name##_offset, x); }                                                \
 326     static void set_##name(jobject obj, type x) { check(JNIHandles::resolve(obj), #name, _##name##_offset); JNIHandles::resolve(obj)->accessor##_put(_##name##_offset, x); }
 327 
 328 #define EMPTY_CAST
 329 #define CHAR_FIELD(klass, name) FIELD(name, jchar, char_field, EMPTY_CAST)
 330 #define INT_FIELD(klass, name) FIELD(name, jint, int_field, EMPTY_CAST)
 331 #define BOOLEAN_FIELD(klass, name) FIELD(name, jboolean, bool_field, EMPTY_CAST)
 332 #define LONG_FIELD(klass, name) FIELD(name, jlong, long_field, EMPTY_CAST)
 333 #define FLOAT_FIELD(klass, name) FIELD(name, jfloat, float_field, EMPTY_CAST)
 334 #define OOP_FIELD(klass, name, signature) FIELD(name, oop, obj_field, EMPTY_CAST)
 335 #define OBJARRAYOOP_FIELD(klass, name, signature) FIELD(name, objArrayOop, obj_field, (objArrayOop))
 336 #define TYPEARRAYOOP_FIELD(klass, name, signature) FIELD(name, typeArrayOop, obj_field, (typeArrayOop))
 337 #define STATIC_OOP_FIELD(klassName, name, signature) STATIC_OOPISH_FIELD(klassName, name, oop, signature)
 338 #define STATIC_OBJARRAYOOP_FIELD(klassName, name, signature) STATIC_OOPISH_FIELD(klassName, name, objArrayOop, signature)
 339 #define STATIC_OOPISH_FIELD(klassName, name, type, signature)                                                  \
 340     static int _##name##_offset;                                                                               \
 341     static type name() {                                                                                       \
 342       assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \
 343       InstanceKlass* ik = klassName::klass();                                                                  \
 344       address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \
 345       if (UseCompressedOops) {                                                                                 \
 346         return (type) oopDesc::load_decode_heap_oop((narrowOop *)addr);                                        \
 347       } else {                                                                                                 \
 348         return (type) oopDesc::load_decode_heap_oop((oop*)addr);                                               \
 349       }                                                                                                        \
 350     }                                                                                                          \
 351     static void set_##name(type x) {                                                                           \
 352       assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \
 353       assert(klassName::klass() != NULL, "Class not yet loaded: " #klassName);                                 \
 354       InstanceKlass* ik = klassName::klass();                                                                  \
 355       address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \
 356       if (UseCompressedOops) {                                                                                 \
 357         oop_store((narrowOop *)addr, x);                                                                       \
 358       } else {                                                                                                 \
 359         oop_store((oop*)addr, x);                                                                              \
 360       }                                                                                                        \
 361     }
 362 #define STATIC_PRIMITIVE_FIELD(klassName, name, jtypename)                                                     \
 363     static int _##name##_offset;                                                                               \
 364     static jtypename name() {                                                                                  \
 365       assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \
 366       InstanceKlass* ik = klassName::klass();                                                                  \
 367       address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \
 368       return *((jtypename *)addr);                                                                             \
 369     }                                                                                                          \
 370     static void set_##name(jtypename x) {                                                                      \
 371       assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \
 372       InstanceKlass* ik = klassName::klass();                                                                  \
 373       address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \
 374       *((jtypename *)addr) = x;                                                                                \
 375     }
 376 
 377 #define STATIC_INT_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jint)
 378 #define STATIC_BOOLEAN_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jboolean)
 379 
 380 COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OOP_FIELD, TYPEARRAYOOP_FIELD, OBJARRAYOOP_FIELD, STATIC_OOP_FIELD, STATIC_OBJARRAYOOP_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD)
 381 #undef START_CLASS
 382 #undef END_CLASS
 383 #undef FIELD
 384 #undef CHAR_FIELD
 385 #undef INT_FIELD
 386 #undef BOOLEAN_FIELD
 387 #undef LONG_FIELD
 388 #undef FLOAT_FIELD
 389 #undef OOP_FIELD
 390 #undef TYPEARRAYOOP_FIELD
 391 #undef OBJARRAYOOP_FIELD
 392 #undef STATIC_OOPISH_FIELD
 393 #undef STATIC_OOP_FIELD
 394 #undef STATIC_OBJARRAYOOP_FIELD
 395 #undef STATIC_INT_FIELD
 396 #undef STATIC_BOOLEAN_FIELD
 397 #undef EMPTY_CAST
 398 
 399 void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field, TRAPS);
 400 
 401 #endif // SHARE_VM_JVMCI_JVMCIJAVACLASSES_HPP