src/share/vm/classfile/vmSymbols.cpp

Fri, 27 Feb 2009 13:27:09 -0800

author
twisti
date
Fri, 27 Feb 2009 13:27:09 -0800
changeset 1040
98cb887364d3
parent 631
d1605aabd0a1
child 1515
7c57aead6d3e
permissions
-rw-r--r--

6810672: Comment typos
Summary: I have collected some typos I have found while looking at the code.
Reviewed-by: kvn, never

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

mercurial