1 /*
  2  * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "code/codeCache.hpp"
 27 #include "compiler/compileBroker.hpp"
 28 #include "gc/shared/collectedHeap.hpp"
 29 #include "jvmci/jvmciCodeInstaller.hpp"
 30 #include "jvmci/jvmciCompilerToVM.hpp"
 31 #include "jvmci/jvmciRuntime.hpp"
 32 #include "jvmci/vmStructs_jvmci.hpp"
 33 #include "oops/klassVtable.hpp"
 34 #include "oops/objArrayKlass.hpp"
 35 #include "runtime/deoptimization.hpp"
 36 #include "runtime/flags/jvmFlag.hpp"
 37 #include "runtime/osThread.hpp"
 38 #include "runtime/sharedRuntime.hpp"
 39 #include "runtime/stubRoutines.hpp"
 40 #include "runtime/vm_version.hpp"
 41 #if INCLUDE_G1GC
 42 #include "gc/g1/g1CardTable.hpp"
 43 #include "gc/g1/heapRegion.hpp"
 44 #include "gc/g1/g1ThreadLocalData.hpp"
 45 #endif
 46 
 47 #define VM_STRUCTS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field) \
 48   static_field(CompilerToVM::Data,             Klass_vtable_start_offset,              int)                                          \
 49   static_field(CompilerToVM::Data,             Klass_vtable_length_offset,             int)                                          \
 50                                                                                                                                      \
 51   static_field(CompilerToVM::Data,             Method_extra_stack_entries,             int)                                          \
 52                                                                                                                                      \
 53   static_field(CompilerToVM::Data,             SharedRuntime_ic_miss_stub,             address)                                      \
 54   static_field(CompilerToVM::Data,             SharedRuntime_handle_wrong_method_stub, address)                                      \
 55   static_field(CompilerToVM::Data,             SharedRuntime_deopt_blob_unpack,        address)                                      \
 56   static_field(CompilerToVM::Data,             SharedRuntime_deopt_blob_unpack_with_exception_in_tls,                                \
 57                                                                                        address)                                      \
 58   static_field(CompilerToVM::Data,             SharedRuntime_deopt_blob_uncommon_trap, address)                                      \
 59                                                                                                                                      \
 60   static_field(CompilerToVM::Data,             ThreadLocalAllocBuffer_alignment_reserve, size_t)                                     \
 61                                                                                                                                      \
 62   static_field(CompilerToVM::Data,             Universe_collectedHeap,                 CollectedHeap*)                               \
 63   static_field(CompilerToVM::Data,             Universe_base_vtable_size,              int)                                          \
 64   static_field(CompilerToVM::Data,             Universe_narrow_oop_base,               address)                                      \
 65   static_field(CompilerToVM::Data,             Universe_narrow_oop_shift,              int)                                          \
 66   static_field(CompilerToVM::Data,             Universe_narrow_klass_base,             address)                                      \
 67   static_field(CompilerToVM::Data,             Universe_narrow_klass_shift,            int)                                          \
 68   static_field(CompilerToVM::Data,             Universe_non_oop_bits,                  void*)                                        \
 69   static_field(CompilerToVM::Data,             Universe_verify_oop_mask,               uintptr_t)                                    \
 70   static_field(CompilerToVM::Data,             Universe_verify_oop_bits,               uintptr_t)                                    \
 71                                                                                                                                      \
 72   static_field(CompilerToVM::Data,             _supports_inline_contig_alloc,          bool)                                         \
 73   static_field(CompilerToVM::Data,             _heap_end_addr,                         HeapWord**)                                   \
 74   static_field(CompilerToVM::Data,             _heap_top_addr,                         HeapWord* volatile*)                          \
 75                                                                                                                                      \
 76   static_field(CompilerToVM::Data,             _max_oop_map_stack_offset,              int)                                          \
 77   static_field(CompilerToVM::Data,             _fields_annotations_base_offset,        int)                                          \
 78                                                                                                                                      \
 79   static_field(CompilerToVM::Data,             cardtable_start_address,                CardTable::CardValue*)                        \
 80   static_field(CompilerToVM::Data,             cardtable_shift,                        int)                                          \
 81                                                                                                                                      \
 82   static_field(CompilerToVM::Data,             vm_page_size,                           int)                                          \
 83                                                                                                                                      \
 84   static_field(CompilerToVM::Data,             sizeof_vtableEntry,                     int)                                          \
 85   static_field(CompilerToVM::Data,             sizeof_ExceptionTableElement,           int)                                          \
 86   static_field(CompilerToVM::Data,             sizeof_LocalVariableTableElement,       int)                                          \
 87   static_field(CompilerToVM::Data,             sizeof_ConstantPool,                    int)                                          \
 88   static_field(CompilerToVM::Data,             sizeof_narrowKlass,                     int)                                          \
 89   static_field(CompilerToVM::Data,             sizeof_arrayOopDesc,                    int)                                          \
 90   static_field(CompilerToVM::Data,             sizeof_BasicLock,                       int)                                          \
 91                                                                                                                                      \
 92   static_field(CompilerToVM::Data,             dsin,                                   address)                                      \
 93   static_field(CompilerToVM::Data,             dcos,                                   address)                                      \
 94   static_field(CompilerToVM::Data,             dtan,                                   address)                                      \
 95   static_field(CompilerToVM::Data,             dexp,                                   address)                                      \
 96   static_field(CompilerToVM::Data,             dlog,                                   address)                                      \
 97   static_field(CompilerToVM::Data,             dlog10,                                 address)                                      \
 98   static_field(CompilerToVM::Data,             dpow,                                   address)                                      \
 99                                                                                                                                      \
100   static_field(CompilerToVM::Data,             symbol_init,                            address)                                      \
101   static_field(CompilerToVM::Data,             symbol_clinit,                          address)                                      \
102                                                                                                                                      \
103   static_field(Abstract_VM_Version,            _features,                              uint64_t)                                     \
104                                                                                                                                      \
105   nonstatic_field(Annotations,                 _fields_annotations,                    Array<AnnotationArray*>*)                     \
106                                                                                                                                      \
107   nonstatic_field(Array<int>,                  _length,                                int)                                          \
108   unchecked_nonstatic_field(Array<u1>,         _data,                                  sizeof(u1))                                   \
109   unchecked_nonstatic_field(Array<u2>,         _data,                                  sizeof(u2))                                   \
110   nonstatic_field(Array<Klass*>,               _length,                                int)                                          \
111   nonstatic_field(Array<Klass*>,               _data[0],                               Klass*)                                       \
112                                                                                                                                      \
113   volatile_nonstatic_field(BasicLock,          _displaced_header,                      markWord)                                     \
114                                                                                                                                      \
115   static_field(CodeCache,                      _low_bound,                             address)                                      \
116   static_field(CodeCache,                      _high_bound,                            address)                                      \
117                                                                                                                                      \
118   nonstatic_field(CollectedHeap,               _total_collections,                     unsigned int)                                 \
119                                                                                                                                      \
120   nonstatic_field(CompileTask,                 _num_inlined_bytecodes,                 int)                                          \
121                                                                                                                                      \
122   nonstatic_field(ConstantPool,                _tags,                                  Array<u1>*)                                   \
123   nonstatic_field(ConstantPool,                _pool_holder,                           InstanceKlass*)                               \
124   nonstatic_field(ConstantPool,                _length,                                int)                                          \
125   nonstatic_field(ConstantPool,                _flags,                                 u2)                                           \
126   nonstatic_field(ConstantPool,                _source_file_name_index,                u2)                                           \
127                                                                                                                                      \
128   nonstatic_field(ConstMethod,                 _constants,                             ConstantPool*)                                \
129   nonstatic_field(ConstMethod,                 _flags,                                 u2)                                           \
130   nonstatic_field(ConstMethod,                 _code_size,                             u2)                                           \
131   nonstatic_field(ConstMethod,                 _name_index,                            u2)                                           \
132   nonstatic_field(ConstMethod,                 _signature_index,                       u2)                                           \
133   nonstatic_field(ConstMethod,                 _method_idnum,                          u2)                                           \
134   nonstatic_field(ConstMethod,                 _max_stack,                             u2)                                           \
135   nonstatic_field(ConstMethod,                 _max_locals,                            u2)                                           \
136                                                                                                                                      \
137   nonstatic_field(DataLayout,                  _header._struct._tag,                   u1)                                           \
138   nonstatic_field(DataLayout,                  _header._struct._flags,                 u1)                                           \
139   nonstatic_field(DataLayout,                  _header._struct._bci,                   u2)                                           \
140   nonstatic_field(DataLayout,                  _header._struct._traps,                 u4)                                           \
141   nonstatic_field(DataLayout,                  _cells[0],                              intptr_t)                                     \
142                                                                                                                                      \
143   nonstatic_field(Deoptimization::UnrollBlock, _size_of_deoptimized_frame,             int)                                          \
144   nonstatic_field(Deoptimization::UnrollBlock, _caller_adjustment,                     int)                                          \
145   nonstatic_field(Deoptimization::UnrollBlock, _number_of_frames,                      int)                                          \
146   nonstatic_field(Deoptimization::UnrollBlock, _total_frame_sizes,                     int)                                          \
147   nonstatic_field(Deoptimization::UnrollBlock, _frame_sizes,                           intptr_t*)                                    \
148   nonstatic_field(Deoptimization::UnrollBlock, _frame_pcs,                             address*)                                     \
149   nonstatic_field(Deoptimization::UnrollBlock, _initial_info,                          intptr_t)                                     \
150   nonstatic_field(Deoptimization::UnrollBlock, _unpack_kind,                           int)                                          \
151                                                                                                                                      \
152   nonstatic_field(ExceptionTableElement,       start_pc,                                      u2)                                    \
153   nonstatic_field(ExceptionTableElement,       end_pc,                                        u2)                                    \
154   nonstatic_field(ExceptionTableElement,       handler_pc,                                    u2)                                    \
155   nonstatic_field(ExceptionTableElement,       catch_type_index,                              u2)                                    \
156                                                                                                                                      \
157   nonstatic_field(InstanceKlass,               _fields,                                       Array<u2>*)                            \
158   nonstatic_field(InstanceKlass,               _constants,                                    ConstantPool*)                         \
159   nonstatic_field(InstanceKlass,               _init_state,                                   u1)                                    \
160   nonstatic_field(InstanceKlass,               _init_thread,                                  Thread*)                               \
161   nonstatic_field(InstanceKlass,               _kind,                                         u1)                                    \
162   nonstatic_field(InstanceKlass,               _misc_flags,                                   u2)                                    \
163   nonstatic_field(InstanceKlass,               _annotations,                                  Annotations*)                          \
164                                                                                                                                      \
165   volatile_nonstatic_field(JavaFrameAnchor,    _last_Java_sp,                                 intptr_t*)                             \
166   volatile_nonstatic_field(JavaFrameAnchor,    _last_Java_pc,                                 address)                               \
167                                                                                                                                      \
168   nonstatic_field(JVMCICompileState,           _jvmti_can_hotswap_or_post_breakpoint,         jbyte)                                 \
169   nonstatic_field(JVMCICompileState,           _jvmti_can_access_local_variables,             jbyte)                                 \
170   nonstatic_field(JVMCICompileState,           _jvmti_can_post_on_exceptions,                 jbyte)                                 \
171   nonstatic_field(JVMCICompileState,           _jvmti_can_pop_frame,                          jbyte)                                 \
172   nonstatic_field(JVMCICompileState,           _compilation_ticks,                            jint)                                  \
173                                                                                                                                      \
174   nonstatic_field(JavaThread,                  _threadObj,                                    OopHandle)                                   \
175   nonstatic_field(JavaThread,                  _vthread,                                      OopHandle)                                   \
176   nonstatic_field(JavaThread,                  _anchor,                                       JavaFrameAnchor)                       \
177   nonstatic_field(JavaThread,                  _vm_result,                                    oop)                                   \
178   nonstatic_field(JavaThread,                  _stack_overflow_state._stack_overflow_limit,   address)                               \
179   volatile_nonstatic_field(JavaThread,         _exception_oop,                                oop)                                   \
180   volatile_nonstatic_field(JavaThread,         _exception_pc,                                 address)                               \
181   volatile_nonstatic_field(JavaThread,         _is_method_handle_return,                      int)                                   \
182   volatile_nonstatic_field(JavaThread,         _doing_unsafe_access,                          bool)                                  \
183   nonstatic_field(JavaThread,                  _osthread,                                     OSThread*)                             \
184   nonstatic_field(JavaThread,                  _pending_deoptimization,                       int)                                   \
185   nonstatic_field(JavaThread,                  _pending_failed_speculation,                   jlong)                                 \
186   nonstatic_field(JavaThread,                  _pending_transfer_to_interpreter,              bool)                                  \
187   nonstatic_field(JavaThread,                  _jvmci_counters,                               jlong*)                                \
188   nonstatic_field(JavaThread,                  _jvmci_reserved0,                              jlong)                                 \
189   nonstatic_field(JavaThread,                  _jvmci_reserved1,                              jlong)                                 \
190   nonstatic_field(JavaThread,                  _jvmci_reserved_oop0,                          oop)                                   \
191   nonstatic_field(JavaThread,                  _should_post_on_exceptions_flag,               int)                                   \
192   nonstatic_field(JavaThread,                  _jni_environment,                              JNIEnv)                                \
193   nonstatic_field(JavaThread,                  _poll_data,                                    SafepointMechanism::ThreadData)        \
194   nonstatic_field(JavaThread,                  _stack_overflow_state._reserved_stack_activation, address)                            \
195   nonstatic_field(JavaThread,                  _held_monitor_count,                           int)                               \
196                                                                                                                                      \
197   static_field(java_lang_Class,                _klass_offset,                                 int)                                   \
198   static_field(java_lang_Class,                _array_klass_offset,                           int)                                   \
199                                                                                                                                      \
200   nonstatic_field(InvocationCounter,           _counter,                                      unsigned int)                          \
201                                                                                                                                      \
202   nonstatic_field(Klass,                       _secondary_super_cache,                        Klass*)                                \
203   nonstatic_field(Klass,                       _secondary_supers,                             Array<Klass*>*)                        \
204   nonstatic_field(Klass,                       _super,                                        Klass*)                                \
205   nonstatic_field(Klass,                       _super_check_offset,                           juint)                                 \
206   volatile_nonstatic_field(Klass,              _subklass,                                     Klass*)                                \
207   nonstatic_field(Klass,                       _layout_helper,                                jint)                                  \
208   nonstatic_field(Klass,                       _name,                                         Symbol*)                               \
209   volatile_nonstatic_field(Klass,              _next_sibling,                                 Klass*)                                \
210   nonstatic_field(Klass,                       _java_mirror,                                  OopHandle)                             \
211   nonstatic_field(Klass,                       _modifier_flags,                               jint)                                  \
212   nonstatic_field(Klass,                       _access_flags,                                 AccessFlags)                           \
213   nonstatic_field(Klass,                       _class_loader_data,                            ClassLoaderData*)                      \
214                                                                                                                                      \
215   nonstatic_field(LocalVariableTableElement,   start_bci,                                     u2)                                    \
216   nonstatic_field(LocalVariableTableElement,   length,                                        u2)                                    \
217   nonstatic_field(LocalVariableTableElement,   name_cp_index,                                 u2)                                    \
218   nonstatic_field(LocalVariableTableElement,   descriptor_cp_index,                           u2)                                    \
219   nonstatic_field(LocalVariableTableElement,   signature_cp_index,                            u2)                                    \
220   nonstatic_field(LocalVariableTableElement,   slot,                                          u2)                                    \
221                                                                                                                                      \
222   nonstatic_field(Method,                      _constMethod,                                  ConstMethod*)                          \
223   nonstatic_field(Method,                      _method_data,                                  MethodData*)                           \
224   nonstatic_field(Method,                      _method_counters,                              MethodCounters*)                       \
225   nonstatic_field(Method,                      _access_flags,                                 AccessFlags)                           \
226   nonstatic_field(Method,                      _vtable_index,                                 int)                                   \
227   nonstatic_field(Method,                      _intrinsic_id,                                 u2)                                    \
228   nonstatic_field(Method,                      _flags,                                        u2)                                    \
229   volatile_nonstatic_field(Method,             _code,                                         CompiledMethod*)                       \
230   volatile_nonstatic_field(Method,             _from_compiled_entry,                          address)                               \
231                                                                                                                                      \
232   nonstatic_field(MethodCounters,              _nmethod_age,                                  int)                                   \
233   nonstatic_field(MethodCounters,              _invoke_mask,                                  int)                                   \
234   nonstatic_field(MethodCounters,              _backedge_mask,                                int)                                   \
235   nonstatic_field(MethodCounters,              _interpreter_throwout_count,                   u2)                                    \
236   JVMTI_ONLY(nonstatic_field(MethodCounters,   _number_of_breakpoints,                        u2))                                   \
237   nonstatic_field(MethodCounters,              _invocation_counter,                           InvocationCounter)                     \
238   nonstatic_field(MethodCounters,              _backedge_counter,                             InvocationCounter)                     \
239                                                                                                                                      \
240   nonstatic_field(MethodData,                  _size,                                         int)                                   \
241   nonstatic_field(MethodData,                  _method,                                       Method*)                               \
242   nonstatic_field(MethodData,                  _data_size,                                    int)                                   \
243   nonstatic_field(MethodData,                  _data[0],                                      intptr_t)                              \
244   nonstatic_field(MethodData,                  _parameters_type_data_di,                      int)                                   \
245   nonstatic_field(MethodData,                  _compiler_counters._nof_decompiles,            uint)                                  \
246   nonstatic_field(MethodData,                  _compiler_counters._nof_overflow_recompiles,   uint)                                  \
247   nonstatic_field(MethodData,                  _compiler_counters._nof_overflow_traps,        uint)                                  \
248   nonstatic_field(MethodData,                  _compiler_counters._trap_hist._array[0],       u1)                                    \
249   nonstatic_field(MethodData,                  _eflags,                                       intx)                                  \
250   nonstatic_field(MethodData,                  _arg_local,                                    intx)                                  \
251   nonstatic_field(MethodData,                  _arg_stack,                                    intx)                                  \
252   nonstatic_field(MethodData,                  _arg_returned,                                 intx)                                  \
253   nonstatic_field(MethodData,                  _tenure_traps,                                 uint)                                  \
254   nonstatic_field(MethodData,                  _invoke_mask,                                  int)                                   \
255   nonstatic_field(MethodData,                  _backedge_mask,                                int)                                   \
256   nonstatic_field(MethodData,                  _jvmci_ir_size,                                int)                                   \
257                                                                                                                                      \
258   nonstatic_field(nmethod,                     _verified_entry_point,                         address)                               \
259   nonstatic_field(nmethod,                     _comp_level,                                   int)                                   \
260                                                                                                                                      \
261   nonstatic_field(ObjArrayKlass,               _element_klass,                                Klass*)                                \
262                                                                                                                                      \
263   unchecked_nonstatic_field(ObjectMonitor,     _owner,                                        sizeof(void *)) /* NOTE: no type */    \
264   volatile_nonstatic_field(ObjectMonitor,      _recursions,                                   intptr_t)                              \
265   volatile_nonstatic_field(ObjectMonitor,      _cxq,                                          ObjectWaiter*)                         \
266   volatile_nonstatic_field(ObjectMonitor,      _EntryList,                                    ObjectWaiter*)                         \
267   volatile_nonstatic_field(ObjectMonitor,      _succ,                                         JavaThread*)                           \
268                                                                                                                                      \
269   volatile_nonstatic_field(oopDesc,            _mark,                                         markWord)                              \
270   volatile_nonstatic_field(oopDesc,            _metadata._klass,                              Klass*)                                \
271                                                                                                                                      \
272   static_field(os,                             _polling_page,                                 address)                               \
273                                                                                                                                      \
274   static_field(StubRoutines,                _verify_oop_count,                                jint)                                  \
275                                                                                                                                      \
276   static_field(StubRoutines,                _throw_delayed_StackOverflowError_entry,          address)                               \
277                                                                                                                                      \
278   static_field(StubRoutines,                _jbyte_arraycopy,                                 address)                               \
279   static_field(StubRoutines,                _jshort_arraycopy,                                address)                               \
280   static_field(StubRoutines,                _jint_arraycopy,                                  address)                               \
281   static_field(StubRoutines,                _jlong_arraycopy,                                 address)                               \
282   static_field(StubRoutines,                _oop_arraycopy,                                   address)                               \
283   static_field(StubRoutines,                _oop_arraycopy_uninit,                            address)                               \
284   static_field(StubRoutines,                _jbyte_disjoint_arraycopy,                        address)                               \
285   static_field(StubRoutines,                _jshort_disjoint_arraycopy,                       address)                               \
286   static_field(StubRoutines,                _jint_disjoint_arraycopy,                         address)                               \
287   static_field(StubRoutines,                _jlong_disjoint_arraycopy,                        address)                               \
288   static_field(StubRoutines,                _oop_disjoint_arraycopy,                          address)                               \
289   static_field(StubRoutines,                _oop_disjoint_arraycopy_uninit,                   address)                               \
290   static_field(StubRoutines,                _arrayof_jbyte_arraycopy,                         address)                               \
291   static_field(StubRoutines,                _arrayof_jshort_arraycopy,                        address)                               \
292   static_field(StubRoutines,                _arrayof_jint_arraycopy,                          address)                               \
293   static_field(StubRoutines,                _arrayof_jlong_arraycopy,                         address)                               \
294   static_field(StubRoutines,                _arrayof_oop_arraycopy,                           address)                               \
295   static_field(StubRoutines,                _arrayof_oop_arraycopy_uninit,                    address)                               \
296   static_field(StubRoutines,                _arrayof_jbyte_disjoint_arraycopy,                address)                               \
297   static_field(StubRoutines,                _arrayof_jshort_disjoint_arraycopy,               address)                               \
298   static_field(StubRoutines,                _arrayof_jint_disjoint_arraycopy,                 address)                               \
299   static_field(StubRoutines,                _arrayof_jlong_disjoint_arraycopy,                address)                               \
300   static_field(StubRoutines,                _arrayof_oop_disjoint_arraycopy,                  address)                               \
301   static_field(StubRoutines,                _arrayof_oop_disjoint_arraycopy_uninit,           address)                               \
302   static_field(StubRoutines,                _checkcast_arraycopy,                             address)                               \
303   static_field(StubRoutines,                _checkcast_arraycopy_uninit,                      address)                               \
304   static_field(StubRoutines,                _unsafe_arraycopy,                                address)                               \
305   static_field(StubRoutines,                _generic_arraycopy,                               address)                               \
306                                                                                                                                      \
307   static_field(StubRoutines,                _aescrypt_encryptBlock,                           address)                               \
308   static_field(StubRoutines,                _aescrypt_decryptBlock,                           address)                               \
309   static_field(StubRoutines,                _cipherBlockChaining_encryptAESCrypt,             address)                               \
310   static_field(StubRoutines,                _cipherBlockChaining_decryptAESCrypt,             address)                               \
311   static_field(StubRoutines,                _electronicCodeBook_encryptAESCrypt,              address)                               \
312   static_field(StubRoutines,                _electronicCodeBook_decryptAESCrypt,              address)                               \
313   static_field(StubRoutines,                _counterMode_AESCrypt,                            address)                               \
314   static_field(StubRoutines,                _galoisCounterMode_AESCrypt,                      address)                               \
315   static_field(StubRoutines,                _base64_encodeBlock,                              address)                               \
316   static_field(StubRoutines,                _base64_decodeBlock,                              address)                               \
317   static_field(StubRoutines,                _ghash_processBlocks,                             address)                               \
318   static_field(StubRoutines,                _sha1_implCompress,                               address)                               \
319   static_field(StubRoutines,                _sha1_implCompressMB,                             address)                               \
320   static_field(StubRoutines,                _sha256_implCompress,                             address)                               \
321   static_field(StubRoutines,                _sha256_implCompressMB,                           address)                               \
322   static_field(StubRoutines,                _sha512_implCompress,                             address)                               \
323   static_field(StubRoutines,                _sha512_implCompressMB,                           address)                               \
324   static_field(StubRoutines,                _updateBytesCRC32,                                address)                               \
325   static_field(StubRoutines,                _crc_table_adr,                                   address)                               \
326   static_field(StubRoutines,                _crc32c_table_addr,                               address)                               \
327   static_field(StubRoutines,                _updateBytesCRC32C,                               address)                               \
328   static_field(StubRoutines,                _updateBytesAdler32,                              address)                               \
329   static_field(StubRoutines,                _multiplyToLen,                                   address)                               \
330   static_field(StubRoutines,                _squareToLen,                                     address)                               \
331   static_field(StubRoutines,                _mulAdd,                                          address)                               \
332   static_field(StubRoutines,                _montgomeryMultiply,                              address)                               \
333   static_field(StubRoutines,                _montgomerySquare,                                address)                               \
334   static_field(StubRoutines,                _vectorizedMismatch,                              address)                               \
335   static_field(StubRoutines,                _bigIntegerRightShiftWorker,                      address)                               \
336   static_field(StubRoutines,                _bigIntegerLeftShiftWorker,                       address)                               \
337   static_field(StubRoutines,                _cont_doYield,                                    address)                               \
338   static_field(StubRoutines,                _cont_thaw,                                       address)                               \
339                                                                                                                                      \
340   nonstatic_field(Thread,                   _tlab,                                            ThreadLocalAllocBuffer)                \
341   nonstatic_field(Thread,                   _allocated_bytes,                                 jlong)                                 \
342                                                                                                                                      \
343   nonstatic_field(ThreadLocalAllocBuffer,   _start,                                           HeapWord*)                             \
344   nonstatic_field(ThreadLocalAllocBuffer,   _top,                                             HeapWord*)                             \
345   nonstatic_field(ThreadLocalAllocBuffer,   _end,                                             HeapWord*)                             \
346   nonstatic_field(ThreadLocalAllocBuffer,   _pf_top,                                          HeapWord*)                             \
347   nonstatic_field(ThreadLocalAllocBuffer,   _desired_size,                                    size_t)                                \
348   nonstatic_field(ThreadLocalAllocBuffer,   _refill_waste_limit,                              size_t)                                \
349   nonstatic_field(ThreadLocalAllocBuffer,   _number_of_refills,                               unsigned)                              \
350   nonstatic_field(ThreadLocalAllocBuffer,   _slow_allocations,                                unsigned)                              \
351                                                                                                                                      \
352   nonstatic_field(SafepointMechanism::ThreadData, _polling_word,                              volatile uintptr_t)                    \
353   nonstatic_field(SafepointMechanism::ThreadData, _polling_page,                              volatile uintptr_t)                    \
354                                                                                                                                      \
355   nonstatic_field(ThreadShadow,             _pending_exception,                               oop)                                   \
356                                                                                                                                      \
357   static_field(Symbol,                      _vm_symbols[0],                                   Symbol*)                               \
358                                                                                                                                      \
359   nonstatic_field(vtableEntry,              _method,                                          Method*)                               \
360 
361 #define VM_TYPES(declare_type, declare_toplevel_type, declare_integer_type, declare_unsigned_integer_type) \
362   declare_integer_type(bool)                                              \
363   declare_unsigned_integer_type(size_t)                                   \
364   declare_integer_type(intx)                                              \
365   declare_unsigned_integer_type(uintx)                                    \
366                                                                           \
367   declare_toplevel_type(BasicLock)                                        \
368   declare_toplevel_type(CompilerToVM)                                     \
369   declare_toplevel_type(ExceptionTableElement)                            \
370   declare_toplevel_type(JVMFlag)                                          \
371   declare_toplevel_type(JVMFlag*)                                         \
372   declare_toplevel_type(InvocationCounter)                                \
373   declare_toplevel_type(JVMCICompileState)                                \
374   declare_toplevel_type(JVMCIEnv)                                         \
375   declare_toplevel_type(LocalVariableTableElement)                        \
376   declare_toplevel_type(narrowKlass)                                      \
377   declare_toplevel_type(ObjectWaiter)                                     \
378   declare_toplevel_type(Symbol*)                                          \
379   declare_toplevel_type(vtableEntry)                                      \
380                                                                           \
381   declare_toplevel_type(oopDesc)                                          \
382     declare_type(arrayOopDesc, oopDesc)                                   \
383                                                                           \
384   declare_toplevel_type(MetaspaceObj)                                     \
385     declare_type(Metadata, MetaspaceObj)                                  \
386     declare_type(Klass, Metadata)                                         \
387       declare_type(InstanceKlass, Klass)                                  \
388     declare_type(ConstantPool, Metadata)                                  \
389 
390 #define VM_INT_CONSTANTS(declare_constant, declare_constant_with_value, declare_preprocessor_constant) \
391   declare_preprocessor_constant("ASSERT", DEBUG_ONLY(1) NOT_DEBUG(0))     \
392   declare_preprocessor_constant("FIELDINFO_TAG_SIZE", FIELDINFO_TAG_SIZE) \
393                                                                           \
394   declare_constant(CompLevel_none)                                        \
395   declare_constant(CompLevel_simple)                                      \
396   declare_constant(CompLevel_limited_profile)                             \
397   declare_constant(CompLevel_full_profile)                                \
398   declare_constant(CompLevel_full_optimization)                           \
399   declare_constant(HeapWordSize)                                          \
400   declare_constant(InvocationEntryBci)                                    \
401   declare_constant(LogKlassAlignmentInBytes)                              \
402   declare_constant(JVMCINMethodData::SPECULATION_LENGTH_BITS)             \
403                                                                           \
404   declare_constant(JVM_ACC_WRITTEN_FLAGS)                                 \
405   declare_constant(JVM_ACC_MONITOR_MATCH)                                 \
406   declare_constant(JVM_ACC_HAS_MONITOR_BYTECODES)                         \
407   declare_constant(JVM_ACC_HAS_FINALIZER)                                 \
408   declare_constant(JVM_ACC_IS_CLONEABLE_FAST)                             \
409   declare_constant(JVM_ACC_IS_HIDDEN_CLASS)                               \
410   declare_constant(JVM_ACC_FIELD_INTERNAL)                                \
411   declare_constant(JVM_ACC_FIELD_STABLE)                                  \
412   declare_constant(JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE)                   \
413   declare_preprocessor_constant("JVM_ACC_VARARGS", JVM_ACC_VARARGS)       \
414   declare_preprocessor_constant("JVM_ACC_BRIDGE", JVM_ACC_BRIDGE)         \
415   declare_preprocessor_constant("JVM_ACC_ANNOTATION", JVM_ACC_ANNOTATION) \
416   declare_preprocessor_constant("JVM_ACC_ENUM", JVM_ACC_ENUM)             \
417   declare_preprocessor_constant("JVM_ACC_SYNTHETIC", JVM_ACC_SYNTHETIC)   \
418   declare_preprocessor_constant("JVM_ACC_INTERFACE", JVM_ACC_INTERFACE)   \
419   declare_preprocessor_constant("JVM_ACC_FIELD_INITIALIZED_FINAL_UPDATE", JVM_ACC_FIELD_INITIALIZED_FINAL_UPDATE) \
420                                                                           \
421   declare_constant(JVM_CONSTANT_Utf8)                                     \
422   declare_constant(JVM_CONSTANT_Unicode)                                  \
423   declare_constant(JVM_CONSTANT_Integer)                                  \
424   declare_constant(JVM_CONSTANT_Float)                                    \
425   declare_constant(JVM_CONSTANT_Long)                                     \
426   declare_constant(JVM_CONSTANT_Double)                                   \
427   declare_constant(JVM_CONSTANT_Class)                                    \
428   declare_constant(JVM_CONSTANT_String)                                   \
429   declare_constant(JVM_CONSTANT_Fieldref)                                 \
430   declare_constant(JVM_CONSTANT_Methodref)                                \
431   declare_constant(JVM_CONSTANT_InterfaceMethodref)                       \
432   declare_constant(JVM_CONSTANT_NameAndType)                              \
433   declare_constant(JVM_CONSTANT_MethodHandle)                             \
434   declare_constant(JVM_CONSTANT_MethodType)                               \
435   declare_constant(JVM_CONSTANT_InvokeDynamic)                            \
436   declare_constant(JVM_CONSTANT_Dynamic)                                  \
437   declare_constant(JVM_CONSTANT_Module)                                   \
438   declare_constant(JVM_CONSTANT_Package)                                  \
439   declare_constant(JVM_CONSTANT_ExternalMax)                              \
440                                                                           \
441   declare_constant(JVM_CONSTANT_Invalid)                                  \
442   declare_constant(JVM_CONSTANT_InternalMin)                              \
443   declare_constant(JVM_CONSTANT_UnresolvedClass)                          \
444   declare_constant(JVM_CONSTANT_ClassIndex)                               \
445   declare_constant(JVM_CONSTANT_StringIndex)                              \
446   declare_constant(JVM_CONSTANT_UnresolvedClassInError)                   \
447   declare_constant(JVM_CONSTANT_MethodHandleInError)                      \
448   declare_constant(JVM_CONSTANT_MethodTypeInError)                        \
449   declare_constant(JVM_CONSTANT_DynamicInError)                           \
450   declare_constant(JVM_CONSTANT_InternalMax)                              \
451                                                                           \
452   declare_constant(ArrayData::array_len_off_set)                          \
453   declare_constant(ArrayData::array_start_off_set)                        \
454                                                                           \
455   declare_constant(BitData::exception_seen_flag)                          \
456   declare_constant(BitData::null_seen_flag)                               \
457   declare_constant(BranchData::not_taken_off_set)                         \
458                                                                           \
459   declare_constant_with_value("CardTable::dirty_card", CardTable::dirty_card_val()) \
460                                                                           \
461   declare_constant(CodeInstaller::VERIFIED_ENTRY)                         \
462   declare_constant(CodeInstaller::UNVERIFIED_ENTRY)                       \
463   declare_constant(CodeInstaller::OSR_ENTRY)                              \
464   declare_constant(CodeInstaller::EXCEPTION_HANDLER_ENTRY)                \
465   declare_constant(CodeInstaller::DEOPT_HANDLER_ENTRY)                    \
466   declare_constant(CodeInstaller::FRAME_COMPLETE)                         \
467   declare_constant(CodeInstaller::INVOKEINTERFACE)                        \
468   declare_constant(CodeInstaller::INVOKEVIRTUAL)                          \
469   declare_constant(CodeInstaller::INVOKESTATIC)                           \
470   declare_constant(CodeInstaller::INVOKESPECIAL)                          \
471   declare_constant(CodeInstaller::INLINE_INVOKE)                          \
472   declare_constant(CodeInstaller::POLL_NEAR)                              \
473   declare_constant(CodeInstaller::POLL_RETURN_NEAR)                       \
474   declare_constant(CodeInstaller::POLL_FAR)                               \
475   declare_constant(CodeInstaller::POLL_RETURN_FAR)                        \
476   declare_constant(CodeInstaller::CARD_TABLE_SHIFT)                       \
477   declare_constant(CodeInstaller::CARD_TABLE_ADDRESS)                     \
478   declare_constant(CodeInstaller::HEAP_TOP_ADDRESS)                       \
479   declare_constant(CodeInstaller::HEAP_END_ADDRESS)                       \
480   declare_constant(CodeInstaller::NARROW_KLASS_BASE_ADDRESS)              \
481   declare_constant(CodeInstaller::NARROW_OOP_BASE_ADDRESS)                \
482   declare_constant(CodeInstaller::CRC_TABLE_ADDRESS)                      \
483   declare_constant(CodeInstaller::LOG_OF_HEAP_REGION_GRAIN_BYTES)         \
484   declare_constant(CodeInstaller::INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED) \
485   declare_constant(CodeInstaller::DEOPT_MH_HANDLER_ENTRY)                 \
486   declare_constant(CodeInstaller::VERIFY_OOP_COUNT_ADDRESS)               \
487   declare_constant(CodeInstaller::VERIFY_OOPS)                            \
488   declare_constant(CodeInstaller::VERIFY_OOP_BITS)                        \
489   declare_constant(CodeInstaller::VERIFY_OOP_MASK)                        \
490   declare_constant(CodeInstaller::INVOKE_INVALID)                         \
491                                                                           \
492   declare_constant(CollectedHeap::None)                                   \
493   declare_constant(CollectedHeap::Serial)                                 \
494   declare_constant(CollectedHeap::Parallel)                               \
495   declare_constant(CollectedHeap::G1)                                     \
496   declare_constant(CollectedHeap::Epsilon)                                \
497   declare_constant(CollectedHeap::Z)                                      \
498   declare_constant(CollectedHeap::Shenandoah)                             \
499                                                                           \
500   declare_constant(vmIntrinsics::FIRST_MH_SIG_POLY)                       \
501   declare_constant(vmIntrinsics::LAST_MH_SIG_POLY)                        \
502   declare_constant(vmIntrinsics::_invokeGeneric)                          \
503   declare_constant(vmIntrinsics::_compiledLambdaForm)                     \
504                                                                           \
505   declare_constant(ConstantPool::CPCACHE_INDEX_TAG)                       \
506   declare_constant(ConstantPool::_has_dynamic_constant)                   \
507                                                                           \
508   declare_constant(ConstMethod::_has_linenumber_table)                    \
509   declare_constant(ConstMethod::_has_localvariable_table)                 \
510   declare_constant(ConstMethod::_has_exception_table)                     \
511   declare_constant(ConstMethod::_has_method_annotations)                  \
512   declare_constant(ConstMethod::_has_parameter_annotations)               \
513                                                                           \
514   declare_constant(CounterData::count_off)                                \
515                                                                           \
516   declare_constant(DataLayout::cell_size)                                 \
517   declare_constant(DataLayout::no_tag)                                    \
518   declare_constant(DataLayout::bit_data_tag)                              \
519   declare_constant(DataLayout::counter_data_tag)                          \
520   declare_constant(DataLayout::jump_data_tag)                             \
521   declare_constant(DataLayout::receiver_type_data_tag)                    \
522   declare_constant(DataLayout::virtual_call_data_tag)                     \
523   declare_constant(DataLayout::ret_data_tag)                              \
524   declare_constant(DataLayout::branch_data_tag)                           \
525   declare_constant(DataLayout::multi_branch_data_tag)                     \
526   declare_constant(DataLayout::arg_info_data_tag)                         \
527   declare_constant(DataLayout::call_type_data_tag)                        \
528   declare_constant(DataLayout::virtual_call_type_data_tag)                \
529   declare_constant(DataLayout::parameters_type_data_tag)                  \
530   declare_constant(DataLayout::speculative_trap_data_tag)                 \
531                                                                           \
532   declare_constant(Deoptimization::Unpack_deopt)                          \
533   declare_constant(Deoptimization::Unpack_exception)                      \
534   declare_constant(Deoptimization::Unpack_uncommon_trap)                  \
535   declare_constant(Deoptimization::Unpack_reexecute)                      \
536                                                                           \
537   declare_constant(Deoptimization::_action_bits)                          \
538   declare_constant(Deoptimization::_reason_bits)                          \
539   declare_constant(Deoptimization::_debug_id_bits)                        \
540   declare_constant(Deoptimization::_action_shift)                         \
541   declare_constant(Deoptimization::_reason_shift)                         \
542   declare_constant(Deoptimization::_debug_id_shift)                       \
543                                                                           \
544   declare_constant(Deoptimization::Action_none)                           \
545   declare_constant(Deoptimization::Action_maybe_recompile)                \
546   declare_constant(Deoptimization::Action_reinterpret)                    \
547   declare_constant(Deoptimization::Action_make_not_entrant)               \
548   declare_constant(Deoptimization::Action_make_not_compilable)            \
549                                                                           \
550   declare_constant(Deoptimization::Reason_none)                           \
551   declare_constant(Deoptimization::Reason_null_check)                     \
552   declare_constant(Deoptimization::Reason_range_check)                    \
553   declare_constant(Deoptimization::Reason_class_check)                    \
554   declare_constant(Deoptimization::Reason_array_check)                    \
555   declare_constant(Deoptimization::Reason_unreached0)                     \
556   declare_constant(Deoptimization::Reason_constraint)                     \
557   declare_constant(Deoptimization::Reason_div0_check)                     \
558   declare_constant(Deoptimization::Reason_loop_limit_check)               \
559   declare_constant(Deoptimization::Reason_type_checked_inlining)          \
560   declare_constant(Deoptimization::Reason_optimized_type_check)           \
561   declare_constant(Deoptimization::Reason_aliasing)                       \
562   declare_constant(Deoptimization::Reason_transfer_to_interpreter)        \
563   declare_constant(Deoptimization::Reason_not_compiled_exception_handler) \
564   declare_constant(Deoptimization::Reason_unresolved)                     \
565   declare_constant(Deoptimization::Reason_jsr_mismatch)                   \
566   declare_constant(Deoptimization::Reason_LIMIT)                          \
567   declare_constant(Deoptimization::_support_large_access_byte_array_virtualization)               \
568                                                                           \
569   declare_constant(FieldInfo::access_flags_offset)                        \
570   declare_constant(FieldInfo::name_index_offset)                          \
571   declare_constant(FieldInfo::signature_index_offset)                     \
572   declare_constant(FieldInfo::initval_index_offset)                       \
573   declare_constant(FieldInfo::low_packed_offset)                          \
574   declare_constant(FieldInfo::high_packed_offset)                         \
575   declare_constant(FieldInfo::field_slots)                                \
576                                                                           \
577   declare_constant(InstanceKlass::linked)                                 \
578   declare_constant(InstanceKlass::being_initialized)                      \
579   declare_constant(InstanceKlass::fully_initialized)                      \
580                                                                           \
581   /*********************************/                                     \
582   /* InstanceKlass _misc_flags */                                         \
583   /*********************************/                                     \
584                                                                           \
585   declare_constant(InstanceKlass::_misc_has_nonstatic_concrete_methods)   \
586   declare_constant(InstanceKlass::_misc_declares_nonstatic_concrete_methods) \
587                                                                           \
588   declare_constant(JumpData::taken_off_set)                               \
589   declare_constant(JumpData::displacement_off_set)                        \
590                                                                           \
591   declare_preprocessor_constant("JVMCI::ok",                      JVMCI::ok)                      \
592   declare_preprocessor_constant("JVMCI::dependencies_failed",     JVMCI::dependencies_failed)     \
593   declare_preprocessor_constant("JVMCI::cache_full",              JVMCI::cache_full)              \
594   declare_preprocessor_constant("JVMCI::code_too_large",          JVMCI::code_too_large)          \
595   declare_preprocessor_constant("JVMCI::nmethod_reclaimed",       JVMCI::nmethod_reclaimed)       \
596   declare_preprocessor_constant("JVMCI::first_permanent_bailout", JVMCI::first_permanent_bailout) \
597                                                                           \
598   declare_constant(JVMCIRuntime::none)                                    \
599   declare_constant(JVMCIRuntime::by_holder)                               \
600   declare_constant(JVMCIRuntime::by_full_signature)                       \
601                                                                           \
602   declare_constant(Klass::_lh_neutral_value)                              \
603   declare_constant(Klass::_lh_instance_slow_path_bit)                     \
604   declare_constant(Klass::_lh_log2_element_size_shift)                    \
605   declare_constant(Klass::_lh_log2_element_size_mask)                     \
606   declare_constant(Klass::_lh_element_type_shift)                         \
607   declare_constant(Klass::_lh_element_type_mask)                          \
608   declare_constant(Klass::_lh_header_size_shift)                          \
609   declare_constant(Klass::_lh_header_size_mask)                           \
610   declare_constant(Klass::_lh_array_tag_shift)                            \
611   declare_constant(Klass::_lh_array_tag_type_value)                       \
612   declare_constant(Klass::_lh_array_tag_obj_value)                        \
613                                                                           \
614   declare_constant(markWord::no_hash)                                     \
615                                                                           \
616   declare_constant(Method::_caller_sensitive)                             \
617   declare_constant(Method::_force_inline)                                 \
618   declare_constant(Method::_dont_inline)                                  \
619   declare_constant(Method::_hidden)                                       \
620   declare_constant(Method::_intrinsic_candidate)                          \
621   declare_constant(Method::_reserved_stack_access)                        \
622   declare_constant(Method::_changes_current_thread)                       \
623                                                                           \
624   declare_constant(Method::nonvirtual_vtable_index)                       \
625   declare_constant(Method::invalid_vtable_index)                          \
626                                                                           \
627   declare_constant(MultiBranchData::per_case_cell_count)                  \
628                                                                           \
629   declare_constant(ReceiverTypeData::nonprofiled_count_off_set)           \
630   declare_constant(ReceiverTypeData::receiver_type_row_cell_count)        \
631   declare_constant(ReceiverTypeData::receiver0_offset)                    \
632   declare_constant(ReceiverTypeData::count0_offset)                       \
633                                                                           \
634   declare_constant(vmIntrinsics::_invokeBasic)                            \
635   declare_constant(vmIntrinsics::_linkToVirtual)                          \
636   declare_constant(vmIntrinsics::_linkToStatic)                           \
637   declare_constant(vmIntrinsics::_linkToSpecial)                          \
638   declare_constant(vmIntrinsics::_linkToInterface)                        \
639                                                                           \
640   declare_constant(vmSymbols::FIRST_SID)                                  \
641   declare_constant(vmSymbols::SID_LIMIT)                                  \
642 
643 #define VM_LONG_CONSTANTS(declare_constant, declare_preprocessor_constant) \
644   declare_constant(InvocationCounter::count_increment)                    \
645   declare_constant(InvocationCounter::count_shift)                        \
646                                                                           \
647   declare_constant(markWord::hash_shift)                                  \
648   declare_constant(markWord::monitor_value)                               \
649                                                                           \
650   declare_constant(markWord::age_mask_in_place)                           \
651   declare_constant(markWord::hash_mask)                                   \
652   declare_constant(markWord::hash_mask_in_place)                          \
653                                                                           \
654   declare_constant(markWord::unlocked_value)                              \
655                                                                           \
656   declare_constant(markWord::no_hash_in_place)                            \
657   declare_constant(markWord::no_lock_in_place)                            \
658 
659 #define VM_ADDRESSES(declare_address, declare_preprocessor_address, declare_function) \
660   declare_function(SharedRuntime::register_finalizer)                     \
661   declare_function(SharedRuntime::exception_handler_for_return_address)   \
662   declare_function(SharedRuntime::OSR_migration_end)                      \
663   declare_function(SharedRuntime::enable_stack_reserved_zone)             \
664   declare_function(SharedRuntime::frem)                                   \
665   declare_function(SharedRuntime::drem)                                   \
666                                                                           \
667   declare_function(os::dll_load)                                          \
668   declare_function(os::dll_lookup)                                        \
669   declare_function(os::javaTimeMillis)                                    \
670   declare_function(os::javaTimeNanos)                                     \
671                                                                           \
672   declare_function(Deoptimization::fetch_unroll_info)                     \
673   declare_function(Deoptimization::uncommon_trap)                         \
674   declare_function(Deoptimization::unpack_frames)                         \
675                                                                           \
676   declare_function(JVMCIRuntime::new_instance) \
677   declare_function(JVMCIRuntime::new_array) \
678   declare_function(JVMCIRuntime::new_multi_array) \
679   declare_function(JVMCIRuntime::dynamic_new_array) \
680   declare_function(JVMCIRuntime::dynamic_new_instance) \
681   \
682   declare_function(JVMCIRuntime::new_instance_or_null) \
683   declare_function(JVMCIRuntime::new_array_or_null) \
684   declare_function(JVMCIRuntime::new_multi_array_or_null) \
685   declare_function(JVMCIRuntime::dynamic_new_array_or_null) \
686   declare_function(JVMCIRuntime::dynamic_new_instance_or_null) \
687   \
688   declare_function(JVMCIRuntime::invoke_static_method_one_arg) \
689   \
690   declare_function(JVMCIRuntime::vm_message) \
691   declare_function(JVMCIRuntime::identity_hash_code) \
692   declare_function(JVMCIRuntime::exception_handler_for_pc) \
693   declare_function(JVMCIRuntime::monitorenter) \
694   declare_function(JVMCIRuntime::monitorexit) \
695   declare_function(JVMCIRuntime::object_notify) \
696   declare_function(JVMCIRuntime::object_notifyAll) \
697   declare_function(JVMCIRuntime::throw_and_post_jvmti_exception) \
698   declare_function(JVMCIRuntime::throw_klass_external_name_exception) \
699   declare_function(JVMCIRuntime::throw_class_cast_exception) \
700   declare_function(JVMCIRuntime::log_primitive) \
701   declare_function(JVMCIRuntime::log_object) \
702   declare_function(JVMCIRuntime::log_printf) \
703   declare_function(JVMCIRuntime::vm_error) \
704   declare_function(JVMCIRuntime::load_and_clear_exception) \
705   G1GC_ONLY(declare_function(JVMCIRuntime::write_barrier_pre)) \
706   G1GC_ONLY(declare_function(JVMCIRuntime::write_barrier_post)) \
707   declare_function(JVMCIRuntime::validate_object) \
708   \
709   declare_function(JVMCIRuntime::test_deoptimize_call_int)
710 
711 
712 #if INCLUDE_G1GC
713 
714 #define VM_STRUCTS_JVMCI_G1GC(nonstatic_field, static_field) \
715   static_field(HeapRegion, LogOfHRGrainBytes, int)
716 
717 #define VM_INT_CONSTANTS_JVMCI_G1GC(declare_constant, declare_constant_with_value, declare_preprocessor_constant) \
718   declare_constant_with_value("G1CardTable::g1_young_gen", G1CardTable::g1_young_card_val()) \
719   declare_constant_with_value("G1ThreadLocalData::satb_mark_queue_active_offset", in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset())) \
720   declare_constant_with_value("G1ThreadLocalData::satb_mark_queue_index_offset", in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset())) \
721   declare_constant_with_value("G1ThreadLocalData::satb_mark_queue_buffer_offset", in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset())) \
722   declare_constant_with_value("G1ThreadLocalData::dirty_card_queue_index_offset", in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset())) \
723   declare_constant_with_value("G1ThreadLocalData::dirty_card_queue_buffer_offset", in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset()))
724 
725 #endif // INCLUDE_G1GC
726 
727 
728 #ifdef LINUX
729 
730 #define VM_ADDRESSES_OS(declare_address, declare_preprocessor_address, declare_function) \
731   declare_preprocessor_address("RTLD_DEFAULT", RTLD_DEFAULT)
732 
733 #endif
734 
735 
736 #ifdef BSD
737 
738 #define VM_ADDRESSES_OS(declare_address, declare_preprocessor_address, declare_function) \
739   declare_preprocessor_address("RTLD_DEFAULT", RTLD_DEFAULT)
740 
741 #endif
742 
743 #ifdef AARCH64
744 
745 #define VM_STRUCTS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \
746   static_field(VM_Version, _zva_length, int)                            \
747   volatile_nonstatic_field(JavaFrameAnchor, _last_Java_fp, intptr_t*)
748 
749 #define DECLARE_INT_CPU_FEATURE_CONSTANT(id, name, bit) GENERATE_VM_INT_CONSTANT_ENTRY(VM_Version::CPU_##id)
750 #define VM_INT_CPU_FEATURE_CONSTANTS CPU_FEATURE_FLAGS(DECLARE_INT_CPU_FEATURE_CONSTANT)
751 
752 #endif
753 
754 #ifdef X86
755 
756 #define VM_STRUCTS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \
757   volatile_nonstatic_field(JavaFrameAnchor, _last_Java_fp, intptr_t*) \
758   static_field(VM_Version, _has_intel_jcc_erratum, bool)
759 
760 #define VM_INT_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \
761   LP64_ONLY(declare_constant(frame::arg_reg_save_area_bytes))       \
762   declare_constant(frame::interpreter_frame_sender_sp_offset)       \
763   declare_constant(frame::interpreter_frame_last_sp_offset)
764 
765 #define DECLARE_LONG_CPU_FEATURE_CONSTANT(id, name, bit) GENERATE_VM_LONG_CONSTANT_ENTRY(VM_Version::CPU_##id)
766 #define VM_LONG_CPU_FEATURE_CONSTANTS CPU_FEATURE_FLAGS(DECLARE_LONG_CPU_FEATURE_CONSTANT)
767 
768 #endif
769 
770 /*
771  * Dummy defines for architectures that don't use these.
772  */
773 #ifndef VM_STRUCTS_CPU
774 #define VM_STRUCTS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field)
775 #endif
776 
777 #ifndef VM_INT_CONSTANTS_CPU
778 #define VM_INT_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
779 #endif
780 
781 #ifndef VM_LONG_CONSTANTS_CPU
782 #define VM_LONG_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
783 #endif
784 
785 #ifndef VM_ADDRESSES_OS
786 #define VM_ADDRESSES_OS(declare_address, declare_preprocessor_address, declare_function)
787 #endif
788 
789 //
790 // Instantiation of VMStructEntries, VMTypeEntries and VMIntConstantEntries
791 //
792 
793 // These initializers are allowed to access private fields in classes
794 // as long as class VMStructs is a friend
795 VMStructEntry JVMCIVMStructs::localHotSpotVMStructs[] = {
796   VM_STRUCTS(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
797              GENERATE_STATIC_VM_STRUCT_ENTRY,
798              GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY,
799              GENERATE_NONSTATIC_VM_STRUCT_ENTRY)
800 
801   VM_STRUCTS_CPU(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
802                  GENERATE_STATIC_VM_STRUCT_ENTRY,
803                  GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY,
804                  GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
805                  GENERATE_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY,
806                  GENERATE_C2_NONSTATIC_VM_STRUCT_ENTRY,
807                  GENERATE_C1_UNCHECKED_STATIC_VM_STRUCT_ENTRY,
808                  GENERATE_C2_UNCHECKED_STATIC_VM_STRUCT_ENTRY)
809 
810 #if INCLUDE_G1GC
811   VM_STRUCTS_JVMCI_G1GC(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
812                         GENERATE_STATIC_VM_STRUCT_ENTRY)
813 #endif
814 
815   GENERATE_VM_STRUCT_LAST_ENTRY()
816 };
817 
818 VMTypeEntry JVMCIVMStructs::localHotSpotVMTypes[] = {
819   VM_TYPES(GENERATE_VM_TYPE_ENTRY,
820            GENERATE_TOPLEVEL_VM_TYPE_ENTRY,
821            GENERATE_INTEGER_VM_TYPE_ENTRY,
822            GENERATE_UNSIGNED_INTEGER_VM_TYPE_ENTRY)
823 
824   GENERATE_VM_TYPE_LAST_ENTRY()
825 };
826 
827 VMIntConstantEntry JVMCIVMStructs::localHotSpotVMIntConstants[] = {
828   VM_INT_CONSTANTS(GENERATE_VM_INT_CONSTANT_ENTRY,
829                    GENERATE_VM_INT_CONSTANT_WITH_VALUE_ENTRY,
830                    GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY)
831 
832   VM_INT_CONSTANTS_CPU(GENERATE_VM_INT_CONSTANT_ENTRY,
833                        GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY,
834                        GENERATE_C1_VM_INT_CONSTANT_ENTRY,
835                        GENERATE_C2_VM_INT_CONSTANT_ENTRY,
836                        GENERATE_C2_PREPROCESSOR_VM_INT_CONSTANT_ENTRY)
837 
838 #if INCLUDE_G1GC
839   VM_INT_CONSTANTS_JVMCI_G1GC(GENERATE_VM_INT_CONSTANT_ENTRY,
840                               GENERATE_VM_INT_CONSTANT_WITH_VALUE_ENTRY,
841                               GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY)
842 #endif
843 #ifdef VM_INT_CPU_FEATURE_CONSTANTS
844   VM_INT_CPU_FEATURE_CONSTANTS
845 #endif
846   GENERATE_VM_INT_CONSTANT_LAST_ENTRY()
847 };
848 
849 VMLongConstantEntry JVMCIVMStructs::localHotSpotVMLongConstants[] = {
850   VM_LONG_CONSTANTS(GENERATE_VM_LONG_CONSTANT_ENTRY,
851                     GENERATE_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY)
852 
853   VM_LONG_CONSTANTS_CPU(GENERATE_VM_LONG_CONSTANT_ENTRY,
854                         GENERATE_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY,
855                         GENERATE_C1_VM_LONG_CONSTANT_ENTRY,
856                         GENERATE_C2_VM_LONG_CONSTANT_ENTRY,
857                         GENERATE_C2_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY)
858 #ifdef VM_LONG_CPU_FEATURE_CONSTANTS
859   VM_LONG_CPU_FEATURE_CONSTANTS
860 #endif
861   GENERATE_VM_LONG_CONSTANT_LAST_ENTRY()
862 };
863 #undef DECLARE_CPU_FEATURE_FLAG
864 
865 VMAddressEntry JVMCIVMStructs::localHotSpotVMAddresses[] = {
866   VM_ADDRESSES(GENERATE_VM_ADDRESS_ENTRY,
867                GENERATE_PREPROCESSOR_VM_ADDRESS_ENTRY,
868                GENERATE_VM_FUNCTION_ENTRY)
869   VM_ADDRESSES_OS(GENERATE_VM_ADDRESS_ENTRY,
870                   GENERATE_PREPROCESSOR_VM_ADDRESS_ENTRY,
871                   GENERATE_VM_FUNCTION_ENTRY)
872 
873   GENERATE_VM_ADDRESS_LAST_ENTRY()
874 };
875 
876 int JVMCIVMStructs::localHotSpotVMStructs_count() {
877   // Ignore sentinel entry at the end
878   return (sizeof(localHotSpotVMStructs) / sizeof(VMStructEntry)) - 1;
879 }
880 int JVMCIVMStructs::localHotSpotVMTypes_count() {
881   // Ignore sentinel entry at the end
882   return (sizeof(localHotSpotVMTypes) / sizeof(VMTypeEntry)) - 1;
883 }
884 int JVMCIVMStructs::localHotSpotVMIntConstants_count() {
885   // Ignore sentinel entry at the end
886   return (sizeof(localHotSpotVMIntConstants) / sizeof(VMIntConstantEntry)) - 1;
887 }
888 int JVMCIVMStructs::localHotSpotVMLongConstants_count() {
889   // Ignore sentinel entry at the end
890   return (sizeof(localHotSpotVMLongConstants) / sizeof(VMLongConstantEntry)) - 1;
891 }
892 int JVMCIVMStructs::localHotSpotVMAddresses_count() {
893   // Ignore sentinel entry at the end
894   return (sizeof(localHotSpotVMAddresses) / sizeof(VMAddressEntry)) - 1;
895 }
896 
897 extern "C" {
898 JNIEXPORT VMStructEntry* jvmciHotSpotVMStructs = JVMCIVMStructs::localHotSpotVMStructs;
899 JNIEXPORT VMTypeEntry* jvmciHotSpotVMTypes = JVMCIVMStructs::localHotSpotVMTypes;
900 JNIEXPORT VMIntConstantEntry* jvmciHotSpotVMIntConstants = JVMCIVMStructs::localHotSpotVMIntConstants;
901 JNIEXPORT VMLongConstantEntry* jvmciHotSpotVMLongConstants = JVMCIVMStructs::localHotSpotVMLongConstants;
902 JNIEXPORT VMAddressEntry* jvmciHotSpotVMAddresses = JVMCIVMStructs::localHotSpotVMAddresses;
903 }
904 
905 #ifdef ASSERT
906 // This is used both to check the types of referenced fields and
907 // to ensure that all of the field types are present.
908 void JVMCIVMStructs::init() {
909   VM_STRUCTS(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
910              CHECK_STATIC_VM_STRUCT_ENTRY,
911              CHECK_NO_OP,
912              CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY);
913 
914 
915   VM_STRUCTS_CPU(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
916                  CHECK_STATIC_VM_STRUCT_ENTRY,
917                  CHECK_NO_OP,
918                  CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
919                  CHECK_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY,
920                  CHECK_C2_NONSTATIC_VM_STRUCT_ENTRY,
921                  CHECK_NO_OP,
922                  CHECK_NO_OP);
923 
924 #if INCLUDE_G1GC
925   VM_STRUCTS_JVMCI_G1GC(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
926                         CHECK_STATIC_VM_STRUCT_ENTRY)
927 #endif
928 
929   VM_TYPES(CHECK_VM_TYPE_ENTRY,
930            CHECK_SINGLE_ARG_VM_TYPE_NO_OP,
931            CHECK_SINGLE_ARG_VM_TYPE_NO_OP,
932            CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
933 }
934 
935 void jvmci_vmStructs_init() {
936   JVMCIVMStructs::init();
937 }
938 #endif // ASSERT