Mercurial > hg > truffle
comparison src/share/vm/interpreter/rewriter.cpp @ 1339:09ac706c2623
Merge
author | asaha |
---|---|
date | Wed, 24 Mar 2010 17:16:33 -0700 |
parents | dd57230ba8fe |
children | 760213a60e8b c18cbe5936b8 ab102d5d923e |
comparison
equal
deleted
inserted
replaced
1338:f5dd08ad65df | 1339:09ac706c2623 |
---|---|
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 |
255 } | 245 } |
256 | 246 |
257 | 247 |
258 void Rewriter::rewrite(instanceKlassHandle klass, TRAPS) { | 248 void Rewriter::rewrite(instanceKlassHandle klass, TRAPS) { |
259 ResourceMark rm(THREAD); | 249 ResourceMark rm(THREAD); |
260 Rewriter rw(klass, CHECK); | 250 Rewriter rw(klass, klass->constants(), klass->methods(), CHECK); |
261 // (That's all, folks.) | 251 // (That's all, folks.) |
262 } | 252 } |
263 | 253 |
264 Rewriter::Rewriter(instanceKlassHandle klass, TRAPS) | 254 |
255 void Rewriter::rewrite(instanceKlassHandle klass, constantPoolHandle cpool, objArrayHandle methods, TRAPS) { | |
256 ResourceMark rm(THREAD); | |
257 Rewriter rw(klass, cpool, methods, CHECK); | |
258 // (That's all, folks.) | |
259 } | |
260 | |
261 | |
262 Rewriter::Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, objArrayHandle methods, TRAPS) | |
265 : _klass(klass), | 263 : _klass(klass), |
266 // gather starting points | 264 _pool(cpool), |
267 _pool( THREAD, klass->constants()), | 265 _methods(methods) |
268 _methods(THREAD, klass->methods()) | |
269 { | 266 { |
270 assert(_pool->cache() == NULL, "constant pool cache must not be set yet"); | 267 assert(_pool->cache() == NULL, "constant pool cache must not be set yet"); |
271 | 268 |
272 // determine index maps for methodOop rewriting | 269 // determine index maps for methodOop rewriting |
273 compute_index_maps(); | 270 compute_index_maps(); |