changeset in /hg/icedtea: 2009-06-04 Gary Benson <gbenson at redh...

Gary Benson gbenson at redhat.com
Wed Jun 10 13:45:36 PDT 2009


changeset 51053321f7b4 in /hg/icedtea
details: http://icedtea.classpath.org/hg/icedtea?cmd=changeset;node=51053321f7b4
description:
	2009-06-04  Gary Benson  <gbenson at redhat.com>

		* ports/hotspot/src/share/vm/shark/sharkConstant.hpp: New file.
		* ports/hotspot/src/share/vm/shark/sharkConstant.cpp: Likewise.

		* ports/hotspot/src/share/vm/shark/sharkBlock.hpp
		(SharkBlock::lookup_for_ldc): Removed.
		(SharkBlock::do_ldc): Likewise.
		* ports/hotspot/src/share/vm/shark/sharkBlock.cpp
		(SharkBlock::parse_bytecode): Use new code for ldc and friends.
		(SharkBlock::do_field_access): Use new code for constant fields.
		(SharkBlock::lookup_for_ldc): Removed.

		* ports/hotspot/src/share/vm/shark/sharkInliner.cpp
		(SharkInlinerHelper::is_inlinable): Use new code for ldc and friends.
		(SharkInlinerHelper::do_field_access): Use new code for constant fields.

		* ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp
		(SharkTopLevelBlock::lookup_for_ldc): Removed.
		* ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp
		(SharkTopLevelBlock::scan_for_traps): Use new code to for ldc and
		constant field traps.
		(SharkTopLevelBlock::lookup_for_ldc): Removed.

		* ports/hotspot/src/share/vm/shark/sharkValue.hpp
		(SharkValue::from_ciConstant): Removed.

		* ports/hotspot/src/share/vm/includeDB_shark: Updated.

diffstat:

10 files changed, 247 insertions(+), 101 deletions(-)
ChangeLog                                               |   29 +++
ports/hotspot/src/share/vm/includeDB_shark              |   14 +
ports/hotspot/src/share/vm/shark/sharkBlock.cpp         |   11 -
ports/hotspot/src/share/vm/shark/sharkBlock.hpp         |   11 -
ports/hotspot/src/share/vm/shark/sharkConstant.cpp      |  121 +++++++++++++++
ports/hotspot/src/share/vm/shark/sharkConstant.hpp      |   68 ++++++++
ports/hotspot/src/share/vm/shark/sharkInliner.cpp       |   16 -
ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp |   38 ----
ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp |    1 
ports/hotspot/src/share/vm/shark/sharkValue.hpp         |   39 ----

diffs (truncated from 512 to 500 lines):

diff -r 6dedbb6d0a87 -r 51053321f7b4 ChangeLog
--- a/ChangeLog	Wed Jun 03 11:15:36 2009 -0400
+++ b/ChangeLog	Thu Jun 04 09:48:19 2009 -0400
@@ -1,3 +1,32 @@ 2009-06-03  Gary Benson  <gbenson at redhat
+2009-06-04  Gary Benson  <gbenson at redhat.com>
+
+	* ports/hotspot/src/share/vm/shark/sharkConstant.hpp: New file.
+	* ports/hotspot/src/share/vm/shark/sharkConstant.cpp: Likewise.
+
+	* ports/hotspot/src/share/vm/shark/sharkBlock.hpp
+	(SharkBlock::lookup_for_ldc): Removed.
+	(SharkBlock::do_ldc): Likewise.
+	* ports/hotspot/src/share/vm/shark/sharkBlock.cpp
+	(SharkBlock::parse_bytecode): Use new code for ldc and friends.
+	(SharkBlock::do_field_access): Use new code for constant fields.
+	(SharkBlock::lookup_for_ldc): Removed.
+
+	* ports/hotspot/src/share/vm/shark/sharkInliner.cpp
+	(SharkInlinerHelper::is_inlinable): Use new code for ldc and friends.
+	(SharkInlinerHelper::do_field_access): Use new code for constant fields.
+
+	* ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp
+	(SharkTopLevelBlock::lookup_for_ldc): Removed.
+	* ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp
+	(SharkTopLevelBlock::scan_for_traps): Use new code to for ldc and
+	constant field traps.
+	(SharkTopLevelBlock::lookup_for_ldc): Removed.
+
+	* ports/hotspot/src/share/vm/shark/sharkValue.hpp
+	(SharkValue::from_ciConstant): Removed.
+
+	* ports/hotspot/src/share/vm/includeDB_shark: Updated.
+
 2009-06-03  Gary Benson  <gbenson at redhat.com>
 
 	* ports/hotspot/src/share/vm/shark/sharkCodeBuffer.hpp:
diff -r 6dedbb6d0a87 -r 51053321f7b4 ports/hotspot/src/share/vm/includeDB_shark
--- a/ports/hotspot/src/share/vm/includeDB_shark	Wed Jun 03 11:15:36 2009 -0400
+++ b/ports/hotspot/src/share/vm/includeDB_shark	Thu Jun 04 09:48:19 2009 -0400
@@ -73,6 +73,7 @@ sharkBlock.cpp                          
 sharkBlock.cpp                          shark_globals.hpp
 sharkBlock.cpp                          sharkBlock.hpp
 sharkBlock.cpp                          sharkBuilder.hpp
+sharkBlock.cpp                          sharkConstant.hpp
 sharkBlock.cpp                          sharkRuntime.hpp
 sharkBlock.cpp                          sharkState.inline.hpp
 sharkBlock.cpp                          sharkValue.hpp
@@ -83,6 +84,7 @@ sharkBlock.hpp                          
 sharkBlock.hpp                          debug.hpp
 sharkBlock.hpp                          llvmHeaders.hpp
 sharkBlock.hpp                          sharkBuilder.hpp
+sharkBlock.hpp                          sharkConstant.hpp
 sharkBlock.hpp                          sharkState.hpp
 sharkBlock.hpp                          sharkValue.hpp
 
@@ -158,6 +160,16 @@ sharkCompiler.hpp                       
 sharkCompiler.hpp                       llvmHeaders.hpp
 sharkCompiler.hpp                       sharkMemoryManager.hpp
 
+sharkConstant.cpp                       ciStreams.hpp
+sharkConstant.cpp                       sharkBuilder.hpp
+sharkConstant.cpp                       sharkConstant.hpp
+sharkConstant.cpp                       sharkValue.hpp
+
+sharkConstant.hpp                       allocation.hpp
+sharkConstant.hpp                       ciStreams.hpp
+sharkConstant.hpp                       sharkBuilder.hpp
+sharkConstant.hpp                       sharkValue.hpp
+
 sharkConstantPool.cpp                   allocation.hpp
 sharkConstantPool.cpp                   constantPoolOop.hpp
 sharkConstantPool.cpp                   cpCacheOop.hpp
@@ -215,6 +227,7 @@ sharkInliner.cpp                        
 sharkInliner.cpp                        ciMethod.hpp
 sharkInliner.cpp                        ciStreams.hpp
 sharkInliner.cpp                        shark_globals.hpp
+sharkInliner.cpp                        sharkConstant.hpp
 sharkInliner.cpp                        sharkInliner.hpp
 sharkInliner.cpp                        sharkIntrinsics.hpp
 sharkInliner.cpp                        sharkState.inline.hpp
@@ -302,6 +315,7 @@ sharkTopLevelBlock.cpp                  
 sharkTopLevelBlock.cpp                  shark_globals.hpp
 sharkTopLevelBlock.cpp                  sharkTopLevelBlock.hpp
 sharkTopLevelBlock.cpp                  sharkBuilder.hpp
+sharkTopLevelBlock.cpp                  sharkConstant.hpp
 sharkTopLevelBlock.cpp                  sharkConstantPool.hpp
 sharkTopLevelBlock.cpp                  sharkInliner.hpp
 sharkTopLevelBlock.cpp                  sharkRuntime.hpp
diff -r 6dedbb6d0a87 -r 51053321f7b4 ports/hotspot/src/share/vm/shark/sharkBlock.cpp
--- a/ports/hotspot/src/share/vm/shark/sharkBlock.cpp	Wed Jun 03 11:15:36 2009 -0400
+++ b/ports/hotspot/src/share/vm/shark/sharkBlock.cpp	Thu Jun 04 09:48:19 2009 -0400
@@ -163,7 +163,7 @@ void SharkBlock::parse_bytecode(int star
     case Bytecodes::_ldc:
     case Bytecodes::_ldc_w:
     case Bytecodes::_ldc2_w:
-      do_ldc();
+      push(SharkConstant::for_ldc(iter())->value(builder()));
       break;
 
     case Bytecodes::_iload_0:
@@ -996,7 +996,9 @@ void SharkBlock::do_field_access(bool is
     object = value->generic_value();
   }
   if (is_get && field->is_constant()) {
-    value = SharkValue::from_ciConstant(field->constant_value());
+    SharkConstant *constant = SharkConstant::for_field(iter());
+    if (constant->is_loaded())
+      value = constant->value(builder());
   }
   if (!is_get || value == NULL) {
     if (!is_field)
@@ -1163,11 +1165,6 @@ void SharkBlock::do_trap(int trap_reques
   ShouldNotCallThis();
 }
 
-Value* SharkBlock::lookup_for_ldc()
-{
-  ShouldNotCallThis();
-}
-
 Value* SharkBlock::lookup_for_field_access()
 {
   ShouldNotCallThis();
diff -r 6dedbb6d0a87 -r 51053321f7b4 ports/hotspot/src/share/vm/shark/sharkBlock.hpp
--- a/ports/hotspot/src/share/vm/shark/sharkBlock.hpp	Wed Jun 03 11:15:36 2009 -0400
+++ b/ports/hotspot/src/share/vm/shark/sharkBlock.hpp	Thu Jun 04 09:48:19 2009 -0400
@@ -202,7 +202,6 @@ class SharkBlock : public ResourceObj {
   // Helpers
  protected:
   virtual void do_zero_check(SharkValue* value);
-  virtual llvm::Value* lookup_for_ldc();
   virtual llvm::Value* lookup_for_field_access();
 
   // Leaf calls
@@ -240,16 +239,6 @@ class SharkBlock : public ResourceObj {
   virtual int  trap_bci();
   virtual void do_trap(int trap_request);
 
-  // ldc*
- private:
-  void do_ldc()
-  {
-    SharkValue *value = SharkValue::from_ciConstant(iter()->get_constant());
-    if (value == NULL)
-      value = SharkValue::create_jobject(lookup_for_ldc(), true);
-    push(value);
-  }
-
   // arraylength
  protected:
   virtual void do_arraylength();
diff -r 6dedbb6d0a87 -r 51053321f7b4 ports/hotspot/src/share/vm/shark/sharkConstant.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ports/hotspot/src/share/vm/shark/sharkConstant.cpp	Thu Jun 04 09:48:19 2009 -0400
@@ -0,0 +1,121 @@
+/*
+ * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2009 Red Hat, Inc.
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+#include "incls/_precompiled.incl"
+#include "incls/_sharkConstant.cpp.incl"
+
+using namespace llvm;
+
+SharkConstant* SharkConstant::for_ldc(ciBytecodeStream *iter)
+{
+  return new SharkConstant(iter->get_constant(), NULL);
+}
+
+SharkConstant* SharkConstant::for_field(ciBytecodeStream *iter)
+{
+  bool will_link;
+  ciField *field = iter->get_field(will_link);
+  assert(will_link, "typeflow responsibility");
+
+  return new SharkConstant(field->constant_value(), field->type());
+}
+
+SharkConstant::SharkConstant(ciConstant constant, ciType *type)
+{
+  SharkValue *value = NULL;
+
+  switch (constant.basic_type()) {
+  case T_BOOLEAN:
+  case T_BYTE:
+  case T_CHAR:
+  case T_SHORT:
+  case T_INT:
+    value = SharkValue::jint_constant(constant.as_int());
+    break;
+
+  case T_LONG:
+    value = SharkValue::jlong_constant(constant.as_long());
+    break;
+
+  case T_FLOAT:
+    value = SharkValue::jfloat_constant(constant.as_float());
+    break;
+
+  case T_DOUBLE:
+    value = SharkValue::jdouble_constant(constant.as_double());
+    break;
+
+  case T_OBJECT:
+  case T_ARRAY:
+    break;
+
+  case T_ILLEGAL:
+    // out of memory
+    _is_loaded = false;
+    return;
+
+  default:
+    tty->print_cr("Unhandled type %s", type2name(constant.basic_type()));
+    ShouldNotReachHere();
+  }
+
+  // Handle primitive types.  We create SharkValues for these
+  // now; doing so doesn't emit any code, and it allows us to
+  // delegate a bunch of stuff to the SharkValue code.
+  if (value) {
+    _value       = value;
+    _is_loaded   = true;
+    _is_nonzero  = value->zero_checked();
+    _is_two_word = value->is_two_word();
+    return;
+  }
+
+  // Handle reference types.  This is tricky because some
+  // ciObjects are psuedo-objects that refer to oops which
+  // have yet to be created.  We need to spot the unloaded
+  // objects (which differ between ldc* and get*, thanks!)
+  ciObject *object = constant.as_object();
+  if (object->is_klass()) {
+    // The constant returned for a klass is the ciKlass
+    // for the entry, but we want the java_mirror.
+    ciKlass *klass = object->as_klass();
+    if (!klass->is_loaded()) {
+      _is_loaded = false;
+      return;
+    }
+    object = klass->java_mirror();
+  }
+  if (object->is_null_object() || !object->has_encoding()) {
+    _is_loaded = false;
+    return;
+  }
+
+  _value       = NULL;
+  _object      = object;
+  _type        = type ? type : ciType::make(T_OBJECT);
+  _is_loaded   = true;
+  _is_nonzero  = true;
+  _is_two_word = false;
+}
diff -r 6dedbb6d0a87 -r 51053321f7b4 ports/hotspot/src/share/vm/shark/sharkConstant.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ports/hotspot/src/share/vm/shark/sharkConstant.hpp	Thu Jun 04 09:48:19 2009 -0400
@@ -0,0 +1,68 @@
+/*
+ * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2009 Red Hat, Inc.
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+class SharkConstant : public ResourceObj {
+ public:
+  static SharkConstant* for_ldc(ciBytecodeStream* iter);
+  static SharkConstant* for_field(ciBytecodeStream* iter);
+
+ private:
+  SharkConstant(ciConstant constant, ciType* type);
+
+ private:
+  SharkValue* _value;
+  ciObject*   _object;
+  ciType*     _type;
+  bool        _is_loaded;
+  bool        _is_nonzero;
+  bool        _is_two_word;
+
+ public:
+  bool is_loaded() const
+  {
+    return _is_loaded;
+  }
+  bool is_nonzero() const
+  {
+    assert(is_loaded(), "should be");
+    return _is_nonzero;
+  }
+  bool is_two_word() const
+  {
+    assert(is_loaded(), "should be");
+    return _is_two_word;
+  }
+
+ public:
+  SharkValue* value(SharkBuilder* builder)
+  {
+    assert(is_loaded(), "should be");
+    if (_value == NULL) {
+      _value = SharkValue::create_generic(
+        _type, builder->CreateInlineOop(_object), _is_nonzero);
+    }
+    return _value;
+  }
+};
diff -r 6dedbb6d0a87 -r 51053321f7b4 ports/hotspot/src/share/vm/shark/sharkInliner.cpp
--- a/ports/hotspot/src/share/vm/shark/sharkInliner.cpp	Wed Jun 03 11:15:36 2009 -0400
+++ b/ports/hotspot/src/share/vm/shark/sharkInliner.cpp	Thu Jun 04 09:48:19 2009 -0400
@@ -267,7 +267,7 @@ bool SharkInlinerHelper::is_inlinable()
   ResourceMark rm;
   initialize_for_check();
 
-  SharkValue *sv;
+  SharkConstant *sc;
   bool a, b, c, d;
 
   iter()->reset_to_bci(0);
@@ -323,11 +323,11 @@ bool SharkInlinerHelper::is_inlinable()
     case Bytecodes::_ldc:
     case Bytecodes::_ldc_w:
     case Bytecodes::_ldc2_w:
-      sv = SharkValue::from_ciConstant(iter()->get_constant());
-      if (sv == NULL)
+      sc = SharkConstant::for_ldc(iter());
+      if (!sc->is_loaded())
         return false;
-      push(sv->zero_checked());
-      if (sv->is_two_word())
+      push(sc->is_nonzero());
+      if (sc->is_two_word())
         push(false);
       break;
 
@@ -753,9 +753,9 @@ bool SharkInlinerHelper::do_field_access
   if (is_get) {
     bool result_pushed = false;
     if (field->is_constant()) {
-      SharkValue *value = SharkValue::from_ciConstant(field->constant_value());
-      if (value != NULL) {
-        push(value->zero_checked());
+      SharkConstant *sc = SharkConstant::for_field(iter());
+      if (sc->is_loaded()) {
+        push(sc->is_nonzero());
         result_pushed = true;
       }
     }
diff -r 6dedbb6d0a87 -r 51053321f7b4 ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp
--- a/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp	Wed Jun 03 11:15:36 2009 -0400
+++ b/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp	Thu Jun 04 09:48:19 2009 -0400
@@ -48,7 +48,7 @@ void SharkTopLevelBlock::scan_for_traps(
     switch (bc()) {
     case Bytecodes::_ldc:
     case Bytecodes::_ldc_w:
-      if (iter()->is_unresolved_string() || iter()->is_unresolved_klass()) {
+      if (!SharkConstant::for_ldc(iter())->is_loaded()) {
         set_trap(
           Deoptimization::make_trap_request(
             Deoptimization::Reason_uninitialized,
@@ -80,10 +80,9 @@ void SharkTopLevelBlock::scan_for_traps(
       if (is_field)
         break;
 
-      // There won't be a pool access if this is a getstatic that
-      // resolves to a handled constant either
+      // There won't be a pool access if this is a constant getstatic
       if (bc() == Bytecodes::_getstatic && field->is_constant()) {
-        if (SharkValue::from_ciConstant(field->constant_value()))
+        if (SharkConstant::for_field(iter())->is_loaded())
           break;
       }
 
@@ -609,37 +608,6 @@ void SharkTopLevelBlock::handle_return(B
   builder()->CreateRetVoid();
 }
 
-Value *SharkTopLevelBlock::lookup_for_ldc()
-{
-  int index = iter()->get_constant_index();
-  constantTag tag = target()->holder()->constant_pool_tag_at(index);
-
-  SharkConstantPool constants(this);
-  Value *entry = constants.object_at(index);
-
-  Value *klass_part;
-  switch (tag.value()) {
-  case JVM_CONSTANT_String:
-    return entry;
-
-  case JVM_CONSTANT_Class:
-    klass_part = builder()->CreateAddressOfStructEntry(
-      entry,
-      in_ByteSize(klassOopDesc::klass_part_offset_in_bytes()),
-      SharkType::klass_type(),
-      "klass_part");
-    // XXX FIXME: We need a memory barrier before this load
-    return builder()->CreateValueOfStructEntry(
-      klass_part,
-      in_ByteSize(Klass::java_mirror_offset_in_bytes()),
-      SharkType::oop_type(),
-      "java_mirror");
-
-  default:
-    ShouldNotReachHere();
-  }
-}
-
 Value* SharkTopLevelBlock::lookup_for_field_access()
 {
   SharkConstantPool constants(this);
diff -r 6dedbb6d0a87 -r 51053321f7b4 ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp
--- a/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp	Wed Jun 03 11:15:36 2009 -0400
+++ b/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp	Thu Jun 04 09:48:19 2009 -0400
@@ -222,7 +222,6 @@ class SharkTopLevelBlock : public SharkB
 
   // Helpers
  private:
-  llvm::Value* lookup_for_ldc();
   llvm::Value* lookup_for_field_access();
   void do_branch(int successor_index);
 
diff -r 6dedbb6d0a87 -r 51053321f7b4 ports/hotspot/src/share/vm/shark/sharkValue.hpp
--- a/ports/hotspot/src/share/vm/shark/sharkValue.hpp	Wed Jun 03 11:15:36 2009 -0400
+++ b/ports/hotspot/src/share/vm/shark/sharkValue.hpp	Thu Jun 04 09:48:19 2009 -0400
@@ -146,45 +146,6 @@ class SharkValue : public ResourceObj {
   }
   static inline SharkValue* address_constant(int bci);
 
-  // Typed conversion from HotSpot ciConstants
- public:
-  static SharkValue* from_ciConstant(ciConstant value)
-  {
-    switch (value.basic_type()) {
-    case T_BOOLEAN:
-      return SharkValue::jint_constant(value.as_boolean());
-
-    case T_BYTE:
-      return SharkValue::jint_constant(value.as_byte());
-
-    case T_CHAR:
-      return SharkValue::jint_constant(value.as_char());
-
-    case T_SHORT:
-      return SharkValue::jint_constant(value.as_short());
-
-    case T_INT:
-      return SharkValue::jint_constant(value.as_int());
-
-    case T_LONG:
-      return SharkValue::jlong_constant(value.as_long());
-      
-    case T_FLOAT:
-      return SharkValue::jfloat_constant(value.as_float());
-      
-    case T_DOUBLE:
-      return SharkValue::jdouble_constant(value.as_double());
-      
-    case T_OBJECT:



More information about the distro-pkg-dev mailing list