1 /*
  2  * Copyright (c) 2012, 2022, 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_JVMCI_JVMCIRUNTIME_HPP
 25 #define SHARE_JVMCI_JVMCIRUNTIME_HPP
 26 
 27 #include "jvm_io.h"
 28 #include "code/nmethod.hpp"
 29 #include "gc/shared/collectedHeap.hpp"
 30 #include "jvmci/jvmci.hpp"
 31 #include "jvmci/jvmciExceptions.hpp"
 32 #include "jvmci/jvmciObject.hpp"
 33 #include "utilities/linkedlist.hpp"
 34 #if INCLUDE_G1GC
 35 #include "gc/g1/g1CardTable.hpp"
 36 #endif // INCLUDE_G1GC
 37 
 38 class JVMCIEnv;
 39 class JVMCICompiler;
 40 class JVMCICompileState;
 41 class MetadataHandles;
 42 
 43 // Encapsulates the JVMCI metadata for an nmethod.
 44 // JVMCINMethodData objects are inlined into nmethods
 45 // at nmethod::_jvmci_data_offset.
 46 class JVMCINMethodData {
 47   friend class JVMCIVMStructs;
 48   // Index for the HotSpotNmethod mirror in the nmethod's oops table.
 49   // This is -1 if there is no mirror in the oops table.
 50   int _nmethod_mirror_index;
 51 
 52   // Is HotSpotNmethod.name non-null? If so, the value is
 53   // embedded in the end of this object.
 54   bool _has_name;
 55 
 56   // Address of the failed speculations list to which a speculation
 57   // is appended when it causes a deoptimization.
 58   FailedSpeculation** _failed_speculations;
 59 
 60   // A speculation id is a length (low 5 bits) and an index into
 61   // a jbyte array (i.e. 31 bits for a positive Java int).
 62   enum {
 63     // Keep in sync with HotSpotSpeculationEncoding.
 64     SPECULATION_LENGTH_BITS = 5,
 65     SPECULATION_LENGTH_MASK = (1 << SPECULATION_LENGTH_BITS) - 1
 66   };
 67 
 68 public:
 69   // Computes the size of a JVMCINMethodData object
 70   static int compute_size(const char* nmethod_mirror_name) {
 71     int size = sizeof(JVMCINMethodData);
 72     if (nmethod_mirror_name != NULL) {
 73       size += (int) strlen(nmethod_mirror_name) + 1;
 74     }
 75     return size;
 76   }
 77 
 78   void initialize(int nmethod_mirror_index,
 79              const char* name,
 80              FailedSpeculation** failed_speculations);
 81 
 82   // Adds `speculation` to the failed speculations list.
 83   void add_failed_speculation(nmethod* nm, jlong speculation);
 84 
 85   // Gets the JVMCI name of the nmethod (which may be NULL).
 86   const char* name() { return _has_name ? (char*)(((address) this) + sizeof(JVMCINMethodData)) : NULL; }
 87 
 88   // Clears the HotSpotNmethod.address field in the  mirror. If nm
 89   // is dead, the HotSpotNmethod.entryPoint field is also cleared.
 90   void invalidate_nmethod_mirror(nmethod* nm);
 91 
 92   // Gets the mirror from nm's oops table.
 93   oop get_nmethod_mirror(nmethod* nm, bool phantom_ref);
 94 
 95   // Sets the mirror in nm's oops table.
 96   void set_nmethod_mirror(nmethod* nm, oop mirror);
 97 };
 98 
 99 // A top level class that represents an initialized JVMCI runtime.
100 // There is one instance of this class per HotSpotJVMCIRuntime object.
101 class JVMCIRuntime: public CHeapObj<mtJVMCI> {
102   friend class JVMCI;
103   friend class JavaVMRefsInitialization;
104  public:
105   // Constants describing whether JVMCI wants to be able to adjust the compilation
106   // level selected for a method by the VM compilation policy and if so, based on
107   // what information about the method being schedule for compilation.
108   enum CompLevelAdjustment {
109      none = 0,             // no adjustment
110      by_holder = 1,        // adjust based on declaring class of method
111      by_full_signature = 2 // adjust based on declaring class, name and signature of method
112   };
113 
114  private:
115 
116   enum InitState {
117     uninitialized,
118     being_initialized,
119     fully_initialized
120   };
121 
122   // Initialization state of this JVMCIRuntime.
123   InitState _init_state;
124 
125   // Initialization state of the references to classes, methods
126   // and fields in the JVMCI shared library.
127   static InitState _shared_library_javavm_refs_init_state;
128 
129   // Initialization state of the references to classes, methods
130   // and fields in HotSpot metadata.
131   static InitState _hotspot_javavm_refs_init_state;
132 
133   // A wrapper for a VM scoped JNI global handle (i.e. JVMCIEnv::make_global)
134   // to a HotSpotJVMCIRuntime instance. This JNI global handle must never
135   // be explicitly destroyed as it can be accessed in a racy way during
136   // JVMCI shutdown. Furthermore, it will be reclaimed when
137   // the VM or shared library JavaVM managing the handle dies.
138   JVMCIObject _HotSpotJVMCIRuntime_instance;
139 
140   // Lock for operations that may be performed by
141   // any thread attached this runtime. To avoid deadlock,
142   // this lock must always be acquired before JVMCI_lock.
143   Monitor* _lock;
144 
145   // Result of calling JNI_CreateJavaVM in the JVMCI shared library.
146   // Must only be mutated under _lock.
147   JavaVM* _shared_library_javavm;
148 
149   // Id for _shared_library_javavm.
150   int _shared_library_javavm_id;
151 
152   // Position and link in global list of JVMCI shared library runtimes.
153   // The HotSpot heap based runtime will have an id of -1 and the
154   // runtime reserved for threads attaching during JVMCI shutdown
155   // will have an id of -2.
156   int _id;
157   JVMCIRuntime* _next;
158 
159   // Handles to Metadata objects.
160   MetadataHandles* _metadata_handles;
161 
162   // List of oop handles allocated via make_oop_handle. This is to support
163   // destroying remaining oop handles when the JavaVM associated
164   // with this runtime is shutdown.
165   GrowableArray<oop*> _oop_handles;
166 
167   // Number of threads attached or about to be attached to this runtime.
168   // Must only be mutated under JVMCI_lock to facilitate safely moving
169   // threads between JVMCI runtimes. A value of -1 implies this runtime is
170   // not available to be attached to another thread because it is in the
171   // process of shutting down and destroying its JavaVM.
172   int _num_attached_threads;
173   static const int cannot_be_attached = -1;
174 
175   // Is this runtime for threads managed by the CompileBroker?
176   // Examples of non-CompileBroker threads are CompileTheWorld threads
177   // or Truffle compilation threads.
178   bool _for_compile_broker;
179 
180   JVMCIObject create_jvmci_primitive_type(BasicType type, JVMCI_TRAPS);
181 
182   // Implementation methods for loading and constant pool access.
183   static Klass* get_klass_by_name_impl(Klass*& accessing_klass,
184                                        const constantPoolHandle& cpool,
185                                        Symbol* klass_name,
186                                        bool require_local);
187   static Klass*   get_klass_by_index_impl(const constantPoolHandle& cpool,
188                                           int klass_index,
189                                           bool& is_accessible,
190                                           Klass* loading_klass);
191   static void   get_field_by_index_impl(InstanceKlass* loading_klass, fieldDescriptor& fd,
192                                         int field_index);
193   static Method*  get_method_by_index_impl(const constantPoolHandle& cpool,
194                                            int method_index, Bytecodes::Code bc,
195                                            InstanceKlass* loading_klass);
196 
197   // Helper methods
198   static bool       check_klass_accessibility(Klass* accessing_klass, Klass* resolved_klass);
199   static Method*    lookup_method(InstanceKlass*  accessor,
200                                   Klass*  holder,
201                                   Symbol*         name,
202                                   Symbol*         sig,
203                                   Bytecodes::Code bc,
204                                   constantTag     tag);
205 
206   // Helpers for `for_thread`.
207 
208   // Selects an existing runtime (except for `skip`) that has
209   // fewer than JVMCI::max_threads_per_runtime() attached threads.
210   // If such a runtime exists, its _num_attached_threads is incremented
211   // and the caller must subsequently attach `thread` to it.
212   // JVMCI_lock must be held by current thread.
213   // If nullptr is returned, then `*count` contains the number of JVMCIRuntimes
214   // currently allocated.
215   static JVMCIRuntime* select_runtime(JavaThread* thread, JVMCIRuntime* skip, int* count);
216 
217   // Selects an existing runtime for `thread` or creates a new one if
218   // no applicable runtime exists.
219   // JVMCI_lock must be held by current thread
220   static JVMCIRuntime* select_or_create_runtime(JavaThread* thread);
221 
222   // Selects an existing runtime for `thread` when in JVMCI shutdown.
223   // JVMCI_lock must be held by current thread
224   static JVMCIRuntime* select_runtime_in_shutdown(JavaThread* thread);
225 
226   // Releases all the non-null entries in _oop_handles and then clears
227   // the list. Returns the number released handles.
228   int release_and_clear_oop_handles();
229 
230  public:
231   JVMCIRuntime(JVMCIRuntime* next, int id, bool for_compile_broker);
232 
233   int id() const        { return _id;   }
234   Monitor* lock() const { return _lock; }
235 
236   // Ensures that a JVMCI shared library JavaVM exists for this runtime.
237   // If the JavaVM was created by this call, then the thread-local JNI
238   // interface pointer for the JavaVM is returned otherwise nullptr is returned.
239   JNIEnv* init_shared_library_javavm();
240 
241   // Determines if the JVMCI shared library JavaVM exists for this runtime.
242   bool has_shared_library_javavm() { return _shared_library_javavm != nullptr; }
243 
244   // Gets an ID for the JVMCI shared library JavaVM associated with this runtime.
245   int get_shared_library_javavm_id() { return _shared_library_javavm_id; }
246 
247   // Copies info about the JVMCI shared library JavaVM associated with this
248   // runtime into `info` as follows:
249   // {
250   //     javaVM, // the {@code JavaVM*} value
251   //     javaVM->functions->reserved0,
252   //     javaVM->functions->reserved1,
253   //     javaVM->functions->reserved2
254   // }
255   void init_JavaVM_info(jlongArray info, JVMCI_TRAPS);
256 
257   // Wrappers for calling Invocation Interface functions on the
258   // JVMCI shared library JavaVM associated with this runtime.
259   // These wrappers ensure all required thread state transitions are performed.
260   jint AttachCurrentThread(JavaThread* thread, void **penv, void *args);
261   jint AttachCurrentThreadAsDaemon(JavaThread* thread, void **penv, void *args);
262   jint DetachCurrentThread(JavaThread* thread);
263   jint GetEnv(JavaThread* thread, void **penv, jint version);
264 
265   // Compute offsets and construct any state required before executing JVMCI code.
266   void initialize(JVMCIEnv* jvmciEnv);
267 
268   // Allocation and management of handles to HotSpot heap objects
269   // whose lifetime is scoped by this JVMCIRuntime. The max lifetime
270   // of these handles is the same as the JVMCI shared library JavaVM
271   // associated with this JVMCIRuntime. These JNI handles are
272   // used when creating an IndirectHotSpotObjectConstantImpl in the
273   // shared library JavaVM.
274   jlong make_oop_handle(const Handle& obj);
275 
276   // Releases all the non-null entries in _oop_handles whose referent is null.
277   // Returns the number of handles released by this call.
278   // The method also resets _last_found_oop_handle_index to -1
279   // and _null_oop_handles to 0.
280   int release_cleared_oop_handles();
281 
282   // Allocation and management of metadata handles.
283   jmetadata allocate_handle(const methodHandle& handle);
284   jmetadata allocate_handle(const constantPoolHandle& handle);
285   void release_handle(jmetadata handle);
286 
287   // Finds a JVMCI runtime for `thread`. A new JVMCI runtime is created if
288   // there are none currently available with JVMCI::max_threads_per_runtime()
289   // or fewer attached threads.
290   static JVMCIRuntime* for_thread(JavaThread* thread);
291 
292   // Finds the JVMCI runtime owning `javavm` and attaches `thread` to it.
293   // Returns an error message if attaching fails.
294   static const char* attach_shared_library_thread(JavaThread* thread, JavaVM* javaVM);
295 
296   // Reserves a slot in this runtime for `thread` to prevent it being
297   // shutdown before `thread` is attached. JVMCI_lock must be held
298   // and the caller must call `attach_thread` upon releasing it.
299   void pre_attach_thread(JavaThread* thread);
300 
301   // Attaches `thread` to this runtime.
302   void attach_thread(JavaThread* thread);
303 
304   // Detaches `thread` from this runtime.
305   // Returns whether DestroyJavaVM was called on the JavaVM associated
306   // with this runtime as a result of detaching.
307   // The `can_destroy_javavm` is false when in the scope of
308   // a down call from the JVMCI shared library JavaVM. Since the scope
309   // will return to the shared library JavaVM, the JavaVM must not be destroyed.
310   bool detach_thread(JavaThread* thread, const char* reason, bool can_destroy_javavm=true);
311 
312   // If `thread` is the last thread attached to this runtime,
313   // move it to another runtime with an existing JavaVM and available capacity
314   // if possible, thus allowing this runtime to release its JavaVM.
315   void repack(JavaThread* thread);
316 
317   // Gets the HotSpotJVMCIRuntime instance for this runtime,
318   // initializing it first if necessary.
319   JVMCIObject get_HotSpotJVMCIRuntime(JVMCI_TRAPS);
320 
321   bool is_HotSpotJVMCIRuntime_initialized() {
322     return _HotSpotJVMCIRuntime_instance.is_non_null();
323   }
324 
325   // Gets the current HotSpotJVMCIRuntime instance for this runtime which
326   // may be a "null" JVMCIObject value.
327   JVMCIObject probe_HotSpotJVMCIRuntime() {
328     return _HotSpotJVMCIRuntime_instance;
329   }
330 
331   // Trigger initialization of HotSpotJVMCIRuntime through JVMCI.getRuntime()
332   void initialize_JVMCI(JVMCI_TRAPS);
333 
334   // Explicitly initialize HotSpotJVMCIRuntime itself
335   void initialize_HotSpotJVMCIRuntime(JVMCI_TRAPS);
336 
337   void call_getCompiler(TRAPS);
338 
339   // Shuts down this runtime by calling HotSpotJVMCIRuntime.shutdown().
340   // If this is the last thread attached to this runtime, then
341   // `_HotSpotJVMCIRuntime_instance` is set to nullptr and `_init_state`
342   // to uninitialized.
343   void shutdown();
344 
345   // Destroys the JVMCI shared library JavaVM attached to this runtime.
346   // Return true iff DestroyJavaVM was called on the JavaVM.
347   bool destroy_shared_library_javavm();
348 
349   void bootstrap_finished(TRAPS);
350 
351   // Look up a klass by name from a particular class loader (the accessor's).
352   // If require_local, result must be defined in that class loader, or NULL.
353   // If !require_local, a result from remote class loader may be reported,
354   // if sufficient class loader constraints exist such that initiating
355   // a class loading request from the given loader is bound to return
356   // the class defined in the remote loader (or throw an error).
357   //
358   // Return an unloaded klass if !require_local and no class at all is found.
359   //
360   // The CI treats a klass as loaded if it is consistently defined in
361   // another loader, even if it hasn't yet been loaded in all loaders
362   // that could potentially see it via delegation.
363   static Klass* get_klass_by_name(Klass* accessing_klass,
364                                   Symbol* klass_name,
365                                   bool require_local);
366 
367   // Constant pool access.
368   static Klass*   get_klass_by_index(const constantPoolHandle& cpool,
369                                      int klass_index,
370                                      bool& is_accessible,
371                                      Klass* loading_klass);
372   static void   get_field_by_index(InstanceKlass* loading_klass, fieldDescriptor& fd,
373                                    int field_index);
374   static Method*  get_method_by_index(const constantPoolHandle& cpool,
375                                       int method_index, Bytecodes::Code bc,
376                                       InstanceKlass* loading_klass);
377 
378   // converts the Klass* representing the holder of a method into a
379   // InstanceKlass*.  This is needed since the holder of a method in
380   // the bytecodes could be an array type.  Basically this converts
381   // array types into java/lang/Object and other types stay as they are.
382   static InstanceKlass* get_instance_klass_for_declared_method_holder(Klass* klass);
383 
384   // Helper routine for determining the validity of a compilation
385   // with respect to concurrent class loading.
386   static JVMCI::CodeInstallResult validate_compile_task_dependencies(Dependencies* target, JVMCICompileState* task, char** failure_detail);
387 
388   // Compiles `target` with the JVMCI compiler.
389   void compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, const methodHandle& target, int entry_bci);
390 
391   // Determines if the GC identified by `name` is supported by the JVMCI compiler.
392   bool is_gc_supported(JVMCIEnv* JVMCIENV, CollectedHeap::Name name);
393 
394   // Register the result of a compilation.
395   JVMCI::CodeInstallResult register_method(JVMCIEnv* JVMCIENV,
396                                            const methodHandle&       target,
397                                            nmethod*&                 nm,
398                                            int                       entry_bci,
399                                            CodeOffsets*              offsets,
400                                            int                       orig_pc_offset,
401                                            CodeBuffer*               code_buffer,
402                                            int                       frame_words,
403                                            OopMapSet*                oop_map_set,
404                                            ExceptionHandlerTable*    handler_table,
405                                            ImplicitExceptionTable*   implicit_exception_table,
406                                            AbstractCompiler*         compiler,
407                                            DebugInformationRecorder* debug_info,
408                                            Dependencies*             dependencies,
409                                            int                       compile_id,
410                                            bool                      has_monitors,
411                                            bool                      has_unsafe_access,
412                                            bool                      has_wide_vector,
413                                            JVMCIObject               compiled_code,
414                                            JVMCIObject               nmethod_mirror,
415                                            FailedSpeculation**       failed_speculations,
416                                            char*                     speculations,
417                                            int                       speculations_len);
418 
419   // Detach `thread` from this runtime and destroy this runtime's JavaVM
420   // if using one JavaVM per JVMCI compilation .
421   void post_compile(JavaThread* thread);
422 
423   // Reports an unexpected exception and exits the VM with a fatal error.
424   static void fatal_exception(JVMCIEnv* JVMCIENV, const char* message);
425 
426   static void describe_pending_hotspot_exception(JavaThread* THREAD, bool clear);
427 
428 #define CHECK_EXIT THREAD); \
429   if (HAS_PENDING_EXCEPTION) { \
430     char buf[256]; \
431     jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
432     JVMCIRuntime::fatal_exception(NULL, buf); \
433     return; \
434   } \
435   (void)(0
436 
437 #define CHECK_EXIT_(v) THREAD);                 \
438   if (HAS_PENDING_EXCEPTION) { \
439     char buf[256]; \
440     jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
441     JVMCIRuntime::fatal_exception(NULL, buf); \
442     return v; \
443   } \
444   (void)(0
445 
446 #define JVMCI_CHECK_EXIT JVMCIENV); \
447   if (JVMCIENV->has_pending_exception()) {      \
448     char buf[256]; \
449     jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
450     JVMCIRuntime::fatal_exception(JVMCIENV, buf); \
451     return; \
452   } \
453   (void)(0
454 
455 #define JVMCI_CHECK_EXIT_(result) JVMCIENV); \
456   if (JVMCIENV->has_pending_exception()) {      \
457     char buf[256]; \
458     jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
459     JVMCIRuntime::fatal_exception(JVMCIENV, buf); \
460     return result; \
461   } \
462   (void)(0
463 
464   static BasicType kindToBasicType(const Handle& kind, TRAPS);
465 
466   static void new_instance_common(JavaThread* current, Klass* klass, bool null_on_fail);
467   static void new_array_common(JavaThread* current, Klass* klass, jint length, bool null_on_fail);
468   static void new_multi_array_common(JavaThread* current, Klass* klass, int rank, jint* dims, bool null_on_fail);
469   static void dynamic_new_array_common(JavaThread* current, oopDesc* element_mirror, jint length, bool null_on_fail);
470   static void dynamic_new_instance_common(JavaThread* current, oopDesc* type_mirror, bool null_on_fail);
471 
472   // The following routines are called from compiled JVMCI code
473 
474   // When allocation fails, these stubs:
475   // 1. Exercise -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError handling and also
476   //    post a JVMTI_EVENT_RESOURCE_EXHAUSTED event if the failure is an OutOfMemroyError
477   // 2. Return NULL with a pending exception.
478   // Compiled code must ensure these stubs are not called twice for the same allocation
479   // site due to the non-repeatable side effects in the case of OOME.
480   static void new_instance(JavaThread* current, Klass* klass) { new_instance_common(current, klass, false); }
481   static void new_array(JavaThread* current, Klass* klass, jint length) { new_array_common(current, klass, length, false); }
482   static void new_multi_array(JavaThread* current, Klass* klass, int rank, jint* dims) { new_multi_array_common(current, klass, rank, dims, false); }
483   static void dynamic_new_array(JavaThread* current, oopDesc* element_mirror, jint length) { dynamic_new_array_common(current, element_mirror, length, false); }
484   static void dynamic_new_instance(JavaThread* current, oopDesc* type_mirror) { dynamic_new_instance_common(current, type_mirror, false); }
485 
486   // When allocation fails, these stubs return NULL and have no pending exception. Compiled code
487   // can use these stubs if a failed allocation will be retried (e.g., by deoptimizing and
488   // re-executing in the interpreter).
489   static void new_instance_or_null(JavaThread* thread, Klass* klass) { new_instance_common(thread, klass, true); }
490   static void new_array_or_null(JavaThread* thread, Klass* klass, jint length) { new_array_common(thread, klass, length, true); }
491   static void new_multi_array_or_null(JavaThread* thread, Klass* klass, int rank, jint* dims) { new_multi_array_common(thread, klass, rank, dims, true); }
492   static void dynamic_new_array_or_null(JavaThread* thread, oopDesc* element_mirror, jint length) { dynamic_new_array_common(thread, element_mirror, length, true); }
493   static void dynamic_new_instance_or_null(JavaThread* thread, oopDesc* type_mirror) { dynamic_new_instance_common(thread, type_mirror, true); }
494 
495   static void vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3);
496   static jint identity_hash_code(JavaThread* current, oopDesc* obj);
497   static address exception_handler_for_pc(JavaThread* current);
498   static void monitorenter(JavaThread* current, oopDesc* obj, BasicLock* lock);
499   static void monitorexit (JavaThread* current, oopDesc* obj, BasicLock* lock);
500   static jboolean object_notify(JavaThread* current, oopDesc* obj);
501   static jboolean object_notifyAll(JavaThread* current, oopDesc* obj);
502   static void vm_error(JavaThread* current, jlong where, jlong format, jlong value);
503   static oopDesc* load_and_clear_exception(JavaThread* thread);
504   static void log_printf(JavaThread* thread, const char* format, jlong v1, jlong v2, jlong v3);
505   static void log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline);
506   // Print the passed in object, optionally followed by a newline.  If
507   // as_string is true and the object is a java.lang.String then it
508   // printed as a string, otherwise the type of the object is printed
509   // followed by its address.
510   static void log_object(JavaThread* thread, oopDesc* object, bool as_string, bool newline);
511 #if INCLUDE_G1GC
512   using CardValue = G1CardTable::CardValue;
513   static void write_barrier_pre(JavaThread* thread, oopDesc* obj);
514   static void write_barrier_post(JavaThread* thread, volatile CardValue* card);
515 #endif
516   static jboolean validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child);
517 
518   // used to throw exceptions from compiled JVMCI code
519   static int throw_and_post_jvmti_exception(JavaThread* current, const char* exception, const char* message);
520   // helper methods to throw exception with complex messages
521   static int throw_klass_external_name_exception(JavaThread* current, const char* exception, Klass* klass);
522   static int throw_class_cast_exception(JavaThread* current, const char* exception, Klass* caster_klass, Klass* target_klass);
523 
524   // A helper to allow invocation of an arbitrary Java method.  For simplicity the method is
525   // restricted to a static method that takes at most one argument.  For calling convention
526   // simplicity all types are passed by being converted into a jlong
527   static jlong invoke_static_method_one_arg(JavaThread* current, Method* method, jlong argument);
528 
529   // Test only function
530   static jint test_deoptimize_call_int(JavaThread* current, int value);
531 };
532 #endif // SHARE_JVMCI_JVMCIRUNTIME_HPP