8147978: Remove Method::_method_data for C1
authorcjplummer
Fri, 26 Feb 2016 09:13:22 -0800
changeset 36345 72e6d0ac646b
parent 36344 5b16931563ac
child 36347 ac01095d767a
8147978: Remove Method::_method_data for C1 Summary: Method::_method_data field removed when not using C2 or JVMCI Reviewed-by: dholmes, kvn
hotspot/src/share/vm/c1/c1_Runtime1.cpp
hotspot/src/share/vm/oops/method.cpp
hotspot/src/share/vm/oops/method.hpp
hotspot/src/share/vm/runtime/arguments.cpp
hotspot/src/share/vm/runtime/vmStructs.cpp
hotspot/src/share/vm/utilities/macros.hpp
--- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Tue Mar 01 18:29:20 2016 +0000
+++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Fri Feb 26 09:13:22 2016 -0800
@@ -1502,21 +1502,23 @@
   nm->make_not_entrant();
 
   methodHandle m(nm->method());
-  MethodData* mdo = m->method_data();
+  if (ProfileInterpreter) {
+    MethodData* mdo = m->method_data();
 
-  if (mdo == NULL && !HAS_PENDING_EXCEPTION) {
-    // Build an MDO.  Ignore errors like OutOfMemory;
-    // that simply means we won't have an MDO to update.
-    Method::build_interpreter_method_data(m, THREAD);
-    if (HAS_PENDING_EXCEPTION) {
-      assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here");
-      CLEAR_PENDING_EXCEPTION;
+    if (mdo == NULL && !HAS_PENDING_EXCEPTION) {
+      // Build an MDO.  Ignore errors like OutOfMemory;
+      // that simply means we won't have an MDO to update.
+      Method::build_interpreter_method_data(m, THREAD);
+      if (HAS_PENDING_EXCEPTION) {
+        assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here");
+        CLEAR_PENDING_EXCEPTION;
+      }
+      mdo = m->method_data();
     }
-    mdo = m->method_data();
-  }
 
-  if (mdo != NULL) {
-    mdo->inc_trap_count(Deoptimization::Reason_none);
+    if (mdo != NULL) {
+      mdo->inc_trap_count(Deoptimization::Reason_none);
+    }
   }
 
   if (TracePredicateFailedTraps) {
--- a/hotspot/src/share/vm/oops/method.cpp	Tue Mar 01 18:29:20 2016 +0000
+++ b/hotspot/src/share/vm/oops/method.cpp	Fri Feb 26 09:13:22 2016 -0800
@@ -383,14 +383,15 @@
   MutexLocker ml(MethodData_lock, THREAD);
   if (method->method_data() == NULL) {
     ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
+#if defined(COMPILER2) || INCLUDE_JVMCI
     MethodData* method_data = MethodData::allocate(loader_data, method, THREAD);
     if (HAS_PENDING_EXCEPTION) {
       CompileBroker::log_metaspace_failure();
       ClassLoaderDataGraph::set_metaspace_oom(true);
       return;   // return the exception (which is cleared)
     }
-
     method->set_method_data(method_data);
+#endif
     if (PrintMethodData && (Verbose || WizardMode)) {
       ResourceMark rm(THREAD);
       tty->print("build_interpreter_method_data for ");
@@ -920,7 +921,7 @@
   // shared class that failed to load, this->link_method() may
   // have already been called (before an exception happened), so
   // this->_method_data may not be NULL.
-  assert(!DumpSharedSpaces || _method_data == NULL, "unexpected method data?");
+  assert(!DumpSharedSpaces || method_data() == NULL, "unexpected method data?");
 
   set_method_data(NULL);
   clear_method_counters();
--- a/hotspot/src/share/vm/oops/method.hpp	Tue Mar 01 18:29:20 2016 +0000
+++ b/hotspot/src/share/vm/oops/method.hpp	Fri Feb 26 09:13:22 2016 -0800
@@ -64,7 +64,9 @@
  friend class JVMCIVMStructs;
  private:
   ConstMethod*      _constMethod;                // Method read-only data.
+#if defined(COMPILER2) || INCLUDE_JVMCI
   MethodData*       _method_data;
+#endif
   MethodCounters*   _method_counters;
   AccessFlags       _access_flags;               // Access flags
   int               _vtable_index;               // vtable index of this method (see VtableIndexFlag)
@@ -319,6 +321,7 @@
   // InterpreterRuntime::exception_handler_for_exception.
   static int fast_exception_handler_bci_for(methodHandle mh, KlassHandle ex_klass, int throw_bci, TRAPS);
 
+#if defined(COMPILER2) || INCLUDE_JVMCI
   // method data access
   MethodData* method_data() const              {
     return _method_data;
@@ -330,6 +333,10 @@
     // the initialization of data otherwise.
     OrderAccess::release_store_ptr((volatile void *)&_method_data, data);
   }
+#else
+  MethodData* method_data() const              { return NULL; }
+  void set_method_data(MethodData* data)       { }
+#endif
 
   MethodCounters* method_counters() const {
     return _method_counters;
@@ -639,9 +646,16 @@
 #endif /* CC_INTERP */
   static ByteSize from_compiled_offset()         { return byte_offset_of(Method, _from_compiled_entry); }
   static ByteSize code_offset()                  { return byte_offset_of(Method, _code); }
+#if defined(COMPILER2) || INCLUDE_JVMCI
   static ByteSize method_data_offset()           {
     return byte_offset_of(Method, _method_data);
   }
+#else
+  static ByteSize method_data_offset()           {
+    ShouldNotReachHere();
+    return in_ByteSize(0);
+  }
+#endif
   static ByteSize method_counters_offset()       {
     return byte_offset_of(Method, _method_counters);
   }
@@ -654,7 +668,11 @@
   static ByteSize signature_handler_offset()     { return in_ByteSize(sizeof(Method) + wordSize);      }
 
   // for code generation
+#if defined(COMPILER2) || INCLUDE_JVMCI
   static int method_data_offset_in_bytes()       { return offset_of(Method, _method_data); }
+#else
+  static int method_data_offset_in_bytes()       { ShouldNotReachHere(); return 0; }
+#endif
   static int intrinsic_id_offset_in_bytes()      { return offset_of(Method, _intrinsic_id); }
   static int intrinsic_id_size_in_bytes()        { return sizeof(u2); }
 
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Tue Mar 01 18:29:20 2016 +0000
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Fri Feb 26 09:13:22 2016 -0800
@@ -3464,6 +3464,12 @@
   }
 #endif
 
+#if !defined(COMPILER2) && !INCLUDE_JVMCI
+  UNSUPPORTED_OPTION(ProfileInterpreter, "ProfileInterpreter");
+  NOT_PRODUCT(UNSUPPORTED_OPTION(TraceProfileInterpreter, "TraceProfileInterpreter"));
+  UNSUPPORTED_OPTION(PrintMethodData, "PrintMethodData");
+#endif
+
 #ifndef TIERED
   // Tiered compilation is undefined.
   UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation");
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Tue Mar 01 18:29:20 2016 +0000
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Fri Feb 26 09:13:22 2016 -0800
@@ -390,7 +390,7 @@
   nonstatic_field(MethodCounters,              _invocation_counter,                           InvocationCounter)                     \
   nonstatic_field(MethodCounters,              _backedge_counter,                             InvocationCounter)                     \
   nonstatic_field(Method,                      _constMethod,                                  ConstMethod*)                          \
-  nonstatic_field(Method,                      _method_data,                                  MethodData*)                           \
+  COMPILER2_OR_JVMCI_PRESENT(nonstatic_field(Method, _method_data,                            MethodData*))                          \
   nonstatic_field(Method,                      _method_counters,                              MethodCounters*)                       \
   nonstatic_field(Method,                      _access_flags,                                 AccessFlags)                           \
   nonstatic_field(Method,                      _vtable_index,                                 int)                                   \
--- a/hotspot/src/share/vm/utilities/macros.hpp	Tue Mar 01 18:29:20 2016 +0000
+++ b/hotspot/src/share/vm/utilities/macros.hpp	Fri Feb 26 09:13:22 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -206,6 +206,15 @@
 #define NOT_COMPILER2(code) code
 #endif // COMPILER2
 
+// COMPILER2 or JVMCI
+#if defined(COMPILER2) || INCLUDE_JVMCI
+#define COMPILER2_OR_JVMCI_PRESENT(code) code
+#define NOT_COMPILER2_OR_JVMCI(code)
+#else
+#define COMPILER2_OR_JVMCI_PRESENT(code)
+#define NOT_COMPILER2_OR_JVMCI(code) code
+#endif
+
 #ifdef TIERED
 #define TIERED_ONLY(code) code
 #define NOT_TIERED(code)