Mon, 19 Aug 2019 10:11:31 +0200
8229401: Fix JFR code cache test failures
8223689: Add JFR Thread Sampling Support
8223690: Add JFR BiasedLock Event Support
8223691: Add JFR G1 Region Type Change Event Support
8223692: Add JFR G1 Heap Summary Event Support
Summary: Backport JFR from JDK11, additional fixes
Reviewed-by: neugens, apetushkov
Contributed-by: denghui.ddh@alibaba-inc.com
apetushkov@9858 | 1 | /* |
apetushkov@9858 | 2 | * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
apetushkov@9858 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
apetushkov@9858 | 4 | * |
apetushkov@9858 | 5 | * This code is free software; you can redistribute it and/or modify it |
apetushkov@9858 | 6 | * under the terms of the GNU General Public License version 2 only, as |
apetushkov@9858 | 7 | * published by the Free Software Foundation. |
apetushkov@9858 | 8 | * |
apetushkov@9858 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
apetushkov@9858 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
apetushkov@9858 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
apetushkov@9858 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
apetushkov@9858 | 13 | * accompanied this code). |
apetushkov@9858 | 14 | * |
apetushkov@9858 | 15 | * You should have received a copy of the GNU General Public License version |
apetushkov@9858 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
apetushkov@9858 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
apetushkov@9858 | 18 | * |
apetushkov@9858 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
apetushkov@9858 | 20 | * or visit www.oracle.com if you need additional information or have any |
apetushkov@9858 | 21 | * questions. |
apetushkov@9858 | 22 | * |
apetushkov@9858 | 23 | */ |
apetushkov@9858 | 24 | |
apetushkov@9858 | 25 | #ifndef SHARE_VM_JFR_RECORDER_CHECKPOINT_JFRCHECKPOINTMANAGER_HPP |
apetushkov@9858 | 26 | #define SHARE_VM_JFR_RECORDER_CHECKPOINT_JFRCHECKPOINTMANAGER_HPP |
apetushkov@9858 | 27 | |
apetushkov@9858 | 28 | #include "jfr/recorder/storage/jfrBuffer.hpp" |
apetushkov@9858 | 29 | #include "jfr/recorder/storage/jfrMemorySpace.hpp" |
apetushkov@9858 | 30 | #include "jfr/recorder/storage/jfrMemorySpaceRetrieval.hpp" |
apetushkov@9858 | 31 | |
apetushkov@9858 | 32 | class JfrCheckpointManager; |
apetushkov@9858 | 33 | class JfrChunkWriter; |
apetushkov@9858 | 34 | class JfrSerializer; |
apetushkov@9858 | 35 | class JfrTypeManager; |
apetushkov@9858 | 36 | class Mutex; |
apetushkov@9858 | 37 | class Thread; |
apetushkov@9858 | 38 | |
apetushkov@9858 | 39 | struct JfrCheckpointEntry { |
apetushkov@9858 | 40 | jlong size; |
apetushkov@9858 | 41 | jlong start_time; |
apetushkov@9858 | 42 | jlong duration; |
apetushkov@9858 | 43 | juint flushpoint; |
apetushkov@9858 | 44 | juint nof_segments; |
apetushkov@9858 | 45 | }; |
apetushkov@9858 | 46 | |
apetushkov@9858 | 47 | typedef JfrMemorySpace<JfrBuffer, JfrMspaceSequentialRetrieval, JfrCheckpointManager> JfrCheckpointMspace; |
apetushkov@9858 | 48 | |
apetushkov@9858 | 49 | // |
apetushkov@9858 | 50 | // Responsible for maintaining checkpoints and by implication types. |
apetushkov@9858 | 51 | // A checkpoint is an event that has a payload consisting of constant types. |
apetushkov@9858 | 52 | // A constant type is a binary relation, a set of key-value pairs. |
apetushkov@9858 | 53 | // |
apetushkov@9858 | 54 | class JfrCheckpointManager : public JfrCHeapObj { |
apetushkov@9858 | 55 | public: |
apetushkov@9858 | 56 | typedef JfrCheckpointMspace::Type Buffer; |
apetushkov@9858 | 57 | private: |
apetushkov@9858 | 58 | JfrCheckpointMspace* _free_list_mspace; |
apetushkov@9858 | 59 | JfrCheckpointMspace* _epoch_transition_mspace; |
apetushkov@9858 | 60 | Mutex* _lock; |
apetushkov@9858 | 61 | const Thread* _service_thread; |
apetushkov@9858 | 62 | JfrChunkWriter& _chunkwriter; |
apetushkov@9858 | 63 | u1 _checkpoint_epoch_state; |
apetushkov@9858 | 64 | |
apetushkov@9858 | 65 | // mspace callback |
apetushkov@9858 | 66 | void register_full(Buffer* t, Thread* thread); |
apetushkov@9858 | 67 | void lock(); |
apetushkov@9858 | 68 | void unlock(); |
apetushkov@9858 | 69 | DEBUG_ONLY(bool is_locked() const;) |
apetushkov@9858 | 70 | |
apetushkov@9858 | 71 | static Buffer* lease_buffer(Thread* t, size_t size = 0); |
apetushkov@9858 | 72 | static Buffer* flush(Buffer* old, size_t used, size_t requested, Thread* t); |
apetushkov@9858 | 73 | |
apetushkov@9858 | 74 | size_t clear(); |
apetushkov@9858 | 75 | size_t write(); |
apetushkov@9858 | 76 | size_t write_epoch_transition_mspace(); |
apetushkov@9858 | 77 | size_t write_types(); |
apetushkov@9858 | 78 | size_t write_safepoint_types(); |
apetushkov@9858 | 79 | void write_type_set(); |
apetushkov@9858 | 80 | void shift_epoch(); |
apetushkov@9858 | 81 | void synchronize_epoch(); |
apetushkov@9858 | 82 | bool use_epoch_transition_mspace(const Thread* t) const; |
apetushkov@9858 | 83 | |
apetushkov@9858 | 84 | JfrCheckpointManager(JfrChunkWriter& cw); |
apetushkov@9858 | 85 | ~JfrCheckpointManager(); |
apetushkov@9858 | 86 | |
apetushkov@9858 | 87 | static JfrCheckpointManager& instance(); |
apetushkov@9858 | 88 | static JfrCheckpointManager* create(JfrChunkWriter& cw); |
apetushkov@9858 | 89 | bool initialize(); |
apetushkov@9858 | 90 | static void destroy(); |
apetushkov@9858 | 91 | |
apetushkov@9858 | 92 | public: |
apetushkov@9858 | 93 | void register_service_thread(const Thread* t); |
apetushkov@9858 | 94 | static void write_type_set_for_unloaded_classes(); |
apetushkov@9858 | 95 | static void create_thread_checkpoint(JavaThread* jt); |
apetushkov@9858 | 96 | static void write_thread_checkpoint(JavaThread* jt); |
apetushkov@9858 | 97 | |
apetushkov@9858 | 98 | friend class JfrRecorder; |
apetushkov@9858 | 99 | friend class JfrRecorderService; |
apetushkov@9858 | 100 | friend class JfrCheckpointFlush; |
apetushkov@9858 | 101 | friend class JfrCheckpointWriter; |
apetushkov@9858 | 102 | friend class JfrSerializer; |
apetushkov@9858 | 103 | friend class JfrStackTraceRepository; |
apetushkov@9858 | 104 | template <typename, template <typename> class, typename> |
apetushkov@9858 | 105 | friend class JfrMemorySpace; |
apetushkov@9858 | 106 | }; |
apetushkov@9858 | 107 | |
apetushkov@9858 | 108 | #endif //SHARE_VM_JFR_RECORDER_CHECKPOINT_JFRCHECKPOINTMANAGER_HPP |