changeset 2015:9b80f24b4ff6

2009-08-14 Gary Benson <gbenson@redhat.com> * ports/hotspot/src/share/vm/shark/sharkFunction.hpp (SharkFunction::CreateStoreLastJavaSP): Removed. (SharkFunction::set_last_Java_frame): Likewise. (SharkFunction::reset_last_Java_frame): Likewise. (SharkFunction::CreateGetVMResult): Likewise. (SharkFunction::pending_exception_address): Likewise. (SharkFunction::CreateGetPendingException): Likewise. * ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp (SharkTopLevelBlock::pending_exception_address): New method. (SharkTopLevelBlock::get_pending_exception): Likewise. (SharkTopLevelBlock::clear_pending_exception): Likewise. (SharkTopLevelBlock::set_last_Java_frame): Likewise. (SharkTopLevelBlock::reset_last_Java_frame): Likewise. (SharkTopLevelBlock::get_vm_result): Likewise. (SharkTopLevelBlock::call_vm): Updated. * ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp (SharkTopLevelBlock::zero_check_value): Updated. (SharkTopLevelBlock::check_bounds): Likewise. (SharkTopLevelBlock::check_pending_exception): Likewise. (SharkTopLevelBlock::handle_return): Likewise. (SharkTopLevelBlock::do_new): Likewise. (SharkTopLevelBlock::do_newarray): Likewise. (SharkTopLevelBlock::do_anewarray): Likewise. (SharkTopLevelBlock::do_multianewarray): Likewise.
author Gary Benson <gbenson@redhat.com>
date Fri, 14 Aug 2009 06:12:14 -0400
parents 9661c5e2d77b
children a5835d58e919
files ChangeLog ports/hotspot/src/share/vm/shark/sharkFunction.hpp ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp
diffstat 4 files changed, 101 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Aug 13 08:01:04 2009 -0400
+++ b/ChangeLog	Fri Aug 14 06:12:14 2009 -0400
@@ -1,3 +1,32 @@
+2009-08-14  Gary Benson  <gbenson@redhat.com>
+
+	* ports/hotspot/src/share/vm/shark/sharkFunction.hpp
+	(SharkFunction::CreateStoreLastJavaSP): Removed.
+	(SharkFunction::set_last_Java_frame): Likewise.
+	(SharkFunction::reset_last_Java_frame): Likewise.
+	(SharkFunction::CreateGetVMResult): Likewise.
+	(SharkFunction::pending_exception_address): Likewise.
+	(SharkFunction::CreateGetPendingException): Likewise.
+
+	* ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp
+	(SharkTopLevelBlock::pending_exception_address): New method.
+	(SharkTopLevelBlock::get_pending_exception): Likewise.
+	(SharkTopLevelBlock::clear_pending_exception): Likewise.
+	(SharkTopLevelBlock::set_last_Java_frame): Likewise.
+	(SharkTopLevelBlock::reset_last_Java_frame): Likewise.
+	(SharkTopLevelBlock::get_vm_result): Likewise.
+	(SharkTopLevelBlock::call_vm): Updated.
+
+	* ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp
+	(SharkTopLevelBlock::zero_check_value): Updated.
+	(SharkTopLevelBlock::check_bounds): Likewise.
+	(SharkTopLevelBlock::check_pending_exception): Likewise.
+	(SharkTopLevelBlock::handle_return): Likewise.
+	(SharkTopLevelBlock::do_new): Likewise.
+	(SharkTopLevelBlock::do_newarray): Likewise.
+	(SharkTopLevelBlock::do_anewarray): Likewise.
+	(SharkTopLevelBlock::do_multianewarray): Likewise.
+
 2009-08-13  Gary Benson  <gbenson@redhat.com>
 
 	* ports/hotspot/src/share/vm/shark/sharkEntry.hpp
--- a/ports/hotspot/src/share/vm/shark/sharkFunction.hpp	Thu Aug 13 08:01:04 2009 -0400
+++ b/ports/hotspot/src/share/vm/shark/sharkFunction.hpp	Fri Aug 14 06:12:14 2009 -0400
@@ -124,12 +124,11 @@
   {
     return builder()->CreateStore(value, zero_stack_pointer_addr());
   }
-
- private:
   llvm::LoadInst* CreateLoadZeroFramePointer(const char *name = "")
   {
     return builder()->CreateLoad(zero_frame_pointer_addr(), name);
   }
+ private:
   llvm::StoreInst* CreateStoreZeroFramePointer(llvm::Value* value)
   {
     return builder()->CreateStore(value, zero_frame_pointer_addr());
@@ -235,56 +234,6 @@
       "displaced_header_addr");
   }
 
-  // VM interface
- private:
-  llvm::StoreInst* CreateStoreLastJavaSP(llvm::Value* value) const
-  {
-    return builder()->CreateStore(
-      value,
-      builder()->CreateAddressOfStructEntry(
-        thread(), JavaThread::last_Java_sp_offset(),
-        llvm::PointerType::getUnqual(SharkType::intptr_type()),
-        "last_Java_sp_addr"));
-  }
-
- public:
-  void set_last_Java_frame()
-  {
-    CreateStoreLastJavaSP(CreateLoadZeroFramePointer());
-  }
-  void reset_last_Java_frame()
-  {
-    CreateStoreLastJavaSP(LLVMValue::intptr_constant(0));
-  }
-
- public:
-  llvm::LoadInst* CreateGetVMResult() const
-  {
-    llvm::Value *addr = builder()->CreateAddressOfStructEntry(
-      thread(), JavaThread::vm_result_offset(),
-      llvm::PointerType::getUnqual(SharkType::jobject_type()),
-      "vm_result_addr");
-    llvm::LoadInst *result = builder()->CreateLoad(addr, "vm_result");
-    builder()->CreateStore(LLVMValue::null(), addr);
-    return result;
-  }
-
- public:
-  llvm::Value* pending_exception_address() const
-  {
-    return builder()->CreateAddressOfStructEntry(
-      thread(), Thread::pending_exception_offset(),
-      llvm::PointerType::getUnqual(SharkType::jobject_type()),
-      "pending_exception_addr");
-  }
-  llvm::LoadInst* CreateGetPendingException() const
-  {
-    llvm::Value *addr = pending_exception_address();
-    llvm::LoadInst *result = builder()->CreateLoad(addr, "pending_exception");
-    builder()->CreateStore(LLVMValue::null(), addr);
-    return result;
-  }
-
   // Deferred zero checks
  public:
   void add_deferred_zero_check(SharkTopLevelBlock* block,
--- a/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp	Thu Aug 13 08:01:04 2009 -0400
+++ b/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp	Fri Aug 14 06:12:14 2009 -0400
@@ -334,7 +334,10 @@
   else {
     builder()->CreateUnimplemented(__FILE__, __LINE__);
   } 
-  handle_exception(function()->CreateGetPendingException(), EX_CHECK_FULL);
+
+  Value *pending_exception = get_pending_exception();
+  clear_pending_exception();
+  handle_exception(pending_exception, EX_CHECK_FULL);
 }
 
 void SharkTopLevelBlock::check_bounds(SharkValue* array, SharkValue* index)
@@ -350,6 +353,7 @@
 
   builder()->SetInsertPoint(out_of_bounds);
   SharkState *saved_state = current_state()->copy();
+
   call_vm(
     builder()->throw_ArrayIndexOutOfBoundsException(),
     builder()->CreateIntToPtr(
@@ -358,7 +362,11 @@
     LLVMValue::jint_constant(__LINE__),
     index->jint_value(),
     EX_CHECK_NONE);
-  handle_exception(function()->CreateGetPendingException(), EX_CHECK_FULL);
+
+  Value *pending_exception = get_pending_exception();
+  clear_pending_exception();
+  handle_exception(pending_exception, EX_CHECK_FULL);
+
   set_current_state(saved_state);  
 
   builder()->SetInsertPoint(in_bounds);
@@ -371,16 +379,12 @@
   BasicBlock *exception    = function()->CreateBlock("exception");
   BasicBlock *no_exception = function()->CreateBlock("no_exception");
 
-  Value *pending_exception_addr = function()->pending_exception_address();
-  Value *pending_exception = builder()->CreateLoad(
-    pending_exception_addr, "pending_exception");
-
+  Value *pending_exception = get_pending_exception();
   builder()->CreateCondBr(
     builder()->CreateICmpEQ(pending_exception, LLVMValue::null()),
     no_exception, exception);
 
   builder()->SetInsertPoint(exception);
-  builder()->CreateStore(LLVMValue::null(), pending_exception_addr);
   SharkState *saved_state = current_state()->copy();
   if (action & EAM_MONITOR_FUDGE) {
     // The top monitor is marked live, but the exception was thrown
@@ -389,6 +393,7 @@
     set_num_monitors(num_monitors() - 1);
     action ^= EAM_MONITOR_FUDGE;
   }
+  clear_pending_exception();
   handle_exception(pending_exception, action); 
   set_current_state(saved_state);
 
@@ -630,7 +635,7 @@
   }
 
   if (exception) {
-    builder()->CreateStore(exception, function()->pending_exception_address());
+    builder()->CreateStore(exception, pending_exception_address());
   }
 
   Value *result_addr = function()->CreatePopFrame(type2size[type]);
@@ -1576,7 +1581,7 @@
     builder()->new_instance(),
     LLVMValue::jint_constant(iter()->get_klass_index()),
     EX_CHECK_FULL);
-  slow_object = function()->CreateGetVMResult();
+  slow_object = get_vm_result();
   got_slow = builder()->GetInsertBlock();
 
   // Push the object
@@ -1608,10 +1613,8 @@
     pop()->jint_value(),
     EX_CHECK_FULL);
 
-  push(SharkValue::create_generic(
-    ciArrayKlass::make(ciType::make(type)),
-    function()->CreateGetVMResult(),
-    true));
+  ciArrayKlass *array_klass = ciArrayKlass::make(ciType::make(type));
+  push(SharkValue::create_generic(array_klass, get_vm_result(), true));
 }
 
 void SharkTopLevelBlock::do_anewarray()
@@ -1631,8 +1634,7 @@
     pop()->jint_value(),
     EX_CHECK_FULL);
 
-  push(SharkValue::create_generic(
-    array_klass, function()->CreateGetVMResult(), true));
+  push(SharkValue::create_generic(array_klass, get_vm_result(), true));
 }
 
 void SharkTopLevelBlock::do_multianewarray()
@@ -1668,8 +1670,7 @@
   for (int i = 0; i < ndims; i++)
     pop();
 
-  push(SharkValue::create_generic(
-    array_klass, function()->CreateGetVMResult(), true));
+  push(SharkValue::create_generic(array_klass, get_vm_result(), true));
 }
 
 void SharkTopLevelBlock::acquire_method_lock()
--- a/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp	Thu Aug 13 08:01:04 2009 -0400
+++ b/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp	Fri Aug 14 06:12:14 2009 -0400
@@ -240,6 +240,24 @@
                               SharkState*       saved_state,
                               llvm::BasicBlock* continue_block);
   // Exceptions
+ private:
+  llvm::Value* pending_exception_address() const
+  {
+    return builder()->CreateAddressOfStructEntry(
+      thread(), Thread::pending_exception_offset(),
+      llvm::PointerType::getUnqual(SharkType::jobject_type()),
+      "pending_exception_addr");
+  }
+  llvm::LoadInst* get_pending_exception() const
+  {
+    return builder()->CreateLoad(
+      pending_exception_address(), "pending_exception");
+  }
+  void clear_pending_exception() const
+  {
+    builder()->CreateStore(LLVMValue::null(), pending_exception_address());
+  }
+ public:
   enum ExceptionActionMask {
     // The actual bitmasks that things test against
     EAM_CHECK         = 1, // whether to check for pending exceptions
@@ -254,6 +272,26 @@
   void check_pending_exception(int action);
   void handle_exception(llvm::Value* exception, int action);
 
+  // Frame anchor
+ private:
+  void set_last_Java_frame(llvm::Value* value) const
+  {
+    builder()->CreateStore(
+      value,
+      builder()->CreateAddressOfStructEntry(
+        thread(), JavaThread::last_Java_sp_offset(),
+        llvm::PointerType::getUnqual(SharkType::intptr_type()),
+        "last_Java_sp_addr"));
+  }
+  void set_last_Java_frame() const
+  {
+    set_last_Java_frame(function()->CreateLoadZeroFramePointer());
+  }
+  void reset_last_Java_frame() const
+  {
+    set_last_Java_frame(LLVMValue::intptr_constant(0));
+  }
+
   // VM calls
  private:
   llvm::CallInst* call_vm(llvm::Value*  callee,
@@ -262,9 +300,9 @@
                           int           exception_action)
   {
     decache_for_VM_call();
-    function()->set_last_Java_frame();
+    set_last_Java_frame();
     llvm::CallInst *res = builder()->CreateCall(callee, args_start, args_end);
-    function()->reset_last_Java_frame();
+    reset_last_Java_frame();
     cache_after_VM_call();
     if (exception_action & EAM_CHECK) {
       check_pending_exception(exception_action);
@@ -305,6 +343,19 @@
     return call_vm(callee, args, args + 4, exception_action);
   }
 
+  // VM call oop return handling
+ private:
+  llvm::LoadInst* get_vm_result() const
+  {
+    llvm::Value *addr = builder()->CreateAddressOfStructEntry(
+      thread(), JavaThread::vm_result_offset(),
+      llvm::PointerType::getUnqual(SharkType::jobject_type()),
+      "vm_result_addr");
+    llvm::LoadInst *result = builder()->CreateLoad(addr, "vm_result");
+    builder()->CreateStore(LLVMValue::null(), addr);
+    return result;
+  }
+
   // Synchronization
  private:
   void acquire_lock(llvm::Value* lockee, int exception_action);