Mercurial > hg > truffle
comparison src/share/vm/runtime/jniHandles.cpp @ 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 | f08d439fab8c |
children | f34d701e952e |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1998, 2011, 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. |
109 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); | 109 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); |
110 } | 110 } |
111 return res; | 111 return res; |
112 } | 112 } |
113 | 113 |
114 jmethodID JNIHandles::make_jmethod_id(methodHandle mh) { | |
115 return (jmethodID) make_weak_global(mh); | |
116 } | |
117 | |
118 | |
119 | |
120 void JNIHandles::change_method_associated_with_jmethod_id(jmethodID jmid, methodHandle mh) { | |
121 MutexLocker ml(JNIGlobalHandle_lock); // Is this necessary? | |
122 Handle obj = (Handle)mh; | |
123 oop* jobj = (oop*)jmid; | |
124 *jobj = obj(); | |
125 } | |
126 | |
127 | 114 |
128 void JNIHandles::destroy_global(jobject handle) { | 115 void JNIHandles::destroy_global(jobject handle) { |
129 if (handle != NULL) { | 116 if (handle != NULL) { |
130 assert(is_global_handle(handle), "Invalid delete of global JNI handle"); | 117 assert(is_global_handle(handle), "Invalid delete of global JNI handle"); |
131 *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it | 118 *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it |
136 void JNIHandles::destroy_weak_global(jobject handle) { | 123 void JNIHandles::destroy_weak_global(jobject handle) { |
137 if (handle != NULL) { | 124 if (handle != NULL) { |
138 assert(!CheckJNICalls || is_weak_global_handle(handle), "Invalid delete of weak global JNI handle"); | 125 assert(!CheckJNICalls || is_weak_global_handle(handle), "Invalid delete of weak global JNI handle"); |
139 *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it | 126 *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it |
140 } | 127 } |
141 } | |
142 | |
143 void JNIHandles::destroy_jmethod_id(jmethodID mid) { | |
144 destroy_weak_global((jobject)mid); | |
145 } | 128 } |
146 | 129 |
147 | 130 |
148 void JNIHandles::oops_do(OopClosure* f) { | 131 void JNIHandles::oops_do(OopClosure* f) { |
149 f->do_oop(&_deleted_handle); | 132 f->do_oop(&_deleted_handle); |
160 _global_handles = JNIHandleBlock::allocate_block(); | 143 _global_handles = JNIHandleBlock::allocate_block(); |
161 _weak_global_handles = JNIHandleBlock::allocate_block(); | 144 _weak_global_handles = JNIHandleBlock::allocate_block(); |
162 EXCEPTION_MARK; | 145 EXCEPTION_MARK; |
163 // We will never reach the CATCH below since Exceptions::_throw will cause | 146 // We will never reach the CATCH below since Exceptions::_throw will cause |
164 // the VM to exit if an exception is thrown during initialization | 147 // the VM to exit if an exception is thrown during initialization |
165 klassOop k = SystemDictionary::Object_klass(); | 148 Klass* k = SystemDictionary::Object_klass(); |
166 _deleted_handle = instanceKlass::cast(k)->allocate_permanent_instance(CATCH); | 149 _deleted_handle = InstanceKlass::cast(k)->allocate_instance(CATCH); |
167 } | 150 } |
168 | 151 |
169 | 152 |
170 bool JNIHandles::is_local_handle(Thread* thread, jobject handle) { | 153 bool JNIHandles::is_local_handle(Thread* thread, jobject handle) { |
171 JNIHandleBlock* block = thread->active_handles(); | 154 JNIHandleBlock* block = thread->active_handles(); |