| 1 | /* | 
|---|
| 2 | * Copyright (c) 2018, 2019, 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 | #ifndef SHARE_GC_SHARED_WEAKPROCESSORPHASES_HPP | 
|---|
| 26 | #define SHARE_GC_SHARED_WEAKPROCESSORPHASES_HPP | 
|---|
| 27 |  | 
|---|
| 28 | #include "memory/allocation.hpp" | 
|---|
| 29 | #include "utilities/globalDefinitions.hpp" | 
|---|
| 30 | #include "utilities/macros.hpp" | 
|---|
| 31 |  | 
|---|
| 32 | class BoolObjectClosure; | 
|---|
| 33 | class OopClosure; | 
|---|
| 34 | class OopStorage; | 
|---|
| 35 |  | 
|---|
| 36 | class WeakProcessorPhases : AllStatic { | 
|---|
| 37 | public: | 
|---|
| 38 | typedef void (*Processor)(BoolObjectClosure*, OopClosure*); | 
|---|
| 39 |  | 
|---|
| 40 | enum Phase { | 
|---|
| 41 | // Serial phases. | 
|---|
| 42 | JVMTI_ONLY(jvmti COMMA) | 
|---|
| 43 | JFR_ONLY(jfr COMMA) | 
|---|
| 44 |  | 
|---|
| 45 | // OopStorage phases. | 
|---|
| 46 | jni, | 
|---|
| 47 | stringtable, | 
|---|
| 48 | resolved_method_table, | 
|---|
| 49 | vm | 
|---|
| 50 | }; | 
|---|
| 51 |  | 
|---|
| 52 | static const uint serial_phase_start = 0; | 
|---|
| 53 | static const uint serial_phase_count = jni; | 
|---|
| 54 | static const uint oop_storage_phase_start = serial_phase_count; | 
|---|
| 55 | static const uint oop_storage_phase_count = (vm + 1) - oop_storage_phase_start; | 
|---|
| 56 | static const uint phase_count = serial_phase_count + oop_storage_phase_count; | 
|---|
| 57 |  | 
|---|
| 58 | static Phase phase(uint value); | 
|---|
| 59 | static uint index(Phase phase); | 
|---|
| 60 | // Indexes relative to the corresponding phase_start constant. | 
|---|
| 61 | static uint serial_index(Phase phase); | 
|---|
| 62 | static uint oop_storage_index(Phase phase); | 
|---|
| 63 |  | 
|---|
| 64 | static bool is_serial(Phase phase); | 
|---|
| 65 | static bool is_oop_storage(Phase phase); | 
|---|
| 66 |  | 
|---|
| 67 | static const char* description(Phase phase); | 
|---|
| 68 | static Processor processor(Phase phase); // Precondition: is_serial(phase) | 
|---|
| 69 | static OopStorage* oop_storage(Phase phase); // Precondition: is_oop_storage(phase) | 
|---|
| 70 |  | 
|---|
| 71 | static bool is_stringtable(Phase phase); | 
|---|
| 72 | static bool is_resolved_method_table(Phase phase); | 
|---|
| 73 | }; | 
|---|
| 74 |  | 
|---|
| 75 | typedef WeakProcessorPhases::Phase WeakProcessorPhase; | 
|---|
| 76 |  | 
|---|
| 77 | #define FOR_EACH_WEAK_PROCESSOR_PHASE(P)                                \ | 
|---|
| 78 | for (WeakProcessorPhase P = static_cast<WeakProcessorPhase>(0);       \ | 
|---|
| 79 | static_cast<uint>(P) <  WeakProcessorPhases::phase_count;        \ | 
|---|
| 80 | P = static_cast<WeakProcessorPhase>(static_cast<uint>(P) + 1)) | 
|---|
| 81 |  | 
|---|
| 82 | #define FOR_EACH_WEAK_PROCESSOR_OOP_STORAGE_PHASE(P)                    \ | 
|---|
| 83 | for (WeakProcessorPhase P = static_cast<WeakProcessorPhase>(WeakProcessorPhases::oop_storage_phase_start); \ | 
|---|
| 84 | static_cast<uint>(P) < (WeakProcessorPhases::oop_storage_phase_start + \ | 
|---|
| 85 | WeakProcessorPhases::oop_storage_phase_count); \ | 
|---|
| 86 | P = static_cast<WeakProcessorPhase>(static_cast<uint>(P) + 1)) | 
|---|
| 87 |  | 
|---|
| 88 | #endif // SHARE_GC_SHARED_WEAKPROCESSORPHASES_HPP | 
|---|
| 89 |  | 
|---|