1 /*
2 * Copyright (c) 1997, 2019, 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 *
34 assert(_handle_mark_nesting > 1, "memory leak: allocating handle outside HandleMark");
35 assert(_no_handle_mark_nesting == 0, "allocating handle inside NoHandleMark");
36 assert(oopDesc::is_oop(obj), "not an oop: " INTPTR_FORMAT, p2i(obj));
37 return real_allocate_handle(obj);
38 }
39 #endif
40
41 // Copy constructors and destructors for metadata handles
42 // These do too much to inline.
43 #define DEF_METADATA_HANDLE_FN_NOINLINE(name, type) \
44 name##Handle::name##Handle(const name##Handle &h) { \
45 _value = h._value; \
46 if (_value != NULL) { \
47 assert(_value->is_valid(), "obj is valid"); \
48 if (h._thread != NULL) { \
49 assert(h._thread == Thread::current(), "thread must be current");\
50 _thread = h._thread; \
51 } else { \
52 _thread = Thread::current(); \
53 } \
54 assert (_thread->is_in_stack((address)this), "not on stack?"); \
55 _thread->metadata_handles()->push((Metadata*)_value); \
56 } else { \
57 _thread = NULL; \
58 } \
59 } \
60 name##Handle& name##Handle::operator=(const name##Handle &s) { \
61 remove(); \
62 _value = s._value; \
63 if (_value != NULL) { \
64 assert(_value->is_valid(), "obj is valid"); \
65 if (s._thread != NULL) { \
66 assert(s._thread == Thread::current(), "thread must be current");\
67 _thread = s._thread; \
68 } else { \
69 _thread = Thread::current(); \
70 } \
71 assert (_thread->is_in_stack((address)this), "not on stack?"); \
72 _thread->metadata_handles()->push((Metadata*)_value); \
73 } else { \
74 _thread = NULL; \
75 } \
76 return *this; \
77 } \
78 inline void name##Handle::remove() { \
79 if (_value != NULL) { \
80 int i = _thread->metadata_handles()->find_from_end((Metadata*)_value); \
81 assert(i!=-1, "not in metadata_handles list"); \
82 _thread->metadata_handles()->remove_at(i); \
83 } \
84 } \
85 name##Handle::~name##Handle () { remove(); } \
86
87 DEF_METADATA_HANDLE_FN_NOINLINE(method, Method)
88 DEF_METADATA_HANDLE_FN_NOINLINE(constantPool, ConstantPool)
89
90
91 static uintx chunk_oops_do(OopClosure* f, Chunk* chunk, char* chunk_top) {
|
1 /*
2 * Copyright (c) 1997, 2020, 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 *
34 assert(_handle_mark_nesting > 1, "memory leak: allocating handle outside HandleMark");
35 assert(_no_handle_mark_nesting == 0, "allocating handle inside NoHandleMark");
36 assert(oopDesc::is_oop(obj), "not an oop: " INTPTR_FORMAT, p2i(obj));
37 return real_allocate_handle(obj);
38 }
39 #endif
40
41 // Copy constructors and destructors for metadata handles
42 // These do too much to inline.
43 #define DEF_METADATA_HANDLE_FN_NOINLINE(name, type) \
44 name##Handle::name##Handle(const name##Handle &h) { \
45 _value = h._value; \
46 if (_value != NULL) { \
47 assert(_value->is_valid(), "obj is valid"); \
48 if (h._thread != NULL) { \
49 assert(h._thread == Thread::current(), "thread must be current");\
50 _thread = h._thread; \
51 } else { \
52 _thread = Thread::current(); \
53 } \
54 assert (_thread->is_in_live_stack((address)this), "not on stack?");\
55 _thread->metadata_handles()->push((Metadata*)_value); \
56 } else { \
57 _thread = NULL; \
58 } \
59 } \
60 name##Handle& name##Handle::operator=(const name##Handle &s) { \
61 remove(); \
62 _value = s._value; \
63 if (_value != NULL) { \
64 assert(_value->is_valid(), "obj is valid"); \
65 if (s._thread != NULL) { \
66 assert(s._thread == Thread::current(), "thread must be current");\
67 _thread = s._thread; \
68 } else { \
69 _thread = Thread::current(); \
70 } \
71 assert (_thread->is_in_live_stack((address)this), "not on stack?");\
72 _thread->metadata_handles()->push((Metadata*)_value); \
73 } else { \
74 _thread = NULL; \
75 } \
76 return *this; \
77 } \
78 inline void name##Handle::remove() { \
79 if (_value != NULL) { \
80 int i = _thread->metadata_handles()->find_from_end((Metadata*)_value); \
81 assert(i!=-1, "not in metadata_handles list"); \
82 _thread->metadata_handles()->remove_at(i); \
83 } \
84 } \
85 name##Handle::~name##Handle () { remove(); } \
86
87 DEF_METADATA_HANDLE_FN_NOINLINE(method, Method)
88 DEF_METADATA_HANDLE_FN_NOINLINE(constantPool, ConstantPool)
89
90
91 static uintx chunk_oops_do(OopClosure* f, Chunk* chunk, char* chunk_top) {
|