comparison src/share/vm/interpreter/rewriter.hpp @ 726:be93aad57795

6655646: dynamic languages need dynamically linked call sites Summary: invokedynamic instruction (JSR 292 RI) Reviewed-by: twisti, never
author jrose
date Tue, 21 Apr 2009 23:21:04 -0700
parents a61af66fc99e
children bd02caa94611
comparison
equal deleted inserted replaced
725:928912ce8438 726:be93aad57795
23 */ 23 */
24 24
25 // The Rewriter adds caches to the constant pool and rewrites bytecode indices 25 // The Rewriter adds caches to the constant pool and rewrites bytecode indices
26 // pointing into the constant pool for better interpreter performance. 26 // pointing into the constant pool for better interpreter performance.
27 27
28 class Rewriter: public AllStatic { 28 class Rewriter: public StackObj {
29 private: 29 private:
30 static void compute_index_maps(constantPoolHandle pool, intArray*& index_map, intStack*& inverse_index_map); 30 instanceKlassHandle _klass;
31 static constantPoolCacheHandle new_constant_pool_cache(intArray& inverse_index_map, TRAPS); 31 constantPoolHandle _pool;
32 static methodHandle rewrite_method(methodHandle method, intArray& index_map, TRAPS); 32 objArrayHandle _methods;
33 static void rewrite_Object_init(methodHandle method, TRAPS); 33 intArray _cp_map;
34 intStack _cp_cache_map;
35
36 void init_cp_map(int length) {
37 _cp_map.initialize(length, -1);
38 // Choose an initial value large enough that we don't get frequent
39 // calls to grow().
40 _cp_cache_map.initialize(length / 2);
41 }
42 int cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map[i]; }
43 bool has_cp_cache(int i) { return (uint)i < (uint)_cp_map.length() && _cp_map[i] >= 0; }
44 int maybe_add_cp_cache_entry(int i) { return has_cp_cache(i) ? _cp_map[i] : add_cp_cache_entry(i); }
45 int add_cp_cache_entry(int cp_index) {
46 assert(_cp_map[cp_index] == -1, "not twice on same cp_index");
47 int cache_index = _cp_cache_map.append(cp_index);
48 _cp_map.at_put(cp_index, cache_index);
49 assert(cp_entry_to_cp_cache(cp_index) == cache_index, "");
50 return cache_index;
51 }
52 int add_extra_cp_cache_entry(int main_entry);
53
54 // All the work goes in here:
55 Rewriter(instanceKlassHandle klass, TRAPS);
56
57 void compute_index_maps();
58 void make_constant_pool_cache(TRAPS);
59 void scan_method(methodOop m);
60 methodHandle rewrite_jsrs(methodHandle m, TRAPS);
61 void rewrite_Object_init(methodHandle m, TRAPS);
62 int rewrite_member_reference(address bcp, int offset);
63 void rewrite_invokedynamic(address bcp, int offset, int cp_index);
34 64
35 public: 65 public:
66 // Driver routine:
36 static void rewrite(instanceKlassHandle klass, TRAPS); 67 static void rewrite(instanceKlassHandle klass, TRAPS);
37 }; 68 };