changeset 2241:68790c7c4ff7

PR icedtea/324: Cope with cases where the array's type is unknown. 2010-04-30 Gary Benson <gbenson@redhat.com> PR icedtea/324 * ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp (SharkTopLevelBlock::do_aload): Cope with cases where the array's type is unknown. (SharkTopLevelBlock::do_astore): Likewise.
author Gary Benson <gbenson@redhat.com>
date Fri, 30 Apr 2010 10:24:39 +0100
parents 66b4c5ea2c8a
children 586b58d937ca
files ChangeLog ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp
diffstat 2 files changed, 24 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jun 09 13:18:34 2010 +0100
+++ b/ChangeLog	Fri Apr 30 10:24:39 2010 +0100
@@ -1,3 +1,11 @@
+2010-04-30  Gary Benson  <gbenson@redhat.com>
+
+	PR icedtea/324
+	* ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp
+	(SharkTopLevelBlock::do_aload): Cope with cases where
+	the array's type is unknown.
+	(SharkTopLevelBlock::do_astore): Likewise.
+
 2010-04-29  Pavel Tisnovsky  <ptisnovs@redhat.com>
 
 	* overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatConverter/GetFormat.java,
--- a/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp	Wed Jun 09 13:18:34 2010 +0100
+++ b/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp	Fri Apr 30 10:24:39 2010 +0100
@@ -691,12 +691,6 @@
   SharkValue *index = pop();
   SharkValue *array = pop();
 
-  assert(array->type()->is_array_klass(), "should be");
-  ciType *element_type = ((ciArrayKlass *) array->type())->element_type();
-  assert((element_type->basic_type() == T_BOOLEAN && basic_type == T_BYTE) ||
-         (element_type->basic_type() == T_ARRAY && basic_type == T_OBJECT) ||
-         (element_type->basic_type() == basic_type), "type mismatch");
-
   check_null(array);
   check_bounds(array, index);
 
@@ -729,7 +723,21 @@
     break;
 
   case T_OBJECT:
-    push(SharkValue::create_generic(element_type, value, false));
+    // You might expect that array->type()->is_array_klass() would
+    // always be true, but it isn't.  If ciTypeFlow detects that a
+    // value is always null then that value becomes an untyped null
+    // object.  Shark doesn't presently support this, so a generic
+    // T_OBJECT is created.  In this case we guess the type using
+    // the BasicType we were supplied.  In reality the generated
+    // code will never be used, as the null value will be caught
+    // by the above null pointer check.
+    // http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=324
+    push(
+      SharkValue::create_generic(
+        array->type()->is_array_klass() ?
+          ((ciArrayKlass *) array->type())->element_type() :
+          ciType::make(basic_type),
+        value, false));
     break;
 
   default:
@@ -743,12 +751,6 @@
   SharkValue *index  = pop();
   SharkValue *array  = pop();
 
-  assert(array->type()->is_array_klass(), "should be");
-  ciType *element_type = ((ciArrayKlass *) array->type())->element_type();
-  assert((element_type->basic_type() == T_BOOLEAN && basic_type == T_BYTE) ||
-         (element_type->basic_type() == T_ARRAY && basic_type == T_OBJECT) ||
-         (element_type->basic_type() == basic_type), "type mismatch");
-
   check_null(array);
   check_bounds(array, index);
 
@@ -792,7 +794,7 @@
 
   builder()->CreateStore(value, addr);
 
-  if (!element_type->is_primitive_type())
+  if (basic_type == T_OBJECT) // XXX or T_ARRAY?
     builder()->CreateUpdateBarrierSet(oopDesc::bs(), addr);
 }