1.1 --- a/src/share/vm/interpreter/rewriter.hpp Mon Apr 20 14:48:03 2009 -0700 1.2 +++ b/src/share/vm/interpreter/rewriter.hpp Tue Apr 21 23:21:04 2009 -0700 1.3 @@ -25,13 +25,44 @@ 1.4 // The Rewriter adds caches to the constant pool and rewrites bytecode indices 1.5 // pointing into the constant pool for better interpreter performance. 1.6 1.7 -class Rewriter: public AllStatic { 1.8 +class Rewriter: public StackObj { 1.9 private: 1.10 - static void compute_index_maps(constantPoolHandle pool, intArray*& index_map, intStack*& inverse_index_map); 1.11 - static constantPoolCacheHandle new_constant_pool_cache(intArray& inverse_index_map, TRAPS); 1.12 - static methodHandle rewrite_method(methodHandle method, intArray& index_map, TRAPS); 1.13 - static void rewrite_Object_init(methodHandle method, TRAPS); 1.14 + instanceKlassHandle _klass; 1.15 + constantPoolHandle _pool; 1.16 + objArrayHandle _methods; 1.17 + intArray _cp_map; 1.18 + intStack _cp_cache_map; 1.19 + 1.20 + void init_cp_map(int length) { 1.21 + _cp_map.initialize(length, -1); 1.22 + // Choose an initial value large enough that we don't get frequent 1.23 + // calls to grow(). 1.24 + _cp_cache_map.initialize(length / 2); 1.25 + } 1.26 + int cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map[i]; } 1.27 + bool has_cp_cache(int i) { return (uint)i < (uint)_cp_map.length() && _cp_map[i] >= 0; } 1.28 + int maybe_add_cp_cache_entry(int i) { return has_cp_cache(i) ? _cp_map[i] : add_cp_cache_entry(i); } 1.29 + int add_cp_cache_entry(int cp_index) { 1.30 + assert(_cp_map[cp_index] == -1, "not twice on same cp_index"); 1.31 + int cache_index = _cp_cache_map.append(cp_index); 1.32 + _cp_map.at_put(cp_index, cache_index); 1.33 + assert(cp_entry_to_cp_cache(cp_index) == cache_index, ""); 1.34 + return cache_index; 1.35 + } 1.36 + int add_extra_cp_cache_entry(int main_entry); 1.37 + 1.38 + // All the work goes in here: 1.39 + Rewriter(instanceKlassHandle klass, TRAPS); 1.40 + 1.41 + void compute_index_maps(); 1.42 + void make_constant_pool_cache(TRAPS); 1.43 + void scan_method(methodOop m); 1.44 + methodHandle rewrite_jsrs(methodHandle m, TRAPS); 1.45 + void rewrite_Object_init(methodHandle m, TRAPS); 1.46 + int rewrite_member_reference(address bcp, int offset); 1.47 + void rewrite_invokedynamic(address bcp, int offset, int cp_index); 1.48 1.49 public: 1.50 + // Driver routine: 1.51 static void rewrite(instanceKlassHandle klass, TRAPS); 1.52 };