comparison src/share/vm/interpreter/rewriter.cpp @ 1059:389049f3f393

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
author jrose
date Fri, 30 Oct 2009 16:22:59 -0700
parents 75596850f863
children dd57230ba8fe
comparison
equal deleted inserted replaced
1058:73a726751507 1059:389049f3f393
46 guarantee((int)_cp_cache_map.length()-1 <= (int)((u2)-1), 46 guarantee((int)_cp_cache_map.length()-1 <= (int)((u2)-1),
47 "all cp cache indexes fit in a u2"); 47 "all cp cache indexes fit in a u2");
48 } 48 }
49 49
50 50
51 int Rewriter::add_extra_cp_cache_entry(int main_entry) {
52 // Hack: We put it on the map as an encoded value.
53 // The only place that consumes this is ConstantPoolCacheEntry::set_initial_state
54 int encoded = constantPoolCacheOopDesc::encode_secondary_index(main_entry);
55 int plain_secondary_index = _cp_cache_map.append(encoded);
56 return constantPoolCacheOopDesc::encode_secondary_index(plain_secondary_index);
57 }
58
59
60
61 // Creates a constant pool cache given a CPC map 51 // Creates a constant pool cache given a CPC map
62 // This creates the constant pool cache initially in a state 52 // This creates the constant pool cache initially in a state
63 // that is unsafe for concurrent GC processing but sets it to 53 // that is unsafe for concurrent GC processing but sets it to
64 // a safe mode before the constant pool cache is returned. 54 // a safe mode before the constant pool cache is returned.
65 void Rewriter::make_constant_pool_cache(TRAPS) { 55 void Rewriter::make_constant_pool_cache(TRAPS) {
125 void Rewriter::rewrite_invokedynamic(address bcp, int offset, int delete_me) { 115 void Rewriter::rewrite_invokedynamic(address bcp, int offset, int delete_me) {
126 address p = bcp + offset; 116 address p = bcp + offset;
127 assert(p[-1] == Bytecodes::_invokedynamic, ""); 117 assert(p[-1] == Bytecodes::_invokedynamic, "");
128 int cp_index = Bytes::get_Java_u2(p); 118 int cp_index = Bytes::get_Java_u2(p);
129 int cpc = maybe_add_cp_cache_entry(cp_index); // add lazily 119 int cpc = maybe_add_cp_cache_entry(cp_index); // add lazily
130 int cpc2 = add_extra_cp_cache_entry(cpc); 120 int cpc2 = add_secondary_cp_cache_entry(cpc);
131 121
132 // Replace the trailing four bytes with a CPC index for the dynamic 122 // Replace the trailing four bytes with a CPC index for the dynamic
133 // call site. Unlike other CPC entries, there is one per bytecode, 123 // call site. Unlike other CPC entries, there is one per bytecode,
134 // not just one per distinct CP entry. In other words, the 124 // not just one per distinct CP entry. In other words, the
135 // CPC-to-CP relation is many-to-one for invokedynamic entries. 125 // CPC-to-CP relation is many-to-one for invokedynamic entries.
136 // This means we must use a larger index size than u2 to address 126 // This means we must use a larger index size than u2 to address
137 // all these entries. That is the main reason invokedynamic 127 // all these entries. That is the main reason invokedynamic
138 // must have a five-byte instruction format. (Of course, other JVM 128 // must have a five-byte instruction format. (Of course, other JVM
139 // implementations can use the bytes for other purposes.) 129 // implementations can use the bytes for other purposes.)
140 Bytes::put_native_u4(p, cpc2); 130 Bytes::put_native_u4(p, constantPoolCacheOopDesc::encode_secondary_index(cpc2));
141 // Note: We use native_u4 format exclusively for 4-byte indexes. 131 // Note: We use native_u4 format exclusively for 4-byte indexes.
142 } 132 }
143 133
144 134
145 // Rewrites a method given the index_map information 135 // Rewrites a method given the index_map information