src/share/vm/services/memTracker.hpp

Print this page


   1 /*
   2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 464 
 465   // pending recorder queue. Recorders are queued to pending queue
 466   // when they are overflowed or collected at nmt sync point.
 467   static void enqueue_pending_recorder(MemRecorder* rec);
 468   static MemRecorder* get_pending_recorders();
 469   static void delete_all_pending_recorders();
 470 
 471   // write a memory tracking record in recorder
 472   static void write_tracking_record(address addr, MEMFLAGS type,
 473     size_t size, jint seq, address pc, JavaThread* thread);
 474 
 475   static bool is_single_threaded_bootstrap() {
 476     return _state == NMT_bootstrapping_single_thread;
 477   }
 478 
 479   static void check_NMT_load(Thread* thr) {
 480     assert(thr != NULL, "Sanity check");
 481     if (_slowdown_calling_thread && thr != _worker_thread) {
 482 #ifdef _WINDOWS
 483       // On Windows, os::NakedYield() does not work as well
 484       // as os::yield_all()
 485       os::yield_all();
 486 #else
 487      // On Solaris, os::yield_all() depends on os::sleep()
 488      // which requires JavaTherad in _thread_in_vm state.
 489      // Transits thread to _thread_in_vm state can be dangerous
 490      // if caller holds lock, as it may deadlock with Threads_lock.
 491      // So use NaKedYield instead.
 492      //
 493      // Linux and BSD, NakedYield() and yield_all() implementations
 494      // are the same.
 495       os::NakedYield();
 496 #endif
 497     }
 498   }
 499 
 500   static void inc_pending_op_count() {
 501     Atomic::inc(&_pending_op_count);
 502   }
 503 
 504   static void dec_pending_op_count() {
 505     Atomic::dec(&_pending_op_count);
 506     assert(_pending_op_count >= 0, "Sanity check");
 507   }
 508 
 509 
 510  private:
 511   // retrieve a pooled memory record or create new one if there is not
 512   // one available
 513   static MemRecorder* get_new_or_pooled_instance();
 514   static void create_memory_record(address addr, MEMFLAGS type,


   1 /*
   2  * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 464 
 465   // pending recorder queue. Recorders are queued to pending queue
 466   // when they are overflowed or collected at nmt sync point.
 467   static void enqueue_pending_recorder(MemRecorder* rec);
 468   static MemRecorder* get_pending_recorders();
 469   static void delete_all_pending_recorders();
 470 
 471   // write a memory tracking record in recorder
 472   static void write_tracking_record(address addr, MEMFLAGS type,
 473     size_t size, jint seq, address pc, JavaThread* thread);
 474 
 475   static bool is_single_threaded_bootstrap() {
 476     return _state == NMT_bootstrapping_single_thread;
 477   }
 478 
 479   static void check_NMT_load(Thread* thr) {
 480     assert(thr != NULL, "Sanity check");
 481     if (_slowdown_calling_thread && thr != _worker_thread) {
 482 #ifdef _WINDOWS
 483       // On Windows, os::NakedYield() does not work as well
 484       // as short sleep.
 485       os::naked_short_sleep(1);
 486 #else








 487       os::NakedYield();
 488 #endif
 489     }
 490   }
 491 
 492   static void inc_pending_op_count() {
 493     Atomic::inc(&_pending_op_count);
 494   }
 495 
 496   static void dec_pending_op_count() {
 497     Atomic::dec(&_pending_op_count);
 498     assert(_pending_op_count >= 0, "Sanity check");
 499   }
 500 
 501 
 502  private:
 503   // retrieve a pooled memory record or create new one if there is not
 504   // one available
 505   static MemRecorder* get_new_or_pooled_instance();
 506   static void create_memory_record(address addr, MEMFLAGS type,