Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/heapRegion.cpp @ 845:df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
Summary: Modifications to G1 so as to allow the use of compressed oops.
Reviewed-by: apetrusenko, coleenp, jmasa, kvn, never, phh, tonyp
author | ysr |
---|---|
date | Tue, 14 Jul 2009 15:40:39 -0700 |
parents | 0316eac49d5a |
children | 18f526145aea |
comparison
equal
deleted
inserted
replaced
839:bb18957ad21e | 845:df6caf649ff7 |
---|---|
64 } | 64 } |
65 | 65 |
66 bool failures() { return _failures; } | 66 bool failures() { return _failures; } |
67 int n_failures() { return _n_failures; } | 67 int n_failures() { return _n_failures; } |
68 | 68 |
69 virtual void do_oop(narrowOop* p) { | 69 virtual void do_oop(narrowOop* p) { do_oop_work(p); } |
70 guarantee(false, "NYI"); | 70 virtual void do_oop( oop* p) { do_oop_work(p); } |
71 } | 71 |
72 | 72 template <class T> void do_oop_work(T* p) { |
73 void do_oop(oop* p) { | |
74 assert(_containing_obj != NULL, "Precondition"); | 73 assert(_containing_obj != NULL, "Precondition"); |
75 assert(!_g1h->is_obj_dead_cond(_containing_obj, _use_prev_marking), | 74 assert(!_g1h->is_obj_dead_cond(_containing_obj, _use_prev_marking), |
76 "Precondition"); | 75 "Precondition"); |
77 oop obj = *p; | 76 T heap_oop = oopDesc::load_heap_oop(p); |
78 if (obj != NULL) { | 77 if (!oopDesc::is_null(heap_oop)) { |
78 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); | |
79 bool failed = false; | 79 bool failed = false; |
80 if (!_g1h->is_in_closed_subset(obj) || | 80 if (!_g1h->is_in_closed_subset(obj) || |
81 _g1h->is_obj_dead_cond(obj, _use_prev_marking)) { | 81 _g1h->is_obj_dead_cond(obj, _use_prev_marking)) { |
82 if (!_failures) { | 82 if (!_failures) { |
83 gclog_or_tty->print_cr(""); | 83 gclog_or_tty->print_cr(""); |
104 failed = true; | 104 failed = true; |
105 _n_failures++; | 105 _n_failures++; |
106 } | 106 } |
107 | 107 |
108 if (!_g1h->full_collection()) { | 108 if (!_g1h->full_collection()) { |
109 HeapRegion* from = _g1h->heap_region_containing(p); | 109 HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p); |
110 HeapRegion* to = _g1h->heap_region_containing(*p); | 110 HeapRegion* to = _g1h->heap_region_containing(obj); |
111 if (from != NULL && to != NULL && | 111 if (from != NULL && to != NULL && |
112 from != to && | 112 from != to && |
113 !to->isHumongous()) { | 113 !to->isHumongous()) { |
114 jbyte cv_obj = *_bs->byte_for_const(_containing_obj); | 114 jbyte cv_obj = *_bs->byte_for_const(_containing_obj); |
115 jbyte cv_field = *_bs->byte_for_const(p); | 115 jbyte cv_field = *_bs->byte_for_const(p); |
532 mr = mr.intersection(used_region()); | 532 mr = mr.intersection(used_region()); |
533 if (mr.is_empty()) return NULL; | 533 if (mr.is_empty()) return NULL; |
534 // Otherwise, find the obj that extends onto mr.start(). | 534 // Otherwise, find the obj that extends onto mr.start(). |
535 | 535 |
536 assert(cur <= mr.start() | 536 assert(cur <= mr.start() |
537 && (oop(cur)->klass() == NULL || | 537 && (oop(cur)->klass_or_null() == NULL || |
538 cur + oop(cur)->size() > mr.start()), | 538 cur + oop(cur)->size() > mr.start()), |
539 "postcondition of block_start"); | 539 "postcondition of block_start"); |
540 oop obj; | 540 oop obj; |
541 while (cur < mr.end()) { | 541 while (cur < mr.end()) { |
542 obj = oop(cur); | 542 obj = oop(cur); |
543 if (obj->klass() == NULL) { | 543 if (obj->klass_or_null() == NULL) { |
544 // Ran into an unparseable point. | 544 // Ran into an unparseable point. |
545 return cur; | 545 return cur; |
546 } else if (!g1h->is_obj_dead(obj)) { | 546 } else if (!g1h->is_obj_dead(obj)) { |
547 cl->do_object(obj); | 547 cl->do_object(obj); |
548 } | 548 } |
575 // to update the BOT while we do this... | 575 // to update the BOT while we do this... |
576 HeapWord* cur = block_start(mr.start()); | 576 HeapWord* cur = block_start(mr.start()); |
577 assert(cur <= mr.start(), "Postcondition"); | 577 assert(cur <= mr.start(), "Postcondition"); |
578 | 578 |
579 while (cur <= mr.start()) { | 579 while (cur <= mr.start()) { |
580 if (oop(cur)->klass() == NULL) { | 580 if (oop(cur)->klass_or_null() == NULL) { |
581 // Ran into an unparseable point. | 581 // Ran into an unparseable point. |
582 return cur; | 582 return cur; |
583 } | 583 } |
584 // Otherwise... | 584 // Otherwise... |
585 int sz = oop(cur)->size(); | 585 int sz = oop(cur)->size(); |
589 } | 589 } |
590 oop obj; | 590 oop obj; |
591 obj = oop(cur); | 591 obj = oop(cur); |
592 // If we finish this loop... | 592 // If we finish this loop... |
593 assert(cur <= mr.start() | 593 assert(cur <= mr.start() |
594 && obj->klass() != NULL | 594 && obj->klass_or_null() != NULL |
595 && cur + obj->size() > mr.start(), | 595 && cur + obj->size() > mr.start(), |
596 "Loop postcondition"); | 596 "Loop postcondition"); |
597 if (!g1h->is_obj_dead(obj)) { | 597 if (!g1h->is_obj_dead(obj)) { |
598 obj->oop_iterate(cl, mr); | 598 obj->oop_iterate(cl, mr); |
599 } | 599 } |
600 | 600 |
601 HeapWord* next; | 601 HeapWord* next; |
602 while (cur < mr.end()) { | 602 while (cur < mr.end()) { |
603 obj = oop(cur); | 603 obj = oop(cur); |
604 if (obj->klass() == NULL) { | 604 if (obj->klass_or_null() == NULL) { |
605 // Ran into an unparseable point. | 605 // Ran into an unparseable point. |
606 return cur; | 606 return cur; |
607 }; | 607 }; |
608 // Otherwise: | 608 // Otherwise: |
609 next = (cur + obj->size()); | 609 next = (cur + obj->size()); |
779 // will be false, and it will pick up top() as the high water mark | 779 // will be false, and it will pick up top() as the high water mark |
780 // of region. If it does so after _gc_time_stamp = ..., then it | 780 // of region. If it does so after _gc_time_stamp = ..., then it |
781 // will pick up the right saved_mark_word() as the high water mark | 781 // will pick up the right saved_mark_word() as the high water mark |
782 // of the region. Either way, the behaviour will be correct. | 782 // of the region. Either way, the behaviour will be correct. |
783 ContiguousSpace::set_saved_mark(); | 783 ContiguousSpace::set_saved_mark(); |
784 OrderAccess::storestore(); | |
784 _gc_time_stamp = curr_gc_time_stamp; | 785 _gc_time_stamp = curr_gc_time_stamp; |
785 OrderAccess::fence(); | 786 // The following fence is to force a flush of the writes above, but |
787 // is strictly not needed because when an allocating worker thread | |
788 // calls set_saved_mark() it does so under the ParGCRareEvent_lock; | |
789 // when the lock is released, the write will be flushed. | |
790 // OrderAccess::fence(); | |
786 } | 791 } |
787 } | 792 } |
788 | 793 |
789 G1OffsetTableContigSpace:: | 794 G1OffsetTableContigSpace:: |
790 G1OffsetTableContigSpace(G1BlockOffsetSharedArray* sharedOffsetArray, | 795 G1OffsetTableContigSpace(G1BlockOffsetSharedArray* sharedOffsetArray, |