void SICompiler::initialize() { assert(theSIC == NULL, "shouldn't have but one compiler at a time"); theSIC = lastSIC = this; theAssembler = new Assembler(SICInstructionsSize, SICInstructionsSize / 2, PrintSICCompiledCode, true); stackLocCount = argCount = 0; countID = 0; nodeGen = new NodeGen(L, send_desc, diLink); topScope = NULL; splitSig = NULL; bbIterator = new BBIterator; /* theAllocator = */ new SICAllocator(); if (theRecompilation && theRecompilation->recompileeVScopes) { vscopes = theRecompilation->recompileeVScopes; } else { vscopes = NULL; } if (baseLookupType(L->lookupType()) == NormalBaseLookupType) { // ignore the receiver static bit (same nmethod covers both cases) L->clearReceiverStatic(); } dispatchToCode(); SScope::currentScopeID = 0; ncodes = 0; rec = new ScopeDescRecorder(SICScopesSize, SICPCsSize); initTopScope(); initLimits(); initializeForPlatform(); }
Lookup::Result* Lookup::findSlotsIn( oop_t rcvr, oop_t selector, LookupType lt ) { static bool reentered = false; if (reentered) fatal("reentered"); reentered = true; static Lookup lp; lp.init(selector, lt); if (baseLookupType(lt) == ResendBaseLookupType) lp.findInParentsOf(rcvr, MapObj::from(mapOop(rcvr))); else lp.findInObject(rcvr); reentered = false; return &lp.result; }
cacheProbingLookup::cacheProbingLookup(oop rcvr, oop sel, oop dgt, oop smh_or_map, abstract_vframe* sendingVf, sendDesc *sd, DIDesc *dc, bool debug, bool canReuseNM ) : compilingLookup( rcvr, sel, dgt, smh_or_map, sendingVf, sd, dc, debug, canReuseNM) { // clear bit; nmethod will be used for other receivers if (baseLookupType(lookupType()) == NormalBaseLookupType) clearReceiverStatic(); }
bool NMethodLookupKey::verify() { bool flag = true; if (!oop(receiverMapOop())->verify_oop()) { lprintf("\tin receiverMap of NMethodLookupKey 0x%lx\n", this); flag = false; } else if (!receiverMapOop()->is_map()) { error1("receiverMapOop() 0x%lx isn't a map", receiverMapOop()); flag = false; } if ( methodHolder_or_map() != MH_TBD && !methodHolder_or_map()->verify_oop()) { lprintf("\tin methodHolder of NMethodLookupKey 0x%lx\n", this); flag = false; } if (selector) { if (!selector->verify_oop()) { lprintf("\tin selector of NMethodLookupKey 0x%lx\n", this); flag = false; /* uncommon but legal } else if (!selector->is_string()) { lprintf("warning: selector "); selector->print_oop(); lprintf(" isn't a string\n"); flag = false; */ } } if (delegatee) { if (!delegatee->verify_oop()) { lprintf("\tin delegatee of NMethodLookupKey 0x%lx\n", this); flag = false; } else { BaseLookupType l = baseLookupType(lookupType); if (l == DirectedResendBaseLookupType && ! delegatee->is_string()) { error1("delegatee 0x%lx isn't a string", delegatee); flag = false; } } } return flag; }
oop_t Lookup::messageTypeForLookupError(LookupType lookupType) { // todo optimize time: put these strings in The. -- Adam, 5/06 switch (baseLookupType(lookupType)) { case NormalBaseLookupType: if (isImplicitSelfLookupType(lookupType)) return StringObj::intern("implicitSelf"); else return StringObj::intern("normal"); case ResendBaseLookupType: return StringObj::intern("undirectedResend"); case DirectedResendBaseLookupType: return StringObj::intern("directedResend"); case DelegatedBaseLookupType: return StringObj::intern("delegated"); default: fatal("should not reach here"); return badOop; } }
bool sendDesc::verify() { if (isPrimCall()) return true; LookupType l= lookupType(); bool flag= checkLookupTypeAndEntryPoint(); if (isPerformLookupType(l)) { if (arg_count() < 0 || arg_count() > 100) { error2("sendDesc %#lx arg count %ld is invalid", this, arg_count()); flag = false; } } else { if (! oop(selector())->verify_oop()) { flag = false; } else if (! selector()->is_string()) { error1("sendDesc %#lx selector isn't a string", this); flag = false; } nmethod* nm = target(); if (nm == NULL) { CountStub* cs = countStub(); if (cs) nm = cs->target(); } if (nm == NULL) { CacheStub* cs = pic(); if (cs) { nm= cs->get_method(0); oop sel= nm->key.selector; for (fint i= 1; i < cs->arity(); ++i) if (cs->get_method(i)->key.selector != sel) error2("sendDesc %#lx: selector != PIC case %d selector", this, i); } } if (nm && nm->key.selector != selector()) error1("sendDesc %#lx: selector != target nmethod's selector", this); } if (l & DelegateeStaticBit) { if (! delegatee()->verify_oop()) { flag = false; } else if (baseLookupType(l) == DirectedResendLookupType && ! delegatee()->is_string()) { error1("sendDesc %#lx delegatee isn't a string", this); flag = false; } } if (!dependency()->verify_list_integrity()) { lprintf("\tof sendDesc %#lx\n", this); flag = false; } if (pic()) { if (dependency()->next != dependency()->prev) error1("sendDesc %#lx: more than one elem in dependency chain", this); pic()->verify(); } else { CountStub *cs= countStub(); if (cs == NULL) { if (isCounting() && jump_addr() != lookupRoutine()) error1("sendDesc %#lx: doesn't have countStub but is counting", this); } else { if (!isCounting() && !cs->isAgingStub()) error1("sendDesc %#lx: has countStub but is not counting", this); if (dependency()->next != dependency()->prev) error1("sendDesc %#lx: more than one elem in dependency chain", this); countStub()->verify2(NULL); } } return flag; }
char* lookupTypeName(LookupType l) { char* name = NEW_RESOURCE_ARRAY(char, 80); switch (l) { case NormalLookupType: strcpy(name, "NormalLookup"); break; case StaticNormalLookupType: strcpy(name, "StaticNormalLookup"); break; case ImplicitSelfLookupType: strcpy(name, "ImplicitSelfLookup"); break; case ResendLookupType: strcpy(name, "ResendLookup"); break; case DirectedResendLookupType: strcpy(name, "DirectedResendLookup"); break; case NormalPerformType: strcpy(name, "NormalPerform"); break; case ResendPerformType: strcpy(name, "ResendPerform"); break; case DelegatedPerformType: strcpy(name, "DelegatedPerform"); break; default: char* baseName; switch (baseLookupType(l)) { case NormalBaseLookupType: baseName ="NormalBaseLookup "; break; case ResendBaseLookupType: baseName ="ResendBaseLookup "; break; case DirectedResendBaseLookupType: baseName ="DirectedResendBaseLookup "; break; case DelegatedBaseLookupType: baseName ="DelegatedBaseLookup "; break; default: fatal("unexpected base lookup type"); } strcpy(name, baseName); if (l & SelectorStaticBit) { strcat(name, "<selector static> "); } if (l & DelegateeStaticBit) { strcat(name, "<delegatee static> "); } if (l & ReceiverStaticBit) { strcat(name, "<receiver map static> "); } } bool hasFlag = false; switch (countType(l)) { case NonCounting: break; case Counting: addFlag(hasFlag, name, "counting "); break; case Comparing: addFlag(hasFlag, name, "comparing "); break; default: fatal1("invalid count type %ld", countType(l)); } if (isSet(l, DirtySendBit)) addFlag(hasFlag, name, "dirty "); if (isSet(l, OptimizedSendBit)) addFlag(hasFlag, name, "optimized "); if (isSet(l, UninlinableSendBit)) addFlag(hasFlag, name, "uninlinable "); if (hasFlag) strcat(name, "}"); return name; }