6975855: don't emit deopt MH handler in C1 if not required
authortwisti
Wed, 11 Aug 2010 01:17:27 -0700
changeset 6186 7eef4cda471c
parent 6185 1d2b3c0c9674
child 6187 4fa7845f7c14
6975855: don't emit deopt MH handler in C1 if not required Summary: This CR implements the same for C1 as 6926782 for C2. Reviewed-by: never
hotspot/src/share/vm/c1/c1_Compilation.cpp
hotspot/src/share/vm/c1/c1_Compilation.hpp
hotspot/src/share/vm/c1/c1_LIRAssembler.cpp
hotspot/src/share/vm/code/nmethod.cpp
--- a/hotspot/src/share/vm/c1/c1_Compilation.cpp	Tue Aug 10 12:15:10 2010 -0700
+++ b/hotspot/src/share/vm/c1/c1_Compilation.cpp	Wed Aug 11 01:17:27 2010 -0700
@@ -220,11 +220,13 @@
   code_offsets->set_value(CodeOffsets::Deopt, assembler->emit_deopt_handler());
   CHECK_BAILOUT();
 
-  // Generate code for MethodHandle deopt handler.  We can use the
-  // same code as for the normal deopt handler, we just need a
-  // different entry point address.
-  code_offsets->set_value(CodeOffsets::DeoptMH, assembler->emit_deopt_handler());
-  CHECK_BAILOUT();
+  // Emit the MethodHandle deopt handler code (if required).
+  if (has_method_handle_invokes()) {
+    // We can use the same code as for the normal deopt handler, we
+    // just need a different entry point address.
+    code_offsets->set_value(CodeOffsets::DeoptMH, assembler->emit_deopt_handler());
+    CHECK_BAILOUT();
+  }
 
   // Emit the handler to remove the activation from the stack and
   // dispatch to the caller.
@@ -446,6 +448,7 @@
 , _has_exception_handlers(false)
 , _has_fpu_code(true)   // pessimistic assumption
 , _has_unsafe_access(false)
+, _has_method_handle_invokes(false)
 , _bailout_msg(NULL)
 , _exception_info_list(NULL)
 , _allocator(NULL)
--- a/hotspot/src/share/vm/c1/c1_Compilation.hpp	Tue Aug 10 12:15:10 2010 -0700
+++ b/hotspot/src/share/vm/c1/c1_Compilation.hpp	Wed Aug 11 01:17:27 2010 -0700
@@ -69,6 +69,7 @@
   bool               _has_exception_handlers;
   bool               _has_fpu_code;
   bool               _has_unsafe_access;
+  bool               _has_method_handle_invokes;  // True if this method has MethodHandle invokes.
   const char*        _bailout_msg;
   ExceptionInfoList* _exception_info_list;
   ExceptionHandlerTable _exception_handler_table;
@@ -147,6 +148,10 @@
   // Statistics gathering
   void notice_inlined_method(ciMethod* method);
 
+  // JSR 292
+  bool     has_method_handle_invokes() const { return _has_method_handle_invokes;     }
+  void set_has_method_handle_invokes(bool z) {        _has_method_handle_invokes = z; }
+
   DebugInformationRecorder* debug_info_recorder() const; // = _env->debug_info();
   Dependencies* dependency_recorder() const; // = _env->dependencies()
   ImplicitExceptionTable* implicit_exception_table()     { return &_implicit_exception_table; }
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp	Tue Aug 10 12:15:10 2010 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp	Wed Aug 11 01:17:27 2010 -0700
@@ -438,6 +438,12 @@
   default: ShouldNotReachHere();
   }
 
+  // JSR 292
+  // Record if this method has MethodHandle invokes.
+  if (op->is_method_handle_invoke()) {
+    compilation()->set_has_method_handle_invokes(true);
+  }
+
 #if defined(X86) && defined(TIERED)
   // C2 leave fpu stack dirty clean it
   if (UseSSE < 2) {
--- a/hotspot/src/share/vm/code/nmethod.cpp	Tue Aug 10 12:15:10 2010 -0700
+++ b/hotspot/src/share/vm/code/nmethod.cpp	Wed Aug 11 01:17:27 2010 -0700
@@ -2472,8 +2472,12 @@
   if (block_begin == exception_begin())         stream->print_cr("[Exception Handler]");
   if (block_begin == stub_begin())              stream->print_cr("[Stub Code]");
   if (block_begin == deopt_handler_begin())     stream->print_cr("[Deopt Handler Code]");
-  if (block_begin == deopt_mh_handler_begin())  stream->print_cr("[Deopt MH Handler Code]");
+
+  if (has_method_handle_invokes())
+    if (block_begin == deopt_mh_handler_begin())  stream->print_cr("[Deopt MH Handler Code]");
+
   if (block_begin == consts_begin())            stream->print_cr("[Constants]");
+
   if (block_begin == entry_point()) {
     methodHandle m = method();
     if (m.not_null()) {