comparison src/share/vm/runtime/handles.inline.hpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents d2a62e0f25eb
children 716c64bda5ba
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
1 /* 1 /*
2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
60 _handle = thread->handle_area()->allocate_handle(obj); 60 _handle = thread->handle_area()->allocate_handle(obj);
61 } 61 }
62 } 62 }
63 #endif // ASSERT 63 #endif // ASSERT
64 64
65 // Constructors for metadata handles
66 #define DEF_METADATA_HANDLE_FN(name, type) \
67 inline name##Handle::name##Handle(type* obj) : _value(obj), _thread(NULL) { \
68 if (obj != NULL) { \
69 assert(((Metadata*)obj)->is_valid(), "obj is valid"); \
70 _thread = Thread::current(); \
71 assert (_thread->is_in_stack((address)this), "not on stack?"); \
72 _thread->metadata_handles()->push((Metadata*)obj); \
73 } \
74 } \
75 inline name##Handle::name##Handle(Thread* thread, type* obj) : _value(obj), _thread(thread) { \
76 if (obj != NULL) { \
77 assert(((Metadata*)obj)->is_valid(), "obj is valid"); \
78 assert(_thread == Thread::current(), "thread must be current"); \
79 assert (_thread->is_in_stack((address)this), "not on stack?"); \
80 _thread->metadata_handles()->push((Metadata*)obj); \
81 } \
82 } \
83 inline name##Handle::name##Handle(const name##Handle &h) { \
84 _value = h._value; \
85 if (_value != NULL) { \
86 assert(_value->is_valid(), "obj is valid"); \
87 if (h._thread != NULL) { \
88 assert(h._thread == Thread::current(), "thread must be current");\
89 _thread = h._thread; \
90 } else { \
91 _thread = Thread::current(); \
92 } \
93 _thread->metadata_handles()->push((Metadata*)_value); \
94 } \
95 } \
96 inline name##Handle& name##Handle::operator=(const name##Handle &s) { \
97 remove(); \
98 _value = s._value; \
99 if (_value != NULL) { \
100 assert(_value->is_valid(), "obj is valid"); \
101 if (s._thread != NULL) { \
102 assert(s._thread == Thread::current(), "thread must be current");\
103 _thread = s._thread; \
104 } else { \
105 _thread = Thread::current(); \
106 } \
107 _thread->metadata_handles()->push((Metadata*)_value); \
108 } \
109 return *this; \
110 } \
111 inline void name##Handle::remove() { \
112 if (_value != NULL) { \
113 int i = _thread->metadata_handles()->find_from_end((Metadata*)_value); \
114 assert(i!=-1, "not in metadata_handles list"); \
115 _thread->metadata_handles()->remove_at(i); \
116 } \
117 } \
118 inline name##Handle::~name##Handle () { remove(); } \
119
120 DEF_METADATA_HANDLE_FN(method, Method)
121 DEF_METADATA_HANDLE_FN(constantPool, ConstantPool)
65 122
66 inline HandleMark::HandleMark() { 123 inline HandleMark::HandleMark() {
67 initialize(Thread::current()); 124 initialize(Thread::current());
68 } 125 }
69 126