changeset 2014:9661c5e2d77b

2009-08-13 Gary Benson <gbenson@redhat.com> * ports/hotspot/src/share/vm/shark/sharkEntry.hpp (SharkEntry::_function): New field. (SharkEntry::function): New method. (SharkEntry::set_function): Likewise. * ports/hotspot/src/share/vm/shark/sharkCompiler.hpp (SharkCompiler::free_compiled_method): New method. * ports/hotspot/src/share/vm/shark/sharkCompiler.cpp (SharkCompiler::free_compiled_method): New method. (SharkCompiler::compile_method): Store a pointer to the LLVM function in the method's SharkEntry. * patches/hotspot/default/icedtea-shark.patch (nmethod::flush): Add code to free Shark methods. * ports/hotspot/src/share/vm/includeDB_shark: Updated.
author Gary Benson <gbenson@redhat.com>
date Thu, 13 Aug 2009 08:01:04 -0400
parents c2763f965b2d
children 9b80f24b4ff6
files ChangeLog patches/hotspot/default/icedtea-shark.patch ports/hotspot/src/share/vm/includeDB_shark ports/hotspot/src/share/vm/shark/sharkCompiler.cpp ports/hotspot/src/share/vm/shark/sharkCompiler.hpp ports/hotspot/src/share/vm/shark/sharkEntry.hpp
diffstat 6 files changed, 57 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Oct 28 23:07:25 2009 +0000
+++ b/ChangeLog	Thu Aug 13 08:01:04 2009 -0400
@@ -1,3 +1,22 @@
+2009-08-13  Gary Benson  <gbenson@redhat.com>
+
+	* ports/hotspot/src/share/vm/shark/sharkEntry.hpp
+	(SharkEntry::_function): New field.
+	(SharkEntry::function): New method.
+	(SharkEntry::set_function): Likewise.
+
+	* ports/hotspot/src/share/vm/shark/sharkCompiler.hpp
+	(SharkCompiler::free_compiled_method): New method.	
+	* ports/hotspot/src/share/vm/shark/sharkCompiler.cpp
+	(SharkCompiler::free_compiled_method): New method.
+	(SharkCompiler::compile_method): Store a pointer to
+	the LLVM function in the method's SharkEntry.
+
+	* patches/hotspot/default/icedtea-shark.patch
+	(nmethod::flush): Add code to free Shark methods.
+
+	* ports/hotspot/src/share/vm/includeDB_shark: Updated.
+
 2009-10-28  Andrew John Hughes  <ahughes@redhat.com>
 
 	* Makefile.am:
--- a/patches/hotspot/default/icedtea-shark.patch	Wed Oct 28 23:07:25 2009 +0000
+++ b/patches/hotspot/default/icedtea-shark.patch	Thu Aug 13 08:01:04 2009 -0400
@@ -124,6 +124,20 @@
    address       native_entry();
    address       interpreter_entry();
  
+diff -r 0d80af392e67 openjdk/hotspot/src/share/vm/code/nmethod.cpp
+--- openjdk/hotspot/src/share/vm/code/nmethod.cpp	Thu Jul 30 10:00:04 2009 +0100
++++ openjdk/hotspot/src/share/vm/code/nmethod.cpp	Fri Jul 31 15:39:43 2009 +0100
+@@ -1296,6 +1296,10 @@
+     ec = next;
+   }
+ 
++#ifdef SHARK
++  ((SharkCompiler *) compiler())->free_compiled_method(instructions_begin());
++#endif // SHARK
++  
+   ((CodeBlob*)(this))->flush();
+ 
+   CodeCache::free(this);
 diff -Nru openjdk.orig/hotspot/src/share/vm/code/nmethod.cpp openjdk/hotspot/src/share/vm/code/nmethod.cpp
 --- openjdk.orig/hotspot/src/share/vm/code/nmethod.cpp	2009-09-21 17:12:24.000000000 +0100
 +++ openjdk/hotspot/src/share/vm/code/nmethod.cpp	2009-09-23 12:40:53.000000000 +0100
--- a/ports/hotspot/src/share/vm/includeDB_shark	Wed Oct 28 23:07:25 2009 +0000
+++ b/ports/hotspot/src/share/vm/includeDB_shark	Thu Aug 13 08:01:04 2009 -0400
@@ -57,7 +57,7 @@
 llvmValue.hpp                           llvmHeaders.hpp
 llvmValue.hpp                           sharkType.hpp
 
-methodOop.cpp                           sharkEntry.hpp
+nmethod.cpp                             sharkCompiler.hpp
 
 shark_globals.cpp                       shark_globals.hpp
 
--- a/ports/hotspot/src/share/vm/shark/sharkCompiler.cpp	Wed Oct 28 23:07:25 2009 +0000
+++ b/ports/hotspot/src/share/vm/shark/sharkCompiler.cpp	Thu Aug 13 08:01:04 2009 -0400
@@ -146,6 +146,7 @@
     if (!fnmatch(SharkPrintBitcodeOf, name, 0))
       function->dump();
   }
+  entry->set_function(function);
 
   // Compile to native code
 #ifndef PRODUCT
@@ -206,6 +207,13 @@
   }
 }
 
+void SharkCompiler::free_compiled_method(address code)
+{
+  Function *function = ((SharkEntry *) code)->function();
+  execution_engine()->freeMachineCodeForFunction(function);
+  function->eraseFromParent();
+}
+
 const char* SharkCompiler::methodname(const ciMethod* target)
 {
   const char *klassname = target->holder()->name()->as_utf8();
--- a/ports/hotspot/src/share/vm/shark/sharkCompiler.hpp	Wed Oct 28 23:07:25 2009 +0000
+++ b/ports/hotspot/src/share/vm/shark/sharkCompiler.hpp	Thu Aug 13 08:01:04 2009 -0400
@@ -45,6 +45,9 @@
   // Compilation entry point for methods
   void compile_method(ciEnv* env, ciMethod* target, int entry_bci);
 
+  // Free compiled methods
+  void free_compiled_method(address code);
+
   // LLVM interface
  private:
   llvm::Module*          _module;
--- a/ports/hotspot/src/share/vm/shark/sharkEntry.hpp	Wed Oct 28 23:07:25 2009 +0000
+++ b/ports/hotspot/src/share/vm/shark/sharkEntry.hpp	Thu Aug 13 08:01:04 2009 -0400
@@ -24,10 +24,9 @@
  */
 
 class SharkEntry : public ZeroEntry {
-  friend class SharkMemoryManager;
-
  private:
-  address _code_limit;
+  address         _code_limit;
+  llvm::Function* _function;
 
  public:
   address code_start() const
@@ -38,9 +37,18 @@
   {
     return _code_limit;
   }
- protected:
+  llvm::Function* function() const
+  {
+    return _function;
+  }
+
+ public:
   void set_code_limit(address code_limit)
   {
     _code_limit = code_limit;
   }
+  void set_function(llvm::Function* function)
+  {
+    _function = function;
+  }
 };