changeset 22722:0229a2ca608b

Make kindToBasicType trapping.
author Roland Schatz <roland.schatz@oracle.com>
date Thu, 05 Nov 2015 10:59:29 +0100
parents 510846133438
children 77d72f719a59
files src/share/vm/jvmci/jvmciCodeInstaller.cpp src/share/vm/jvmci/jvmciCodeInstaller.hpp src/share/vm/jvmci/jvmciRuntime.cpp src/share/vm/jvmci/jvmciRuntime.hpp
diffstat 4 files changed, 19 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/jvmci/jvmciCodeInstaller.cpp	Tue Nov 03 16:55:51 2015 +0100
+++ b/src/share/vm/jvmci/jvmciCodeInstaller.cpp	Thu Nov 05 10:59:29 2015 +0100
@@ -278,7 +278,7 @@
         jlong prim = PrimitiveConstant::primitive(value);
         return new ConstantLongValue(prim);
       } else {
-        BasicType constantType = JVMCIRuntime::kindToBasicType(JavaKind::typeChar(PrimitiveConstant::kind(value)));
+        BasicType constantType = JVMCIRuntime::kindToBasicType(JavaKind::typeChar(PrimitiveConstant::kind(value)), CHECK_NULL);
         if (type != constantType) {
           JVMCI_ERROR_NULL("primitive constant type doesn't match, expected %s but got %s", basictype_to_str(type), basictype_to_str(constantType));
         }
@@ -346,7 +346,7 @@
   for (jint i = 0; i < values->length(); i++) {
     ScopeValue* cur_second = NULL;
     Handle object = values->obj_at(i);
-    BasicType type = JVMCIRuntime::kindToBasicType(JavaKind::typeChar(slotKinds->obj_at(i)));
+    BasicType type = JVMCIRuntime::kindToBasicType(JavaKind::typeChar(slotKinds->obj_at(i)), CHECK);
     ScopeValue* value = get_scope_value(object, type, objects, cur_second, CHECK);
 
     if (isLongArray && cur_second == NULL) {
@@ -845,14 +845,14 @@
       ScopeValue* second = NULL;
       Handle value = values->obj_at(i);
       if (i < local_count) {
-        BasicType type = JVMCIRuntime::kindToBasicType(JavaKind::typeChar(slotKinds->obj_at(i)));
+        BasicType type = JVMCIRuntime::kindToBasicType(JavaKind::typeChar(slotKinds->obj_at(i)), CHECK);
         ScopeValue* first = get_scope_value(value, type, objects, second, CHECK);
         if (second != NULL) {
           locals->append(second);
         }
         locals->append(first);
       } else if (i < local_count + expression_count) {
-        BasicType type = JVMCIRuntime::kindToBasicType(JavaKind::typeChar(slotKinds->obj_at(i)));
+        BasicType type = JVMCIRuntime::kindToBasicType(JavaKind::typeChar(slotKinds->obj_at(i)), CHECK);
         ScopeValue* first = get_scope_value(value, type, objects, second, CHECK);
         if (second != NULL) {
           expressions->append(second);
--- a/src/share/vm/jvmci/jvmciCodeInstaller.hpp	Tue Nov 03 16:55:51 2015 +0100
+++ b/src/share/vm/jvmci/jvmciCodeInstaller.hpp	Thu Nov 05 10:59:29 2015 +0100
@@ -27,20 +27,6 @@
 #include "jvmci/jvmciCompiler.hpp"
 #include "jvmci/jvmciEnv.hpp"
 
-#define JVMCI_ERROR(...)       \
-  { Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::jdk_vm_ci_common_JVMCIError(), __VA_ARGS__); return; }
-
-#define JVMCI_ERROR_0(...)     \
-  { Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::jdk_vm_ci_common_JVMCIError(), __VA_ARGS__); return 0; }
-
-#define JVMCI_ERROR_NULL(...)  \
-  { Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::jdk_vm_ci_common_JVMCIError(), __VA_ARGS__); return NULL; }
-
-#define JVMCI_ERROR_OK(...)    \
-  { Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::jdk_vm_ci_common_JVMCIError(), __VA_ARGS__); return JVMCIEnv::ok; }
-
-#define CHECK_OK                  CHECK_(JVMCIEnv::ok)
-
 /*
  * This class handles the conversion from a InstalledCode to a CodeBlob or an nmethod.
  */
--- a/src/share/vm/jvmci/jvmciRuntime.cpp	Tue Nov 03 16:55:51 2015 +0100
+++ b/src/share/vm/jvmci/jvmciRuntime.cpp	Thu Nov 05 10:59:29 2015 +0100
@@ -57,7 +57,7 @@
 static const char* OPTION_PREFIX = "jvmci.option.";
 static const size_t OPTION_PREFIX_LEN = strlen(OPTION_PREFIX);
 
-BasicType JVMCIRuntime::kindToBasicType(jchar ch) {
+BasicType JVMCIRuntime::kindToBasicType(jchar ch, TRAPS) {
   switch(ch) {
     case 'z': return T_BOOLEAN;
     case 'b': return T_BYTE;
@@ -69,8 +69,9 @@
     case 'd': return T_DOUBLE;
     case 'a': return T_OBJECT;
     case '-': return T_ILLEGAL;
+    default:
+      JVMCI_ERROR_(T_ILLEGAL, "unexpected Kind: %c", ch);
   }
-  return T_ILLEGAL;
 }
 
 // Simple helper to see if the caller of a runtime stub which
--- a/src/share/vm/jvmci/jvmciRuntime.hpp	Tue Nov 03 16:55:51 2015 +0100
+++ b/src/share/vm/jvmci/jvmciRuntime.hpp	Thu Nov 05 10:59:29 2015 +0100
@@ -29,6 +29,17 @@
 #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; }
+
+#define JVMCI_ERROR_(ret, ...) \
+  { Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::jdk_vm_ci_common_JVMCIError(), __VA_ARGS__); return ret; }
+
+#define JVMCI_ERROR_0(...)    JVMCI_ERROR_(0, __VA_ARGS__)
+#define JVMCI_ERROR_NULL(...) JVMCI_ERROR_(NULL, __VA_ARGS__)
+#define JVMCI_ERROR_OK(...)   JVMCI_ERROR_(JVMCIEnv::ok, __VA_ARGS__)
+#define CHECK_OK              CHECK_(JVMCIEnv::ok)
+
 class ParseClosure : public StackObj {
   int _lineNo;
   char* _filename;
@@ -196,7 +207,7 @@
    */
   static Klass* load_required_class(Symbol* name);
 
-  static BasicType kindToBasicType(jchar ch);
+  static BasicType kindToBasicType(jchar ch, TRAPS);
 
   // The following routines are all called from compiled JVMCI code