src/share/vm/runtime/safepoint.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File

## src/share/vm/runtime/safepoint.cpp

Print this page

      34 #include "interpreter/interpreter.hpp"
      35 #include "memory/resourceArea.hpp"
      36 #include "memory/universe.inline.hpp"
      37 #include "oops/oop.inline.hpp"
      38 #include "oops/symbol.hpp"
      39 #include "runtime/compilationPolicy.hpp"
      40 #include "runtime/deoptimization.hpp"
      41 #include "runtime/frame.inline.hpp"
      42 #include "runtime/interfaceSupport.hpp"
      43 #include "runtime/mutexLocker.hpp"
      44 #include "runtime/orderAccess.inline.hpp"
      45 #include "runtime/osThread.hpp"
      46 #include "runtime/safepoint.hpp"
      47 #include "runtime/signature.hpp"
      48 #include "runtime/stubCodeGenerator.hpp"
      49 #include "runtime/stubRoutines.hpp"
      50 #include "runtime/sweeper.hpp"
      51 #include "runtime/synchronizer.hpp"
      52 #include "runtime/thread.inline.hpp"
      53 #include "services/runtimeService.hpp"

      54 #include "utilities/events.hpp"
      55 #include "utilities/macros.hpp"
      56 #ifdef TARGET_ARCH_x86
      57 # include "nativeInst_x86.hpp"
      58 # include "vmreg_x86.inline.hpp"
      59 #endif
      60 #ifdef TARGET_ARCH_sparc
      61 # include "nativeInst_sparc.hpp"
      62 # include "vmreg_sparc.inline.hpp"
      63 #endif
      64 #ifdef TARGET_ARCH_zero
      65 # include "nativeInst_zero.hpp"
      66 # include "vmreg_zero.inline.hpp"
      67 #endif
      68 #ifdef TARGET_ARCH_arm
      69 # include "nativeInst_arm.hpp"
      70 # include "vmreg_arm.inline.hpp"
      71 #endif
      72 #ifdef TARGET_ARCH_ppc
      73 # include "nativeInst_ppc.hpp"
     485   }
     486 #if INCLUDE_ALL_GCS
     487   // If there are any concurrent GC threads resume them.
     488   if (UseConcMarkSweepGC) {
     489     ConcurrentMarkSweepThread::desynchronize(false);
     490   } else if (UseG1GC) {
     491     SuspendibleThreadSet::desynchronize();
     492   }
     493 #endif // INCLUDE_ALL_GCS
     494   // record this time so VMThread can keep track how much time has elasped
     495   // since last safepoint.
     496   _end_of_last_safepoint = os::javaTimeMillis();
     497 }
     498
     499 bool SafepointSynchronize::is_cleanup_needed() {
     500   // Need a safepoint if some inline cache buffers is non-empty
     501   if (!InlineCacheBuffer::is_empty()) return true;
     502   return false;
     503 }
     504
     505
     506
     507 // Various cleaning tasks that should be done periodically at safepoints
     508 void SafepointSynchronize::do_cleanup_tasks() {
     509   {
     510     TraceTime t1("deflating idle monitors", TraceSafepointCleanupTime);
     511     ObjectSynchronizer::deflate_idle_monitors();
     512   }
     513
     514   {
     515     TraceTime t2("updating inline caches", TraceSafepointCleanupTime);
     516     InlineCacheBuffer::update_inline_caches();
     517   }

     518   {
     519     TraceTime t3("compilation policy safepoint handler", TraceSafepointCleanupTime);
     520     CompilationPolicy::policy()->do_safepoint_work();
     521   }
     522
     523   {
     524     TraceTime t4("mark nmethods", TraceSafepointCleanupTime);
     525     NMethodSweeper::mark_active_nmethods();
     526   }
     527

     528   if (SymbolTable::needs_rehashing()) {
     529     TraceTime t5("rehashing symbol table", TraceSafepointCleanupTime);
     530     SymbolTable::rehash_table();
     531   }
     532
     533   if (StringTable::needs_rehashing()) {
     534     TraceTime t6("rehashing string table", TraceSafepointCleanupTime);
     535     StringTable::rehash_table();
     536   }
     537
     538   // rotate log files?
     539   if (UseGCLogFileRotation) {
     540     gclog_or_tty->rotate_log(false);
     541   }
     542
     543   {
     544     // CMS delays purging the CLDG until the beginning of the next safepoint and to
     545     // make sure concurrent sweep is done
     546     TraceTime t7("purging class loader data graph", TraceSafepointCleanupTime);
     547     ClassLoaderDataGraph::purge_if_needed();
     548   }
     549 }
     550
     551
     552 bool SafepointSynchronize::safepoint_safe(JavaThread *thread, JavaThreadState state) {
     553   switch(state) {
     554   case _thread_in_native:
      34 #include "interpreter/interpreter.hpp"
      35 #include "memory/resourceArea.hpp"
      36 #include "memory/universe.inline.hpp"
      37 #include "oops/oop.inline.hpp"
      38 #include "oops/symbol.hpp"
      39 #include "runtime/compilationPolicy.hpp"
      40 #include "runtime/deoptimization.hpp"
      41 #include "runtime/frame.inline.hpp"
      42 #include "runtime/interfaceSupport.hpp"
      43 #include "runtime/mutexLocker.hpp"
      44 #include "runtime/orderAccess.inline.hpp"
      45 #include "runtime/osThread.hpp"
      46 #include "runtime/safepoint.hpp"
      47 #include "runtime/signature.hpp"
      48 #include "runtime/stubCodeGenerator.hpp"
      49 #include "runtime/stubRoutines.hpp"
      50 #include "runtime/sweeper.hpp"
      51 #include "runtime/synchronizer.hpp"
      52 #include "runtime/thread.inline.hpp"
      53 #include "services/runtimeService.hpp"
      54 #include "trace/tracing.hpp"
      55 #include "utilities/events.hpp"
      56 #include "utilities/macros.hpp"
      57 #ifdef TARGET_ARCH_x86
      58 # include "nativeInst_x86.hpp"
      59 # include "vmreg_x86.inline.hpp"
      60 #endif
      61 #ifdef TARGET_ARCH_sparc
      62 # include "nativeInst_sparc.hpp"
      63 # include "vmreg_sparc.inline.hpp"
      64 #endif
      65 #ifdef TARGET_ARCH_zero
      66 # include "nativeInst_zero.hpp"
      67 # include "vmreg_zero.inline.hpp"
      68 #endif
      69 #ifdef TARGET_ARCH_arm
      70 # include "nativeInst_arm.hpp"
      71 # include "vmreg_arm.inline.hpp"
      72 #endif
      73 #ifdef TARGET_ARCH_ppc
      74 # include "nativeInst_ppc.hpp"
     486   }
     487 #if INCLUDE_ALL_GCS
     488   // If there are any concurrent GC threads resume them.
     489   if (UseConcMarkSweepGC) {
     490     ConcurrentMarkSweepThread::desynchronize(false);
     491   } else if (UseG1GC) {
     492     SuspendibleThreadSet::desynchronize();
     493   }
     494 #endif // INCLUDE_ALL_GCS
     495   // record this time so VMThread can keep track how much time has elasped
     496   // since last safepoint.
     497   _end_of_last_safepoint = os::javaTimeMillis();
     498 }
     499
     500 bool SafepointSynchronize::is_cleanup_needed() {
     501   // Need a safepoint if some inline cache buffers is non-empty
     502   if (!InlineCacheBuffer::is_empty()) return true;
     503   return false;
     504 }
     505

     506 // Various cleaning tasks that should be done periodically at safepoints
     507 void SafepointSynchronize::do_cleanup_tasks() {
     508   {
     509     TraceTime t1("deflating idle monitors", TraceSafepointCleanupTime);
     510     ObjectSynchronizer::deflate_idle_monitors();
     511   }
     512
     513   {
     514     TraceTime t2("updating inline caches", TraceSafepointCleanupTime);
     515     InlineCacheBuffer::update_inline_caches();
     516   }
     517
     518   {
     519     TraceTime t3("compilation policy safepoint handler", TraceSafepointCleanupTime);
     520     CompilationPolicy::policy()->do_safepoint_work();
     521   }
     522
     523   {
     524     TraceTime t4("mark nmethods", TraceSafepointCleanupTime);
     525     NMethodSweeper::mark_active_nmethods();
     526   }
     527
     528 //#define PRINT_RESIZE
     529
     530   if (HashtablesResizeSymbolTable == true) {
     531     ResizeHashtableStats stats;
     532     {
     533       //tty->print("SymbolTable      ");
     534       TraceTime t5("resize_table for SymbolTable", TraceSafepointCleanupTime);
     535       EventSymbolTableResize event;
     536       stats = SymbolTable::the_table()->resize_table(SymbolTable_lock,
     537                                                       HashtablesResizeSymbolTableTriggerLoadFactor,
     538                                                         HashtablesResizeSymbolTableDesiredLoadFactor);
     539       if (stats.resized == true) {
     540         if (PrintSymbolTableStatisticsTimeline == true) {
     541           tty->print("-------------------------------------------------------------------------------\n");
     542           tty->print("SymbolTable resized from %d to %d\n", stats.old_size, stats.new_size);
     543           tty->print("-------------------------------------------------------------------------------\n");
     544         }
     545         if (event.should_commit() == true) {
     546           event.set_oldSize(stats.old_size);
     547           event.set_newSize(stats.new_size);
     548           event.commit();
     549         }
     550       }
     551     }
     552   }
     553
     554   if (HashtablesResizeStringTable == true) {
     555     ResizeHashtableStats stats;
     556     {
     557       //tty->print("StringTable      ");
     558       TraceTime t6("resize_table for StringTable", TraceSafepointCleanupTime);
     559       EventStringTableResize event;
     560       stats = StringTable::the_table()->resize_table(StringTable_lock,
     561                                                       HashtablesResizeStringTableTriggerLoadFactor,
     562                                                         HashtablesResizeStringTableDesiredLoadFactor);
     563       if (stats.resized == true) {
     564         if (PrintStringTableStatisticsTimeline == true) {
     565           tty->print("-------------------------------------------------------------------------------\n");
     566           tty->print("StringTable resized from %d to %d\n", stats.old_size, stats.new_size);
     567           tty->print("-------------------------------------------------------------------------------\n");
     568         }
     569         if (event.should_commit() == true) {
     570           event.set_oldSize(stats.old_size);
     571           event.set_newSize(stats.new_size);
     572           event.commit();
     573         }
     574       }
     575     }
     576   }
     577
     578   if (HashtablesResizeSystemDictionary == true) {
     579     ResizeHashtableStats stats;
     580     {
     581       //tty->print("SystemDictionary ");
     582       TraceTime t6("resize_table for SystemDictionary", TraceSafepointCleanupTime);
     583       EventSystemDictionaryResize event;
     584       stats = SystemDictionary::the_table()->resize_table(SystemDictionary_lock,
     585                                                             HashtablesResizeSystemDictionaryTriggerLoadFactor,
     586                                                               HashtablesResizeSystemDictionaryDesiredLoadFactor);
     587       if (stats.resized == true) {
     588         if (PrintStringTableStatisticsTimeline == true) {
     589           tty->print("-------------------------------------------------------------------------------\n");
     590           tty->print("SystemDictionary resized from %d to %d\n", stats.old_size, stats.new_size);
     591           tty->print("-------------------------------------------------------------------------------\n");
     592         }
     593         if (event.should_commit() == true) {
     594           event.set_oldSize(stats.old_size);
     595           event.set_newSize(stats.new_size);
     596           event.commit();
     597         }
     598       }
     599     }
     600   }
     601
     602   {
     603     bool wants = false;
     604     bool reported = false;
     605     static int skip = 1000;
     606     if (PrintSymbolTableStatisticsTimeline == true) {
     607       wants = true;
     608       static int number_of_entries = 0;
     609       if (SymbolTable::the_table()->number_of_entries() > (skip+number_of_entries)) {
     610         number_of_entries = SymbolTable::the_table()->number_of_entries();
     611         tty->print("SymbolTable      %9d:%6.3f:%lld\n", number_of_entries, (float)number_of_entries/(float)SymbolTable::the_table()->table_size(), os::javaTimeNanos());
     612         reported = true;
     613       }
     614     }
     615     if (PrintStringTableStatisticsTimeline == true) {
     616       wants = true;
     617       static int number_of_entries = 0;
     618       if (StringTable::the_table()->number_of_entries() > (skip+number_of_entries)) {
     619         number_of_entries = StringTable::the_table()->number_of_entries();
     620         tty->print("StringTable      %9d:%6.3f:%lld\n", number_of_entries, (float)number_of_entries/(float)SymbolTable::the_table()->table_size(), os::javaTimeNanos());
     621         reported = true;
     622       }
     623     }
     624     if (PrintSystemDictionaryStatisticsTimeline == true) {
     625       wants = true;
     626       static int number_of_entries = 0;
     627       if (SystemDictionary::the_table()->number_of_entries() > (skip+number_of_entries)) {
     628         number_of_entries = SystemDictionary::the_table()->number_of_entries();
     629         tty->print("SystemDictionary %9d:%6.3f:%lld\n", number_of_entries, (float)number_of_entries/(float)SymbolTable::the_table()->table_size(), os::javaTimeNanos());
     630         reported = true;
     631       }
     632     }
     633     if ((wants == true) && (reported == false)) {
     634       tty->print(".\n");
     635     }
     636   }
     637
     638   if (SymbolTable::needs_rehashing()) {
     639     TraceTime t8("rehashing symbol table", TraceSafepointCleanupTime);
     640     SymbolTable::rehash_table();
     641   }
     642
     643   if (StringTable::needs_rehashing()) {
     644     TraceTime t9("rehashing string table", TraceSafepointCleanupTime);
     645     StringTable::rehash_table();
     646   }
     647
     648   // rotate log files?
     649   if (UseGCLogFileRotation) {
     650     gclog_or_tty->rotate_log(false);
     651   }
     652
     653   {
     654     // CMS delays purging the CLDG until the beginning of the next safepoint and to
     655     // make sure concurrent sweep is done
     656     TraceTime t7("purging class loader data graph", TraceSafepointCleanupTime);
     657     ClassLoaderDataGraph::purge_if_needed();
     658   }
     659 }
     660
     661
     662 bool SafepointSynchronize::safepoint_safe(JavaThread *thread, JavaThreadState state) {
     663   switch(state) {
     664   case _thread_in_native:

src/share/vm/runtime/safepoint.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File