changeset 1545:42808514c1fb

More
author Gary Benson <gbenson@redhat.com>
date Thu, 20 May 2010 10:12:20 +0100
parents 83e300e89e9a
children f9f20a7a2119
files src/share/vm/shark/sharkTopLevelBlock.cpp src/share/vm/shark/sharkTopLevelBlock.hpp
diffstat 2 files changed, 55 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/shark/sharkTopLevelBlock.cpp	Thu May 20 09:56:14 2010 +0100
+++ b/src/share/vm/shark/sharkTopLevelBlock.cpp	Thu May 20 10:12:20 2010 +0100
@@ -508,7 +508,7 @@
     if (has_catch_all)
       num_options--;
 
-    // Drop into the runtime if there are non-catch-all options
+    // Handle non-catch-all handlers
     if (num_options > 0) {
       bool all_loaded = true;
       for (int i = 0; i < num_options; i++) {
@@ -518,55 +518,16 @@
         }
       }
 
-      if (PrintCompilation) {
-        tty->print_cr("            all_loaded = %d", all_loaded);
-      }
-
-      int *indexes = NEW_RESOURCE_ARRAY(int, num_options);
-      for (int i = 0; i < num_options; i++)
-        indexes[i] = exc_handler(i)->catch_klass_index();
-
-      Value *index = call_vm(
-        builder()->find_exception_handler(),
-        builder()->CreateInlineData(
-          indexes,
-          num_options * sizeof(int),
-          PointerType::getUnqual(SharkType::jint_type())),
-        LLVMValue::jint_constant(num_options),
-        EX_CHECK_NO_CATCH);
-
-      // Jump to the exception handler, if found
-      BasicBlock *no_handler = function()->CreateBlock("no_handler");
-      SwitchInst *switchinst = builder()->CreateSwitch(
-        index, no_handler, num_options);
-
-      for (int i = 0; i < num_options; i++) {
-        SharkTopLevelBlock *successor = this->exception(i);
-        BasicBlock* handler;
-        if (successor) {
-          handler = successor->entry_block();
-          successor->add_incoming(current_state());
-        }
-        else {
-          handler = make_trap(
-            exc_handler(i)->handler_bci(),
-            Deoptimization::make_trap_request(
-              Deoptimization::Reason_unhandled,
-              Deoptimization::Action_reinterpret));
-        }
-
-        switchinst->addCase(
-          LLVMValue::jint_constant(i),
-          handler);
-      }
-
-      builder()->SetInsertPoint(no_handler);
+      if (all_loaded)
+        marshal_exception_fast(num_options);
+      else
+        marshal_exception_slow(num_options);
     }
 
-    // No specific handler exists, but maybe there's a catch-all
+    // Handle catch-all handler
     if (has_catch_all) {
       SharkTopLevelBlock* handler = this->exception(num_options);
-      assert(handler, "no catch all handler?");
+      assert(handler != NULL, "catch-all handler cannot be unloaded");
 
       builder()->CreateBr(handler->entry_block());
       handler->add_incoming(current_state());
@@ -578,6 +539,52 @@
   handle_return(T_VOID, exception);
 }
 
+void SharkTopLevelBlock::marshal_exception_fast(int num_options) {
+  Unimplemented();
+}
+
+void SharkTopLevelBlock::marshal_exception_slow(int num_options) {
+  int *indexes = NEW_RESOURCE_ARRAY(int, num_options);
+  for (int i = 0; i < num_options; i++)
+    indexes[i] = exc_handler(i)->catch_klass_index();
+
+  Value *index = call_vm(
+    builder()->find_exception_handler(),
+    builder()->CreateInlineData(
+      indexes,
+      num_options * sizeof(int),
+      PointerType::getUnqual(SharkType::jint_type())),
+    LLVMValue::jint_constant(num_options),
+    EX_CHECK_NO_CATCH);
+
+  // Jump to the exception handler, if found
+  BasicBlock *no_handler = function()->CreateBlock("no_handler");
+  SwitchInst *switchinst = builder()->CreateSwitch(
+    index, no_handler, num_options);
+
+  for (int i = 0; i < num_options; i++) {
+    SharkTopLevelBlock *successor = this->exception(i);
+    BasicBlock* handler;
+    if (successor) {
+      handler = successor->entry_block();
+      successor->add_incoming(current_state());
+    }
+    else {
+      handler = make_trap(
+        exc_handler(i)->handler_bci(),
+        Deoptimization::make_trap_request(
+          Deoptimization::Reason_unhandled,
+          Deoptimization::Action_reinterpret));
+    }
+
+    switchinst->addCase(
+      LLVMValue::jint_constant(i),
+      handler);
+  }
+
+  builder()->SetInsertPoint(no_handler);
+}
+
 void SharkTopLevelBlock::maybe_add_safepoint() {
   if (current_state()->has_safepointed())
     return;
--- a/src/share/vm/shark/sharkTopLevelBlock.hpp	Thu May 20 09:56:14 2010 +0100
+++ b/src/share/vm/shark/sharkTopLevelBlock.hpp	Thu May 20 10:12:20 2010 +0100
@@ -263,6 +263,8 @@
   };
   void check_pending_exception(int action);
   void handle_exception(llvm::Value* exception, int action);
+  void marshal_exception_fast(int num_options);
+  void marshal_exception_slow(int num_options);
 
   // VM calls
  private: