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 // The Rewriter adds caches to the constant pool and rewrites bytecode indices 26 // pointing into the constant pool for better interpreter performance. 27 28 class Rewriter: public StackObj { 29 private: 30 instanceKlassHandle _klass; 31 constantPoolHandle _pool; 32 objArrayHandle _methods; 33 intArray _cp_map; 34 intStack _cp_cache_map; 35 bool _have_invoke_dynamic; 36 37 void init_cp_map(int length) { 38 _cp_map.initialize(length, -1); 39 // Choose an initial value large enough that we don't get frequent 40 // calls to grow(). 41 _cp_cache_map.initialize(length / 2); 42 } 43 int cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map[i]; } 44 bool has_cp_cache(int i) { return (uint)i < (uint)_cp_map.length() && _cp_map[i] >= 0; } 77 Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, objArrayHandle methods, TRAPS); 78 79 void compute_index_maps(); 80 void make_constant_pool_cache(TRAPS); 81 void scan_method(methodOop m); 82 methodHandle rewrite_jsrs(methodHandle m, TRAPS); 83 void rewrite_Object_init(methodHandle m, TRAPS); 84 void rewrite_member_reference(address bcp, int offset); 85 void rewrite_invokedynamic(address bcp, int offset); 86 void maybe_rewrite_ldc(address bcp, int offset, bool is_wide); 87 88 public: 89 // Driver routine: 90 static void rewrite(instanceKlassHandle klass, TRAPS); 91 static void rewrite(instanceKlassHandle klass, constantPoolHandle cpool, objArrayHandle methods, TRAPS); 92 93 enum { 94 _secondary_entry_tag = nth_bit(30) 95 }; 96 }; | 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_INTERPRETER_REWRITER_HPP 26 #define SHARE_VM_INTERPRETER_REWRITER_HPP 27 28 #include "memory/allocation.hpp" 29 #include "runtime/handles.inline.hpp" 30 #include "utilities/growableArray.hpp" 31 32 // The Rewriter adds caches to the constant pool and rewrites bytecode indices 33 // pointing into the constant pool for better interpreter performance. 34 35 class Rewriter: public StackObj { 36 private: 37 instanceKlassHandle _klass; 38 constantPoolHandle _pool; 39 objArrayHandle _methods; 40 intArray _cp_map; 41 intStack _cp_cache_map; 42 bool _have_invoke_dynamic; 43 44 void init_cp_map(int length) { 45 _cp_map.initialize(length, -1); 46 // Choose an initial value large enough that we don't get frequent 47 // calls to grow(). 48 _cp_cache_map.initialize(length / 2); 49 } 50 int cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map[i]; } 51 bool has_cp_cache(int i) { return (uint)i < (uint)_cp_map.length() && _cp_map[i] >= 0; } 84 Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, objArrayHandle methods, TRAPS); 85 86 void compute_index_maps(); 87 void make_constant_pool_cache(TRAPS); 88 void scan_method(methodOop m); 89 methodHandle rewrite_jsrs(methodHandle m, TRAPS); 90 void rewrite_Object_init(methodHandle m, TRAPS); 91 void rewrite_member_reference(address bcp, int offset); 92 void rewrite_invokedynamic(address bcp, int offset); 93 void maybe_rewrite_ldc(address bcp, int offset, bool is_wide); 94 95 public: 96 // Driver routine: 97 static void rewrite(instanceKlassHandle klass, TRAPS); 98 static void rewrite(instanceKlassHandle klass, constantPoolHandle cpool, objArrayHandle methods, TRAPS); 99 100 enum { 101 _secondary_entry_tag = nth_bit(30) 102 }; 103 }; 104 105 #endif // SHARE_VM_INTERPRETER_REWRITER_HPP |