Print this page
rev 1023 : [mq]: meth.walker.patch
rev 1026 : imported patch indy.compiler.inline.patch
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/classfile/vmSymbols.cpp
+++ new/src/share/vm/classfile/vmSymbols.cpp
1 1 /*
2 2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 21 * have any questions.
22 22 *
23 23 */
24 24
25 25 # include "incls/_precompiled.incl"
26 26 # include "incls/_vmSymbols.cpp.incl"
27 27
28 28
29 29 symbolOop vmSymbols::_symbols[vmSymbols::SID_LIMIT];
30 30
31 31 symbolOop vmSymbols::_type_signatures[T_VOID+1] = { NULL /*, NULL...*/ };
32 32
33 33 inline int compare_symbol(symbolOop a, symbolOop b) {
34 34 if (a == b) return 0;
35 35 // follow the natural address order:
36 36 return (address)a > (address)b ? +1 : -1;
37 37 }
38 38
39 39 static vmSymbols::SID vm_symbol_index[vmSymbols::SID_LIMIT];
40 40 extern "C" {
41 41 static int compare_vmsymbol_sid(const void* void_a, const void* void_b) {
42 42 symbolOop a = vmSymbols::symbol_at(*((vmSymbols::SID*) void_a));
43 43 symbolOop b = vmSymbols::symbol_at(*((vmSymbols::SID*) void_b));
44 44 return compare_symbol(a, b);
45 45 }
46 46 }
47 47
48 48 #ifndef PRODUCT
49 49 #define VM_SYMBOL_ENUM_NAME_BODY(name, string) #name "\0"
50 50 static const char* vm_symbol_enum_names =
51 51 VM_SYMBOLS_DO(VM_SYMBOL_ENUM_NAME_BODY, VM_ALIAS_IGNORE)
52 52 "\0";
53 53 static const char* vm_symbol_enum_name(vmSymbols::SID sid) {
54 54 const char* string = &vm_symbol_enum_names[0];
55 55 int skip = (int)sid - (int)vmSymbols::FIRST_SID;
56 56 for (; skip != 0; skip--) {
57 57 size_t skiplen = strlen(string);
58 58 if (skiplen == 0) return "<unknown>"; // overflow
59 59 string += skiplen+1;
60 60 }
61 61 return string;
62 62 }
63 63 #endif //PRODUCT
64 64
65 65 // Put all the VM symbol strings in one place.
66 66 // Makes for a more compact libjvm.
67 67 #define VM_SYMBOL_BODY(name, string) string "\0"
68 68 static const char* vm_symbol_bodies = VM_SYMBOLS_DO(VM_SYMBOL_BODY, VM_ALIAS_IGNORE);
69 69
70 70 void vmSymbols::initialize(TRAPS) {
71 71 assert((int)SID_LIMIT <= (1<<log2_SID_LIMIT), "must fit in this bitfield");
72 72 assert((int)SID_LIMIT*5 > (1<<log2_SID_LIMIT), "make the bitfield smaller, please");
73 73
74 74 if (!UseSharedSpaces) {
75 75 const char* string = &vm_symbol_bodies[0];
76 76 for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
77 77 symbolOop sym = oopFactory::new_symbol(string, CHECK);
78 78 _symbols[index] = sym;
79 79 string += strlen(string); // skip string body
80 80 string += 1; // skip trailing null
81 81 }
82 82
83 83 _type_signatures[T_BYTE] = byte_signature();
84 84 _type_signatures[T_CHAR] = char_signature();
85 85 _type_signatures[T_DOUBLE] = double_signature();
86 86 _type_signatures[T_FLOAT] = float_signature();
87 87 _type_signatures[T_INT] = int_signature();
88 88 _type_signatures[T_LONG] = long_signature();
89 89 _type_signatures[T_SHORT] = short_signature();
90 90 _type_signatures[T_BOOLEAN] = bool_signature();
91 91 _type_signatures[T_VOID] = void_signature();
92 92 // no single signatures for T_OBJECT or T_ARRAY
93 93 }
94 94
95 95 #ifdef ASSERT
96 96 // Check for duplicates:
97 97 for (int i1 = (int)FIRST_SID; i1 < (int)SID_LIMIT; i1++) {
98 98 symbolOop sym = symbol_at((SID)i1);
99 99 for (int i2 = (int)FIRST_SID; i2 < i1; i2++) {
100 100 if (symbol_at((SID)i2) == sym) {
101 101 tty->print("*** Duplicate VM symbol SIDs %s(%d) and %s(%d): \"",
102 102 vm_symbol_enum_name((SID)i2), i2,
103 103 vm_symbol_enum_name((SID)i1), i1);
104 104 sym->print_symbol_on(tty);
105 105 tty->print_cr("\"");
106 106 }
107 107 }
108 108 }
109 109 #endif //ASSERT
110 110
111 111 // Create an index for find_id:
112 112 {
113 113 for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
114 114 vm_symbol_index[index] = (SID)index;
115 115 }
116 116 int num_sids = SID_LIMIT-FIRST_SID;
117 117 qsort(&vm_symbol_index[FIRST_SID], num_sids, sizeof(vm_symbol_index[0]),
118 118 compare_vmsymbol_sid);
119 119 }
120 120
121 121 #ifdef ASSERT
122 122 {
123 123 // Spot-check correspondence between strings, symbols, and enums:
124 124 assert(_symbols[NO_SID] == NULL, "must be");
125 125 const char* str = "java/lang/Object";
126 126 symbolOop sym = oopFactory::new_symbol(str, CHECK);
127 127 assert(strcmp(str, (char*)sym->base()) == 0, "");
128 128 assert(sym == java_lang_Object(), "");
129 129 SID sid = VM_SYMBOL_ENUM_NAME(java_lang_Object);
130 130 assert(find_sid(sym) == sid, "");
131 131 assert(symbol_at(sid) == sym, "");
132 132
133 133 // Make sure find_sid produces the right answer in each case.
134 134 for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
135 135 sym = symbol_at((SID)index);
136 136 sid = find_sid(sym);
137 137 assert(sid == (SID)index, "symbol index works");
138 138 // Note: If there are duplicates, this assert will fail.
139 139 // A "Duplicate VM symbol" message will have already been printed.
140 140 }
141 141
142 142 // The string "format" happens (at the moment) not to be a vmSymbol,
143 143 // though it is a method name in java.lang.String.
144 144 str = "format";
145 145 sym = oopFactory::new_symbol(str, CHECK);
146 146 sid = find_sid(sym);
147 147 assert(sid == NO_SID, "symbol index works (negative test)");
148 148 }
149 149 #endif
150 150 }
151 151
152 152
153 153 #ifndef PRODUCT
154 154 const char* vmSymbols::name_for(vmSymbols::SID sid) {
155 155 if (sid == NO_SID)
156 156 return "NO_SID";
157 157 const char* string = &vm_symbol_bodies[0];
158 158 for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
159 159 if (index == (int)sid)
160 160 return string;
161 161 string += strlen(string); // skip string body
162 162 string += 1; // skip trailing null
163 163 }
164 164 return "BAD_SID";
165 165 }
166 166 #endif
167 167
168 168
169 169
170 170 void vmSymbols::oops_do(OopClosure* f, bool do_all) {
171 171 for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
172 172 f->do_oop((oop*) &_symbols[index]);
173 173 }
174 174 for (int i = 0; i < T_VOID+1; i++) {
175 175 if (_type_signatures[i] != NULL) {
176 176 assert(i >= T_BOOLEAN, "checking");
177 177 f->do_oop((oop*)&_type_signatures[i]);
178 178 } else if (do_all) {
179 179 f->do_oop((oop*)&_type_signatures[i]);
180 180 }
181 181 }
182 182 }
183 183
184 184
185 185 BasicType vmSymbols::signature_type(symbolOop s) {
186 186 assert(s != NULL, "checking");
187 187 for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
188 188 if (s == _type_signatures[i]) {
189 189 return (BasicType)i;
190 190 }
191 191 }
192 192 return T_OBJECT;
193 193 }
194 194
195 195
196 196 static int mid_hint = (int)vmSymbols::FIRST_SID+1;
197 197
198 198 #ifndef PRODUCT
199 199 static int find_sid_calls, find_sid_probes;
200 200 // (Typical counts are calls=7000 and probes=17000.)
201 201 #endif
202 202
203 203 vmSymbols::SID vmSymbols::find_sid(symbolOop symbol) {
204 204 // Handle the majority of misses by a bounds check.
205 205 // Then, use a binary search over the index.
206 206 // Expected trip count is less than log2_SID_LIMIT, about eight.
207 207 // This is slow but acceptable, given that calls are not
208 208 // dynamically common. (methodOop::intrinsic_id has a cache.)
209 209 NOT_PRODUCT(find_sid_calls++);
210 210 int min = (int)FIRST_SID, max = (int)SID_LIMIT - 1;
211 211 SID sid = NO_SID, sid1;
212 212 int cmp1;
213 213 sid1 = vm_symbol_index[min];
214 214 cmp1 = compare_symbol(symbol, symbol_at(sid1));
215 215 if (cmp1 <= 0) { // before the first
216 216 if (cmp1 == 0) sid = sid1;
217 217 } else {
218 218 sid1 = vm_symbol_index[max];
219 219 cmp1 = compare_symbol(symbol, symbol_at(sid1));
220 220 if (cmp1 >= 0) { // after the last
221 221 if (cmp1 == 0) sid = sid1;
222 222 } else {
223 223 // After checking the extremes, do a binary search.
224 224 ++min; --max; // endpoints are done
225 225 int mid = mid_hint; // start at previous success
226 226 while (max >= min) {
227 227 assert(mid >= min && mid <= max, "");
228 228 NOT_PRODUCT(find_sid_probes++);
229 229 sid1 = vm_symbol_index[mid];
230 230 cmp1 = compare_symbol(symbol, symbol_at(sid1));
231 231 if (cmp1 == 0) {
232 232 mid_hint = mid;
233 233 sid = sid1;
234 234 break;
235 235 }
236 236 if (cmp1 < 0)
237 237 max = mid - 1; // symbol < symbol_at(sid)
238 238 else
239 239 min = mid + 1;
240 240
241 241 // Pick a new probe point:
242 242 mid = (max + min) / 2;
243 243 }
244 244 }
245 245 }
246 246
247 247 #ifdef ASSERT
248 248 // Perform the exhaustive self-check the first 1000 calls,
249 249 // and every 100 calls thereafter.
250 250 static int find_sid_check_count = -2000;
251 251 if ((uint)++find_sid_check_count > (uint)100) {
252 252 if (find_sid_check_count > 0) find_sid_check_count = 0;
253 253
254 254 // Make sure this is the right answer, using linear search.
255 255 // (We have already proven that there are no duplicates in the list.)
256 256 SID sid2 = NO_SID;
257 257 for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
258 258 symbolOop sym2 = symbol_at((SID)index);
259 259 if (sym2 == symbol) {
260 260 sid2 = (SID)index;
261 261 break;
262 262 }
263 263 }
264 264 // Unless it's a duplicate, assert that the sids are the same.
265 265 if (_symbols[sid] != _symbols[sid2]) {
266 266 assert(sid == sid2, "binary same as linear search");
267 267 }
268 268 }
269 269 #endif //ASSERT
270 270
271 271 return sid;
272 272 }
273 273
274 274 static vmIntrinsics::ID wrapper_intrinsic(BasicType type, bool unboxing) {
275 275 #define TYPE2(type, unboxing) ((int)(type)*2 + ((unboxing) ? 1 : 0))
276 276 switch (TYPE2(type, unboxing)) {
277 277 #define BASIC_TYPE_CASE(type, box, unbox) \
278 278 case TYPE2(type, false): return vmIntrinsics::box; \
279 279 case TYPE2(type, true): return vmIntrinsics::unbox
280 280 BASIC_TYPE_CASE(T_BOOLEAN, _Boolean_valueOf, _booleanValue);
281 281 BASIC_TYPE_CASE(T_BYTE, _Byte_valueOf, _byteValue);
282 282 BASIC_TYPE_CASE(T_CHAR, _Character_valueOf, _charValue);
283 283 BASIC_TYPE_CASE(T_SHORT, _Short_valueOf, _shortValue);
284 284 BASIC_TYPE_CASE(T_INT, _Integer_valueOf, _intValue);
285 285 BASIC_TYPE_CASE(T_LONG, _Long_valueOf, _longValue);
286 286 BASIC_TYPE_CASE(T_FLOAT, _Float_valueOf, _floatValue);
287 287 BASIC_TYPE_CASE(T_DOUBLE, _Double_valueOf, _doubleValue);
288 288 #undef BASIC_TYPE_CASE
289 289 }
290 290 #undef TYPE2
↓ open down ↓ |
290 lines elided |
↑ open up ↑ |
291 291 return vmIntrinsics::_none;
292 292 }
293 293
294 294 vmIntrinsics::ID vmIntrinsics::for_boxing(BasicType type) {
295 295 return wrapper_intrinsic(type, false);
296 296 }
297 297 vmIntrinsics::ID vmIntrinsics::for_unboxing(BasicType type) {
298 298 return wrapper_intrinsic(type, true);
299 299 }
300 300
301 +vmIntrinsics::ID vmIntrinsics::for_raw_conversion(BasicType src, BasicType dest) {
302 +#define SRC_DEST(s,d) (((int)(s) << 4) + (int)(d))
303 + switch (SRC_DEST(src, dest)) {
304 + case SRC_DEST(T_INT, T_FLOAT): return vmIntrinsics::_intBitsToFloat;
305 + case SRC_DEST(T_FLOAT, T_INT): return vmIntrinsics::_floatToRawIntBits;
306 +
307 + case SRC_DEST(T_LONG, T_DOUBLE): return vmIntrinsics::_longBitsToDouble;
308 + case SRC_DEST(T_DOUBLE, T_LONG): return vmIntrinsics::_doubleToRawLongBits;
309 + }
310 +#undef SRC_DEST
311 +
312 + return vmIntrinsics::_none;
313 +}
314 +
301 315 methodOop vmIntrinsics::method_for(vmIntrinsics::ID id) {
302 316 if (id == _none) return NULL;
303 317 symbolOop cname = vmSymbols::symbol_at(class_for(id));
304 318 symbolOop mname = vmSymbols::symbol_at(name_for(id));
305 319 symbolOop msig = vmSymbols::symbol_at(signature_for(id));
306 320 if (cname == NULL || mname == NULL || msig == NULL) return NULL;
307 321 klassOop k = SystemDictionary::find_well_known_klass(cname);
308 322 if (k == NULL) return NULL;
309 323 return instanceKlass::cast(k)->find_method(mname, msig);
310 324 }
311 325
312 326
313 327 #define VM_INTRINSIC_INITIALIZE(id, klass, name, sig, flags) #id "\0"
314 328 static const char* vm_intrinsic_name_bodies =
315 329 VM_INTRINSICS_DO(VM_INTRINSIC_INITIALIZE,
316 330 VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE);
317 331
318 332 static const char* vm_intrinsic_name_table[vmIntrinsics::ID_LIMIT];
319 333
320 334 const char* vmIntrinsics::name_at(vmIntrinsics::ID id) {
321 335 const char** nt = &vm_intrinsic_name_table[0];
322 336 if (nt[_none] == NULL) {
323 337 char* string = (char*) &vm_intrinsic_name_bodies[0];
324 338 for (int index = FIRST_ID; index < ID_LIMIT; index++) {
325 339 nt[index] = string;
326 340 string += strlen(string); // skip string body
327 341 string += 1; // skip trailing null
328 342 }
329 343 assert(!strcmp(nt[_hashCode], "_hashCode"), "lined up");
330 344 nt[_none] = "_none";
331 345 }
332 346 if ((uint)id < (uint)ID_LIMIT)
333 347 return vm_intrinsic_name_table[(uint)id];
334 348 else
335 349 return "(unknown intrinsic)";
336 350 }
337 351
338 352 // These are flag-matching functions:
339 353 inline bool match_F_R(jshort flags) {
340 354 const int req = 0;
341 355 const int neg = JVM_ACC_STATIC | JVM_ACC_SYNCHRONIZED;
342 356 return (flags & (req | neg)) == req;
343 357 }
344 358 inline bool match_F_RN(jshort flags) {
345 359 const int req = JVM_ACC_NATIVE;
346 360 const int neg = JVM_ACC_STATIC | JVM_ACC_SYNCHRONIZED;
347 361 return (flags & (req | neg)) == req;
348 362 }
349 363 inline bool match_F_S(jshort flags) {
350 364 const int req = JVM_ACC_STATIC;
351 365 const int neg = JVM_ACC_SYNCHRONIZED;
352 366 return (flags & (req | neg)) == req;
353 367 }
354 368 inline bool match_F_SN(jshort flags) {
355 369 const int req = JVM_ACC_STATIC | JVM_ACC_NATIVE;
356 370 const int neg = JVM_ACC_SYNCHRONIZED;
357 371 return (flags & (req | neg)) == req;
358 372 }
359 373 inline bool match_F_RNY(jshort flags) {
360 374 const int req = JVM_ACC_NATIVE | JVM_ACC_SYNCHRONIZED;
361 375 const int neg = JVM_ACC_STATIC;
362 376 return (flags & (req | neg)) == req;
363 377 }
364 378
365 379 // These are for forming case labels:
366 380 #define ID3(x, y, z) (( jint)(z) + \
367 381 ((jint)(y) << vmSymbols::log2_SID_LIMIT) + \
368 382 ((jint)(x) << (2*vmSymbols::log2_SID_LIMIT)) )
369 383 #define SID_ENUM(n) vmSymbols::VM_SYMBOL_ENUM_NAME(n)
370 384
371 385 vmIntrinsics::ID vmIntrinsics::find_id(vmSymbols::SID holder,
372 386 vmSymbols::SID name,
373 387 vmSymbols::SID sig,
374 388 jshort flags) {
375 389 assert((int)vmSymbols::SID_LIMIT <= (1<<vmSymbols::log2_SID_LIMIT), "must fit");
376 390
377 391 // Let the C compiler build the decision tree.
378 392
379 393 #define VM_INTRINSIC_CASE(id, klass, name, sig, fcode) \
380 394 case ID3(SID_ENUM(klass), SID_ENUM(name), SID_ENUM(sig)): \
381 395 if (!match_##fcode(flags)) break; \
382 396 return id;
383 397
384 398 switch (ID3(holder, name, sig)) {
385 399 VM_INTRINSICS_DO(VM_INTRINSIC_CASE,
386 400 VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE);
387 401 }
388 402 return vmIntrinsics::_none;
389 403
390 404 #undef VM_INTRINSIC_CASE
391 405 }
392 406
393 407
394 408 const char* vmIntrinsics::short_name_as_C_string(vmIntrinsics::ID id, char* buf, int buflen) {
395 409 const char* str = name_at(id);
396 410 #ifndef PRODUCT
397 411 const char* kname = vmSymbols::name_for(class_for(id));
398 412 const char* mname = vmSymbols::name_for(name_for(id));
399 413 const char* sname = vmSymbols::name_for(signature_for(id));
400 414 const char* fname = "";
401 415 switch (flags_for(id)) {
402 416 case F_RN: fname = "native "; break;
403 417 case F_SN: fname = "native static "; break;
404 418 case F_S: fname = "static "; break;
405 419 case F_RNY:fname = "native synchronized "; break;
406 420 }
407 421 const char* kptr = strrchr(kname, '/');
408 422 if (kptr != NULL) kname = kptr + 1;
409 423 int len = jio_snprintf(buf, buflen, "%s: %s%s.%s%s",
410 424 str, fname, kname, mname, sname);
411 425 if (len < buflen)
412 426 str = buf;
413 427 #endif //PRODUCT
414 428 return str;
415 429 }
416 430
417 431
418 432 // These are for friendly printouts of intrinsics.
419 433
420 434 #define log2_FLAG_LIMIT 4
421 435 #define ID4(x, y, z, f) ((ID3(x, y, z) << log2_FLAG_LIMIT) | (int)(f))
422 436
423 437 #define VM_INTRINSIC_INFO(ignore_id, klass, name, sig, fcode) \
424 438 ID4(SID_ENUM(klass), SID_ENUM(name), SID_ENUM(sig), vmIntrinsics::fcode),
425 439
426 440 static const jint intrinsic_info_array[vmIntrinsics::ID_LIMIT+1] = {
427 441 0, VM_INTRINSICS_DO(VM_INTRINSIC_INFO,
428 442 VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE)
429 443 0
430 444 };
431 445
432 446 inline jint intrinsic_info(vmIntrinsics::ID id) {
433 447 return intrinsic_info_array[vmIntrinsics::ID_from((int)id)];
434 448 }
435 449
436 450 vmSymbols::SID vmIntrinsics::class_for(vmIntrinsics::ID id) {
437 451 jint info = intrinsic_info(id);
438 452 int shift = 2*vmSymbols::log2_SID_LIMIT + log2_FLAG_LIMIT, mask = right_n_bits(vmSymbols::log2_SID_LIMIT);
439 453 assert(((ID4(1,3,5,7) >> shift) & mask) == 1, "");
440 454 return vmSymbols::SID( (info >> shift) & mask );
441 455 }
442 456
443 457 vmSymbols::SID vmIntrinsics::name_for(vmIntrinsics::ID id) {
444 458 jint info = intrinsic_info(id);
445 459 int shift = vmSymbols::log2_SID_LIMIT + log2_FLAG_LIMIT, mask = right_n_bits(vmSymbols::log2_SID_LIMIT);
446 460 assert(((ID4(1,3,5,7) >> shift) & mask) == 3, "");
447 461 return vmSymbols::SID( (info >> shift) & mask );
448 462 }
449 463
450 464 vmSymbols::SID vmIntrinsics::signature_for(vmIntrinsics::ID id) {
451 465 jint info = intrinsic_info(id);
452 466 int shift = log2_FLAG_LIMIT, mask = right_n_bits(vmSymbols::log2_SID_LIMIT);
453 467 assert(((ID4(1,3,5,7) >> shift) & mask) == 5, "");
454 468 return vmSymbols::SID( (info >> shift) & mask );
455 469 }
456 470
457 471 vmIntrinsics::Flags vmIntrinsics::flags_for(vmIntrinsics::ID id) {
458 472 jint info = intrinsic_info(id);
459 473 int shift = 0, mask = right_n_bits(log2_FLAG_LIMIT);
460 474 assert(((ID4(1,3,5,7) >> shift) & mask) == 7, "");
461 475 return Flags( (info >> shift) & mask );
462 476 }
463 477
464 478
465 479 #ifndef PRODUCT
466 480 // verify_method performs an extra check on a matched intrinsic method
467 481
468 482 static bool match_method(methodOop m, symbolOop n, symbolOop s) {
469 483 return (m->name() == n &&
470 484 m->signature() == s);
471 485 }
472 486
473 487 static vmIntrinsics::ID match_method_with_klass(methodOop m, symbolOop mk) {
474 488 #define VM_INTRINSIC_MATCH(id, klassname, namepart, sigpart, flags) \
475 489 { symbolOop k = vmSymbols::klassname(); \
476 490 if (mk == k) { \
477 491 symbolOop n = vmSymbols::namepart(); \
478 492 symbolOop s = vmSymbols::sigpart(); \
479 493 if (match_method(m, n, s)) \
480 494 return vmIntrinsics::id; \
481 495 } }
482 496 VM_INTRINSICS_DO(VM_INTRINSIC_MATCH,
483 497 VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE);
484 498 return vmIntrinsics::_none;
485 499 #undef VM_INTRINSIC_MATCH
486 500 }
487 501
488 502 void vmIntrinsics::verify_method(ID actual_id, methodOop m) {
489 503 symbolOop mk = Klass::cast(m->method_holder())->name();
490 504 ID declared_id = match_method_with_klass(m, mk);
491 505
492 506 if (declared_id == actual_id) return; // success
493 507
494 508 if (declared_id == _none && actual_id != _none && mk == vmSymbols::java_lang_StrictMath()) {
495 509 // Here are a few special cases in StrictMath not declared in vmSymbols.hpp.
496 510 switch (actual_id) {
497 511 case _min:
498 512 case _max:
499 513 case _dsqrt:
500 514 declared_id = match_method_with_klass(m, vmSymbols::java_lang_Math());
501 515 if (declared_id == actual_id) return; // acceptable alias
502 516 break;
503 517 }
504 518 }
505 519
506 520 const char* declared_name = name_at(declared_id);
507 521 const char* actual_name = name_at(actual_id);
508 522 methodHandle mh = m;
509 523 m = NULL;
510 524 ttyLocker ttyl;
511 525 if (xtty != NULL) {
512 526 xtty->begin_elem("intrinsic_misdeclared actual='%s' declared='%s'",
513 527 actual_name, declared_name);
514 528 xtty->method(mh);
515 529 xtty->end_elem("");
516 530 }
517 531 if (PrintMiscellaneous && (WizardMode || Verbose)) {
518 532 tty->print_cr("*** misidentified method; %s(%d) should be %s(%d):",
519 533 declared_name, declared_id, actual_name, actual_id);
520 534 mh()->print_short_name(tty);
521 535 tty->cr();
522 536 }
523 537 }
524 538 #endif //PRODUCT
↓ open down ↓ |
214 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX