vmSymbols.cpp revision 5776:de6a9e811145
160107Sobrien/*
22786Ssos * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
32786Ssos * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
42786Ssos *
52786Ssos * This code is free software; you can redistribute it and/or modify it
62786Ssos * under the terms of the GNU General Public License version 2 only, as
72786Ssos * published by the Free Software Foundation.
82786Ssos *
96851Ssos * This code is distributed in the hope that it will be useful, but WITHOUT
10270114Sse * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11270310Sse * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
122786Ssos * version 2 for more details (a copy is included in the LICENSE file that
132786Ssos * accompanied this code).
142786Ssos *
152786Ssos * You should have received a copy of the GNU General Public License version
162786Ssos * 2 along with this work; if not, write to the Free Software Foundation,
172786Ssos * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
182786Ssos *
192786Ssos * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
207420Ssos * or visit www.oracle.com if you need additional information or have any
214686Sache * questions.
222786Ssos *
232786Ssos */
24270114Sse
252786Ssos#include "precompiled.hpp"
262786Ssos#include "classfile/vmSymbols.hpp"
272786Ssos#include "memory/oopFactory.hpp"
282786Ssos#include "oops/oop.inline.hpp"
292786Ssos#include "runtime/handles.inline.hpp"
302786Ssos#include "utilities/xmlstream.hpp"
312786Ssos
32270114Sse
332786SsosSymbol* vmSymbols::_symbols[vmSymbols::SID_LIMIT];
342786Ssos
352786SsosSymbol* vmSymbols::_type_signatures[T_VOID+1] = { NULL /*, NULL...*/ };
362786Ssos
372786Ssosinline int compare_symbol(Symbol* a, Symbol* b) {
382786Ssos  if (a == b)  return 0;
392786Ssos  // follow the natural address order:
402786Ssos  return (address)a > (address)b ? +1 : -1;
412786Ssos}
422786Ssos
432786Ssosstatic vmSymbols::SID vm_symbol_index[vmSymbols::SID_LIMIT];
442786Ssosextern "C" {
45270114Sse  static int compare_vmsymbol_sid(const void* void_a, const void* void_b) {
46270114Sse    Symbol* a = vmSymbols::symbol_at(*((vmSymbols::SID*) void_a));
47270310Sse    Symbol* b = vmSymbols::symbol_at(*((vmSymbols::SID*) void_b));
482786Ssos    return compare_symbol(a, b);
492786Ssos  }
502786Ssos}
512786Ssos
522786Ssos#ifdef ASSERT
532786Ssos#define VM_SYMBOL_ENUM_NAME_BODY(name, string) #name "\0"
542786Ssosstatic const char* vm_symbol_enum_names =
552786Ssos  VM_SYMBOLS_DO(VM_SYMBOL_ENUM_NAME_BODY, VM_ALIAS_IGNORE)
562786Ssos  "\0";
572786Ssosstatic const char* vm_symbol_enum_name(vmSymbols::SID sid) {
582786Ssos  const char* string = &vm_symbol_enum_names[0];
5938140Syokota  int skip = (int)sid - (int)vmSymbols::FIRST_SID;
602786Ssos  for (; skip != 0; skip--) {
612786Ssos    size_t skiplen = strlen(string);
622786Ssos    if (skiplen == 0)  return "<unknown>";  // overflow
6332822Syokota    string += skiplen+1;
642786Ssos  }
652786Ssos  return string;
662786Ssos}
672786Ssos#endif //ASSERT
682786Ssos
692786Ssos// Put all the VM symbol strings in one place.
702786Ssos// Makes for a more compact libjvm.
712786Ssos#define VM_SYMBOL_BODY(name, string) string "\0"
722786Ssosstatic const char* vm_symbol_bodies = VM_SYMBOLS_DO(VM_SYMBOL_BODY, VM_ALIAS_IGNORE);
732786Ssos
742786Ssosvoid vmSymbols::initialize(TRAPS) {
752786Ssos  assert((int)SID_LIMIT <= (1<<log2_SID_LIMIT), "must fit in this bitfield");
762786Ssos  assert((int)SID_LIMIT*5 > (1<<log2_SID_LIMIT), "make the bitfield smaller, please");
772786Ssos  assert(vmIntrinsics::FLAG_LIMIT <= (1 << vmIntrinsics::log2_FLAG_LIMIT), "must fit in this bitfield");
782786Ssos
792786Ssos  if (!UseSharedSpaces) {
802786Ssos    const char* string = &vm_symbol_bodies[0];
812786Ssos    for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
825994Ssos      Symbol* sym = SymbolTable::new_permanent_symbol(string, CHECK);
832786Ssos      _symbols[index] = sym;
842786Ssos      string += strlen(string); // skip string body
852786Ssos      string += 1;              // skip trailing null
862786Ssos    }
872786Ssos
882786Ssos    _type_signatures[T_BYTE]    = byte_signature();
896045Ssos    _type_signatures[T_CHAR]    = char_signature();
902786Ssos    _type_signatures[T_DOUBLE]  = double_signature();
912786Ssos    _type_signatures[T_FLOAT]   = float_signature();
922786Ssos    _type_signatures[T_INT]     = int_signature();
932786Ssos    _type_signatures[T_LONG]    = long_signature();
942786Ssos    _type_signatures[T_SHORT]   = short_signature();
9518194Ssos    _type_signatures[T_BOOLEAN] = bool_signature();
962786Ssos    _type_signatures[T_VOID]    = void_signature();
972786Ssos    // no single signatures for T_OBJECT or T_ARRAY
9874119Sache  }
992786Ssos
1002786Ssos#ifdef ASSERT
1012786Ssos  // Check for duplicates:
1022786Ssos  for (int i1 = (int)FIRST_SID; i1 < (int)SID_LIMIT; i1++) {
1032786Ssos    Symbol* sym = symbol_at((SID)i1);
1042786Ssos    for (int i2 = (int)FIRST_SID; i2 < i1; i2++) {
1052786Ssos      if (symbol_at((SID)i2) == sym) {
1062786Ssos        tty->print("*** Duplicate VM symbol SIDs %s(%d) and %s(%d): \"",
1072786Ssos                   vm_symbol_enum_name((SID)i2), i2,
10874119Sache                   vm_symbol_enum_name((SID)i1), i1);
109270114Sse        sym->print_symbol_on(tty);
11043334Syokota        tty->print_cr("\"");
11143334Syokota      }
11243334Syokota    }
11343334Syokota  }
11443334Syokota#endif //ASSERT
115
116  // Create an index for find_id:
117  {
118    for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
119      vm_symbol_index[index] = (SID)index;
120    }
121    int num_sids = SID_LIMIT-FIRST_SID;
122    qsort(&vm_symbol_index[FIRST_SID], num_sids, sizeof(vm_symbol_index[0]),
123          compare_vmsymbol_sid);
124  }
125
126#ifdef ASSERT
127  {
128    // Spot-check correspondence between strings, symbols, and enums:
129    assert(_symbols[NO_SID] == NULL, "must be");
130    const char* str = "java/lang/Object";
131    TempNewSymbol jlo = SymbolTable::new_permanent_symbol(str, CHECK);
132    assert(strncmp(str, (char*)jlo->base(), jlo->utf8_length()) == 0, "");
133    assert(jlo == java_lang_Object(), "");
134    SID sid = VM_SYMBOL_ENUM_NAME(java_lang_Object);
135    assert(find_sid(jlo) == sid, "");
136    assert(symbol_at(sid) == jlo, "");
137
138    // Make sure find_sid produces the right answer in each case.
139    for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
140      Symbol* sym = symbol_at((SID)index);
141      sid = find_sid(sym);
142      assert(sid == (SID)index, "symbol index works");
143      // Note:  If there are duplicates, this assert will fail.
144      // A "Duplicate VM symbol" message will have already been printed.
145    }
146
147    // The string "format" happens (at the moment) not to be a vmSymbol,
148    // though it is a method name in java.lang.String.
149    str = "format";
150    TempNewSymbol fmt = SymbolTable::new_permanent_symbol(str, CHECK);
151    sid = find_sid(fmt);
152    assert(sid == NO_SID, "symbol index works (negative test)");
153  }
154#endif
155}
156
157
158#ifndef PRODUCT
159const char* vmSymbols::name_for(vmSymbols::SID sid) {
160  if (sid == NO_SID)
161    return "NO_SID";
162  const char* string = &vm_symbol_bodies[0];
163  for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
164    if (index == (int)sid)
165      return string;
166    string += strlen(string); // skip string body
167    string += 1;              // skip trailing null
168  }
169  return "BAD_SID";
170}
171#endif
172
173
174
175void vmSymbols::symbols_do(SymbolClosure* f) {
176  for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
177    f->do_symbol(&_symbols[index]);
178  }
179  for (int i = 0; i < T_VOID+1; i++) {
180    f->do_symbol(&_type_signatures[i]);
181  }
182}
183
184void vmSymbols::serialize(SerializeClosure* soc) {
185  soc->do_region((u_char*)&_symbols[FIRST_SID],
186                 (SID_LIMIT - FIRST_SID) * sizeof(_symbols[0]));
187  soc->do_region((u_char*)_type_signatures, sizeof(_type_signatures));
188}
189
190
191BasicType vmSymbols::signature_type(Symbol* s) {
192  assert(s != NULL, "checking");
193  for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
194    if (s == _type_signatures[i]) {
195      return (BasicType)i;
196    }
197  }
198  return T_OBJECT;
199}
200
201
202static int mid_hint = (int)vmSymbols::FIRST_SID+1;
203
204#ifndef PRODUCT
205static int find_sid_calls, find_sid_probes;
206// (Typical counts are calls=7000 and probes=17000.)
207#endif
208
209vmSymbols::SID vmSymbols::find_sid(Symbol* symbol) {
210  // Handle the majority of misses by a bounds check.
211  // Then, use a binary search over the index.
212  // Expected trip count is less than log2_SID_LIMIT, about eight.
213  // This is slow but acceptable, given that calls are not
214  // dynamically common.  (Method*::intrinsic_id has a cache.)
215  NOT_PRODUCT(find_sid_calls++);
216  int min = (int)FIRST_SID, max = (int)SID_LIMIT - 1;
217  SID sid = NO_SID, sid1;
218  int cmp1;
219  sid1 = vm_symbol_index[min];
220  cmp1 = compare_symbol(symbol, symbol_at(sid1));
221  if (cmp1 <= 0) {              // before the first
222    if (cmp1 == 0)  sid = sid1;
223  } else {
224    sid1 = vm_symbol_index[max];
225    cmp1 = compare_symbol(symbol, symbol_at(sid1));
226    if (cmp1 >= 0) {            // after the last
227      if (cmp1 == 0)  sid = sid1;
228    } else {
229      // After checking the extremes, do a binary search.
230      ++min; --max;             // endpoints are done
231      int mid = mid_hint;       // start at previous success
232      while (max >= min) {
233        assert(mid >= min && mid <= max, "");
234        NOT_PRODUCT(find_sid_probes++);
235        sid1 = vm_symbol_index[mid];
236        cmp1 = compare_symbol(symbol, symbol_at(sid1));
237        if (cmp1 == 0) {
238          mid_hint = mid;
239          sid = sid1;
240          break;
241        }
242        if (cmp1 < 0)
243          max = mid - 1;        // symbol < symbol_at(sid)
244        else
245          min = mid + 1;
246
247        // Pick a new probe point:
248        mid = (max + min) / 2;
249      }
250    }
251  }
252
253#ifdef ASSERT
254  // Perform the exhaustive self-check the first 1000 calls,
255  // and every 100 calls thereafter.
256  static int find_sid_check_count = -2000;
257  if ((uint)++find_sid_check_count > (uint)100) {
258    if (find_sid_check_count > 0)  find_sid_check_count = 0;
259
260    // Make sure this is the right answer, using linear search.
261    // (We have already proven that there are no duplicates in the list.)
262    SID sid2 = NO_SID;
263    for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
264      Symbol* sym2 = symbol_at((SID)index);
265      if (sym2 == symbol) {
266        sid2 = (SID)index;
267        break;
268      }
269    }
270    // Unless it's a duplicate, assert that the sids are the same.
271    if (_symbols[sid] != _symbols[sid2]) {
272      assert(sid == sid2, "binary same as linear search");
273    }
274  }
275#endif //ASSERT
276
277  return sid;
278}
279
280vmSymbols::SID vmSymbols::find_sid(const char* symbol_name) {
281  Symbol* symbol = SymbolTable::probe(symbol_name, (int) strlen(symbol_name));
282  if (symbol == NULL)  return NO_SID;
283  return find_sid(symbol);
284}
285
286static vmIntrinsics::ID wrapper_intrinsic(BasicType type, bool unboxing) {
287#define TYPE2(type, unboxing) ((int)(type)*2 + ((unboxing) ? 1 : 0))
288  switch (TYPE2(type, unboxing)) {
289#define BASIC_TYPE_CASE(type, box, unbox) \
290    case TYPE2(type, false):  return vmIntrinsics::box; \
291    case TYPE2(type, true):   return vmIntrinsics::unbox
292    BASIC_TYPE_CASE(T_BOOLEAN, _Boolean_valueOf,   _booleanValue);
293    BASIC_TYPE_CASE(T_BYTE,    _Byte_valueOf,      _byteValue);
294    BASIC_TYPE_CASE(T_CHAR,    _Character_valueOf, _charValue);
295    BASIC_TYPE_CASE(T_SHORT,   _Short_valueOf,     _shortValue);
296    BASIC_TYPE_CASE(T_INT,     _Integer_valueOf,   _intValue);
297    BASIC_TYPE_CASE(T_LONG,    _Long_valueOf,      _longValue);
298    BASIC_TYPE_CASE(T_FLOAT,   _Float_valueOf,     _floatValue);
299    BASIC_TYPE_CASE(T_DOUBLE,  _Double_valueOf,    _doubleValue);
300#undef BASIC_TYPE_CASE
301  }
302#undef TYPE2
303  return vmIntrinsics::_none;
304}
305
306vmIntrinsics::ID vmIntrinsics::for_boxing(BasicType type) {
307  return wrapper_intrinsic(type, false);
308}
309vmIntrinsics::ID vmIntrinsics::for_unboxing(BasicType type) {
310  return wrapper_intrinsic(type, true);
311}
312
313vmIntrinsics::ID vmIntrinsics::for_raw_conversion(BasicType src, BasicType dest) {
314#define SRC_DEST(s,d) (((int)(s) << 4) + (int)(d))
315  switch (SRC_DEST(src, dest)) {
316  case SRC_DEST(T_INT, T_FLOAT):   return vmIntrinsics::_intBitsToFloat;
317  case SRC_DEST(T_FLOAT, T_INT):   return vmIntrinsics::_floatToRawIntBits;
318
319  case SRC_DEST(T_LONG, T_DOUBLE): return vmIntrinsics::_longBitsToDouble;
320  case SRC_DEST(T_DOUBLE, T_LONG): return vmIntrinsics::_doubleToRawLongBits;
321  }
322#undef SRC_DEST
323
324  return vmIntrinsics::_none;
325}
326
327
328#define VM_INTRINSIC_INITIALIZE(id, klass, name, sig, flags) #id "\0"
329static const char* vm_intrinsic_name_bodies =
330  VM_INTRINSICS_DO(VM_INTRINSIC_INITIALIZE,
331                   VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE);
332
333static const char* vm_intrinsic_name_table[vmIntrinsics::ID_LIMIT];
334
335const char* vmIntrinsics::name_at(vmIntrinsics::ID id) {
336  const char** nt = &vm_intrinsic_name_table[0];
337  if (nt[_none] == NULL) {
338    char* string = (char*) &vm_intrinsic_name_bodies[0];
339    for (int index = FIRST_ID; index < ID_LIMIT; index++) {
340      nt[index] = string;
341      string += strlen(string); // skip string body
342      string += 1;              // skip trailing null
343    }
344    assert(!strcmp(nt[_hashCode], "_hashCode"), "lined up");
345    nt[_none] = "_none";
346  }
347  if ((uint)id < (uint)ID_LIMIT)
348    return vm_intrinsic_name_table[(uint)id];
349  else
350    return "(unknown intrinsic)";
351}
352
353// These are flag-matching functions:
354inline bool match_F_R(jshort flags) {
355  const int req = 0;
356  const int neg = JVM_ACC_STATIC | JVM_ACC_SYNCHRONIZED;
357  return (flags & (req | neg)) == req;
358}
359inline bool match_F_Y(jshort flags) {
360  const int req = JVM_ACC_SYNCHRONIZED;
361  const int neg = JVM_ACC_STATIC;
362  return (flags & (req | neg)) == req;
363}
364inline bool match_F_RN(jshort flags) {
365  const int req = JVM_ACC_NATIVE;
366  const int neg = JVM_ACC_STATIC | JVM_ACC_SYNCHRONIZED;
367  return (flags & (req | neg)) == req;
368}
369inline bool match_F_S(jshort flags) {
370  const int req = JVM_ACC_STATIC;
371  const int neg = JVM_ACC_SYNCHRONIZED;
372  return (flags & (req | neg)) == req;
373}
374inline bool match_F_SN(jshort flags) {
375  const int req = JVM_ACC_STATIC | JVM_ACC_NATIVE;
376  const int neg = JVM_ACC_SYNCHRONIZED;
377  return (flags & (req | neg)) == req;
378}
379inline bool match_F_RNY(jshort flags) {
380  const int req = JVM_ACC_NATIVE | JVM_ACC_SYNCHRONIZED;
381  const int neg = JVM_ACC_STATIC;
382  return (flags & (req | neg)) == req;
383}
384
385// These are for forming case labels:
386#define ID3(x, y, z) (( jlong)(z) +                                  \
387                      ((jlong)(y) <<    vmSymbols::log2_SID_LIMIT) + \
388                      ((jlong)(x) << (2*vmSymbols::log2_SID_LIMIT))  )
389#define SID_ENUM(n) vmSymbols::VM_SYMBOL_ENUM_NAME(n)
390
391vmIntrinsics::ID vmIntrinsics::find_id_impl(vmSymbols::SID holder,
392                                            vmSymbols::SID name,
393                                            vmSymbols::SID sig,
394                                            jshort flags) {
395  assert((int)vmSymbols::SID_LIMIT <= (1<<vmSymbols::log2_SID_LIMIT), "must fit");
396
397  // Let the C compiler build the decision tree.
398
399#define VM_INTRINSIC_CASE(id, klass, name, sig, fcode) \
400  case ID3(SID_ENUM(klass), SID_ENUM(name), SID_ENUM(sig)): \
401    if (!match_##fcode(flags))  break; \
402    return id;
403
404  switch (ID3(holder, name, sig)) {
405    VM_INTRINSICS_DO(VM_INTRINSIC_CASE,
406                     VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE);
407  }
408  return vmIntrinsics::_none;
409
410#undef VM_INTRINSIC_CASE
411}
412
413
414const char* vmIntrinsics::short_name_as_C_string(vmIntrinsics::ID id, char* buf, int buflen) {
415  const char* str = name_at(id);
416#ifndef PRODUCT
417  const char* kname = vmSymbols::name_for(class_for(id));
418  const char* mname = vmSymbols::name_for(name_for(id));
419  const char* sname = vmSymbols::name_for(signature_for(id));
420  const char* fname = "";
421  switch (flags_for(id)) {
422  case F_Y:  fname = "synchronized ";  break;
423  case F_RN: fname = "native ";        break;
424  case F_SN: fname = "native static "; break;
425  case F_S:  fname = "static ";        break;
426  case F_RNY:fname = "native synchronized "; break;
427  }
428  const char* kptr = strrchr(kname, '/');
429  if (kptr != NULL)  kname = kptr + 1;
430  int len = jio_snprintf(buf, buflen, "%s: %s%s.%s%s",
431                         str, fname, kname, mname, sname);
432  if (len < buflen)
433    str = buf;
434#endif //PRODUCT
435  return str;
436}
437
438
439// These are to get information about intrinsics.
440
441#define ID4(x, y, z, f) ((ID3(x, y, z) << vmIntrinsics::log2_FLAG_LIMIT) | (jlong) (f))
442
443static const jlong intrinsic_info_array[vmIntrinsics::ID_LIMIT+1] = {
444#define VM_INTRINSIC_INFO(ignore_id, klass, name, sig, fcode) \
445  ID4(SID_ENUM(klass), SID_ENUM(name), SID_ENUM(sig), vmIntrinsics::fcode),
446
447  0, VM_INTRINSICS_DO(VM_INTRINSIC_INFO,
448                     VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE)
449    0
450#undef VM_INTRINSIC_INFO
451};
452
453inline jlong intrinsic_info(vmIntrinsics::ID id) {
454  return intrinsic_info_array[vmIntrinsics::ID_from((int)id)];
455}
456
457vmSymbols::SID vmIntrinsics::class_for(vmIntrinsics::ID id) {
458  jlong info = intrinsic_info(id);
459  int shift = 2*vmSymbols::log2_SID_LIMIT + log2_FLAG_LIMIT, mask = right_n_bits(vmSymbols::log2_SID_LIMIT);
460  assert(((ID4(1021,1022,1023,15) >> shift) & mask) == 1021, "");
461  return vmSymbols::SID( (info >> shift) & mask );
462}
463
464vmSymbols::SID vmIntrinsics::name_for(vmIntrinsics::ID id) {
465  jlong info = intrinsic_info(id);
466  int shift = vmSymbols::log2_SID_LIMIT + log2_FLAG_LIMIT, mask = right_n_bits(vmSymbols::log2_SID_LIMIT);
467  assert(((ID4(1021,1022,1023,15) >> shift) & mask) == 1022, "");
468  return vmSymbols::SID( (info >> shift) & mask );
469}
470
471vmSymbols::SID vmIntrinsics::signature_for(vmIntrinsics::ID id) {
472  jlong info = intrinsic_info(id);
473  int shift = log2_FLAG_LIMIT, mask = right_n_bits(vmSymbols::log2_SID_LIMIT);
474  assert(((ID4(1021,1022,1023,15) >> shift) & mask) == 1023, "");
475  return vmSymbols::SID( (info >> shift) & mask );
476}
477
478vmIntrinsics::Flags vmIntrinsics::flags_for(vmIntrinsics::ID id) {
479  jlong info = intrinsic_info(id);
480  int shift = 0, mask = right_n_bits(log2_FLAG_LIMIT);
481  assert(((ID4(1021,1022,1023,15) >> shift) & mask) == 15, "");
482  return Flags( (info >> shift) & mask );
483}
484
485
486#ifndef PRODUCT
487// verify_method performs an extra check on a matched intrinsic method
488
489static bool match_method(Method* m, Symbol* n, Symbol* s) {
490  return (m->name() == n &&
491          m->signature() == s);
492}
493
494static vmIntrinsics::ID match_method_with_klass(Method* m, Symbol* mk) {
495#define VM_INTRINSIC_MATCH(id, klassname, namepart, sigpart, flags) \
496  { Symbol* k = vmSymbols::klassname(); \
497    if (mk == k) { \
498      Symbol* n = vmSymbols::namepart(); \
499      Symbol* s = vmSymbols::sigpart(); \
500      if (match_method(m, n, s)) \
501        return vmIntrinsics::id; \
502    } }
503  VM_INTRINSICS_DO(VM_INTRINSIC_MATCH,
504                   VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE);
505  return vmIntrinsics::_none;
506#undef VM_INTRINSIC_MATCH
507}
508
509void vmIntrinsics::verify_method(ID actual_id, Method* m) {
510  Symbol* mk = m->method_holder()->name();
511  ID declared_id = match_method_with_klass(m, mk);
512
513  if (declared_id == actual_id)  return; // success
514
515  if (declared_id == _none && actual_id != _none && mk == vmSymbols::java_lang_StrictMath()) {
516    // Here are a few special cases in StrictMath not declared in vmSymbols.hpp.
517    switch (actual_id) {
518    case _min:
519    case _max:
520    case _dsqrt:
521      declared_id = match_method_with_klass(m, vmSymbols::java_lang_Math());
522      if (declared_id == actual_id)  return; // acceptable alias
523      break;
524    }
525  }
526
527  const char* declared_name = name_at(declared_id);
528  const char* actual_name   = name_at(actual_id);
529  methodHandle mh = m;
530  m = NULL;
531  ttyLocker ttyl;
532  if (xtty != NULL) {
533    xtty->begin_elem("intrinsic_misdeclared actual='%s' declared='%s'",
534                     actual_name, declared_name);
535    xtty->method(mh);
536    xtty->end_elem("");
537  }
538  if (PrintMiscellaneous && (WizardMode || Verbose)) {
539    tty->print_cr("*** misidentified method; %s(%d) should be %s(%d):",
540                  declared_name, declared_id, actual_name, actual_id);
541    mh()->print_short_name(tty);
542    tty->cr();
543  }
544}
545#endif //PRODUCT
546