8057827: notify an obj when allocation context stats are available

Wed, 10 Sep 2014 16:06:53 -0700

author
jcoomes
date
Wed, 10 Sep 2014 16:06:53 -0700
changeset 7164
fa6c442c59ee
parent 7163
2402de236865
child 7165
e2452c3ff7fb
child 7166
f8afcfbdbf1c

8057827: notify an obj when allocation context stats are available
Reviewed-by: mikael, jmasa, tschatzl

src/share/vm/gc_implementation/g1/g1AllocationContext.hpp file | annotate | diff | comparison | revisions
src/share/vm/memory/universe.cpp file | annotate | diff | comparison | revisions
src/share/vm/memory/universe.hpp file | annotate | diff | comparison | revisions
src/share/vm/memory/universe.inline.hpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/serviceThread.cpp file | annotate | diff | comparison | revisions
src/share/vm/services/allocationContextService.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/gc_implementation/g1/g1AllocationContext.hpp	Wed Sep 10 21:45:28 2014 +0000
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1AllocationContext.hpp	Wed Sep 10 16:06:53 2014 -0700
     1.3 @@ -46,6 +46,7 @@
     1.4    inline void clear() { }
     1.5    inline void update(bool full_gc) { }
     1.6    inline void update_at_remark() { }
     1.7 +  inline bool available() { return false; }
     1.8  };
     1.9  
    1.10  #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCATIONCONTEXT_HPP
     2.1 --- a/src/share/vm/memory/universe.cpp	Wed Sep 10 21:45:28 2014 +0000
     2.2 +++ b/src/share/vm/memory/universe.cpp	Wed Sep 10 16:06:53 2014 -0700
     2.3 @@ -126,6 +126,8 @@
     2.4  oop Universe::_arithmetic_exception_instance          = NULL;
     2.5  oop Universe::_virtual_machine_error_instance         = NULL;
     2.6  oop Universe::_vm_exception                           = NULL;
     2.7 +oop Universe::_allocation_context_notification_obj    = NULL;
     2.8 +
     2.9  Method* Universe::_throw_illegal_access_error         = NULL;
    2.10  Array<int>* Universe::_the_empty_int_array            = NULL;
    2.11  Array<u2>* Universe::_the_empty_short_array           = NULL;
    2.12 @@ -195,6 +197,7 @@
    2.13    f->do_oop((oop*)&_main_thread_group);
    2.14    f->do_oop((oop*)&_system_thread_group);
    2.15    f->do_oop((oop*)&_vm_exception);
    2.16 +  f->do_oop((oop*)&_allocation_context_notification_obj);
    2.17    debug_only(f->do_oop((oop*)&_fullgc_alot_dummy_array);)
    2.18  }
    2.19  
     3.1 --- a/src/share/vm/memory/universe.hpp	Wed Sep 10 21:45:28 2014 +0000
     3.2 +++ b/src/share/vm/memory/universe.hpp	Wed Sep 10 16:06:53 2014 -0700
     3.3 @@ -178,6 +178,8 @@
     3.4    // the vm thread.
     3.5    static oop          _vm_exception;
     3.6  
     3.7 +  static oop          _allocation_context_notification_obj;
     3.8 +
     3.9    // The particular choice of collected heap.
    3.10    static CollectedHeap* _collectedHeap;
    3.11  
    3.12 @@ -307,6 +309,10 @@
    3.13    static oop          arithmetic_exception_instance() { return _arithmetic_exception_instance; }
    3.14    static oop          virtual_machine_error_instance() { return _virtual_machine_error_instance; }
    3.15    static oop          vm_exception()                  { return _vm_exception; }
    3.16 +
    3.17 +  static inline oop   allocation_context_notification_obj();
    3.18 +  static inline void  set_allocation_context_notification_obj(oop obj);
    3.19 +
    3.20    static Method*      throw_illegal_access_error()    { return _throw_illegal_access_error; }
    3.21  
    3.22    static Array<int>*       the_empty_int_array()    { return _the_empty_int_array; }
     4.1 --- a/src/share/vm/memory/universe.inline.hpp	Wed Sep 10 21:45:28 2014 +0000
     4.2 +++ b/src/share/vm/memory/universe.inline.hpp	Wed Sep 10 16:06:53 2014 -0700
     4.3 @@ -41,4 +41,12 @@
     4.4    return type == T_DOUBLE || type == T_LONG;
     4.5  }
     4.6  
     4.7 +inline oop Universe::allocation_context_notification_obj() {
     4.8 +  return _allocation_context_notification_obj;
     4.9 +}
    4.10 +
    4.11 +inline void Universe::set_allocation_context_notification_obj(oop obj) {
    4.12 +  _allocation_context_notification_obj = obj;
    4.13 +}
    4.14 +
    4.15  #endif // SHARE_VM_MEMORY_UNIVERSE_INLINE_HPP
     5.1 --- a/src/share/vm/runtime/serviceThread.cpp	Wed Sep 10 21:45:28 2014 +0000
     5.2 +++ b/src/share/vm/runtime/serviceThread.cpp	Wed Sep 10 16:06:53 2014 -0700
     5.3 @@ -28,6 +28,7 @@
     5.4  #include "runtime/serviceThread.hpp"
     5.5  #include "runtime/mutexLocker.hpp"
     5.6  #include "prims/jvmtiImpl.hpp"
     5.7 +#include "services/allocationContextService.hpp"
     5.8  #include "services/gcNotifier.hpp"
     5.9  #include "services/diagnosticArgument.hpp"
    5.10  #include "services/diagnosticFramework.hpp"
    5.11 @@ -86,6 +87,7 @@
    5.12      bool has_jvmti_events = false;
    5.13      bool has_gc_notification_event = false;
    5.14      bool has_dcmd_notification_event = false;
    5.15 +    bool acs_notify = false;
    5.16      JvmtiDeferredEvent jvmti_event;
    5.17      {
    5.18        // Need state transition ThreadBlockInVM so that this thread
    5.19 @@ -102,7 +104,8 @@
    5.20        while (!(sensors_changed = LowMemoryDetector::has_pending_requests()) &&
    5.21               !(has_jvmti_events = JvmtiDeferredEventQueue::has_events()) &&
    5.22                !(has_gc_notification_event = GCNotifier::has_event()) &&
    5.23 -              !(has_dcmd_notification_event = DCmdFactory::has_pending_jmx_notification())) {
    5.24 +              !(has_dcmd_notification_event = DCmdFactory::has_pending_jmx_notification()) &&
    5.25 +             !(acs_notify = AllocationContextService::should_notify())) {
    5.26          // wait until one of the sensors has pending requests, or there is a
    5.27          // pending JVMTI event or JMX GC notification to post
    5.28          Service_lock->wait(Mutex::_no_safepoint_check_flag);
    5.29 @@ -128,6 +131,10 @@
    5.30      if(has_dcmd_notification_event) {
    5.31        DCmdFactory::send_notification(CHECK);
    5.32      }
    5.33 +
    5.34 +    if (acs_notify) {
    5.35 +      AllocationContextService::notify(CHECK);
    5.36 +    }
    5.37    }
    5.38  }
    5.39  
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/share/vm/services/allocationContextService.hpp	Wed Sep 10 16:06:53 2014 -0700
     6.3 @@ -0,0 +1,39 @@
     6.4 +/*
     6.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 + *
     6.8 + * This code is free software; you can redistribute it and/or modify it
     6.9 + * under the terms of the GNU General Public License version 2 only, as
    6.10 + * published by the Free Software Foundation.
    6.11 + *
    6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.15 + * version 2 for more details (a copy is included in the LICENSE file that
    6.16 + * accompanied this code).
    6.17 + *
    6.18 + * You should have received a copy of the GNU General Public License version
    6.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.21 + *
    6.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.23 + * or visit www.oracle.com if you need additional information or have any
    6.24 + * questions.
    6.25 + *
    6.26 + */
    6.27 +
    6.28 +#ifndef SHARE_VM_SERVICES_ALLOCATION_CONTEXT_SERVICE_HPP
    6.29 +#define SHARE_VM_SERVICES_ALLOCATION_CONTEXT_SERVICE_HPP
    6.30 +
    6.31 +#include "utilities/exceptions.hpp"
    6.32 +
    6.33 +class AllocationContextService: public AllStatic {
    6.34 +public:
    6.35 +  static inline bool should_notify();
    6.36 +  static inline void notify(TRAPS);
    6.37 +};
    6.38 +
    6.39 +bool AllocationContextService::should_notify() { return false; }
    6.40 +void AllocationContextService::notify(TRAPS) { }
    6.41 +
    6.42 +#endif // SHARE_VM_SERVICES_ALLOCATION_CONTEXT_SERVICE_HPP

mercurial