mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
7158805: Better rewriting of nested subroutine calls
Reviewed-by: mschoene, coleenp
This commit is contained in:
parent
1b5f599819
commit
455fd39d49
3 changed files with 46 additions and 27 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -274,7 +274,7 @@ class Chunk: CHeapObj<mtChunk> {
|
|||
Chunk* _next; // Next Chunk in list
|
||||
const size_t _len; // Size of this Chunk
|
||||
public:
|
||||
void* operator new(size_t size, size_t length);
|
||||
void* operator new(size_t size, AllocFailType alloc_failmode, size_t length);
|
||||
void operator delete(void* p);
|
||||
Chunk(size_t length);
|
||||
|
||||
|
@ -337,10 +337,15 @@ protected:
|
|||
|
||||
void signal_out_of_memory(size_t request, const char* whence) const;
|
||||
|
||||
void check_for_overflow(size_t request, const char* whence) const {
|
||||
bool check_for_overflow(size_t request, const char* whence,
|
||||
AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) const {
|
||||
if (UINTPTR_MAX - request < (uintptr_t)_hwm) {
|
||||
if (alloc_failmode == AllocFailStrategy::RETURN_NULL) {
|
||||
return false;
|
||||
}
|
||||
signal_out_of_memory(request, whence);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -364,7 +369,8 @@ protected:
|
|||
assert(is_power_of_2(ARENA_AMALLOC_ALIGNMENT) , "should be a power of 2");
|
||||
x = ARENA_ALIGN(x);
|
||||
debug_only(if (UseMallocOnly) return malloc(x);)
|
||||
check_for_overflow(x, "Arena::Amalloc");
|
||||
if (!check_for_overflow(x, "Arena::Amalloc", alloc_failmode))
|
||||
return NULL;
|
||||
NOT_PRODUCT(inc_bytes_allocated(x);)
|
||||
if (_hwm + x > _max) {
|
||||
return grow(x, alloc_failmode);
|
||||
|
@ -378,7 +384,8 @@ protected:
|
|||
void *Amalloc_4(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
|
||||
assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" );
|
||||
debug_only(if (UseMallocOnly) return malloc(x);)
|
||||
check_for_overflow(x, "Arena::Amalloc_4");
|
||||
if (!check_for_overflow(x, "Arena::Amalloc_4", alloc_failmode))
|
||||
return NULL;
|
||||
NOT_PRODUCT(inc_bytes_allocated(x);)
|
||||
if (_hwm + x > _max) {
|
||||
return grow(x, alloc_failmode);
|
||||
|
@ -399,7 +406,8 @@ protected:
|
|||
size_t delta = (((size_t)_hwm + DALIGN_M1) & ~DALIGN_M1) - (size_t)_hwm;
|
||||
x += delta;
|
||||
#endif
|
||||
check_for_overflow(x, "Arena::Amalloc_D");
|
||||
if (!check_for_overflow(x, "Arena::Amalloc_D", alloc_failmode))
|
||||
return NULL;
|
||||
NOT_PRODUCT(inc_bytes_allocated(x);)
|
||||
if (_hwm + x > _max) {
|
||||
return grow(x, alloc_failmode); // grow() returns a result aligned >= 8 bytes.
|
||||
|
@ -539,6 +547,9 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC {
|
|||
#define NEW_RESOURCE_ARRAY(type, size)\
|
||||
(type*) resource_allocate_bytes((size) * sizeof(type))
|
||||
|
||||
#define NEW_RESOURCE_ARRAY_RETURN_NULL(type, size)\
|
||||
(type*) resource_allocate_bytes((size) * sizeof(type), AllocFailStrategy::RETURN_NULL)
|
||||
|
||||
#define NEW_RESOURCE_ARRAY_IN_THREAD(thread, type, size)\
|
||||
(type*) resource_allocate_bytes(thread, (size) * sizeof(type))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue