< prev index next >

src/hotspot/share/c1/c1_Instruction.cpp

Print this page

@@ -112,20 +112,61 @@
     return t->as_klass()->exact_klass();
   }
   return NULL;
 }
 
+
+// FIXME -- make this obsolete. Use maybe_flattened_array() or check_flattened_array() instead.
 bool Instruction::is_flattened_array() const {
   if (ValueArrayFlatten) {
     ciType* type = declared_type();
     if (type != NULL && type->is_value_array_klass()) {
       ciValueKlass* element_klass = type->as_value_array_klass()->element_klass()->as_value_klass();
       if (!element_klass->is_loaded() || element_klass->flatten_array()) {
         // Assume that all unloaded value arrays are not flattenable. If they
         // turn out to be flattenable, we deoptimize on aaload/aastore.
+        // ^^^^ uugh -- this is ugly!
+        return true;
+      }
+    }
+  }
+
+  return false;
+}
+
+bool Instruction::is_loaded_flattened_array() const {
+  if (ValueArrayFlatten) {
+    ciType* type = declared_type();
+    if (type != NULL && type->is_value_array_klass()) {
+      ciValueKlass* element_klass = type->as_value_array_klass()->element_klass()->as_value_klass();
+      if (element_klass->is_loaded() && element_klass->flatten_array()) {
+        return true;
+      }
+    }
+  }
+
+  return false;
+}
+
+bool Instruction::maybe_flattened_array() const {
+  if (ValueArrayFlatten) {
+    ciType* type = declared_type();
+    if (type != NULL) {
+      if (type->is_value_array_klass()) {
+        ciValueKlass* element_klass = type->as_value_array_klass()->element_klass()->as_value_klass();
+        if (!element_klass->is_loaded() || element_klass->flatten_array()) {
+          // For unloaded value arrays, we will add a runtime check for flat-ness.
         return true;
       }
+      } else if (type->is_obj_array_klass()) {
+        ciKlass* element_klass = type->as_obj_array_klass()->element_klass();
+        if (element_klass->is_java_lang_Object()) {
+          // Array covariance (ValueType[] <: Object[])
+          // We will add a runtime check for flat-ness.
+          return true;
+        }
+      }
     }
   }
 
   return false;
 }
< prev index next >