hotspot/src/share/vm/memory/heap.cpp

Print this page
rev 611 : Merge
   1 #ifdef USE_PRAGMA_IDENT_SRC
   2 #pragma ident "@(#)heap.cpp     1.55 07/10/04 10:49:31 JVM"
   3 #endif
   4 /*
   5  * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  


  88 
  89 
  90 void CodeHeap::on_code_mapping(char* base, size_t size) {
  91 #ifdef LINUX  
  92   extern void linux_wrap_code(char* base, size_t size);
  93   linux_wrap_code(base, size);
  94 #endif
  95 }
  96 
  97 
  98 bool CodeHeap::reserve(size_t reserved_size, size_t committed_size,
  99                        size_t segment_size) {
 100   assert(reserved_size >= committed_size, "reserved < committed");
 101   assert(segment_size >= sizeof(FreeBlock), "segment size is too small");
 102   assert(is_power_of_2(segment_size), "segment_size must be a power of 2");
 103 
 104   _segment_size      = segment_size;
 105   _log2_segment_size = exact_log2(segment_size);
 106 
 107   // Reserve and initialize space for _memory.
 108   const size_t page_size = os::page_size_for_region(committed_size,
 109                                                     reserved_size, 8);

 110   const size_t granularity = os::vm_allocation_granularity();
 111   const size_t r_align = MAX2(page_size, granularity);
 112   const size_t r_size = align_size_up(reserved_size, r_align);
 113   const size_t c_size = align_size_up(committed_size, page_size);
 114   
 115   const size_t rs_align = page_size == (size_t) os::vm_page_size() ? 0 :
 116     MAX2(page_size, granularity);
 117   ReservedSpace rs(r_size, rs_align, false);
 118   os::trace_page_sizes("code heap", committed_size, reserved_size, page_size,
 119                        rs.base(), rs.size());
 120   if (!_memory.initialize(rs, c_size)) {
 121     return false;
 122   }
 123 
 124   on_code_mapping(_memory.low(), _memory.committed_size());
 125   _number_of_committed_segments = number_of_segments(_memory.committed_size());
 126   _number_of_reserved_segments  = number_of_segments(_memory.reserved_size());
 127   assert(_number_of_reserved_segments >= _number_of_committed_segments, "just checking");
 128 
 129   // reserve space for _segmap
 130   if (!_segmap.initialize(align_to_page_size(_number_of_reserved_segments), align_to_page_size(_number_of_committed_segments))) {
 131     return false;  
 132   }
 133   assert(_segmap.committed_size() >= (size_t) _number_of_committed_segments, "could not commit  enough space for segment map");
 134   assert(_segmap.reserved_size()  >= (size_t) _number_of_reserved_segments , "could not reserve enough space for segment map");
 135   assert(_segmap.reserved_size()  >= _segmap.committed_size()     , "just checking");
 136 
 137   // initialize remaining instance variables


   1 #ifdef USE_PRAGMA_IDENT_SRC
   2 #pragma ident "@(#)heap.cpp     1.55 07/10/04 10:49:31 JVM"
   3 #endif
   4 /*
   5  * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  


  88 
  89 
  90 void CodeHeap::on_code_mapping(char* base, size_t size) {
  91 #ifdef LINUX  
  92   extern void linux_wrap_code(char* base, size_t size);
  93   linux_wrap_code(base, size);
  94 #endif
  95 }
  96 
  97 
  98 bool CodeHeap::reserve(size_t reserved_size, size_t committed_size,
  99                        size_t segment_size) {
 100   assert(reserved_size >= committed_size, "reserved < committed");
 101   assert(segment_size >= sizeof(FreeBlock), "segment size is too small");
 102   assert(is_power_of_2(segment_size), "segment_size must be a power of 2");
 103 
 104   _segment_size      = segment_size;
 105   _log2_segment_size = exact_log2(segment_size);
 106 
 107   // Reserve and initialize space for _memory.
 108   const size_t page_size = os::can_execute_large_page_memory() ?
 109           os::page_size_for_region(committed_size, reserved_size, 8) :
 110           os::vm_page_size();
 111   const size_t granularity = os::vm_allocation_granularity();
 112   const size_t r_align = MAX2(page_size, granularity);
 113   const size_t r_size = align_size_up(reserved_size, r_align);
 114   const size_t c_size = align_size_up(committed_size, page_size);
 115   
 116   const size_t rs_align = page_size == (size_t) os::vm_page_size() ? 0 :
 117     MAX2(page_size, granularity);
 118   ReservedSpace rs(r_size, rs_align, rs_align > 0);
 119   os::trace_page_sizes("code heap", committed_size, reserved_size, page_size,
 120                        rs.base(), rs.size());
 121   if (!_memory.initialize(rs, c_size)) {
 122     return false;
 123   }
 124 
 125   on_code_mapping(_memory.low(), _memory.committed_size());
 126   _number_of_committed_segments = number_of_segments(_memory.committed_size());
 127   _number_of_reserved_segments  = number_of_segments(_memory.reserved_size());
 128   assert(_number_of_reserved_segments >= _number_of_committed_segments, "just checking");
 129 
 130   // reserve space for _segmap
 131   if (!_segmap.initialize(align_to_page_size(_number_of_reserved_segments), align_to_page_size(_number_of_committed_segments))) {
 132     return false;  
 133   }
 134   assert(_segmap.committed_size() >= (size_t) _number_of_committed_segments, "could not commit  enough space for segment map");
 135   assert(_segmap.reserved_size()  >= (size_t) _number_of_reserved_segments , "could not reserve enough space for segment map");
 136   assert(_segmap.reserved_size()  >= _segmap.committed_size()     , "just checking");
 137 
 138   // initialize remaining instance variables