hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp
author kvn
Fri, 21 Jun 2013 15:56:24 -0700
changeset 22808 88bca865e247
parent 22807 1cf02ef734e2
parent 18025 b7bcf7497f93
child 22828 17ecb098bc1e
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
     2
 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3262
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3262
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3262
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONMANAGER_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONMANAGER_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    27
12226
590560cfc997 7154517: Build error in hotspot-gc without precompiled headers
nloodin
parents: 11753
diff changeset
    28
#include "gc_implementation/parallelScavenge/psOldGen.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    29
#include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    30
#include "gc_implementation/parallelScavenge/psScavenge.hpp"
22807
1cf02ef734e2 8016586: PPC64 (part 3): basic changes for PPC64
goetz
parents: 13925
diff changeset
    31
#include "oops/oop.psgc.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    32
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
inline PSPromotionManager* PSPromotionManager::manager_array(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  assert(_manager_array != NULL, "access of NULL manager_array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  assert(index >= 0 && index <= (int)ParallelGCThreads, "out of range manager_array access");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  return _manager_array[index];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    39
template <class T>
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    40
inline void PSPromotionManager::claim_or_forward_internal_depth(T* p) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    41
  if (p != NULL) { // XXX: error if p != NULL here
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    42
    oop o = oopDesc::load_decode_heap_oop_not_null(p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    if (o->is_forwarded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
      o = o->forwardee();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
      // Card mark
17852
59b05e1db547 8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents: 13925
diff changeset
    46
      if (PSScavenge::is_obj_in_young(o)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
        PSScavenge::card_table()->inline_write_ref_field_gc(p, o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
      }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    49
      oopDesc::encode_store_heap_oop_not_null(p, o);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
      push_depth(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    56
template <class T>
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    57
inline void PSPromotionManager::claim_or_forward_depth(T* p) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    58
  assert(PSScavenge::should_scavenge(p, true), "revisiting object?");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    59
  assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    60
         "Sanity");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  assert(Universe::heap()->is_in(p), "pointer outside heap");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  claim_or_forward_internal_depth(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    66
//
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    67
// This method is pretty bulky. It would be nice to split it up
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    68
// into smaller submethods, but we need to be careful not to hurt
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    69
// performance.
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    70
//
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    71
template<bool promote_immediately>
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    72
oop PSPromotionManager::copy_to_survivor_space(oop o) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    73
  assert(PSScavenge::should_scavenge(&o), "Sanity");
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    74
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    75
  oop new_obj = NULL;
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    76
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    77
  // NOTE! We must be very careful with any methods that access the mark
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    78
  // in o. There may be multiple threads racing on it, and it may be forwarded
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    79
  // at any time. Do not use oop methods for accessing the mark!
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    80
  markOop test_mark = o->mark();
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    81
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    82
  // The same test as "o->is_forwarded()"
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    83
  if (!test_mark->is_marked()) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    84
    bool new_obj_is_tenured = false;
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    85
    size_t new_obj_size = o->size();
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    86
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    87
    if (!promote_immediately) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    88
      // Find the objects age, MT safe.
13925
37f75ba502b1 8000351: Tenuring threshold should be unsigned
jwilhelm
parents: 13924
diff changeset
    89
      uint age = (test_mark->has_displaced_mark_helper() /* o->has_displaced_mark() */) ?
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    90
        test_mark->displaced_mark_helper()->age() : test_mark->age();
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    91
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    92
      // Try allocating obj in to-space (unless too old)
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    93
      if (age < PSScavenge::tenuring_threshold()) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    94
        new_obj = (oop) _young_lab.allocate(new_obj_size);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    95
        if (new_obj == NULL && !_young_gen_is_full) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    96
          // Do we allocate directly, or flush and refill?
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    97
          if (new_obj_size > (YoungPLABSize / 2)) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    98
            // Allocate this object directly
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
    99
            new_obj = (oop)young_space()->cas_allocate(new_obj_size);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   100
          } else {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   101
            // Flush and fill
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   102
            _young_lab.flush();
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   103
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   104
            HeapWord* lab_base = young_space()->cas_allocate(YoungPLABSize);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   105
            if (lab_base != NULL) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   106
              _young_lab.initialize(MemRegion(lab_base, YoungPLABSize));
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   107
              // Try the young lab allocation again.
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   108
              new_obj = (oop) _young_lab.allocate(new_obj_size);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   109
            } else {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   110
              _young_gen_is_full = true;
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   111
            }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   112
          }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   113
        }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   114
      }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   115
    }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   116
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   117
    // Otherwise try allocating obj tenured
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   118
    if (new_obj == NULL) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   119
#ifndef PRODUCT
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   120
      if (Universe::heap()->promotion_should_fail()) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   121
        return oop_promotion_failed(o, test_mark);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   122
      }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   123
#endif  // #ifndef PRODUCT
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   124
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   125
      new_obj = (oop) _old_lab.allocate(new_obj_size);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   126
      new_obj_is_tenured = true;
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   127
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   128
      if (new_obj == NULL) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   129
        if (!_old_gen_is_full) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   130
          // Do we allocate directly, or flush and refill?
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   131
          if (new_obj_size > (OldPLABSize / 2)) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   132
            // Allocate this object directly
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   133
            new_obj = (oop)old_gen()->cas_allocate(new_obj_size);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   134
          } else {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   135
            // Flush and fill
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   136
            _old_lab.flush();
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   137
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   138
            HeapWord* lab_base = old_gen()->cas_allocate(OldPLABSize);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   139
            if(lab_base != NULL) {
13924
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   140
#ifdef ASSERT
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   141
              // Delay the initialization of the promotion lab (plab).
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   142
              // This exposes uninitialized plabs to card table processing.
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   143
              if (GCWorkerDelayMillis > 0) {
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   144
                os::sleep(Thread::current(), GCWorkerDelayMillis, false);
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   145
              }
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   146
#endif
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   147
              _old_lab.initialize(MemRegion(lab_base, OldPLABSize));
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   148
              // Try the old lab allocation again.
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   149
              new_obj = (oop) _old_lab.allocate(new_obj_size);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   150
            }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   151
          }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   152
        }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   153
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   154
        // This is the promotion failed test, and code handling.
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   155
        // The code belongs here for two reasons. It is slightly
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17852
diff changeset
   156
        // different than the code below, and cannot share the
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   157
        // CAS testing code. Keeping the code here also minimizes
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   158
        // the impact on the common case fast path code.
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   159
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   160
        if (new_obj == NULL) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   161
          _old_gen_is_full = true;
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   162
          return oop_promotion_failed(o, test_mark);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   163
        }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   164
      }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   165
    }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   166
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   167
    assert(new_obj != NULL, "allocation should have succeeded");
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   168
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   169
    // Copy obj
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   170
    Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   171
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   172
    // Now we have to CAS in the header.
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   173
    if (o->cas_forward_to(new_obj, test_mark)) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   174
      // We won any races, we "own" this object.
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   175
      assert(new_obj == o->forwardee(), "Sanity");
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   176
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   177
      // Increment age if obj still in new generation. Now that
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   178
      // we're dealing with a markOop that cannot change, it is
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   179
      // okay to use the non mt safe oop methods.
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   180
      if (!new_obj_is_tenured) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   181
        new_obj->incr_age();
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   182
        assert(young_space()->contains(new_obj), "Attempt to push non-promoted obj");
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   183
      }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   184
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   185
      // Do the size comparison first with new_obj_size, which we
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   186
      // already have. Hopefully, only a few objects are larger than
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   187
      // _min_array_size_for_chunking, and most of them will be arrays.
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   188
      // So, the is->objArray() test would be very infrequent.
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   189
      if (new_obj_size > _min_array_size_for_chunking &&
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   190
          new_obj->is_objArray() &&
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   191
          PSChunkLargeArrays) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   192
        // we'll chunk it
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   193
        oop* const masked_o = mask_chunked_array_oop(o);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   194
        push_depth(masked_o);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   195
        TASKQUEUE_STATS_ONLY(++_arrays_chunked; ++_masked_pushes);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   196
      } else {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   197
        // we'll just push its contents
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   198
        new_obj->push_contents(this);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   199
      }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   200
    }  else {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   201
      // We lost, someone else "owns" this object
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   202
      guarantee(o->is_forwarded(), "Object must be forwarded if the cas failed.");
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   203
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   204
      // Try to deallocate the space.  If it was directly allocated we cannot
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   205
      // deallocate it, so we have to test.  If the deallocation fails,
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   206
      // overwrite with a filler object.
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   207
      if (new_obj_is_tenured) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   208
        if (!_old_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   209
          CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   210
        }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   211
      } else if (!_young_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   212
        CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size);
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   213
      }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   214
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   215
      // don't update this before the unallocation!
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   216
      new_obj = o->forwardee();
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   217
    }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   218
  } else {
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   219
    assert(o->is_forwarded(), "Sanity");
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   220
    new_obj = o->forwardee();
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   221
  }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   222
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12226
diff changeset
   223
#ifndef PRODUCT
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   224
  // This code must come after the CAS test, or it will print incorrect
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   225
  // information.
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   226
  if (TraceScavenge) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12226
diff changeset
   227
    gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   228
       PSScavenge::should_scavenge(&new_obj) ? "copying" : "tenuring",
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12226
diff changeset
   229
       new_obj->klass()->internal_name(), o, new_obj, new_obj->size());
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   230
  }
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   231
#endif
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   232
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   233
  return new_obj;
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   234
}
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   235
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   236
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   237
inline void PSPromotionManager::process_popped_location_depth(StarTask p) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  if (is_oop_masked(p)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    assert(PSChunkLargeArrays, "invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    oop const old = unmask_chunked_array_oop(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    process_array_chunk(old);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  } else {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   243
    if (p.is_narrow()) {
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 670
diff changeset
   244
      assert(UseCompressedOops, "Error");
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   245
      PSScavenge::copy_and_push_safe_barrier<narrowOop, /*promote_immediately=*/false>(this, p);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   246
    } else {
11753
c9e420473a11 7144296: PS: Optimize nmethods processing
iveresov
parents: 7397
diff changeset
   247
      PSScavenge::copy_and_push_safe_barrier<oop, /*promote_immediately=*/false>(this, p);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   248
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
}
6067
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5547
diff changeset
   251
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5547
diff changeset
   252
#if TASKQUEUE_STATS
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5547
diff changeset
   253
void PSPromotionManager::record_steal(StarTask& p) {
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5547
diff changeset
   254
  if (is_oop_masked(p)) {
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5547
diff changeset
   255
    ++_masked_steals;
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5547
diff changeset
   256
  }
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5547
diff changeset
   257
}
8bfddf73fc04 6962947: shared TaskQueue statistics
jcoomes
parents: 5547
diff changeset
   258
#endif // TASKQUEUE_STATS
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
   259
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
   260
#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONMANAGER_INLINE_HPP