static vmIntrinsics::ID match_method_with_klass(methodOop m, Symbol* mk) { #define VM_INTRINSIC_MATCH(id, klassname, namepart, sigpart, flags) \ { Symbol* k = vmSymbols::klassname(); \ if (mk == k) { \ Symbol* n = vmSymbols::namepart(); \ Symbol* s = vmSymbols::sigpart(); \ if (match_method(m, n, s)) \ return vmIntrinsics::id; \ } } VM_INTRINSICS_DO(VM_INTRINSIC_MATCH, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE); return vmIntrinsics::_none; #undef VM_INTRINSIC_MATCH }
vmIntrinsics::ID vmIntrinsics::find_id_impl(vmSymbols::SID holder, vmSymbols::SID name, vmSymbols::SID sig, jshort flags) { assert((int)vmSymbols::SID_LIMIT <= (1<<vmSymbols::log2_SID_LIMIT), "must fit"); // Let the C compiler build the decision tree. #define VM_INTRINSIC_CASE(id, klass, name, sig, fcode) \ case ID3(SID_ENUM(klass), SID_ENUM(name), SID_ENUM(sig)): \ if (!match_##fcode(flags)) break; \ return id; switch (ID3(holder, name, sig)) { VM_INTRINSICS_DO(VM_INTRINSIC_CASE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE); } return vmIntrinsics::_none; #undef VM_INTRINSIC_CASE }
methodOop vmIntrinsics::method_for(vmIntrinsics::ID id) { if (id == _none) return NULL; Symbol* cname = vmSymbols::symbol_at(class_for(id)); Symbol* mname = vmSymbols::symbol_at(name_for(id)); Symbol* msig = vmSymbols::symbol_at(signature_for(id)); if (cname == NULL || mname == NULL || msig == NULL) return NULL; klassOop k = SystemDictionary::find_well_known_klass(cname); if (k == NULL) return NULL; return instanceKlass::cast(k)->find_method(mname, msig); } #define VM_INTRINSIC_INITIALIZE(id, klass, name, sig, flags) #id "\0" static const char* vm_intrinsic_name_bodies = VM_INTRINSICS_DO(VM_INTRINSIC_INITIALIZE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE); static const char* vm_intrinsic_name_table[vmIntrinsics::ID_LIMIT]; const char* vmIntrinsics::name_at(vmIntrinsics::ID id) { const char** nt = &vm_intrinsic_name_table[0]; if (nt[_none] == NULL) { char* string = (char*) &vm_intrinsic_name_bodies[0]; for (int index = FIRST_ID; index < ID_LIMIT; index++) { nt[index] = string; string += strlen(string); // skip string body string += 1; // skip trailing null } assert(!strcmp(nt[_hashCode], "_hashCode"), "lined up"); nt[_none] = "_none"; }
// ciMethod // // This class represents a methodOop in the HotSpot virtual // machine. class ciMethod : public ciObject { friend class CompileBroker; CI_PACKAGE_ACCESS friend class ciEnv; friend class ciExceptionHandlerStream; public: #define VM_INTRINSIC_ENUM(id, klass, name, sig) id, enum IntrinsicId { _none = 0, // not an intrinsic (default answer) VM_INTRINSICS_DO(VM_INTRINSIC_ENUM) _vm_intrinsics_terminating_enum }; #undef VM_INTRINSIC_ENUM private: // General method information. ciFlags _flags; ciSymbol* _name; ciInstanceKlass* _holder; ciSignature* _signature; ciMethodData* _method_data; // Code attributes. int _code_size; int _max_stack;