src/hotspot/share/gc/shared/weakProcessorPhases.cpp
changeset 51546 b9f6a4427da9
child 51599 3198179d97fa
equal deleted inserted replaced
51545:29517169ad2d 51546:b9f6a4427da9
       
     1 /*
       
     2  * Copyright (c) 2018, 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 "gc/shared/weakProcessorPhases.hpp"
       
    28 #include "runtime/jniHandles.hpp"
       
    29 #include "utilities/debug.hpp"
       
    30 #include "utilities/macros.hpp"
       
    31 
       
    32 #if INCLUDE_JFR
       
    33 #include "jfr/jfr.hpp"
       
    34 #endif // INCLUDE_JFR
       
    35 
       
    36 #if INCLUDE_JVMTI
       
    37 #include "prims/jvmtiExport.hpp"
       
    38 #endif // INCLUDE_JVMTI
       
    39 
       
    40 WeakProcessorPhases::Phase WeakProcessorPhases::phase(uint value) {
       
    41   assert(value < phase_count, "Invalid phase value %u", value);
       
    42   return static_cast<Phase>(value);
       
    43 }
       
    44 
       
    45 uint WeakProcessorPhases::index(Phase phase) {
       
    46   uint value = static_cast<uint>(phase);
       
    47   assert(value < phase_count, "Invalid phase %u", value);
       
    48   return value;
       
    49 }
       
    50 
       
    51 uint WeakProcessorPhases::serial_index(Phase phase) {
       
    52   assert(is_serial(phase), "not serial phase %u", index(phase));
       
    53   return index(phase) - serial_phase_start;
       
    54 }
       
    55 
       
    56 uint WeakProcessorPhases::oop_storage_index(Phase phase) {
       
    57   assert(is_oop_storage(phase), "not oop storage phase %u", index(phase));
       
    58   return index(phase) - oop_storage_phase_start;
       
    59 }
       
    60 
       
    61 bool WeakProcessorPhases::is_serial(Phase phase) {
       
    62   return (index(phase) - serial_phase_start) < serial_phase_count;
       
    63 }
       
    64 
       
    65 bool WeakProcessorPhases::is_oop_storage(Phase phase) {
       
    66   return (index(phase) - oop_storage_phase_start) < oop_storage_phase_count;
       
    67 }
       
    68 
       
    69 const char* WeakProcessorPhases::description(Phase phase) {
       
    70   switch (phase) {
       
    71   JVMTI_ONLY(case jvmti: return "JVMTI weak processing";)
       
    72   JFR_ONLY(case jfr: return "JFR weak processing";)
       
    73   case jni: return "JNI weak processing";
       
    74   case vm: return "VM weak processing";
       
    75   default:
       
    76     ShouldNotReachHere();
       
    77     return "Invalid weak processing phase";
       
    78   }
       
    79 }
       
    80 
       
    81 WeakProcessorPhases::Processor WeakProcessorPhases::processor(Phase phase) {
       
    82   switch (phase) {
       
    83   JVMTI_ONLY(case jvmti: return &JvmtiExport::weak_oops_do;)
       
    84   JFR_ONLY(case jfr: return &Jfr::weak_oops_do;)
       
    85   default:
       
    86     ShouldNotReachHere();
       
    87     return NULL;
       
    88   }
       
    89 }
       
    90 
       
    91 OopStorage* WeakProcessorPhases::oop_storage(Phase phase) {
       
    92   switch (phase) {
       
    93   case jni: return JNIHandles::weak_global_handles();
       
    94   case vm: return SystemDictionary::vm_weak_oop_storage();
       
    95   default:
       
    96     ShouldNotReachHere();
       
    97     return NULL;
       
    98   }
       
    99 }