Mercurial > hg > graal-jvmci-8
comparison src/share/vm/prims/methodComparator.cpp @ 1565:ab102d5d923e
6939207: refactor constant pool index processing
Summary: Factored cleanup of instruction decode which prepares for enhanced ldc semantics.
Reviewed-by: twisti
author | jrose |
---|---|
date | Sun, 23 May 2010 01:38:26 -0700 |
parents | bd02caa94611 |
children | beb77f0d41b3 |
comparison
equal
deleted
inserted
replaced
1564:61b2245abf36 | 1565:ab102d5d923e |
---|---|
1 /* | 1 /* |
2 * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
128 case Bytecodes::_new : // fall through | 128 case Bytecodes::_new : // fall through |
129 case Bytecodes::_anewarray : // fall through | 129 case Bytecodes::_anewarray : // fall through |
130 case Bytecodes::_multianewarray : // fall through | 130 case Bytecodes::_multianewarray : // fall through |
131 case Bytecodes::_checkcast : // fall through | 131 case Bytecodes::_checkcast : // fall through |
132 case Bytecodes::_instanceof : { | 132 case Bytecodes::_instanceof : { |
133 u2 cpi_old = _s_old->get_index_big(); | 133 u2 cpi_old = _s_old->get_index_u2(); |
134 u2 cpi_new = _s_new->get_index_big(); | 134 u2 cpi_new = _s_new->get_index_u2(); |
135 if ((_old_cp->klass_at_noresolve(cpi_old) != _new_cp->klass_at_noresolve(cpi_new))) | 135 if ((_old_cp->klass_at_noresolve(cpi_old) != _new_cp->klass_at_noresolve(cpi_new))) |
136 return false; | 136 return false; |
137 if (c_old == Bytecodes::_multianewarray && | 137 if (c_old == Bytecodes::_multianewarray && |
138 *(jbyte*)(_s_old->bcp() + 3) != *(jbyte*)(_s_new->bcp() + 3)) | 138 *(jbyte*)(_s_old->bcp() + 3) != *(jbyte*)(_s_new->bcp() + 3)) |
139 return false; | 139 return false; |
145 case Bytecodes::_getfield : // fall through | 145 case Bytecodes::_getfield : // fall through |
146 case Bytecodes::_putfield : // fall through | 146 case Bytecodes::_putfield : // fall through |
147 case Bytecodes::_invokevirtual : // fall through | 147 case Bytecodes::_invokevirtual : // fall through |
148 case Bytecodes::_invokespecial : // fall through | 148 case Bytecodes::_invokespecial : // fall through |
149 case Bytecodes::_invokestatic : // fall through | 149 case Bytecodes::_invokestatic : // fall through |
150 case Bytecodes::_invokedynamic : // fall through | |
150 case Bytecodes::_invokeinterface : { | 151 case Bytecodes::_invokeinterface : { |
151 u2 cpci_old = _s_old->get_index_int(); | 152 u2 cpci_old = _s_old->has_index_u4() ? _s_old->get_index_u4() : _s_old->get_index_u2(); |
152 u2 cpci_new = _s_new->get_index_int(); | 153 u2 cpci_new = _s_new->has_index_u4() ? _s_new->get_index_u4() : _s_new->get_index_u2(); |
153 // Check if the names of classes, field/method names and signatures at these indexes | 154 // Check if the names of classes, field/method names and signatures at these indexes |
154 // are the same. Indices which are really into constantpool cache (rather than constant | 155 // are the same. Indices which are really into constantpool cache (rather than constant |
155 // pool itself) are accepted by the constantpool query routines below. | 156 // pool itself) are accepted by the constantpool query routines below. |
156 if ((_old_cp->klass_ref_at_noresolve(cpci_old) != _new_cp->klass_ref_at_noresolve(cpci_new)) || | 157 if ((_old_cp->klass_ref_at_noresolve(cpci_old) != _new_cp->klass_ref_at_noresolve(cpci_new)) || |
157 (_old_cp->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) || | 158 (_old_cp->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) || |
165 u2 cpi_old, cpi_new; | 166 u2 cpi_old, cpi_new; |
166 if (c_old == Bytecodes::_ldc) { | 167 if (c_old == Bytecodes::_ldc) { |
167 cpi_old = _s_old->bcp()[1]; | 168 cpi_old = _s_old->bcp()[1]; |
168 cpi_new = _s_new->bcp()[1]; | 169 cpi_new = _s_new->bcp()[1]; |
169 } else { | 170 } else { |
170 cpi_old = _s_old->get_index_big(); | 171 cpi_old = _s_old->get_index_u2(); |
171 cpi_new = _s_new->get_index_big(); | 172 cpi_new = _s_new->get_index_u2(); |
172 } | 173 } |
173 constantTag tag_old = _old_cp->tag_at(cpi_old); | 174 constantTag tag_old = _old_cp->tag_at(cpi_old); |
174 constantTag tag_new = _new_cp->tag_at(cpi_new); | 175 constantTag tag_new = _new_cp->tag_at(cpi_new); |
175 if (tag_old.is_int() || tag_old.is_float()) { | 176 if (tag_old.is_int() || tag_old.is_float()) { |
176 if (tag_old.value() != tag_new.value()) | 177 if (tag_old.value() != tag_new.value()) |
197 } | 198 } |
198 break; | 199 break; |
199 } | 200 } |
200 | 201 |
201 case Bytecodes::_ldc2_w : { | 202 case Bytecodes::_ldc2_w : { |
202 u2 cpi_old = _s_old->get_index_big(); | 203 u2 cpi_old = _s_old->get_index_u2(); |
203 u2 cpi_new = _s_new->get_index_big(); | 204 u2 cpi_new = _s_new->get_index_u2(); |
204 constantTag tag_old = _old_cp->tag_at(cpi_old); | 205 constantTag tag_old = _old_cp->tag_at(cpi_old); |
205 constantTag tag_new = _new_cp->tag_at(cpi_new); | 206 constantTag tag_new = _new_cp->tag_at(cpi_new); |
206 if (tag_old.value() != tag_new.value()) | 207 if (tag_old.value() != tag_new.value()) |
207 return false; | 208 return false; |
208 if (tag_old.is_long()) { | 209 if (tag_old.is_long()) { |
219 if (_s_old->bcp()[1] != _s_new->bcp()[1]) | 220 if (_s_old->bcp()[1] != _s_new->bcp()[1]) |
220 return false; | 221 return false; |
221 break; | 222 break; |
222 | 223 |
223 case Bytecodes::_sipush : | 224 case Bytecodes::_sipush : |
224 if (_s_old->get_index_big() != _s_new->get_index_big()) | 225 if (_s_old->get_index_u2() != _s_new->get_index_u2()) |
225 return false; | 226 return false; |
226 break; | 227 break; |
227 | 228 |
228 case Bytecodes::_aload : // fall through | 229 case Bytecodes::_aload : // fall through |
229 case Bytecodes::_astore : // fall through | 230 case Bytecodes::_astore : // fall through |
258 case Bytecodes::_ifgt : // fall through | 259 case Bytecodes::_ifgt : // fall through |
259 case Bytecodes::_ifle : // fall through | 260 case Bytecodes::_ifle : // fall through |
260 case Bytecodes::_ifnonnull : // fall through | 261 case Bytecodes::_ifnonnull : // fall through |
261 case Bytecodes::_ifnull : // fall through | 262 case Bytecodes::_ifnull : // fall through |
262 case Bytecodes::_jsr : { | 263 case Bytecodes::_jsr : { |
263 short old_ofs = (short) _s_old->get_index_big(); | 264 short old_ofs = (short) _s_old->get_index_u2(); |
264 short new_ofs = (short) _s_new->get_index_big(); | 265 short new_ofs = (short) _s_new->get_index_u2(); |
265 if (_switchable_test) { | 266 if (_switchable_test) { |
266 int old_dest = _s_old->bci() + old_ofs; | 267 int old_dest = _s_old->bci() + old_ofs; |
267 int new_dest = _s_new->bci() + new_ofs; | 268 int new_dest = _s_new->bci() + new_ofs; |
268 if (old_ofs < 0 && new_ofs < 0) { | 269 if (old_ofs < 0 && new_ofs < 0) { |
269 if (! _bci_map->old_and_new_locations_same(old_dest, new_dest)) | 270 if (! _bci_map->old_and_new_locations_same(old_dest, new_dest)) |
283 | 284 |
284 case Bytecodes::_iinc : | 285 case Bytecodes::_iinc : |
285 if (_s_old->is_wide() != _s_new->is_wide()) | 286 if (_s_old->is_wide() != _s_new->is_wide()) |
286 return false; | 287 return false; |
287 if (! _s_old->is_wide()) { | 288 if (! _s_old->is_wide()) { |
288 if (_s_old->get_index_big() != _s_new->get_index_big()) | 289 // We could use get_index_u1 and get_constant_u1, but it's simpler to grab both bytes at once: |
289 return false; | 290 if (Bytes::get_Java_u2(_s_old->bcp() + 1) != Bytes::get_Java_u2(_s_new->bcp() + 1)) |
290 } else { | 291 return false; |
292 } else { | |
293 // We could use get_index_u2 and get_constant_u2, but it's simpler to grab all four bytes at once: | |
291 if (Bytes::get_Java_u4(_s_old->bcp() + 1) != Bytes::get_Java_u4(_s_new->bcp() + 1)) | 294 if (Bytes::get_Java_u4(_s_old->bcp() + 1) != Bytes::get_Java_u4(_s_new->bcp() + 1)) |
292 return false; | 295 return false; |
293 } | 296 } |
294 break; | 297 break; |
295 | 298 |
355 _fwd_jmps->append(_s_old->bci() + ofs_old); | 358 _fwd_jmps->append(_s_old->bci() + ofs_old); |
356 _fwd_jmps->append(_s_new->bci() + ofs_new); | 359 _fwd_jmps->append(_s_new->bci() + ofs_new); |
357 } | 360 } |
358 } | 361 } |
359 } else { // !_switchable_test, can use fast rough compare | 362 } else { // !_switchable_test, can use fast rough compare |
360 int len_old = _s_old->next_bcp() - _s_old->bcp(); | 363 int len_old = _s_old->instruction_size(); |
361 int len_new = _s_new->next_bcp() - _s_new->bcp(); | 364 int len_new = _s_new->instruction_size(); |
362 if (len_old != len_new) | 365 if (len_old != len_new) |
363 return false; | 366 return false; |
364 if (memcmp(_s_old->bcp(), _s_new->bcp(), len_old) != 0) | 367 if (memcmp(_s_old->bcp(), _s_new->bcp(), len_old) != 0) |
365 return false; | 368 return false; |
366 } | 369 } |