Mercurial > hg > graal-jvmci-8
comparison src/share/vm/interpreter/rewriter.cpp @ 1602:136b78722a08
6939203: JSR 292 needs method handle constants
Summary: Add new CP types CONSTANT_MethodHandle, CONSTANT_MethodType; extend 'ldc' bytecode.
Reviewed-by: twisti, never
author | jrose |
---|---|
date | Wed, 09 Jun 2010 18:50:45 -0700 |
parents | e9ff18c4ace7 |
children | 083fde3b838e |
comparison
equal
deleted
inserted
replaced
1585:49fac4acd688 | 1602:136b78722a08 |
---|---|
36 int tag = _pool->tag_at(i).value(); | 36 int tag = _pool->tag_at(i).value(); |
37 switch (tag) { | 37 switch (tag) { |
38 case JVM_CONSTANT_InterfaceMethodref: | 38 case JVM_CONSTANT_InterfaceMethodref: |
39 case JVM_CONSTANT_Fieldref : // fall through | 39 case JVM_CONSTANT_Fieldref : // fall through |
40 case JVM_CONSTANT_Methodref : // fall through | 40 case JVM_CONSTANT_Methodref : // fall through |
41 case JVM_CONSTANT_MethodHandle : // fall through | |
42 case JVM_CONSTANT_MethodType : // fall through | |
41 add_cp_cache_entry(i); | 43 add_cp_cache_entry(i); |
42 break; | 44 break; |
43 } | 45 } |
44 } | 46 } |
45 | 47 |
129 Bytes::put_native_u4(p, constantPoolCacheOopDesc::encode_secondary_index(cpc2)); | 131 Bytes::put_native_u4(p, constantPoolCacheOopDesc::encode_secondary_index(cpc2)); |
130 // Note: We use native_u4 format exclusively for 4-byte indexes. | 132 // Note: We use native_u4 format exclusively for 4-byte indexes. |
131 } | 133 } |
132 | 134 |
133 | 135 |
136 // Rewrite some ldc bytecodes to _fast_aldc | |
137 void Rewriter::maybe_rewrite_ldc(address bcp, int offset, bool is_wide) { | |
138 assert((*bcp) == (is_wide ? Bytecodes::_ldc_w : Bytecodes::_ldc), ""); | |
139 address p = bcp + offset; | |
140 int cp_index = is_wide ? Bytes::get_Java_u2(p) : (u1)(*p); | |
141 constantTag tag = _pool->tag_at(cp_index).value(); | |
142 if (tag.is_method_handle() || tag.is_method_type()) { | |
143 int cache_index = cp_entry_to_cp_cache(cp_index); | |
144 if (is_wide) { | |
145 (*bcp) = Bytecodes::_fast_aldc_w; | |
146 assert(cache_index == (u2)cache_index, ""); | |
147 Bytes::put_native_u2(p, cache_index); | |
148 } else { | |
149 (*bcp) = Bytecodes::_fast_aldc; | |
150 assert(cache_index == (u1)cache_index, ""); | |
151 (*p) = (u1)cache_index; | |
152 } | |
153 } | |
154 } | |
155 | |
156 | |
134 // Rewrites a method given the index_map information | 157 // Rewrites a method given the index_map information |
135 void Rewriter::scan_method(methodOop method) { | 158 void Rewriter::scan_method(methodOop method) { |
136 | 159 |
137 int nof_jsrs = 0; | 160 int nof_jsrs = 0; |
138 bool has_monitor_bytecodes = false; | 161 bool has_monitor_bytecodes = false; |
195 case Bytecodes::_invokeinterface: | 218 case Bytecodes::_invokeinterface: |
196 rewrite_member_reference(bcp, prefix_length+1); | 219 rewrite_member_reference(bcp, prefix_length+1); |
197 break; | 220 break; |
198 case Bytecodes::_invokedynamic: | 221 case Bytecodes::_invokedynamic: |
199 rewrite_invokedynamic(bcp, prefix_length+1); | 222 rewrite_invokedynamic(bcp, prefix_length+1); |
223 break; | |
224 case Bytecodes::_ldc: | |
225 maybe_rewrite_ldc(bcp, prefix_length+1, false); | |
226 break; | |
227 case Bytecodes::_ldc_w: | |
228 maybe_rewrite_ldc(bcp, prefix_length+1, true); | |
200 break; | 229 break; |
201 case Bytecodes::_jsr : // fall through | 230 case Bytecodes::_jsr : // fall through |
202 case Bytecodes::_jsr_w : nof_jsrs++; break; | 231 case Bytecodes::_jsr_w : nof_jsrs++; break; |
203 case Bytecodes::_monitorenter : // fall through | 232 case Bytecodes::_monitorenter : // fall through |
204 case Bytecodes::_monitorexit : has_monitor_bytecodes = true; break; | 233 case Bytecodes::_monitorexit : has_monitor_bytecodes = true; break; |