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 // Recording and retrieval of oop relocations in compiled code. 26 27 class CodeBlob; 28 29 class OopRecorder : public ResourceObj { 30 public: 31 // A two-way mapping from positive indexes to oop handles. 32 // The zero index is reserved for a constant (sharable) null. 33 // Indexes may not be negative. 34 35 // Use the given arena to manage storage, if not NULL. 36 // By default, uses the current ResourceArea. 37 OopRecorder(Arena* arena = NULL); 38 39 // Generate a new index on which CodeBlob::oop_addr_at will work. 40 // allocate_index and find_index never return the same index, 41 // and allocate_index never returns the same index twice. 42 // In fact, two successive calls to allocate_index return successive ints. 43 int allocate_index(jobject h) { 44 return add_handle(h, false); 117 }; 118 119 // Helper function; returns false for NULL or Universe::non_oop_word(). 120 inline bool is_real_jobject(jobject h); 121 122 void maybe_initialize(); 123 int add_handle(jobject h, bool make_findable); 124 125 enum { null_index = 0, first_index = 1, index_cache_threshold = 20 }; 126 127 GrowableArray<jobject>* _handles; // ordered list (first is always NULL) 128 GrowableArray<int>* _no_finds; // all unfindable indexes; usually empty 129 IndexCache* _indexes; // map: jobject -> its probable index 130 Arena* _arena; 131 bool _complete; 132 133 #ifdef ASSERT 134 static int _find_index_calls, _hit_indexes, _missed_indexes; 135 #endif 136 }; | 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_CODE_OOPRECORDER_HPP 26 #define SHARE_VM_CODE_OOPRECORDER_HPP 27 28 #include "runtime/handles.hpp" 29 #include "utilities/growableArray.hpp" 30 31 // Recording and retrieval of oop relocations in compiled code. 32 33 class CodeBlob; 34 35 class OopRecorder : public ResourceObj { 36 public: 37 // A two-way mapping from positive indexes to oop handles. 38 // The zero index is reserved for a constant (sharable) null. 39 // Indexes may not be negative. 40 41 // Use the given arena to manage storage, if not NULL. 42 // By default, uses the current ResourceArea. 43 OopRecorder(Arena* arena = NULL); 44 45 // Generate a new index on which CodeBlob::oop_addr_at will work. 46 // allocate_index and find_index never return the same index, 47 // and allocate_index never returns the same index twice. 48 // In fact, two successive calls to allocate_index return successive ints. 49 int allocate_index(jobject h) { 50 return add_handle(h, false); 123 }; 124 125 // Helper function; returns false for NULL or Universe::non_oop_word(). 126 inline bool is_real_jobject(jobject h); 127 128 void maybe_initialize(); 129 int add_handle(jobject h, bool make_findable); 130 131 enum { null_index = 0, first_index = 1, index_cache_threshold = 20 }; 132 133 GrowableArray<jobject>* _handles; // ordered list (first is always NULL) 134 GrowableArray<int>* _no_finds; // all unfindable indexes; usually empty 135 IndexCache* _indexes; // map: jobject -> its probable index 136 Arena* _arena; 137 bool _complete; 138 139 #ifdef ASSERT 140 static int _find_index_calls, _hit_indexes, _missed_indexes; 141 #endif 142 }; 143 144 #endif // SHARE_VM_CODE_OOPRECORDER_HPP |