1 /* 2 * Copyright (c) 1997, 2009, 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 * 23 */ 24 25 # include "incls/_precompiled.incl" 26 # include "incls/_safepoint.cpp.incl" 27 28 // -------------------------------------------------------------------------------------------------- 29 // Implementation of Safepoint begin/end 30 31 SafepointSynchronize::SynchronizeState volatile SafepointSynchronize::_state = SafepointSynchronize::_not_synchronized; 32 volatile int SafepointSynchronize::_waiting_to_block = 0; 33 volatile int SafepointSynchronize::_safepoint_counter = 0; 34 long SafepointSynchronize::_end_of_last_safepoint = 0; 35 static volatile int PageArmed = 0 ; // safepoint polling page is RO|RW vs PROT_NONE 36 static volatile int TryingToBlock = 0 ; // proximate value -- for advisory use only 37 static bool timeout_error_printed = false; 38 39 // Roll all threads forward to a safepoint and suspend them all 40 void SafepointSynchronize::begin() { 41 42 Thread* myThread = Thread::current(); 43 assert(myThread->is_VM_thread(), "Only VM thread may execute a safepoint"); 44 45 if (PrintSafepointStatistics || PrintSafepointStatisticsTimeout > 0) { 46 _safepoint_begin_time = os::javaTimeNanos(); | 1 /* 2 * Copyright (c) 1997, 2010, 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 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "classfile/systemDictionary.hpp" 27 #include "code/codeCache.hpp" 28 #include "code/icBuffer.hpp" 29 #include "code/nmethod.hpp" 30 #include "code/pcDesc.hpp" 31 #include "code/scopeDesc.hpp" 32 #include "gc_interface/collectedHeap.hpp" 33 #include "interpreter/interpreter.hpp" 34 #include "memory/resourceArea.hpp" 35 #include "memory/universe.inline.hpp" 36 #include "oops/oop.inline.hpp" 37 #include "oops/symbolOop.hpp" 38 #include "runtime/compilationPolicy.hpp" 39 #include "runtime/deoptimization.hpp" 40 #include "runtime/frame.inline.hpp" 41 #include "runtime/interfaceSupport.hpp" 42 #include "runtime/mutexLocker.hpp" 43 #include "runtime/osThread.hpp" 44 #include "runtime/safepoint.hpp" 45 #include "runtime/signature.hpp" 46 #include "runtime/stubCodeGenerator.hpp" 47 #include "runtime/stubRoutines.hpp" 48 #include "runtime/sweeper.hpp" 49 #include "runtime/synchronizer.hpp" 50 #include "services/runtimeService.hpp" 51 #include "utilities/events.hpp" 52 #ifdef TARGET_ARCH_x86 53 # include "nativeInst_x86.hpp" 54 # include "vmreg_x86.inline.hpp" 55 #endif 56 #ifdef TARGET_ARCH_sparc 57 # include "nativeInst_sparc.hpp" 58 # include "vmreg_sparc.inline.hpp" 59 #endif 60 #ifdef TARGET_ARCH_zero 61 # include "nativeInst_zero.hpp" 62 # include "vmreg_zero.inline.hpp" 63 #endif 64 #ifdef TARGET_OS_FAMILY_linux 65 # include "thread_linux.inline.hpp" 66 #endif 67 #ifdef TARGET_OS_FAMILY_solaris 68 # include "thread_solaris.inline.hpp" 69 #endif 70 #ifdef TARGET_OS_FAMILY_windows 71 # include "thread_windows.inline.hpp" 72 #endif 73 #ifndef SERIALGC 74 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp" 75 #include "gc_implementation/shared/concurrentGCThread.hpp" 76 #endif 77 #ifdef COMPILER1 78 #include "c1/c1_globals.hpp" 79 #endif 80 81 // -------------------------------------------------------------------------------------------------- 82 // Implementation of Safepoint begin/end 83 84 SafepointSynchronize::SynchronizeState volatile SafepointSynchronize::_state = SafepointSynchronize::_not_synchronized; 85 volatile int SafepointSynchronize::_waiting_to_block = 0; 86 volatile int SafepointSynchronize::_safepoint_counter = 0; 87 long SafepointSynchronize::_end_of_last_safepoint = 0; 88 static volatile int PageArmed = 0 ; // safepoint polling page is RO|RW vs PROT_NONE 89 static volatile int TryingToBlock = 0 ; // proximate value -- for advisory use only 90 static bool timeout_error_printed = false; 91 92 // Roll all threads forward to a safepoint and suspend them all 93 void SafepointSynchronize::begin() { 94 95 Thread* myThread = Thread::current(); 96 assert(myThread->is_VM_thread(), "Only VM thread may execute a safepoint"); 97 98 if (PrintSafepointStatistics || PrintSafepointStatisticsTimeout > 0) { 99 _safepoint_begin_time = os::javaTimeNanos(); |