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