Thu, 24 Mar 2011 02:11:50 -0700
7030207: Zero tweak to remove accidentally incorporated code
Summary: IcedTea contains a now-unmaintained ARM-specific interpreter and part of that interpreter was accidentally incorporated in one of the webrevs when Zero was initially imported.
Reviewed-by: twisti
Contributed-by: Gary Benson <gbenson@redhat.com>
duke@435 | 1 | /* |
jrose@1934 | 2 | * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_INTERPRETER_REWRITER_HPP |
stefank@2314 | 26 | #define SHARE_VM_INTERPRETER_REWRITER_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "memory/allocation.hpp" |
stefank@2314 | 29 | #include "runtime/handles.inline.hpp" |
stefank@2314 | 30 | #include "utilities/growableArray.hpp" |
stefank@2314 | 31 | |
duke@435 | 32 | // The Rewriter adds caches to the constant pool and rewrites bytecode indices |
duke@435 | 33 | // pointing into the constant pool for better interpreter performance. |
duke@435 | 34 | |
jrose@1161 | 35 | class Rewriter: public StackObj { |
duke@435 | 36 | private: |
jrose@1161 | 37 | instanceKlassHandle _klass; |
jrose@1161 | 38 | constantPoolHandle _pool; |
jrose@1161 | 39 | objArrayHandle _methods; |
jrose@1161 | 40 | intArray _cp_map; |
jrose@1161 | 41 | intStack _cp_cache_map; |
jrose@2015 | 42 | bool _have_invoke_dynamic; |
jrose@1161 | 43 | |
jrose@1161 | 44 | void init_cp_map(int length) { |
jrose@1161 | 45 | _cp_map.initialize(length, -1); |
jrose@1161 | 46 | // Choose an initial value large enough that we don't get frequent |
jrose@1161 | 47 | // calls to grow(). |
jrose@1161 | 48 | _cp_cache_map.initialize(length / 2); |
jrose@1161 | 49 | } |
jrose@1161 | 50 | int cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map[i]; } |
jrose@1161 | 51 | bool has_cp_cache(int i) { return (uint)i < (uint)_cp_map.length() && _cp_map[i] >= 0; } |
jrose@1161 | 52 | int maybe_add_cp_cache_entry(int i) { return has_cp_cache(i) ? _cp_map[i] : add_cp_cache_entry(i); } |
jrose@1161 | 53 | int add_cp_cache_entry(int cp_index) { |
jrose@1494 | 54 | assert((cp_index & _secondary_entry_tag) == 0, "bad tag"); |
jrose@1161 | 55 | assert(_cp_map[cp_index] == -1, "not twice on same cp_index"); |
jrose@1161 | 56 | int cache_index = _cp_cache_map.append(cp_index); |
jrose@1161 | 57 | _cp_map.at_put(cp_index, cache_index); |
jrose@1161 | 58 | assert(cp_entry_to_cp_cache(cp_index) == cache_index, ""); |
jrose@1161 | 59 | return cache_index; |
jrose@1161 | 60 | } |
jrose@1494 | 61 | int add_secondary_cp_cache_entry(int main_cpc_entry) { |
jrose@1494 | 62 | assert(main_cpc_entry < _cp_cache_map.length(), "must be earlier CP cache entry"); |
jrose@1494 | 63 | int cache_index = _cp_cache_map.append(main_cpc_entry | _secondary_entry_tag); |
jrose@1494 | 64 | return cache_index; |
jrose@1494 | 65 | } |
jrose@1161 | 66 | |
jrose@2015 | 67 | // Access the contents of _cp_cache_map to determine CP cache layout. |
jrose@2015 | 68 | int cp_cache_entry_pool_index(int cache_index) { |
jrose@2015 | 69 | int cp_index = _cp_cache_map[cache_index]; |
jrose@2015 | 70 | if ((cp_index & _secondary_entry_tag) != 0) |
jrose@2015 | 71 | return -1; |
jrose@2015 | 72 | else |
jrose@2015 | 73 | return cp_index; |
jrose@2015 | 74 | } |
jrose@2015 | 75 | int cp_cache_secondary_entry_main_index(int cache_index) { |
jrose@2015 | 76 | int cp_index = _cp_cache_map[cache_index]; |
jrose@2015 | 77 | if ((cp_index & _secondary_entry_tag) == 0) |
jrose@2015 | 78 | return -1; |
jrose@2015 | 79 | else |
jrose@2015 | 80 | return (cp_index - _secondary_entry_tag); |
jrose@2015 | 81 | } |
jrose@2015 | 82 | |
jrose@1161 | 83 | // All the work goes in here: |
twisti@1573 | 84 | Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, objArrayHandle methods, TRAPS); |
jrose@1161 | 85 | |
jrose@1161 | 86 | void compute_index_maps(); |
jrose@1161 | 87 | void make_constant_pool_cache(TRAPS); |
jrose@1161 | 88 | void scan_method(methodOop m); |
jrose@1161 | 89 | methodHandle rewrite_jsrs(methodHandle m, TRAPS); |
jrose@1161 | 90 | void rewrite_Object_init(methodHandle m, TRAPS); |
jrose@1920 | 91 | void rewrite_member_reference(address bcp, int offset); |
jrose@1920 | 92 | void rewrite_invokedynamic(address bcp, int offset); |
jrose@1957 | 93 | void maybe_rewrite_ldc(address bcp, int offset, bool is_wide); |
duke@435 | 94 | |
duke@435 | 95 | public: |
jrose@1161 | 96 | // Driver routine: |
duke@435 | 97 | static void rewrite(instanceKlassHandle klass, TRAPS); |
twisti@1573 | 98 | static void rewrite(instanceKlassHandle klass, constantPoolHandle cpool, objArrayHandle methods, TRAPS); |
jrose@1494 | 99 | |
jrose@1494 | 100 | enum { |
jrose@1494 | 101 | _secondary_entry_tag = nth_bit(30) |
jrose@1494 | 102 | }; |
duke@435 | 103 | }; |
stefank@2314 | 104 | |
stefank@2314 | 105 | #endif // SHARE_VM_INTERPRETER_REWRITER_HPP |