src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp

changeset 1993
b2a00dd3117c
parent 1907
c18cbe5936b8
child 2020
a93a9eda13f7
     1.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp	Wed Jun 30 11:52:10 2010 -0400
     1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp	Thu Jul 01 21:40:45 2010 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -94,45 +94,13 @@
    1.11    print_stats();
    1.12  #endif // PS_PM_STATS
    1.13  
    1.14 -  for(uint i=0; i<ParallelGCThreads+1; i++) {
    1.15 +  for (uint i = 0; i < ParallelGCThreads + 1; i++) {
    1.16      PSPromotionManager* manager = manager_array(i);
    1.17 -
    1.18 -    // the guarantees are a bit gratuitous but, if one fires, we'll
    1.19 -    // have a better idea of what went wrong
    1.20 -    if (i < ParallelGCThreads) {
    1.21 -      guarantee((!UseDepthFirstScavengeOrder ||
    1.22 -                 manager->overflow_stack_depth()->length() <= 0),
    1.23 -                "promotion manager overflow stack must be empty");
    1.24 -      guarantee((UseDepthFirstScavengeOrder ||
    1.25 -                 manager->overflow_stack_breadth()->length() <= 0),
    1.26 -                "promotion manager overflow stack must be empty");
    1.27 -
    1.28 -      guarantee((!UseDepthFirstScavengeOrder ||
    1.29 -                 manager->claimed_stack_depth()->size() <= 0),
    1.30 -                "promotion manager claimed stack must be empty");
    1.31 -      guarantee((UseDepthFirstScavengeOrder ||
    1.32 -                 manager->claimed_stack_breadth()->size() <= 0),
    1.33 -                "promotion manager claimed stack must be empty");
    1.34 +    if (UseDepthFirstScavengeOrder) {
    1.35 +      assert(manager->claimed_stack_depth()->is_empty(), "should be empty");
    1.36      } else {
    1.37 -      guarantee((!UseDepthFirstScavengeOrder ||
    1.38 -                 manager->overflow_stack_depth()->length() <= 0),
    1.39 -                "VM Thread promotion manager overflow stack "
    1.40 -                "must be empty");
    1.41 -      guarantee((UseDepthFirstScavengeOrder ||
    1.42 -                 manager->overflow_stack_breadth()->length() <= 0),
    1.43 -                "VM Thread promotion manager overflow stack "
    1.44 -                "must be empty");
    1.45 -
    1.46 -      guarantee((!UseDepthFirstScavengeOrder ||
    1.47 -                 manager->claimed_stack_depth()->size() <= 0),
    1.48 -                "VM Thread promotion manager claimed stack "
    1.49 -                "must be empty");
    1.50 -      guarantee((UseDepthFirstScavengeOrder ||
    1.51 -                 manager->claimed_stack_breadth()->size() <= 0),
    1.52 -                "VM Thread promotion manager claimed stack "
    1.53 -                "must be empty");
    1.54 +      assert(manager->claimed_stack_breadth()->is_empty(), "should be empty");
    1.55      }
    1.56 -
    1.57      manager->flush_labs();
    1.58    }
    1.59  }
    1.60 @@ -181,15 +149,9 @@
    1.61    if (depth_first()) {
    1.62      claimed_stack_depth()->initialize();
    1.63      queue_size = claimed_stack_depth()->max_elems();
    1.64 -    // We want the overflow stack to be permanent
    1.65 -    _overflow_stack_depth = new (ResourceObj::C_HEAP) GrowableArray<StarTask>(10, true);
    1.66 -    _overflow_stack_breadth = NULL;
    1.67    } else {
    1.68      claimed_stack_breadth()->initialize();
    1.69      queue_size = claimed_stack_breadth()->max_elems();
    1.70 -    // We want the overflow stack to be permanent
    1.71 -    _overflow_stack_breadth = new (ResourceObj::C_HEAP) GrowableArray<oop>(10, true);
    1.72 -    _overflow_stack_depth = NULL;
    1.73    }
    1.74  
    1.75    _totally_drain = (ParallelGCThreads == 1) || (GCDrainStackTargetSize == 0);
    1.76 @@ -209,8 +171,7 @@
    1.77  }
    1.78  
    1.79  void PSPromotionManager::reset() {
    1.80 -  assert(claimed_stack_empty(), "reset of non-empty claimed stack");
    1.81 -  assert(overflow_stack_empty(), "reset of non-empty overflow stack");
    1.82 +  assert(stacks_empty(), "reset of non-empty stack");
    1.83  
    1.84    // We need to get an assert in here to make sure the labs are always flushed.
    1.85  
    1.86 @@ -243,7 +204,7 @@
    1.87  
    1.88  void PSPromotionManager::drain_stacks_depth(bool totally_drain) {
    1.89    assert(depth_first(), "invariant");
    1.90 -  assert(overflow_stack_depth() != NULL, "invariant");
    1.91 +  assert(claimed_stack_depth()->overflow_stack() != NULL, "invariant");
    1.92    totally_drain = totally_drain || _totally_drain;
    1.93  
    1.94  #ifdef ASSERT
    1.95 @@ -254,41 +215,35 @@
    1.96    MutableSpace* perm_space = heap->perm_gen()->object_space();
    1.97  #endif /* ASSERT */
    1.98  
    1.99 +  OopStarTaskQueue* const tq = claimed_stack_depth();
   1.100    do {
   1.101      StarTask p;
   1.102  
   1.103      // Drain overflow stack first, so other threads can steal from
   1.104      // claimed stack while we work.
   1.105 -    while(!overflow_stack_depth()->is_empty()) {
   1.106 -      // linux compiler wants different overloaded operator= in taskqueue to
   1.107 -      // assign to p that the other compilers don't like.
   1.108 -      StarTask ptr = overflow_stack_depth()->pop();
   1.109 -      process_popped_location_depth(ptr);
   1.110 +    while (tq->pop_overflow(p)) {
   1.111 +      process_popped_location_depth(p);
   1.112      }
   1.113  
   1.114      if (totally_drain) {
   1.115 -      while (claimed_stack_depth()->pop_local(p)) {
   1.116 +      while (tq->pop_local(p)) {
   1.117          process_popped_location_depth(p);
   1.118        }
   1.119      } else {
   1.120 -      while (claimed_stack_depth()->size() > _target_stack_size &&
   1.121 -             claimed_stack_depth()->pop_local(p)) {
   1.122 +      while (tq->size() > _target_stack_size && tq->pop_local(p)) {
   1.123          process_popped_location_depth(p);
   1.124        }
   1.125      }
   1.126 -  } while( (totally_drain && claimed_stack_depth()->size() > 0) ||
   1.127 -           (overflow_stack_depth()->length() > 0) );
   1.128 +  } while (totally_drain && !tq->taskqueue_empty() || !tq->overflow_empty());
   1.129  
   1.130 -  assert(!totally_drain || claimed_stack_empty(), "Sanity");
   1.131 -  assert(totally_drain ||
   1.132 -         claimed_stack_depth()->size() <= _target_stack_size,
   1.133 -         "Sanity");
   1.134 -  assert(overflow_stack_empty(), "Sanity");
   1.135 +  assert(!totally_drain || tq->taskqueue_empty(), "Sanity");
   1.136 +  assert(totally_drain || tq->size() <= _target_stack_size, "Sanity");
   1.137 +  assert(tq->overflow_empty(), "Sanity");
   1.138  }
   1.139  
   1.140  void PSPromotionManager::drain_stacks_breadth(bool totally_drain) {
   1.141    assert(!depth_first(), "invariant");
   1.142 -  assert(overflow_stack_breadth() != NULL, "invariant");
   1.143 +  assert(claimed_stack_breadth()->overflow_stack() != NULL, "invariant");
   1.144    totally_drain = totally_drain || _totally_drain;
   1.145  
   1.146  #ifdef ASSERT
   1.147 @@ -299,51 +254,39 @@
   1.148    MutableSpace* perm_space = heap->perm_gen()->object_space();
   1.149  #endif /* ASSERT */
   1.150  
   1.151 +  OverflowTaskQueue<oop>* const tq = claimed_stack_breadth();
   1.152    do {
   1.153      oop obj;
   1.154  
   1.155      // Drain overflow stack first, so other threads can steal from
   1.156      // claimed stack while we work.
   1.157 -    while(!overflow_stack_breadth()->is_empty()) {
   1.158 -      obj = overflow_stack_breadth()->pop();
   1.159 +    while (tq->pop_overflow(obj)) {
   1.160        obj->copy_contents(this);
   1.161      }
   1.162  
   1.163      if (totally_drain) {
   1.164 -      // obj is a reference!!!
   1.165 -      while (claimed_stack_breadth()->pop_local(obj)) {
   1.166 -        // It would be nice to assert about the type of objects we might
   1.167 -        // pop, but they can come from anywhere, unfortunately.
   1.168 +      while (tq->pop_local(obj)) {
   1.169          obj->copy_contents(this);
   1.170        }
   1.171      } else {
   1.172 -      // obj is a reference!!!
   1.173 -      while (claimed_stack_breadth()->size() > _target_stack_size &&
   1.174 -             claimed_stack_breadth()->pop_local(obj)) {
   1.175 -        // It would be nice to assert about the type of objects we might
   1.176 -        // pop, but they can come from anywhere, unfortunately.
   1.177 +      while (tq->size() > _target_stack_size && tq->pop_local(obj)) {
   1.178          obj->copy_contents(this);
   1.179        }
   1.180      }
   1.181  
   1.182      // If we could not find any other work, flush the prefetch queue
   1.183 -    if (claimed_stack_breadth()->size() == 0 &&
   1.184 -        (overflow_stack_breadth()->length() == 0)) {
   1.185 +    if (tq->is_empty()) {
   1.186        flush_prefetch_queue();
   1.187      }
   1.188 -  } while((totally_drain && claimed_stack_breadth()->size() > 0) ||
   1.189 -          (overflow_stack_breadth()->length() > 0));
   1.190 +  } while (totally_drain && !tq->taskqueue_empty() || !tq->overflow_empty());
   1.191  
   1.192 -  assert(!totally_drain || claimed_stack_empty(), "Sanity");
   1.193 -  assert(totally_drain ||
   1.194 -         claimed_stack_breadth()->size() <= _target_stack_size,
   1.195 -         "Sanity");
   1.196 -  assert(overflow_stack_empty(), "Sanity");
   1.197 +  assert(!totally_drain || tq->taskqueue_empty(), "Sanity");
   1.198 +  assert(totally_drain || tq->size() <= _target_stack_size, "Sanity");
   1.199 +  assert(tq->overflow_empty(), "Sanity");
   1.200  }
   1.201  
   1.202  void PSPromotionManager::flush_labs() {
   1.203 -  assert(claimed_stack_empty(), "Attempt to flush lab with live stack");
   1.204 -  assert(overflow_stack_empty(), "Attempt to flush lab with live overflow stack");
   1.205 +  assert(stacks_empty(), "Attempt to flush lab with live stack");
   1.206  
   1.207    // If either promotion lab fills up, we can flush the
   1.208    // lab but not refill it, so check first.

mercurial