< prev index next >

src/share/vm/jvmci/jvmciRuntime.hpp

Print this page




  37   void abort() { _abort = true; }
  38   void warn_and_abort(const char* message) {
  39     warn(message);
  40     abort();
  41   }
  42   void warn(const char* message) {
  43     warning("Error at line %d while parsing %s: %s", _lineNo, _filename == NULL ? "?" : _filename, message);
  44   }
  45  public:
  46   ParseClosure() : _lineNo(0), _filename(NULL), _abort(false) {}
  47   void parse_line(char* line) {
  48     _lineNo++;
  49     do_line(line);
  50   }
  51   virtual void do_line(char* line) = 0;
  52   int lineNo() { return _lineNo; }
  53   bool is_aborted() { return _abort; }
  54   void set_filename(char* path) {_filename = path; _lineNo = 0;}
  55 };
  56 
  57 #define CHECK_ABORT THREAD); \
  58   if (HAS_PENDING_EXCEPTION) { \
  59     char buf[256]; \
  60     jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
  61     JVMCIRuntime::abort_on_pending_exception(PENDING_EXCEPTION, buf); \
  62     return; \
  63   } \
  64   (void)(0
  65 
  66 #define CHECK_ABORT_(result) THREAD); \
  67   if (HAS_PENDING_EXCEPTION) { \
  68     char buf[256]; \
  69     jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
  70     JVMCIRuntime::abort_on_pending_exception(PENDING_EXCEPTION, buf); \
  71     return result; \
  72   } \
  73   (void)(0
  74 
  75 class JVMCIRuntime: public AllStatic {
  76  private:
  77   static jobject _HotSpotJVMCIRuntime_instance;
  78   static bool _HotSpotJVMCIRuntime_initialized;
  79   static bool _well_known_classes_initialized;
  80   static const char* _compiler;
  81   static int _options_count;
  82   static SystemProperty** _options;
  83 



  84   static bool _shutdown_called;
  85 
  86   /**
  87    * Instantiates a service object, calls its default constructor and returns it.
  88    *
  89    * @param name the name of a class implementing jdk.vm.ci.service.Service
  90    */
  91   static Handle create_Service(const char* name, TRAPS);
  92 
  93  public:
  94 
  95   /**
  96    * Parses *.properties files in jre/lib/jvmci/ and adds the properties to plist.
  97    */
  98   static void init_system_properties(SystemProperty** plist);
  99 
 100   /**
 101    * Saves the value of the "jvmci.compiler" system property for processing
 102    * when JVMCI is initialized.
 103    */
 104   static void save_compiler(const char* compiler);
 105 
 106   /**
 107    * Saves the value of the system properties starting with "jvmci.option." for processing
 108    * when JVMCI is initialized.
 109    *
 110    * @param props the head of the system property list
 111    * @return JNI_ERR if a JVMCI option has a zero length value, JNI_OK otherwise
 112    */
 113   static jint save_options(SystemProperty* props);






 114 
 115   static bool is_HotSpotJVMCIRuntime_initialized() { return _HotSpotJVMCIRuntime_initialized; }
 116 
 117   /**
 118    * Gets the singleton HotSpotJVMCIRuntime instance, initializing it if necessary
 119    */
 120   static Handle get_HotSpotJVMCIRuntime(TRAPS) {
 121     initialize_JVMCI(CHECK_(Handle()));
 122     return Handle(JNIHandles::resolve_non_null(_HotSpotJVMCIRuntime_instance));
 123   }
 124 
 125   static jobject get_HotSpotJVMCIRuntime_jobject(TRAPS) {
 126     initialize_JVMCI(CHECK_NULL);
 127     assert(_HotSpotJVMCIRuntime_initialized, "must be");
 128     return _HotSpotJVMCIRuntime_instance;
 129   }
 130 
 131   static Handle callStatic(const char* className, const char* methodName, const char* returnType, JavaCallArguments* args, TRAPS);
 132 
 133   /**
 134    * Trigger initialization of HotSpotJVMCIRuntime through JVMCI.getRuntime()
 135    */
 136   static void initialize_JVMCI(TRAPS);
 137 
 138   /**
 139    * Explicitly initialize HotSpotJVMCIRuntime itself
 140    */
 141   static void initialize_HotSpotJVMCIRuntime(TRAPS);
 142 
 143   static void initialize_well_known_classes(TRAPS);
 144 
 145   static void metadata_do(void f(Metadata*));
 146 
 147   static void shutdown();
 148 
 149   static bool shutdown_called() {
 150     return _shutdown_called;
 151   }
 152 

 153   static void parse_lines(char* path, ParseClosure* closure, bool warnStatFailure);
 154 
 155   /**
 156    * Aborts the VM due to an unexpected exception.
 157    */
 158   static void abort_on_pending_exception(Handle exception, const char* message, bool dump_core = false);
 159 
 160   /**
 161    * Calls Throwable.printStackTrace() on a given exception.
 162    */
 163   static void call_printStackTrace(Handle exception, Thread* thread);
 164 


















 165   static BasicType kindToBasicType(jchar ch);
 166 
 167   // The following routines are all called from compiled JVMCI code
 168 
 169   static void new_instance(JavaThread* thread, Klass* klass);
 170   static void new_array(JavaThread* thread, Klass* klass, jint length);
 171   static void new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims);
 172   static void dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length);
 173   static void dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror);
 174   static jboolean thread_is_interrupted(JavaThread* thread, oopDesc* obj, jboolean clear_interrupted);
 175   static void vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3);
 176   static jint identity_hash_code(JavaThread* thread, oopDesc* obj);
 177   static address exception_handler_for_pc(JavaThread* thread);
 178   static void monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock);
 179   static void monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock);
 180   static void create_null_exception(JavaThread* thread);
 181   static void create_out_of_bounds_exception(JavaThread* thread, jint index);
 182   static void vm_error(JavaThread* thread, jlong where, jlong format, jlong value);
 183   static oopDesc* load_and_clear_exception(JavaThread* thread);
 184   static void log_printf(JavaThread* thread, oopDesc* format, jlong v1, jlong v2, jlong v3);
 185   static void log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline);
 186   // Note: Must be kept in sync with constants in com.oracle.graal.replacements.Log
 187   enum {
 188     LOG_OBJECT_NEWLINE = 0x01,
 189     LOG_OBJECT_STRING  = 0x02,
 190     LOG_OBJECT_ADDRESS = 0x04
 191   };
 192   static void log_object(JavaThread* thread, oopDesc* msg, jint flags);
 193   static void write_barrier_pre(JavaThread* thread, oopDesc* obj);
 194   static void write_barrier_post(JavaThread* thread, void* card);
 195   static jboolean validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child);
 196   static void new_store_pre_barrier(JavaThread* thread);
 197 
 198   // Test only function
 199   static int test_deoptimize_call_int(JavaThread* thread, int value);
 200 };
 201 
 202 // Tracing macros.
 203 
 204 #define IF_TRACE_jvmci_1 if (!(JVMCITraceLevel >= 1)) ; else
 205 #define IF_TRACE_jvmci_2 if (!(JVMCITraceLevel >= 2)) ; else
 206 #define IF_TRACE_jvmci_3 if (!(JVMCITraceLevel >= 3)) ; else
 207 #define IF_TRACE_jvmci_4 if (!(JVMCITraceLevel >= 4)) ; else
 208 #define IF_TRACE_jvmci_5 if (!(JVMCITraceLevel >= 5)) ; else
 209 
 210 #define TRACE_jvmci_1 if (!(JVMCITraceLevel >= 1 && (tty->print("JVMCITrace-1: "), true))) ; else tty->print_cr
 211 #define TRACE_jvmci_2 if (!(JVMCITraceLevel >= 2 && (tty->print("   JVMCITrace-2: "), true))) ; else tty->print_cr
 212 #define TRACE_jvmci_3 if (!(JVMCITraceLevel >= 3 && (tty->print("      JVMCITrace-3: "), true))) ; else tty->print_cr


  37   void abort() { _abort = true; }
  38   void warn_and_abort(const char* message) {
  39     warn(message);
  40     abort();
  41   }
  42   void warn(const char* message) {
  43     warning("Error at line %d while parsing %s: %s", _lineNo, _filename == NULL ? "?" : _filename, message);
  44   }
  45  public:
  46   ParseClosure() : _lineNo(0), _filename(NULL), _abort(false) {}
  47   void parse_line(char* line) {
  48     _lineNo++;
  49     do_line(line);
  50   }
  51   virtual void do_line(char* line) = 0;
  52   int lineNo() { return _lineNo; }
  53   bool is_aborted() { return _abort; }
  54   void set_filename(char* path) {_filename = path; _lineNo = 0;}
  55 };
  56 


















  57 class JVMCIRuntime: public AllStatic {
  58  private:
  59   static jobject _HotSpotJVMCIRuntime_instance;
  60   static bool _HotSpotJVMCIRuntime_initialized;
  61   static bool _well_known_classes_initialized;
  62   static const char* _compiler;
  63   static int _options_count;
  64   static SystemProperty** _options;
  65 
  66   static int _trivial_prefixes_count;
  67   static char** _trivial_prefixes;
  68 
  69   static bool _shutdown_called;
  70 
  71   /**
  72    * Instantiates a service object, calls its default constructor and returns it.
  73    *
  74    * @param name the name of a class implementing jdk.vm.ci.service.Service
  75    */
  76   static Handle create_Service(const char* name, TRAPS);
  77 
  78  public:
  79 
  80   /**
  81    * Parses *.properties files in jre/lib/jvmci/ and adds the properties to plist.
  82    */
  83   static void init_system_properties(SystemProperty** plist);
  84 
  85   /**
  86    * Saves the value of the "jvmci.compiler" system property for processing
  87    * when JVMCI is initialized.
  88    */
  89   static void save_compiler(const char* compiler);
  90 
  91   /**
  92    * Saves the value of the system properties starting with "jvmci.option." for processing
  93    * when JVMCI is initialized.
  94    *
  95    * @param props the head of the system property list

  96    */
  97   static void save_options(SystemProperty* props);
  98 
  99   /**
 100    * If either the PrintFlags or ShowFlags JVMCI option is present,
 101    * then JVMCI is initialized to show the help message.
 102    */
 103   static void maybe_print_flags(TRAPS);
 104 
 105   static bool is_HotSpotJVMCIRuntime_initialized() { return _HotSpotJVMCIRuntime_initialized; }
 106 
 107   /**
 108    * Gets the singleton HotSpotJVMCIRuntime instance, initializing it if necessary
 109    */
 110   static Handle get_HotSpotJVMCIRuntime(TRAPS) {
 111     initialize_JVMCI(CHECK_(Handle()));
 112     return Handle(JNIHandles::resolve_non_null(_HotSpotJVMCIRuntime_instance));
 113   }
 114 
 115   static jobject get_HotSpotJVMCIRuntime_jobject(TRAPS) {
 116     initialize_JVMCI(CHECK_NULL);
 117     assert(_HotSpotJVMCIRuntime_initialized, "must be");
 118     return _HotSpotJVMCIRuntime_instance;
 119   }
 120 
 121   static Handle callStatic(const char* className, const char* methodName, const char* returnType, JavaCallArguments* args, TRAPS);
 122 
 123   /**
 124    * Trigger initialization of HotSpotJVMCIRuntime through JVMCI.getRuntime()
 125    */
 126   static void initialize_JVMCI(TRAPS);
 127 
 128   /**
 129    * Explicitly initialize HotSpotJVMCIRuntime itself
 130    */
 131   static void initialize_HotSpotJVMCIRuntime(TRAPS);
 132 
 133   static void initialize_well_known_classes(TRAPS);
 134 
 135   static void metadata_do(void f(Metadata*));
 136 
 137   static void shutdown();
 138 
 139   static bool shutdown_called() {
 140     return _shutdown_called;
 141   }
 142 
 143   static bool treat_as_trivial(Method* method);
 144   static void parse_lines(char* path, ParseClosure* closure, bool warnStatFailure);
 145 
 146   /**
 147    * Aborts the VM due to an unexpected exception.
 148    */
 149   static void abort_on_pending_exception(Handle exception, const char* message, bool dump_core = false);
 150 
 151   /**
 152    * Calls Throwable.printStackTrace() on a given exception.
 153    */
 154   static void call_printStackTrace(Handle exception, Thread* thread);
 155 
 156 #define CHECK_ABORT THREAD); \
 157   if (HAS_PENDING_EXCEPTION) { \
 158     char buf[256]; \
 159     jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
 160     JVMCIRuntime::abort_on_pending_exception(PENDING_EXCEPTION, buf); \
 161     return; \
 162   } \
 163   (void)(0
 164 
 165 #define CHECK_ABORT_(result) THREAD); \
 166   if (HAS_PENDING_EXCEPTION) { \
 167     char buf[256]; \
 168     jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
 169     JVMCIRuntime::abort_on_pending_exception(PENDING_EXCEPTION, buf); \
 170     return result; \
 171   } \
 172   (void)(0
 173 
 174   static BasicType kindToBasicType(jchar ch);
 175 
 176   // The following routines are all called from compiled JVMCI code
 177 
 178   static void new_instance(JavaThread* thread, Klass* klass);
 179   static void new_array(JavaThread* thread, Klass* klass, jint length);
 180   static void new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims);
 181   static void dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length);
 182   static void dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror);
 183   static jboolean thread_is_interrupted(JavaThread* thread, oopDesc* obj, jboolean clear_interrupted);
 184   static void vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3);
 185   static jint identity_hash_code(JavaThread* thread, oopDesc* obj);
 186   static address exception_handler_for_pc(JavaThread* thread);
 187   static void monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock);
 188   static void monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock);
 189   static void create_null_exception(JavaThread* thread);
 190   static void create_out_of_bounds_exception(JavaThread* thread, jint index);
 191   static void vm_error(JavaThread* thread, jlong where, jlong format, jlong value);
 192   static oopDesc* load_and_clear_exception(JavaThread* thread);
 193   static void log_printf(JavaThread* thread, oopDesc* format, jlong v1, jlong v2, jlong v3);
 194   static void log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline);
 195   // Print the passed in object, optionally followed by a newline.  If
 196   // as_string is true and the object is a java.lang.String then it
 197   // printed as a string, otherwise the type of the object is printed
 198   // followed by its address.
 199   static void log_object(JavaThread* thread, oopDesc* object, bool as_string, bool newline);


 200   static void write_barrier_pre(JavaThread* thread, oopDesc* obj);
 201   static void write_barrier_post(JavaThread* thread, void* card);
 202   static jboolean validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child);
 203   static void new_store_pre_barrier(JavaThread* thread);
 204 
 205   // Test only function
 206   static int test_deoptimize_call_int(JavaThread* thread, int value);
 207 };
 208 
 209 // Tracing macros.
 210 
 211 #define IF_TRACE_jvmci_1 if (!(JVMCITraceLevel >= 1)) ; else
 212 #define IF_TRACE_jvmci_2 if (!(JVMCITraceLevel >= 2)) ; else
 213 #define IF_TRACE_jvmci_3 if (!(JVMCITraceLevel >= 3)) ; else
 214 #define IF_TRACE_jvmci_4 if (!(JVMCITraceLevel >= 4)) ; else
 215 #define IF_TRACE_jvmci_5 if (!(JVMCITraceLevel >= 5)) ; else
 216 
 217 #define TRACE_jvmci_1 if (!(JVMCITraceLevel >= 1 && (tty->print("JVMCITrace-1: "), true))) ; else tty->print_cr
 218 #define TRACE_jvmci_2 if (!(JVMCITraceLevel >= 2 && (tty->print("   JVMCITrace-2: "), true))) ; else tty->print_cr
 219 #define TRACE_jvmci_3 if (!(JVMCITraceLevel >= 3 && (tty->print("      JVMCITrace-3: "), true))) ; else tty->print_cr
< prev index next >