src/share/vm/memory/threadLocalAllocBuffer.cpp

changeset 10015
eb7ce841ccec
parent 9448
73d689add964
parent 9965
c39172598323
equal deleted inserted replaced
9934:2251ba078bec 10015:eb7ce841ccec
1 /* 1 /*
2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2020, 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.
86 // _gc_waste is not subtracted because it's included in 86 // _gc_waste is not subtracted because it's included in
87 // "used". 87 // "used".
88 // The result can be larger than 1.0 due to direct to old allocations. 88 // The result can be larger than 1.0 due to direct to old allocations.
89 // These allocations should ideally not be counted but since it is not possible 89 // These allocations should ideally not be counted but since it is not possible
90 // to filter them out here we just cap the fraction to be at most 1.0. 90 // to filter them out here we just cap the fraction to be at most 1.0.
91 double alloc_frac = MIN2(1.0, (double) allocated_since_last_gc / used); 91 // Keep alloc_frac as float and not double to avoid the double to float conversion
92 float alloc_frac = MIN2(1.0f, allocated_since_last_gc / (float) used);
92 _allocation_fraction.sample(alloc_frac); 93 _allocation_fraction.sample(alloc_frac);
93 } 94 }
94 global_stats()->update_allocating_threads(); 95 global_stats()->update_allocating_threads();
95 global_stats()->update_number_of_refills(_number_of_refills); 96 global_stats()->update_number_of_refills(_number_of_refills);
96 global_stats()->update_allocation(_number_of_refills * desired_size()); 97 global_stats()->update_allocation(_number_of_refills * desired_size());
203 // Following check is needed because at startup the main 204 // Following check is needed because at startup the main
204 // thread is initialized before the heap is. The initialization for 205 // thread is initialized before the heap is. The initialization for
205 // this thread is redone in startup_initialization below. 206 // this thread is redone in startup_initialization below.
206 if (Universe::heap() != NULL) { 207 if (Universe::heap() != NULL) {
207 size_t capacity = Universe::heap()->tlab_capacity(myThread()) / HeapWordSize; 208 size_t capacity = Universe::heap()->tlab_capacity(myThread()) / HeapWordSize;
208 double alloc_frac = desired_size() * target_refills() / (double) capacity; 209 // Keep alloc_frac as float and not double to avoid the double to float conversion
210 float alloc_frac = desired_size() * target_refills() / (float) capacity;
209 _allocation_fraction.sample(alloc_frac); 211 _allocation_fraction.sample(alloc_frac);
210 } 212 }
211 213
212 set_refill_waste_limit(initial_refill_waste_limit()); 214 set_refill_waste_limit(initial_refill_waste_limit());
213 215

mercurial