changeset 1309:e34ba0ba2281

2009-01-12 Andrew Haley <aph@redhat.com> * ports/hotspot/src/share/vm/shark/sharkBlock.cpp (SharkBlock::do_ldc): Add logic for ldc(Class).
author Andrew Haley <aph@redhat.com>
date Mon, 12 Jan 2009 17:29:21 +0000
parents bce8d56dfa03
children c672bd2ca978
files ChangeLog ports/hotspot/src/share/vm/shark/sharkBlock.cpp
diffstat 2 files changed, 29 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Jan 11 18:56:44 2009 +0100
+++ b/ChangeLog	Mon Jan 12 17:29:21 2009 +0000
@@ -1,3 +1,8 @@
+2009-01-12  Andrew Haley  <aph@redhat.com>
+
+	* ports/hotspot/src/share/vm/shark/sharkBlock.cpp (SharkBlock::do_ldc):
+        Add logic for ldc(Class).
+
 2009-01-11  Mark Wielaard  <mark@klomp.org>
 
 	* Makefile.am: Escape single quotes in empty bootclasspath.
--- a/ports/hotspot/src/share/vm/shark/sharkBlock.cpp	Sun Jan 11 18:56:44 2009 +0100
+++ b/ports/hotspot/src/share/vm/shark/sharkBlock.cpp	Mon Jan 12 17:29:21 2009 +0000
@@ -1236,10 +1236,11 @@
     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);
@@ -1247,7 +1248,7 @@
     switchinst->addCase(
       LLVMValue::jbyte_constant(JVM_CONSTANT_String), resolved);
     switchinst->addCase(
-      LLVMValue::jbyte_constant(JVM_CONSTANT_Class), resolved);
+      LLVMValue::jbyte_constant(JVM_CONSTANT_Class), resolved_class);
     switchinst->addCase(
       LLVMValue::jbyte_constant(JVM_CONSTANT_UnresolvedString), unresolved);
     switchinst->addCase(
@@ -1260,6 +1261,26 @@
     Value *resolved_value = constants.object_at(iter()->get_constant_index());
     builder()->CreateBr(done);
 
+    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()))));
+    resolved_class_value
+      // FIXME: We need a memory barrier before this load.
+      = (builder()->CreateLoad
+         (builder()->CreateIntToPtr
+          (resolved_class_value,
+           PointerType::getUnqual(SharkType::jobject_type()))));
+    builder()->CreateBr(done);
+
     builder()->SetInsertPoint(unresolved);
     builder()->CreateUnimplemented(__FILE__, __LINE__);
     Value *unresolved_value = LLVMValue::null();
@@ -1272,6 +1293,7 @@
     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);
     value = SharkValue::create_jobject(phi);
   }