1 /*
2 * Copyright (c) 1998, 2014, 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 *
272 }
273
274 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) {
275 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
276
277 AdapterBlob* blob = NULL;
278 unsigned int size = allocation_size(cb, sizeof(AdapterBlob));
279 {
280 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
281 // The parameter 'true' indicates a critical memory allocation.
282 // This means that CodeCacheMinimumFreeSpace is used, if necessary
283 const bool is_critical = true;
284 blob = new (size, is_critical) AdapterBlob(size, cb);
285 }
286 // Track memory usage statistic after releasing CodeCache_lock
287 MemoryService::track_code_cache_memory_usage();
288
289 return blob;
290 }
291
292
293 //----------------------------------------------------------------------------------------------------
294 // Implementation of MethodHandlesAdapterBlob
295
296 MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) {
297 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
298
299 MethodHandlesAdapterBlob* blob = NULL;
300 unsigned int size = sizeof(MethodHandlesAdapterBlob);
301 // align the size to CodeEntryAlignment
302 size = align_code_offset(size);
303 size += round_to(buffer_size, oopSize);
304 {
305 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
306 // The parameter 'true' indicates a critical memory allocation.
307 // This means that CodeCacheMinimumFreeSpace is used, if necessary
308 const bool is_critical = true;
309 blob = new (size, is_critical) MethodHandlesAdapterBlob(size);
310 }
311 // Track memory usage statistic after releasing CodeCache_lock
312 MemoryService::track_code_cache_memory_usage();
|
1 /*
2 * Copyright (c) 1998, 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 *
272 }
273
274 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) {
275 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
276
277 AdapterBlob* blob = NULL;
278 unsigned int size = allocation_size(cb, sizeof(AdapterBlob));
279 {
280 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
281 // The parameter 'true' indicates a critical memory allocation.
282 // This means that CodeCacheMinimumFreeSpace is used, if necessary
283 const bool is_critical = true;
284 blob = new (size, is_critical) AdapterBlob(size, cb);
285 }
286 // Track memory usage statistic after releasing CodeCache_lock
287 MemoryService::track_code_cache_memory_usage();
288
289 return blob;
290 }
291
292 VtableBlob::VtableBlob(const char* name, int size) :
293 BufferBlob(name, size) {
294 }
295
296 VtableBlob* VtableBlob::create(const char* name, int buffer_size) {
297 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
298
299 VtableBlob* blob = NULL;
300 unsigned int size = sizeof(VtableBlob);
301 // align the size to CodeEntryAlignment
302 size = align_code_offset(size);
303 size += round_to(buffer_size, oopSize);
304 assert(name != NULL, "must provide a name");
305 {
306 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
307 blob = new (size) VtableBlob(name, size);
308 }
309 // Track memory usage statistic after releasing CodeCache_lock
310 MemoryService::track_code_cache_memory_usage();
311
312 return blob;
313 }
314
315 //----------------------------------------------------------------------------------------------------
316 // Implementation of MethodHandlesAdapterBlob
317
318 MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) {
319 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
320
321 MethodHandlesAdapterBlob* blob = NULL;
322 unsigned int size = sizeof(MethodHandlesAdapterBlob);
323 // align the size to CodeEntryAlignment
324 size = align_code_offset(size);
325 size += round_to(buffer_size, oopSize);
326 {
327 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
328 // The parameter 'true' indicates a critical memory allocation.
329 // This means that CodeCacheMinimumFreeSpace is used, if necessary
330 const bool is_critical = true;
331 blob = new (size, is_critical) MethodHandlesAdapterBlob(size);
332 }
333 // Track memory usage statistic after releasing CodeCache_lock
334 MemoryService::track_code_cache_memory_usage();
|