1 /*
2 * Copyright (c) 1998, 2002, 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 *
23 */
24
25 // All classes in the virtual machine must be subclassed
26 // by one of the following allocation classes:
27 //
28 //
29 // For objects allocated in the C-heap (managed by: free & malloc).
30 // - CHeapObj
31 //
32 //
33 // For embedded objects.
34 // - ValueObj
35 //
36 // For classes used as name spaces.
37 // - AllStatic
38 //
39
40 class CHeapObj {
41 public:
42 void* operator new(size_t size);
43 void operator delete(void* p);
44 void* new_array(size_t size);
138 void Afree(void *ptr, size_t size) {
139 if (((char*)ptr) + size == _hwm) _hwm = (char*)ptr;
140 }
141
142 void *Acalloc( size_t items, size_t x );
143 void *Arealloc( void *old_ptr, size_t old_size, size_t new_size );
144
145 // Reset this Arena to empty, and return this Arenas guts in a new Arena.
146 Arena *reset(void);
147
148 // Determine if pointer belongs to this Arena or not.
149 bool contains( const void *ptr ) const;
150
151 // Total of all chunks in use (not thread-safe)
152 size_t used() const;
153
154 // Total # of bytes used
155 size_t size_in_bytes() const { return _size_in_bytes; }
156 void set_size_in_bytes(size_t size) { _size_in_bytes = size; }
157 };
|
1 /*
2 * Copyright (c) 1998, 2010, 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 *
23 */
24
25 #ifndef SHARE_VM_ADLC_ARENA_HPP
26 #define SHARE_VM_ADLC_ARENA_HPP
27
28 // All classes in the virtual machine must be subclassed
29 // by one of the following allocation classes:
30 //
31 //
32 // For objects allocated in the C-heap (managed by: free & malloc).
33 // - CHeapObj
34 //
35 //
36 // For embedded objects.
37 // - ValueObj
38 //
39 // For classes used as name spaces.
40 // - AllStatic
41 //
42
43 class CHeapObj {
44 public:
45 void* operator new(size_t size);
46 void operator delete(void* p);
47 void* new_array(size_t size);
141 void Afree(void *ptr, size_t size) {
142 if (((char*)ptr) + size == _hwm) _hwm = (char*)ptr;
143 }
144
145 void *Acalloc( size_t items, size_t x );
146 void *Arealloc( void *old_ptr, size_t old_size, size_t new_size );
147
148 // Reset this Arena to empty, and return this Arenas guts in a new Arena.
149 Arena *reset(void);
150
151 // Determine if pointer belongs to this Arena or not.
152 bool contains( const void *ptr ) const;
153
154 // Total of all chunks in use (not thread-safe)
155 size_t used() const;
156
157 // Total # of bytes used
158 size_t size_in_bytes() const { return _size_in_bytes; }
159 void set_size_in_bytes(size_t size) { _size_in_bytes = size; }
160 };
161
162 #endif // SHARE_VM_ADLC_ARENA_HPP
|