src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp
changeset 54659 62d6baca22fc
parent 53414 fe8991950105
child 59221 cc3a82fc7bcb
equal deleted inserted replaced
54658:a86c5059749b 54659:62d6baca22fc
     1 /*
     1 /*
     2  * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   279             _gc_waste * HeapWordSize,
   279             _gc_waste * HeapWordSize,
   280             _slow_refill_waste * HeapWordSize,
   280             _slow_refill_waste * HeapWordSize,
   281             _fast_refill_waste * HeapWordSize);
   281             _fast_refill_waste * HeapWordSize);
   282 }
   282 }
   283 
   283 
   284 void ThreadLocalAllocBuffer::set_sample_end() {
   284 void ThreadLocalAllocBuffer::set_sample_end(bool reset_byte_accumulation) {
   285   size_t heap_words_remaining = pointer_delta(_end, _top);
   285   size_t heap_words_remaining = pointer_delta(_end, _top);
   286   size_t bytes_until_sample = thread()->heap_sampler().bytes_until_sample();
   286   size_t bytes_until_sample = thread()->heap_sampler().bytes_until_sample();
   287   size_t words_until_sample = bytes_until_sample / HeapWordSize;
   287   size_t words_until_sample = bytes_until_sample / HeapWordSize;
   288 
   288 
       
   289   if (reset_byte_accumulation) {
       
   290     _bytes_since_last_sample_point = 0;
       
   291   }
       
   292 
   289   if (heap_words_remaining > words_until_sample) {
   293   if (heap_words_remaining > words_until_sample) {
   290     HeapWord* new_end = _top + words_until_sample;
   294     HeapWord* new_end = _top + words_until_sample;
   291     set_end(new_end);
   295     set_end(new_end);
   292     _bytes_since_last_sample_point = bytes_until_sample;
   296     _bytes_since_last_sample_point += bytes_until_sample;
   293   } else {
   297   } else {
   294     _bytes_since_last_sample_point = heap_words_remaining * HeapWordSize;
   298     _bytes_since_last_sample_point += heap_words_remaining * HeapWordSize;
   295   }
   299   }
   296 }
   300 }
   297 
   301 
   298 Thread* ThreadLocalAllocBuffer::thread() {
   302 Thread* ThreadLocalAllocBuffer::thread() {
   299   return (Thread*)(((char*)this) + in_bytes(start_offset()) - in_bytes(Thread::tlab_start_offset()));
   303   return (Thread*)(((char*)this) + in_bytes(start_offset()) - in_bytes(Thread::tlab_start_offset()));