< prev index next >

src/hotspot/share/gc/g1/g1PageBasedVirtualSpace.cpp

Print this page


   1 /*
   2  * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 218   size_t end_page = start_page + size_in_pages;
 219   if (_special) {
 220     // Mark that memory is dirty. If committed again the memory might
 221     // need to be cleared explicitly.
 222     _dirty.set_range(start_page, end_page);
 223   } else {
 224     uncommit_internal(start_page, end_page);
 225   }
 226 
 227   _committed.clear_range(start_page, end_page);
 228 }
 229 
 230 class G1PretouchTask : public AbstractGangTask {
 231 private:
 232   char* volatile _cur_addr;
 233   char* const _start_addr;
 234   char* const _end_addr;
 235   size_t const _page_size;
 236 public:
 237   G1PretouchTask(char* start_address, char* end_address, size_t page_size) :
 238     AbstractGangTask("G1 PreTouch",
 239                      Universe::is_fully_initialized() &&
 240                      Thread::current()->is_Named_thread() ? GCId::current_raw() :
 241                                                             // During VM initialization there is
 242                                                             // no GC cycle that this task can be
 243                                                             // associated with.
 244                                                             GCId::undefined()),
 245     _cur_addr(start_address),
 246     _start_addr(start_address),
 247     _end_addr(end_address),
 248     _page_size(page_size) {
 249   }
 250 
 251   virtual void work(uint worker_id) {
 252     size_t const actual_chunk_size = MAX2(chunk_size(), _page_size);
 253     while (true) {
 254       char* touch_addr = Atomic::add(actual_chunk_size, &_cur_addr) - actual_chunk_size;
 255       if (touch_addr < _start_addr || touch_addr >= _end_addr) {
 256         break;
 257       }
 258       char* end_addr = touch_addr + MIN2(actual_chunk_size, pointer_delta(_end_addr, touch_addr, sizeof(char)));
 259       os::pretouch_memory(touch_addr, end_addr, _page_size);
 260     }
 261   }
 262 
 263   static size_t chunk_size() { return PreTouchParallelChunkSize; }
 264 };


   1 /*
   2  * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 218   size_t end_page = start_page + size_in_pages;
 219   if (_special) {
 220     // Mark that memory is dirty. If committed again the memory might
 221     // need to be cleared explicitly.
 222     _dirty.set_range(start_page, end_page);
 223   } else {
 224     uncommit_internal(start_page, end_page);
 225   }
 226 
 227   _committed.clear_range(start_page, end_page);
 228 }
 229 
 230 class G1PretouchTask : public AbstractGangTask {
 231 private:
 232   char* volatile _cur_addr;
 233   char* const _start_addr;
 234   char* const _end_addr;
 235   size_t const _page_size;
 236 public:
 237   G1PretouchTask(char* start_address, char* end_address, size_t page_size) :
 238     AbstractGangTask("G1 PreTouch"),






 239     _cur_addr(start_address),
 240     _start_addr(start_address),
 241     _end_addr(end_address),
 242     _page_size(page_size) {
 243   }
 244 
 245   virtual void work(uint worker_id) {
 246     size_t const actual_chunk_size = MAX2(chunk_size(), _page_size);
 247     while (true) {
 248       char* touch_addr = Atomic::add(actual_chunk_size, &_cur_addr) - actual_chunk_size;
 249       if (touch_addr < _start_addr || touch_addr >= _end_addr) {
 250         break;
 251       }
 252       char* end_addr = touch_addr + MIN2(actual_chunk_size, pointer_delta(_end_addr, touch_addr, sizeof(char)));
 253       os::pretouch_memory(touch_addr, end_addr, _page_size);
 254     }
 255   }
 256 
 257   static size_t chunk_size() { return PreTouchParallelChunkSize; }
 258 };


< prev index next >