hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp
changeset 27682 dbd1c3f92130
parent 26837 72a43d3841e7
child 27883 3179632c8f66
equal deleted inserted replaced
27681:cc54c45a93ac 27682:dbd1c3f92130
   148       dispatch_reference(ref);
   148       dispatch_reference(ref);
   149     }
   149     }
   150   } while (!_refs->is_empty());
   150   } while (!_refs->is_empty());
   151 }
   151 }
   152 
   152 
   153 oop G1ParScanThreadState::copy_to_survivor_space(oop const old) {
   153 oop G1ParScanThreadState::copy_to_survivor_space(oop const old,
       
   154                                                  markOop const old_mark) {
   154   size_t word_sz = old->size();
   155   size_t word_sz = old->size();
   155   HeapRegion* from_region = _g1h->heap_region_containing_raw(old);
   156   HeapRegion* from_region = _g1h->heap_region_containing_raw(old);
   156   // +1 to make the -1 indexes valid...
   157   // +1 to make the -1 indexes valid...
   157   int       young_index = from_region->young_index_in_cset()+1;
   158   int       young_index = from_region->young_index_in_cset()+1;
   158   assert( (from_region->is_young() && young_index >  0) ||
   159   assert( (from_region->is_young() && young_index >  0) ||
   159          (!from_region->is_young() && young_index == 0), "invariant" );
   160          (!from_region->is_young() && young_index == 0), "invariant" );
   160   G1CollectorPolicy* g1p = _g1h->g1_policy();
   161   G1CollectorPolicy* g1p = _g1h->g1_policy();
   161   markOop m = old->mark();
   162   uint age = old_mark->has_displaced_mark_helper() ? old_mark->displaced_mark_helper()->age()
   162   int age = m->has_displaced_mark_helper() ? m->displaced_mark_helper()->age()
   163                                                    : old_mark->age();
   163                                            : m->age();
       
   164   GCAllocPurpose alloc_purpose = g1p->evacuation_destination(from_region, age,
   164   GCAllocPurpose alloc_purpose = g1p->evacuation_destination(from_region, age,
   165                                                              word_sz);
   165                                                              word_sz);
   166   AllocationContext_t context = from_region->allocation_context();
   166   AllocationContext_t context = from_region->allocation_context();
   167   HeapWord* obj_ptr = _g1_par_allocator->allocate(alloc_purpose, word_sz, context);
   167   HeapWord* obj_ptr = _g1_par_allocator->allocate(alloc_purpose, word_sz, context);
   168 #ifndef PRODUCT
   168 #ifndef PRODUCT
   194     // we actually allocated from and update alloc_purpose accordingly
   194     // we actually allocated from and update alloc_purpose accordingly
   195     HeapRegion* to_region = _g1h->heap_region_containing_raw(obj_ptr);
   195     HeapRegion* to_region = _g1h->heap_region_containing_raw(obj_ptr);
   196     alloc_purpose = to_region->is_young() ? GCAllocForSurvived : GCAllocForTenured;
   196     alloc_purpose = to_region->is_young() ? GCAllocForSurvived : GCAllocForTenured;
   197 
   197 
   198     if (g1p->track_object_age(alloc_purpose)) {
   198     if (g1p->track_object_age(alloc_purpose)) {
   199       // We could simply do obj->incr_age(). However, this causes a
   199       if (age < markOopDesc::max_age) {
   200       // performance issue. obj->incr_age() will first check whether
   200         age++;
   201       // the object has a displaced mark by checking its mark word;
   201       }
   202       // getting the mark word from the new location of the object
   202       if (old_mark->has_displaced_mark_helper()) {
   203       // stalls. So, given that we already have the mark word and we
   203         // In this case, we have to install the mark word first,
   204       // are about to install it anyway, it's better to increase the
       
   205       // age on the mark word, when the object does not have a
       
   206       // displaced mark word. We're not expecting many objects to have
       
   207       // a displaced marked word, so that case is not optimized
       
   208       // further (it could be...) and we simply call obj->incr_age().
       
   209 
       
   210       if (m->has_displaced_mark_helper()) {
       
   211         // in this case, we have to install the mark word first,
       
   212         // otherwise obj looks to be forwarded (the old mark word,
   204         // otherwise obj looks to be forwarded (the old mark word,
   213         // which contains the forward pointer, was copied)
   205         // which contains the forward pointer, was copied)
   214         obj->set_mark(m);
   206         obj->set_mark(old_mark);
   215         obj->incr_age();
   207         markOop new_mark = old_mark->displaced_mark_helper()->set_age(age);
       
   208         old_mark->set_displaced_mark_helper(new_mark);
   216       } else {
   209       } else {
   217         m = m->incr_age();
   210         obj->set_mark(old_mark->set_age(age));
   218         obj->set_mark(m);
       
   219       }
   211       }
   220       age_table()->add(obj, word_sz);
   212       age_table()->add(age, word_sz);
   221     } else {
   213     } else {
   222       obj->set_mark(m);
   214       obj->set_mark(old_mark);
   223     }
   215     }
   224 
   216 
   225     if (G1StringDedup::is_enabled()) {
   217     if (G1StringDedup::is_enabled()) {
   226       G1StringDedup::enqueue_from_evacuation(from_region->is_young(),
   218       G1StringDedup::enqueue_from_evacuation(from_region->is_young(),
   227                                              to_region->is_young(),
   219                                              to_region->is_young(),