845 i = os::random() % lgrp_spaces()->length();
846 }
847 LGRPSpace *ls = lgrp_spaces()->at(i);
848 MutableSpace *s = ls->space();
849 HeapWord *p = s->cas_allocate(size);
850 if (p != NULL) {
851 size_t remainder = pointer_delta(s->end(), p + size);
852 if (remainder < CollectedHeap::min_fill_size() && remainder > 0) {
853 if (s->cas_deallocate(p, size)) {
854 // We were the last to allocate and created a fragment less than
855 // a minimal object.
856 p = NULL;
857 } else {
858 guarantee(false, "Deallocation should always succeed");
859 }
860 }
861 }
862 if (p != NULL) {
863 HeapWord* cur_top, *cur_chunk_top = p + size;
864 while ((cur_top = top()) < cur_chunk_top) { // Keep _top updated.
865 if (Atomic::cmpxchg_ptr(cur_chunk_top, top_addr(), cur_top) == cur_top) {
866 break;
867 }
868 }
869 }
870
871 // Make the page allocation happen here if there is no static binding.
872 if (p != NULL && !os::numa_has_static_binding() ) {
873 for (HeapWord *i = p; i < p + size; i += os::vm_page_size() >> LogHeapWordSize) {
874 *(int*)i = 0;
875 }
876 }
877 if (p == NULL) {
878 ls->set_allocation_failed();
879 }
880 return p;
881 }
882
883 void MutableNUMASpace::print_short_on(outputStream* st) const {
884 MutableSpace::print_short_on(st);
885 st->print(" (");
|
845 i = os::random() % lgrp_spaces()->length();
846 }
847 LGRPSpace *ls = lgrp_spaces()->at(i);
848 MutableSpace *s = ls->space();
849 HeapWord *p = s->cas_allocate(size);
850 if (p != NULL) {
851 size_t remainder = pointer_delta(s->end(), p + size);
852 if (remainder < CollectedHeap::min_fill_size() && remainder > 0) {
853 if (s->cas_deallocate(p, size)) {
854 // We were the last to allocate and created a fragment less than
855 // a minimal object.
856 p = NULL;
857 } else {
858 guarantee(false, "Deallocation should always succeed");
859 }
860 }
861 }
862 if (p != NULL) {
863 HeapWord* cur_top, *cur_chunk_top = p + size;
864 while ((cur_top = top()) < cur_chunk_top) { // Keep _top updated.
865 if (Atomic::cmpxchg(cur_chunk_top, top_addr(), cur_top) == cur_top) {
866 break;
867 }
868 }
869 }
870
871 // Make the page allocation happen here if there is no static binding.
872 if (p != NULL && !os::numa_has_static_binding() ) {
873 for (HeapWord *i = p; i < p + size; i += os::vm_page_size() >> LogHeapWordSize) {
874 *(int*)i = 0;
875 }
876 }
877 if (p == NULL) {
878 ls->set_allocation_failed();
879 }
880 return p;
881 }
882
883 void MutableNUMASpace::print_short_on(outputStream* st) const {
884 MutableSpace::print_short_on(st);
885 st->print(" (");
|