< prev index next >

src/share/vm/ci/ciArray.cpp

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -40,23 +40,23 @@
   if (bt == T_ARRAY)    return T_OBJECT;
   if (bt == T_BOOLEAN)  return T_BYTE;
   return bt;
 }
 
-ciConstant ciArray::element_value_impl(BasicType elembt,
-                                       arrayOop ary,
-                                       int index) {
+ciConstant ciArray::element_value_impl(BasicType elembt, arrayOop ary,
+                                       int index, bool mismatched) {
   if (ary == NULL)
     return ciConstant();
   assert(ary->is_array(), "");
   if (index < 0 || index >= ary->length())
     return ciConstant();
   ArrayKlass* ak = (ArrayKlass*) ary->klass();
   BasicType abt = ak->element_type();
-  if (fixup_element_type(elembt) !=
-      fixup_element_type(abt))
+  if (!mismatched && fixup_element_type(elembt) != fixup_element_type(abt)) {
+    // Types should match for non-mismatched accesses
     return ciConstant();
+  }
   switch (elembt) {
   case T_ARRAY:
   case T_OBJECT:
     {
       assert(ary->is_objArray(), "");

@@ -88,13 +88,18 @@
 // ciArray::element_value
 //
 // Current value of an element.
 // Returns T_ILLEGAL if there is no element at the given index.
 ciConstant ciArray::element_value(int index) {
-  BasicType elembt = element_basic_type();
+  return element_value(index, element_basic_type());
+}
+
+// Support for mismatched accesses
+ciConstant ciArray::element_value(int index, BasicType elembt) {
+  bool mismatched = (elembt != element_basic_type());
   GUARDED_VM_ENTRY(
-    return element_value_impl(elembt, get_arrayOop(), index);
+    return element_value_impl(elembt, get_arrayOop(), index, mismatched);
   )
 }
 
 // ------------------------------------------------------------------
 // ciArray::element_value_by_offset
< prev index next >