hotspot/src/share/vm/gc/shared/referencePendingListLocker.hpp
author coleenp
Mon, 25 Apr 2016 09:51:00 -0400
changeset 38074 8475fdc6dcc3
parent 37129 af29e306e50b
permissions -rw-r--r--
8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure Summary: GC walks the mirror using OopClosure rather than using CLDClosure in oops_interpreted_do() Reviewed-by: dlong, twisti, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37129
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
     1
/*
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
     4
 *
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
     7
 * published by the Free Software Foundation.
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
     8
 *
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    13
 * accompanied this code).
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    14
 *
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    18
 *
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    21
 * questions.
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    22
 *
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    23
 */
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    24
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_SHARED_REFERENCEPENDINGLISTLOCKER_HPP
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    26
#define SHARE_VM_GC_SHARED_REFERENCEPENDINGLISTLOCKER_HPP
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    27
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    28
#include "memory/allocation.hpp"
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    29
#include "runtime/basicLock.hpp"
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    30
#include "runtime/mutex.hpp"
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    31
#include "runtime/thread.hpp"
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    32
#include "utilities/exceptions.hpp"
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    33
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    34
//
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    35
// The ReferencePendingListLockerThread locks and unlocks the reference
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    36
// pending list lock on behalf a non-Java thread, typically a concurrent
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    37
// GC thread. This interface should not be directly accessed. All uses
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    38
// should instead go through the ReferencePendingListLocker, which calls
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    39
// this thread if needed.
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    40
//
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    41
class ReferencePendingListLockerThread : public JavaThread {
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    42
private:
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    43
  enum Message {
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    44
    NONE,
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    45
    LOCK,
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    46
    UNLOCK
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    47
  };
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    48
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    49
  Monitor _monitor;
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    50
  Message _message;
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    51
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    52
  ReferencePendingListLockerThread();
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    53
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    54
  static void start(JavaThread* thread, TRAPS);
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    55
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    56
  void send_message(Message message);
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    57
  void receive_and_handle_messages();
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    58
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    59
public:
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    60
  static ReferencePendingListLockerThread* create(TRAPS);
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    61
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    62
  virtual bool is_hidden_from_external_view() const;
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    63
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    64
  void lock();
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    65
  void unlock();
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    66
};
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    67
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    68
//
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    69
// The ReferencePendingListLocker is the main interface for locking and
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    70
// unlocking the reference pending list lock, which needs to be held by
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    71
// the GC when adding references to the pending list. Since this is a
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    72
// Java-level monitor it can only be locked/unlocked by a Java thread.
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    73
// For this reason there is an option to spawn a helper thread, the
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    74
// ReferencePendingListLockerThread, during initialization. If a helper
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    75
// thread is spawned all lock operations from non-Java threads will be
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    76
// delegated to the helper thread. The helper thread is typically needed
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    77
// by concurrent GCs.
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    78
//
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    79
class ReferencePendingListLocker VALUE_OBJ_CLASS_SPEC {
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    80
private:
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    81
  static bool                              _is_initialized;
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    82
  static ReferencePendingListLockerThread* _locker_thread;
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    83
  BasicLock                                _basic_lock;
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    84
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    85
public:
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    86
  static void initialize(bool needs_locker_thread, TRAPS);
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    87
  static bool is_initialized();
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    88
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    89
  static bool is_locked_by_self();
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    90
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    91
  void lock();
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    92
  void unlock();
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    93
};
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    94
af29e306e50b 8151601: Cleanup locking of the Reference pending list
pliden
parents:
diff changeset
    95
#endif // SHARE_VM_GC_SHARED_REFERENCEPENDINGLISTLOCKER_HPP