/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_ADLC_ARENA_HPP
#define SHARE_VM_ADLC_ARENA_HPP
// All classes in the virtual machine must be subclassed
// by one of the following allocation classes:
//
//
// For objects allocated in the C-heap (managed by: free & malloc).
// - CHeapObj
//
//
// For embedded objects.
// - ValueObj
//
// For classes used as name spaces.
// - AllStatic
//
class CHeapObj {
public:
void operator delete(void* p);
};
// Base class for objects used as value objects.
// Calling new or delete will result in fatal error.
class ValueObj {
public:
void operator delete(void* p);
};
// Base class for classes that constitute name spaces.
class AllStatic {
public:
void operator delete(void* p);
};
//------------------------------Chunk------------------------------------------
// Linked list of raw memory chunks
public:
enum {
};
void chop(); // Chop this chunk
void next_chop(); // Chop next chunk
// Boundaries of data area (possibly unused)
};
//------------------------------Arena------------------------------------------
// Fast allocation of memory
protected:
friend class ResourceMark;
friend class HandleMark;
friend class NoHandleMark;
public:
Arena();
// Fast allocate in the arena. Common case is: pointer test + increment.
#ifdef _LP64
x = (x + (8-1)) & ((unsigned)(-8));
#else
x = (x + (4-1)) & ((unsigned)(-4));
#endif
return grow(x);
} else {
_hwm += x;
return old;
}
}
// Further assume size is padded out to words
// Warning: in LP64, Amalloc_4 is really Amalloc_8
return grow(x);
} else {
_hwm += x;
return old;
}
}
// Fast delete in area. Common case is: NOP (except for storage reclaimed)
}
// Reset this Arena to empty, and return this Arenas guts in a new Arena.
// Determine if pointer belongs to this Arena or not.
// Total of all chunks in use (not thread-safe)
// Total # of bytes used
};
#endif // SHARE_VM_ADLC_ARENA_HPP