hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp
author kbarrett
Wed, 15 Apr 2015 12:16:01 -0400
changeset 30182 1c980a880941
parent 28213 b0bf57cd1e9d
child 30566 18eb9aa972d0
child 30564 a37d98a1eb54
permissions -rw-r--r--
8069367: Eagerly reclaimed humongous objects left on mark stack Summary: Prevent eager reclaim of objects that might be on mark stack. Reviewed-by: brutisso, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     1
/*
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     4
 *
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     8
 *
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    14
 *
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    18
 *
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    21
 * questions.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    22
 *
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    23
 */
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    24
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    27
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    28
#include "gc_implementation/g1/dirtyCardQueue.hpp"
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    29
#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    30
#include "gc_implementation/g1/g1CollectedHeap.hpp"
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    31
#include "gc_implementation/g1/g1CollectorPolicy.hpp"
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    32
#include "gc_implementation/g1/g1OopClosures.hpp"
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    33
#include "gc_implementation/g1/g1RemSet.hpp"
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    34
#include "gc_implementation/shared/ageTable.hpp"
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    35
#include "memory/allocation.hpp"
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    36
#include "oops/oop.hpp"
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    37
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    38
class HeapRegion;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    39
class outputStream;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    40
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    41
class G1ParScanThreadState : public StackObj {
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    42
 private:
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    43
  G1CollectedHeap* _g1h;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    44
  RefToScanQueue*  _refs;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    45
  DirtyCardQueue   _dcq;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    46
  G1SATBCardTableModRefBS* _ct_bs;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    47
  G1RemSet* _g1_rem;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    48
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    49
  G1ParGCAllocator* _g1_par_allocator;
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    50
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    51
  ageTable          _age_table;
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    52
  InCSetState       _dest[InCSetState::Num];
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    53
  // Local tenuring threshold.
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    54
  uint              _tenuring_threshold;
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    55
  G1ParScanClosure  _scanner;
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    56
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    57
  size_t            _alloc_buffer_waste;
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    58
  size_t            _undo_waste;
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    59
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    60
  OopsInHeapRegionClosure*      _evac_failure_cl;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    61
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    62
  int  _hash_seed;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    63
  uint _queue_num;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    64
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    65
  size_t _term_attempts;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    66
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    67
  double _start;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    68
  double _start_strong_roots;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    69
  double _strong_roots_time;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    70
  double _start_term;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    71
  double _term_time;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    72
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    73
  // Map from young-age-index (0 == not young, 1 is youngest) to
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    74
  // surviving words. base is what we get back from the malloc call
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    75
  size_t* _surviving_young_words_base;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    76
  // this points into the array, as we use the first few entries for padding
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    77
  size_t* _surviving_young_words;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    78
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    79
#define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t))
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    80
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    81
  void   add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    82
  void   add_to_undo_waste(size_t waste)         { _undo_waste += waste; }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    83
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    84
  DirtyCardQueue& dirty_card_queue()             { return _dcq;  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    85
  G1SATBCardTableModRefBS* ctbs()                { return _ct_bs; }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    86
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    87
  InCSetState dest(InCSetState original) const {
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    88
    assert(original.is_valid(),
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    89
           err_msg("Original state invalid: " CSETSTATE_FORMAT, original.value()));
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    90
    assert(_dest[original.value()].is_valid_gen(),
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    91
           err_msg("Dest state is invalid: " CSETSTATE_FORMAT, _dest[original.value()].value()));
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    92
    return _dest[original.value()];
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    93
  }
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    94
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    95
 public:
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    96
  G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp);
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    97
  ~G1ParScanThreadState();
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    98
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    99
  ageTable*         age_table()       { return &_age_table;       }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   100
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   101
#ifdef ASSERT
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   102
  bool queue_is_empty() const { return _refs->is_empty(); }
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   103
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   104
  bool verify_ref(narrowOop* ref) const;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   105
  bool verify_ref(oop* ref) const;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   106
  bool verify_task(StarTask ref) const;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   107
#endif // ASSERT
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   108
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   109
  template <class T> void push_on_queue(T* ref) {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   110
    assert(verify_ref(ref), "sanity");
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   111
    _refs->push(ref);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   112
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   113
26850
515ff48cf5f0 8036116: Fix thread-id types in G1 remembered set implementations
brutisso
parents: 26837
diff changeset
   114
  template <class T> void update_rs(HeapRegion* from, T* p, uint tid) {
26701
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 25483
diff changeset
   115
    // If the new value of the field points to the same region or
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 25483
diff changeset
   116
    // is the to-space, we don't need to include it in the Rset updates.
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 25483
diff changeset
   117
    if (!from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) && !from->is_survivor()) {
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 25483
diff changeset
   118
      size_t card_index = ctbs()->index_for(p);
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 25483
diff changeset
   119
      // If the card hasn't been added to the buffer, do it.
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 25483
diff changeset
   120
      if (ctbs()->mark_card_deferred(card_index)) {
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 25483
diff changeset
   121
        dirty_card_queue().enqueue((jbyte*)ctbs()->byte_for_index(card_index));
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 25483
diff changeset
   122
      }
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 25483
diff changeset
   123
    }
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 25483
diff changeset
   124
  }
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   125
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   126
  void set_evac_failure_closure(OopsInHeapRegionClosure* evac_failure_cl) {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   127
    _evac_failure_cl = evac_failure_cl;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   128
  }
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   129
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   130
  OopsInHeapRegionClosure* evac_failure_closure() { return _evac_failure_cl; }
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   131
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   132
  int* hash_seed() { return &_hash_seed; }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   133
  uint queue_num() { return _queue_num; }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   134
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   135
  size_t term_attempts() const  { return _term_attempts; }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   136
  void note_term_attempt() { _term_attempts++; }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   137
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   138
  void start_strong_roots() {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   139
    _start_strong_roots = os::elapsedTime();
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   140
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   141
  void end_strong_roots() {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   142
    _strong_roots_time += (os::elapsedTime() - _start_strong_roots);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   143
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   144
  double strong_roots_time() const { return _strong_roots_time; }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   145
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   146
  void start_term_time() {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   147
    note_term_attempt();
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   148
    _start_term = os::elapsedTime();
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   149
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   150
  void end_term_time() {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   151
    _term_time += (os::elapsedTime() - _start_term);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   152
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   153
  double term_time() const { return _term_time; }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   154
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   155
  double elapsed_time() const {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   156
    return os::elapsedTime() - _start;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   157
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   158
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   159
  static void print_termination_stats_hdr(outputStream* const st = gclog_or_tty);
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   160
  void print_termination_stats(int i, outputStream* const st = gclog_or_tty) const;
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   161
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   162
  size_t* surviving_young_words() {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   163
    // We add on to hide entry 0 which accumulates surviving words for
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   164
    // age -1 regions (i.e. non-young ones)
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   165
    return _surviving_young_words;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   166
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   167
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   168
 private:
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   169
  #define G1_PARTIAL_ARRAY_MASK 0x2
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   170
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   171
  inline bool has_partial_array_mask(oop* ref) const {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   172
    return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   173
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   174
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   175
  // We never encode partial array oops as narrowOop*, so return false immediately.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   176
  // This allows the compiler to create optimized code when popping references from
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   177
  // the work queue.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   178
  inline bool has_partial_array_mask(narrowOop* ref) const {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   179
    assert(((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) != G1_PARTIAL_ARRAY_MASK, "Partial array oop reference encoded as narrowOop*");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   180
    return false;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   181
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   182
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   183
  // Only implement set_partial_array_mask() for regular oops, not for narrowOops.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   184
  // We always encode partial arrays as regular oop, to allow the
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   185
  // specialization for has_partial_array_mask() for narrowOops above.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   186
  // This means that unintentional use of this method with narrowOops are caught
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   187
  // by the compiler.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   188
  inline oop* set_partial_array_mask(oop obj) const {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   189
    assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   190
    return (oop*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   191
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   192
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   193
  inline oop clear_partial_array_mask(oop* ref) const {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   194
    return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   195
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   196
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   197
  inline void do_oop_partial_array(oop* p);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   198
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   199
  // This method is applied to the fields of the objects that have just been copied.
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   200
  template <class T> inline void do_oop_evac(T* p, HeapRegion* from);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   201
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   202
  template <class T> inline void deal_with_reference(T* ref_to_scan);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   203
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   204
  inline void dispatch_reference(StarTask ref);
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   205
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   206
  // Tries to allocate word_sz in the PLAB of the next "generation" after trying to
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   207
  // allocate into dest. State is the original (source) cset state for the object
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   208
  // that is allocated for.
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   209
  // Returns a non-NULL pointer if successful, and updates dest if required.
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   210
  HeapWord* allocate_in_next_plab(InCSetState const state,
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   211
                                  InCSetState* dest,
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   212
                                  size_t word_sz,
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   213
                                  AllocationContext_t const context);
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   214
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   215
  inline InCSetState next_state(InCSetState const state, markOop const m, uint& age);
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   216
 public:
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   217
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   218
  oop copy_to_survivor_space(InCSetState const state, oop const obj, markOop const old_mark);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   219
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   220
  void trim_queue();
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   221
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   222
  inline void steal_and_trim_queue(RefToScanQueueSet *task_queues);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   223
};
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   224
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   225
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP