changeset 22733:732763293625

must use JVMCI class loader when trying to throw a JVMCIError from native VM code
author Doug Simon <doug.simon@oracle.com>
date Thu, 12 Nov 2015 20:03:43 +0100
parents b2ffe9891356
children ab84ba890aa4
files src/share/vm/jvmci/jvmciRuntime.cpp src/share/vm/jvmci/jvmciRuntime.hpp
diffstat 2 files changed, 24 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/jvmci/jvmciRuntime.cpp	Thu Nov 12 12:12:38 2015 +0100
+++ b/src/share/vm/jvmci/jvmciRuntime.cpp	Thu Nov 12 20:03:43 2015 +0100
@@ -1046,6 +1046,19 @@
   vm_abort(dump_core);
 }
 
+void JVMCIRuntime::fthrow_error(Thread* thread, const char* file, int line, const char* format, ...) {
+  const int max_msg_size = 1024;
+  va_list ap;
+  va_start(ap, format);
+  char msg[max_msg_size];
+  vsnprintf(msg, max_msg_size, format, ap);
+  msg[max_msg_size-1] = '\0';
+  va_end(ap);
+  Handle h_loader = Handle(thread, SystemDictionary::jvmci_loader());
+  Handle h_protection_domain = Handle();
+  Exceptions::_throw_msg(thread, file, line, vmSymbols::jdk_vm_ci_common_JVMCIError(), msg, h_loader, h_protection_domain);
+}
+
 Klass* JVMCIRuntime::resolve_or_null(Symbol* name, TRAPS) {
   return SystemDictionary::resolve_or_null(name, SystemDictionary::jvmci_loader(), Handle(), CHECK_NULL);
 }
--- a/src/share/vm/jvmci/jvmciRuntime.hpp	Thu Nov 12 12:12:38 2015 +0100
+++ b/src/share/vm/jvmci/jvmciRuntime.hpp	Thu Nov 12 20:03:43 2015 +0100
@@ -29,11 +29,13 @@
 #include "runtime/arguments.hpp"
 #include "runtime/deoptimization.hpp"
 
+
+
 #define JVMCI_ERROR(...)       \
-  { Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::jdk_vm_ci_common_JVMCIError(), __VA_ARGS__); return; }
+  { JVMCIRuntime::fthrow_error(THREAD_AND_LOCATION, __VA_ARGS__); return; }
 
 #define JVMCI_ERROR_(ret, ...) \
-  { Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::jdk_vm_ci_common_JVMCIError(), __VA_ARGS__); return ret; }
+  { JVMCIRuntime::fthrow_error(THREAD_AND_LOCATION, __VA_ARGS__); return ret; }
 
 #define JVMCI_ERROR_0(...)    JVMCI_ERROR_(0, __VA_ARGS__)
 #define JVMCI_ERROR_NULL(...) JVMCI_ERROR_(NULL, __VA_ARGS__)
@@ -165,6 +167,13 @@
   static void parse_lines(char* path, ParseClosure* closure, bool warnStatFailure);
 
   /**
+   * Throws a JVMCIError with a formatted error message. Ideally we would use
+   * a variation of Exceptions::fthrow that takes a class loader argument but alas,
+   * no such variation exists.
+   */
+  static void fthrow_error(Thread* thread, const char* file, int line, const char* format, ...) ATTRIBUTE_PRINTF(4, 5);
+
+  /**
    * Aborts the VM due to an unexpected exception.
    */
   static void abort_on_pending_exception(Handle exception, const char* message, bool dump_core = false);