src/share/vm/interpreter/rewriter.hpp

Fri, 30 Oct 2009 16:22:59 -0700

author
jrose
date
Fri, 30 Oct 2009 16:22:59 -0700
changeset 1494
389049f3f393
parent 1279
bd02caa94611
child 1573
dd57230ba8fe
permissions
-rw-r--r--

6858164: invokedynamic code needs some cleanup (post-6655638)
Summary: Fix several crashers, remove needless paths for boxed-style bootstrap method call, refactor & simplify APIs for rewriter constantPoolOop, remove sun.dyn.CallSiteImpl
Reviewed-by: kvn

duke@435 1 /*
xdono@1279 2 * Copyright 1998-2009 Sun Microsystems, Inc. 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 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 // The Rewriter adds caches to the constant pool and rewrites bytecode indices
duke@435 26 // pointing into the constant pool for better interpreter performance.
duke@435 27
jrose@1161 28 class Rewriter: public StackObj {
duke@435 29 private:
jrose@1161 30 instanceKlassHandle _klass;
jrose@1161 31 constantPoolHandle _pool;
jrose@1161 32 objArrayHandle _methods;
jrose@1161 33 intArray _cp_map;
jrose@1161 34 intStack _cp_cache_map;
jrose@1161 35
jrose@1161 36 void init_cp_map(int length) {
jrose@1161 37 _cp_map.initialize(length, -1);
jrose@1161 38 // Choose an initial value large enough that we don't get frequent
jrose@1161 39 // calls to grow().
jrose@1161 40 _cp_cache_map.initialize(length / 2);
jrose@1161 41 }
jrose@1161 42 int cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map[i]; }
jrose@1161 43 bool has_cp_cache(int i) { return (uint)i < (uint)_cp_map.length() && _cp_map[i] >= 0; }
jrose@1161 44 int maybe_add_cp_cache_entry(int i) { return has_cp_cache(i) ? _cp_map[i] : add_cp_cache_entry(i); }
jrose@1161 45 int add_cp_cache_entry(int cp_index) {
jrose@1494 46 assert((cp_index & _secondary_entry_tag) == 0, "bad tag");
jrose@1161 47 assert(_cp_map[cp_index] == -1, "not twice on same cp_index");
jrose@1161 48 int cache_index = _cp_cache_map.append(cp_index);
jrose@1161 49 _cp_map.at_put(cp_index, cache_index);
jrose@1161 50 assert(cp_entry_to_cp_cache(cp_index) == cache_index, "");
jrose@1161 51 return cache_index;
jrose@1161 52 }
jrose@1494 53 int add_secondary_cp_cache_entry(int main_cpc_entry) {
jrose@1494 54 assert(main_cpc_entry < _cp_cache_map.length(), "must be earlier CP cache entry");
jrose@1494 55 int cache_index = _cp_cache_map.append(main_cpc_entry | _secondary_entry_tag);
jrose@1494 56 return cache_index;
jrose@1494 57 }
jrose@1161 58
jrose@1161 59 // All the work goes in here:
jrose@1161 60 Rewriter(instanceKlassHandle klass, TRAPS);
jrose@1161 61
jrose@1161 62 void compute_index_maps();
jrose@1161 63 void make_constant_pool_cache(TRAPS);
jrose@1161 64 void scan_method(methodOop m);
jrose@1161 65 methodHandle rewrite_jsrs(methodHandle m, TRAPS);
jrose@1161 66 void rewrite_Object_init(methodHandle m, TRAPS);
jrose@1161 67 int rewrite_member_reference(address bcp, int offset);
jrose@1161 68 void rewrite_invokedynamic(address bcp, int offset, int cp_index);
duke@435 69
duke@435 70 public:
jrose@1161 71 // Driver routine:
duke@435 72 static void rewrite(instanceKlassHandle klass, TRAPS);
jrose@1494 73
jrose@1494 74 enum {
jrose@1494 75 _secondary_entry_tag = nth_bit(30)
jrose@1494 76 };
duke@435 77 };

mercurial