Improve static type information to ldc and ldc_w in Shark

Gary Benson gbenson at redhat.com
Fri Jun 19 06:00:41 PDT 2009


Hi all,

This commit sets the static type of objects constants loaded by ldc
and ldc_w to either java.lang.String or java.lang.Class.  Previously
the type was set to java.lang.Object.  This should improve the scope
for the various static type optimizations (checkcast/instanceof
elimination, virtual-direct call improvement, etc).

Cheers,
Gary

-- 
http://gbenson.net/
-------------- next part --------------
diff -r 2bd8742661b3 -r 2861671c8434 ChangeLog
--- a/ChangeLog	Fri Jun 19 06:03:31 2009 -0400
+++ b/ChangeLog	Fri Jun 19 08:48:56 2009 -0400
@@ -1,3 +1,9 @@
+2009-06-19  Gary Benson  <gbenson at redhat.com>
+
+	* ports/hotspot/src/share/vm/shark/sharkConstant.cpp
+	(SharkConstant::for_ldc): Set type for object constants.
+	(SharkConstant::SharkConstant): Updated.
+
 2009-06-19  Gary Benson  <gbenson at redhat.com>
 
 	* ports/hotspot/src/share/vm/shark/sharkCompiler.hpp
diff -r 2bd8742661b3 -r 2861671c8434 ports/hotspot/src/share/vm/shark/sharkConstant.cpp
--- a/ports/hotspot/src/share/vm/shark/sharkConstant.cpp	Fri Jun 19 06:03:31 2009 -0400
+++ b/ports/hotspot/src/share/vm/shark/sharkConstant.cpp	Fri Jun 19 08:48:56 2009 -0400
@@ -30,7 +30,16 @@
 
 SharkConstant* SharkConstant::for_ldc(ciBytecodeStream *iter)
 {
-  return new SharkConstant(iter->get_constant(), NULL);
+  ciConstant constant = iter->get_constant();
+  ciType *type = NULL;
+  if (constant.basic_type() == T_OBJECT) {
+    ciEnv *env = ciEnv::current();
+    if (constant.as_object()->is_klass())
+      type = env->Class_klass();
+    else
+      type = env->String_klass();
+  }
+  return new SharkConstant(constant, type);
 }
 
 SharkConstant* SharkConstant::for_field(ciBytecodeStream *iter)
@@ -97,6 +106,7 @@
   // have yet to be created.  We need to spot the unloaded
   // objects (which differ between ldc* and get*, thanks!)
   ciObject *object = constant.as_object();
+  assert(type != NULL, "shouldn't be");
   if (object->is_klass()) {
     // The constant returned for a klass is the ciKlass
     // for the entry, but we want the java_mirror.
@@ -114,7 +124,7 @@
 
   _value       = NULL;
   _object      = object;
-  _type        = type ? type : ciType::make(T_OBJECT);
+  _type        = type;
   _is_loaded   = true;
   _is_nonzero  = true;
   _is_two_word = false;


More information about the distro-pkg-dev mailing list