changeset 1786:1dd098e01109

2009-04-29 Gary Benson <gbenson@redhat.com> * ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp (SharkTopLevelBlock::scan_for_traps): Trap on ldc and ldc_w when the constant is unresolved. (SharkTopLevelBlock::lookup_for_ldc): Rewritten. * ports/hotspot/src/share/vm/shark/sharkConstantPool.cpp (SharkConstantPool::java_mirror): Add a comment.
author Gary Benson <gbenson@redhat.com>
date Wed, 29 Apr 2009 04:53:32 -0400
parents 559f45c9f58a
children 05e7319d1854
files ChangeLog ports/hotspot/src/share/vm/shark/sharkConstantPool.cpp ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp
diffstat 3 files changed, 44 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue May 19 16:12:46 2009 +0100
+++ b/ChangeLog	Wed Apr 29 04:53:32 2009 -0400
@@ -1,3 +1,12 @@
+2009-04-29  Gary Benson  <gbenson@redhat.com>
+
+	* ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp
+	(SharkTopLevelBlock::scan_for_traps): Trap on ldc and ldc_w
+	when the constant is unresolved.
+	(SharkTopLevelBlock::lookup_for_ldc): Rewritten.
+	* ports/hotspot/src/share/vm/shark/sharkConstantPool.cpp
+	(SharkConstantPool::java_mirror): Add a comment.
+
 2009-04-28  Gary Benson  <gbenson@redhat.com>
 
 	* patches/hotspot/default/icedtea-shark.patch
--- a/ports/hotspot/src/share/vm/shark/sharkConstantPool.cpp	Tue May 19 16:12:46 2009 +0100
+++ b/ports/hotspot/src/share/vm/shark/sharkConstantPool.cpp	Wed Apr 29 04:53:32 2009 -0400
@@ -116,6 +116,7 @@
     SharkType::klass_type(),
     "klass_part");
 
+  // XXX should there be a memory barrier before this load?
   return builder()->CreateValueOfStructEntry(
     klass_part,
     in_ByteSize(Klass::java_mirror_offset_in_bytes()),
--- a/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp	Tue May 19 16:12:46 2009 +0100
+++ b/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp	Wed Apr 29 04:53:32 2009 -0400
@@ -46,6 +46,17 @@
     int index = -1;
 
     switch (bc()) {
+    case Bytecodes::_ldc:
+    case Bytecodes::_ldc_w:
+      if (iter()->is_unresolved_string() || iter()->is_unresolved_klass()) {
+        set_trap(
+          Deoptimization::make_trap_request(
+            Deoptimization::Reason_uninitialized,
+            Deoptimization::Action_reinterpret), bci());
+        return;
+      }
+      break;
+      
     case Bytecodes::_getfield:
     case Bytecodes::_getstatic:
     case Bytecodes::_putfield:
@@ -579,69 +590,33 @@
 
 Value *SharkTopLevelBlock::lookup_for_ldc()
 {
-  SharkConstantPool constants(this);
-
-  BasicBlock *resolved       = function()->CreateBlock("resolved");
-  BasicBlock *resolved_class = function()->CreateBlock("resolved_class");
-  BasicBlock *unresolved     = function()->CreateBlock("unresolved");
-  BasicBlock *unknown        = function()->CreateBlock("unknown");
-  BasicBlock *done           = function()->CreateBlock("done");
-
-  SwitchInst *switchinst = builder()->CreateSwitch(
-    constants.tag_at(iter()->get_constant_index()),
-    unknown, 5);
+  int index = iter()->get_constant_index();
+  constantTag tag = target()->holder()->constant_pool_tag_at(index);
 
-  switchinst->addCase(
-    LLVMValue::jbyte_constant(JVM_CONSTANT_String), resolved);
-  switchinst->addCase(
-    LLVMValue::jbyte_constant(JVM_CONSTANT_Class), resolved_class);
-  switchinst->addCase(
-    LLVMValue::jbyte_constant(JVM_CONSTANT_UnresolvedString), unresolved);
-  switchinst->addCase(
-    LLVMValue::jbyte_constant(JVM_CONSTANT_UnresolvedClass), unresolved);
-  switchinst->addCase(
-    LLVMValue::jbyte_constant(JVM_CONSTANT_UnresolvedClassInError),
-    unresolved);
+  SharkConstantPool constants(this);
+  Value *entry = constants.object_at(index);
 
-  builder()->SetInsertPoint(resolved);
-  Value *resolved_value = constants.object_at(iter()->get_constant_index());
-  builder()->CreateBr(done);
+  Value *klass_part;
+  switch (tag.value()) {
+  case JVM_CONSTANT_String:
+    return entry;
 
-  builder()->SetInsertPoint(resolved_class);
-  Value *resolved_class_value
-    = constants.object_at(iter()->get_constant_index());
-  resolved_class_value
-    = builder()->CreatePtrToInt(resolved_class_value,
-                                SharkType::intptr_type());
-  resolved_class_value
-    = (builder()->CreateAdd
-       (resolved_class_value,
-        (LLVMValue::intptr_constant
-         (klassOopDesc::klass_part_offset_in_bytes()
-          + Klass::java_mirror_offset_in_bytes()))));
-  // XXX FIXME: We need a memory barrier before this load.
-  resolved_class_value
-    = (builder()->CreateLoad
-       (builder()->CreateIntToPtr
-        (resolved_class_value,
-         PointerType::getUnqual(SharkType::jobject_type()))));
-  builder()->CreateBr(done);
+  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");
 
-  builder()->SetInsertPoint(unresolved);
-  builder()->CreateUnimplemented(__FILE__, __LINE__);
-  Value *unresolved_value = LLVMValue::null();
-  builder()->CreateBr(done);
-
-  builder()->SetInsertPoint(unknown);
-  builder()->CreateShouldNotReachHere(__FILE__, __LINE__);
-  builder()->CreateUnreachable();
-
-  builder()->SetInsertPoint(done);
-  PHINode *phi = builder()->CreatePHI(SharkType::jobject_type(), "constant");
-  phi->addIncoming(resolved_value, resolved);
-  phi->addIncoming(resolved_class_value, resolved_class);
-  phi->addIncoming(unresolved_value, unresolved);
-  return phi;
+  default:
+    ShouldNotReachHere();
+  }
 }
 
 Value* SharkTopLevelBlock::lookup_for_field_access()