1 /* |
1 /* |
2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
30 #include "runtime/mutexLocker.hpp" |
30 #include "runtime/mutexLocker.hpp" |
31 #include "runtime/orderAccess.inline.hpp" |
31 #include "runtime/orderAccess.inline.hpp" |
32 #include "runtime/os.hpp" |
32 #include "runtime/os.hpp" |
33 #include "runtime/perfData.hpp" |
33 #include "runtime/perfData.hpp" |
34 #include "runtime/perfMemory.hpp" |
34 #include "runtime/perfMemory.hpp" |
|
35 #include "runtime/safepoint.hpp" |
35 #include "runtime/statSampler.hpp" |
36 #include "runtime/statSampler.hpp" |
36 #include "utilities/globalDefinitions.hpp" |
37 #include "utilities/globalDefinitions.hpp" |
37 |
38 |
38 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
39 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
39 |
40 |
62 void perfMemory_exit() { |
63 void perfMemory_exit() { |
63 |
64 |
64 if (!UsePerfData) return; |
65 if (!UsePerfData) return; |
65 if (!PerfMemory::is_initialized()) return; |
66 if (!PerfMemory::is_initialized()) return; |
66 |
67 |
67 // if the StatSampler is active, then we don't want to remove |
68 // Only destroy PerfData objects if we're at a safepoint and the |
68 // resources it may be dependent on. Typically, the StatSampler |
69 // StatSampler is not active. Otherwise, we risk removing PerfData |
69 // is disengaged from the watcher thread when this method is called, |
70 // objects that are currently being used by running JavaThreads |
70 // but it is not disengaged if this method is invoked during a |
71 // or the StatSampler. This method is invoked while we are not at |
71 // VM abort. |
72 // a safepoint during a VM abort so leaving the PerfData objects |
|
73 // around may also help diagnose the failure. In rare cases, |
|
74 // PerfData objects are used in parallel with a safepoint. See |
|
75 // the work around in PerfDataManager::destroy(). |
72 // |
76 // |
73 if (!StatSampler::is_active()) |
77 if (SafepointSynchronize::is_at_safepoint() && !StatSampler::is_active()) { |
74 PerfDataManager::destroy(); |
78 PerfDataManager::destroy(); |
75 |
79 } |
76 // remove the persistent external resources, if any. this method |
80 |
|
81 // Remove the persistent external resources, if any. This method |
77 // does not unmap or invalidate any virtual memory allocated during |
82 // does not unmap or invalidate any virtual memory allocated during |
78 // initialization. |
83 // initialization. |
79 // |
84 // |
80 PerfMemory::destroy(); |
85 PerfMemory::destroy(); |
81 } |
86 } |