src/hotspot/share/utilities/constantTag.hpp
changeset 48826 c4d9d1b08e2e
parent 47765 b7c7428eaab9
child 49364 601146c66cad
--- a/src/hotspot/share/utilities/constantTag.hpp	Wed Jan 31 10:55:49 2018 -0800
+++ b/src/hotspot/share/utilities/constantTag.hpp	Fri Sep 08 10:46:46 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,8 @@
   JVM_CONSTANT_UnresolvedClassInError   = 103,  // Error tag due to resolution error
   JVM_CONSTANT_MethodHandleInError      = 104,  // Error tag due to resolution error
   JVM_CONSTANT_MethodTypeInError        = 105,  // Error tag due to resolution error
-  JVM_CONSTANT_InternalMax              = 105   // Last implementation tag
+  JVM_CONSTANT_DynamicInError           = 106,  // Error tag due to resolution error
+  JVM_CONSTANT_InternalMax              = 106   // Last implementation tag
 };
 
 
@@ -80,6 +81,10 @@
     return _tag == JVM_CONSTANT_MethodTypeInError;
   }
 
+  bool is_dynamic_constant_in_error() const {
+    return _tag == JVM_CONSTANT_DynamicInError;
+  }
+
   bool is_klass_index() const       { return _tag == JVM_CONSTANT_ClassIndex; }
   bool is_string_index() const      { return _tag == JVM_CONSTANT_StringIndex; }
 
@@ -88,13 +93,14 @@
   bool is_field_or_method() const   { return is_field() || is_method() || is_interface_method(); }
   bool is_symbol() const            { return is_utf8(); }
 
-  bool is_method_type() const              { return _tag == JVM_CONSTANT_MethodType; }
-  bool is_method_handle() const            { return _tag == JVM_CONSTANT_MethodHandle; }
-  bool is_invoke_dynamic() const           { return _tag == JVM_CONSTANT_InvokeDynamic; }
+  bool is_method_type() const       { return _tag == JVM_CONSTANT_MethodType; }
+  bool is_method_handle() const     { return _tag == JVM_CONSTANT_MethodHandle; }
+  bool is_dynamic_constant() const  { return _tag == JVM_CONSTANT_Dynamic; }
+  bool is_invoke_dynamic() const    { return _tag == JVM_CONSTANT_InvokeDynamic; }
 
   bool is_loadable_constant() const {
     return ((_tag >= JVM_CONSTANT_Integer && _tag <= JVM_CONSTANT_String) ||
-            is_method_type() || is_method_handle() ||
+            is_method_type() || is_method_handle() || is_dynamic_constant() ||
             is_unresolved_klass());
   }
 
@@ -108,6 +114,20 @@
     _tag = tag;
   }
 
+  static constantTag ofBasicType(BasicType bt) {
+    if (is_subword_type(bt))  bt = T_INT;
+    switch (bt) {
+      case T_OBJECT: return constantTag(JVM_CONSTANT_String);
+      case T_INT:    return constantTag(JVM_CONSTANT_Integer);
+      case T_LONG:   return constantTag(JVM_CONSTANT_Long);
+      case T_FLOAT:  return constantTag(JVM_CONSTANT_Float);
+      case T_DOUBLE: return constantTag(JVM_CONSTANT_Double);
+      default:       break;
+    }
+    assert(false, "bad basic type for tag");
+    return constantTag();
+  }
+
   jbyte value() const                { return _tag; }
   jbyte error_value() const;
   jbyte non_error_value() const;