A bunch of Shark fixes

Andrew Haley aph at redhat.com
Fri Nov 21 10:54:18 PST 2008


This is a combination of endian fixes, wordsize fizes, and a change to work
with the latest LLVM.

Shark still doesn't work right on x86_64, though: more to do.

Andrew.


2008-11-21  Andrew Haley  <aph at redhat.com>

	* ports/hotspot/src/share/vm/shark/sharkValue.hpp
	(class SharkComputableValue): Use IRBuilder<>, not IRBuilder.
	(class SharkValue): Use IRBuilder<>, not IRBuilder.
	* ports/hotspot/src/share/vm/shark/sharkFunction.cpp
	(SharkFunction::CreatePopFrame): Change a few jint_types to
	intptr_types.
	* ports/hotspot/src/share/vm/shark/sharkConstantPool.cpp
	(SharkConstantPool::cache_entry_at): Byte-swap the cache index.
	* ports/hotspot/src/share/vm/shark/sharkBuilder.cpp
	(SharkBuilder::SharkBuilder) Inherit from template class
	IRBuilder<>.
	* ports/hotspot/src/share/vm/shark/sharkBuilder.hpp:
	(SharkBuilder::SharkBuilder) Inherit from template class
	IRBuilder<>.
	Change a few jint_types to intptr_types.	
	* ports/hotspot/src/share/vm/shark/sharkBlock.cpp
	(SharkBlock::get_interface_callee): Change a few jint_types to
	intptr_types.

diff -r ff7010bc3cae ports/hotspot/src/share/vm/shark/sharkBlock.cpp
--- a/ports/hotspot/src/share/vm/shark/sharkBlock.cpp	Tue Nov 18 11:04:46 2008 -0500
+++ b/ports/hotspot/src/share/vm/shark/sharkBlock.cpp	Fri Nov 21 17:43:16 2008 +0000
@@ -1814,6 +1814,8 @@
     in_ByteSize(instanceKlass::vtable_length_offset() * HeapWordSize),
     SharkType::jint_type(),
     "vtable_length");
+  vtable_length =
+    builder()->CreateIntCast(vtable_length, SharkType::intptr_type(), false);

   bool needs_aligning = HeapWordsPerLong > 1;
   const char *itable_start_name = "itable_start";
@@ -1821,7 +1823,7 @@
     vtable_start,
     builder()->CreateShl(
       vtable_length,
-      LLVMValue::jint_constant(exact_log2(vtableEntry::size() * wordSize))),
+      LLVMValue::intptr_constant(exact_log2(vtableEntry::size() * wordSize))),
     needs_aligning ? "" : itable_start_name);
   if (needs_aligning)
     itable_start = builder()->CreateAlign(
@@ -1878,6 +1880,8 @@
     in_ByteSize(itableOffsetEntry::offset_offset_in_bytes()),
     SharkType::jint_type(),
     "offset");
+  offset =
+    builder()->CreateIntCast(offset, SharkType::intptr_type(), false);

   Value *index = builder()->CreateValueOfStructEntry(
     cache, ConstantPoolCacheEntry::f2_offset(),
@@ -1894,7 +1898,7 @@
             offset),
           builder()->CreateShl(
             index,
-            LLVMValue::jint_constant(
+            LLVMValue::intptr_constant(
               exact_log2(itableMethodEntry::size() * wordSize)))),
         LLVMValue::intptr_constant(
           itableMethodEntry::method_offset_in_bytes())),
diff -r ff7010bc3cae ports/hotspot/src/share/vm/shark/sharkBuilder.cpp
--- a/ports/hotspot/src/share/vm/shark/sharkBuilder.cpp	Tue Nov 18 11:04:46 2008 -0500
+++ b/ports/hotspot/src/share/vm/shark/sharkBuilder.cpp	Fri Nov 21 17:43:16 2008 +0000
@@ -29,7 +29,7 @@
 using namespace llvm;

 SharkBuilder::SharkBuilder()
-  : IRBuilder(),
+  : IRBuilder<>(),
       _module("shark"),
       _module_provider(module()),
       _execution_engine(ExecutionEngine::create(&_module_provider))
diff -r ff7010bc3cae ports/hotspot/src/share/vm/shark/sharkBuilder.hpp
--- a/ports/hotspot/src/share/vm/shark/sharkBuilder.hpp	Tue Nov 18 11:04:46 2008 -0500
+++ b/ports/hotspot/src/share/vm/shark/sharkBuilder.hpp	Fri Nov 21 17:43:16 2008 +0000
@@ -23,7 +23,7 @@
  *
  */

-class SharkBuilder : public llvm::IRBuilder {
+class SharkBuilder : public llvm::IRBuilder<> {
  public:
   SharkBuilder();

@@ -81,13 +81,13 @@
                                   llvm::Value*      index,
                                   const char*       name = "")
   {
-    llvm::Value* offset = index;
+    llvm::Value* offset = CreateIntCast(index, SharkType::intptr_type(), false);
     if (element_bytes != 1)
       offset = CreateShl(
         offset,
-        LLVMValue::jint_constant(exact_log2(element_bytes)));
+        LLVMValue::intptr_constant(exact_log2(element_bytes)));
     offset = CreateAdd(
-      LLVMValue::jint_constant(in_bytes(base_offset)), offset);
+      LLVMValue::intptr_constant(in_bytes(base_offset)), offset);

     return CreateIntToPtr(
       CreateAdd(CreatePtrToInt(arrayoop, SharkType::intptr_type()), offset),
diff -r ff7010bc3cae ports/hotspot/src/share/vm/shark/sharkConstantPool.cpp
--- a/ports/hotspot/src/share/vm/shark/sharkConstantPool.cpp	Tue Nov 18 11:04:46 2008 -0500
+++ b/ports/hotspot/src/share/vm/shark/sharkConstantPool.cpp	Fri Nov 21 17:43:16 2008 +0000
@@ -82,6 +82,12 @@

 Value *SharkConstantPool::cache_entry_at(int which)
 {
+  // Takes a constant pool cache index in byte-swapped byte order
+  // (which comes from the bytecodes after rewriting).  This is a
+  // bizarre hack but it's the same as
+  // constantPoolOopDesc::field_or_method_at().
+  which = Bytes::swap_u2(which);
+
   Value *entry = builder()->CreateIntToPtr(
     builder()->CreateAdd(
       builder()->CreatePtrToInt(
@@ -109,7 +115,7 @@
       builder()->CreateValueOfStructEntry(
         entry, ConstantPoolCacheEntry::indices_offset(),
         SharkType::intptr_type()),
-      LLVMValue::jint_constant(shift)),
+      LLVMValue::intptr_constant(shift)),
     LLVMValue::intptr_constant(0xff));

   BasicBlock *orig_block = builder()->GetInsertBlock();
diff -r ff7010bc3cae ports/hotspot/src/share/vm/shark/sharkFunction.cpp
--- a/ports/hotspot/src/share/vm/shark/sharkFunction.cpp	Tue Nov 18 11:04:46 2008 -0500
+++ b/ports/hotspot/src/share/vm/shark/sharkFunction.cpp	Fri Nov 21 17:43:16 2008 +0000
@@ -182,7 +182,7 @@
   Value *fp = CreateLoadZeroFramePointer();
   Value *sp = builder()->CreateAdd(
     fp,
-    LLVMValue::jint_constant((1 + locals_to_pop) * wordSize));
+    LLVMValue::intptr_constant((1 + locals_to_pop) * wordSize));

   CreateStoreZeroStackPointer(sp);
   CreateStoreZeroFramePointer(
diff -r ff7010bc3cae ports/hotspot/src/share/vm/shark/sharkValue.hpp
--- a/ports/hotspot/src/share/vm/shark/sharkValue.hpp	Tue Nov 18 11:04:46 2008 -0500
+++ b/ports/hotspot/src/share/vm/shark/sharkValue.hpp	Fri Nov 21 17:43:16 2008 +0000
@@ -246,7 +246,7 @@
   {
     ShouldNotCallThis();
   }
-  virtual llvm::Value* intptr_value(llvm::IRBuilder* builder) const
+  virtual llvm::Value* intptr_value(llvm::IRBuilder<>* builder) const
   {
     ShouldNotCallThis();
   }
@@ -370,7 +370,7 @@
   {
     return llvm_value();
   }
-  llvm::Value* intptr_value(llvm::IRBuilder* builder) const
+  llvm::Value* intptr_value(llvm::IRBuilder<>* builder) const
   {
     assert(is_jobject(), "should be");
     return builder->CreatePtrToInt(llvm_value(), SharkType::intptr_type());



More information about the distro-pkg-dev mailing list