src/hotspot/share/gc/shared/gcBehaviours.hpp
author eosterlund
Fri, 02 Nov 2018 08:33:59 +0100
changeset 52385 5c679ec60888
child 53244 9807daeb47c4
permissions -rw-r--r--
8209189: Make CompiledMethod::do_unloading more concurrent Reviewed-by: kvn, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52385
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
     1
/*
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
     4
 *
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
     8
 *
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    13
 * accompanied this code).
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    14
 *
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    18
 *
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    21
 * questions.
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    22
 *
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    23
 */
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    24
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    25
#ifndef SHARE_GC_SHARED_BEHAVIOURS_HPP
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    26
#define SHARE_GC_SHARED_BEHAVIOURS_HPP
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    27
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    28
#include "memory/iterator.hpp"
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    29
#include "oops/oopsHierarchy.hpp"
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    30
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    31
// This is the behaviour for checking if a CompiledMethod is unloading
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    32
// or has unloaded due to having phantomly dead oops in it after a GC.
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    33
class IsUnloadingBehaviour {
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    34
  static IsUnloadingBehaviour* _current;
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    35
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    36
public:
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    37
  virtual bool is_unloading(CompiledMethod* cm) const = 0;
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    38
  static IsUnloadingBehaviour* current() { return _current; }
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    39
  static void set_current(IsUnloadingBehaviour* current) { _current = current; }
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    40
};
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    41
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    42
class ClosureIsUnloadingBehaviour: public IsUnloadingBehaviour {
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    43
  BoolObjectClosure *const _cl;
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    44
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    45
public:
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    46
  ClosureIsUnloadingBehaviour(BoolObjectClosure* is_alive)
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    47
    : _cl(is_alive)
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    48
  { }
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    49
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    50
  virtual bool is_unloading(CompiledMethod* cm) const;
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    51
};
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    52
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff changeset
    53
#endif // SHARE_GC_SHARED_BEHAVIOURS_HPP