char* nmethod::entryPointFor(sendDesc *sd) { if (sd->pic()) return verifiedEntryPoint(); bool rcvrStaticLookupType= sd->lookupType() & ReceiverStaticBit; if (!rcvrStaticLookupType) return insts(); return ReuseNICMethods && findNMethod(sd)->reusable() ? insts() : verifiedEntryPoint(); }
int main(int argc,char** argv){ open_file("Test.txt"); car_cour=getc(file); sym_suiv(); insts(); return 0; }
//instsaux : insts | epsilon void instaux(){ switch(sym_cour.code){ case DB_TOKEN : insts(); break; case FIN_TOKEN : sym_suiv(); break; default : Error(INST_ERR) ; break; } }
bool nmethod::encompasses(void* p) { return includes(p, this, this + 1) || includes(p, deps(), depsEnd()) || includes(p, insts(), instsEnd()) || includes(p, locs(), locsEnd()) || scopes->includes((ScopeDesc*) p) || includes(p, pcs(), pcsEnd()); }
void ComparingStub::set_recompile_addr(pc_t addr) { CountCodePattern* patt = CountStub::pattern[Comparing]; int32* p = (int32*)insts() + patt->recompile_offset; assert(isSetHi(p), "wrong pattern"); assert(isJump(p + 1), "strange instruction after setHi"); setSetHiImm(p , int32(addr)); setArithImm(p + 1, int32(addr)); }
pc_t ComparingStub::get_recompile_addr() { CountCodePattern* patt = CountStub::pattern[Comparing]; int32* p = (int32*)insts() + patt->recompile_offset; assert(isSetHi(p), "wrong pattern"); assert(isJump(p + 1), "strange instruction after setHi"); int32 val = getSetHiImm(p) + getArithImm(p + 1); return (pc_t)val; }
void ComparingStub::init(nmethod* nm) { CountCodePattern* patt = CountStub::pattern[Comparing]; int32* p = (int32*)insts(); set_recompile_addr(Memory->code->trapdoors->Recompile_stub_td()); set_count_addr(patt, (int32)&sendCounts[id()]); assert(isSetHi(p + patt->limit_sethi_offset), "wrong pattern"); fint limit = recompileLimit(nm->level()); setSetHiImm(p + patt->limit_sethi_offset, limit); }
pc_t CountStub::jump_addr() { CountCodePattern* patt = CountStub::pattern[countType()]; int32* p = (int32*)insts(); assert(isSetHi(p + patt->nm_sethi_offset), "wrong pattern"); assert(isJump (p + patt->nm_jmp_offset), "wrong pattern"); pc_t n = (pc_t)getSetHiImm(p + patt->nm_sethi_offset); n += getArithImm(p + patt->nm_jmp_offset); return n; }
void AgingStub::init(nmethod* nm) { CountCodePattern* patt = CountStub::pattern[Comparing]; set_recompile_addr(first_inst_addr(MakeOld_stub)); set_count_addr(patt, (int32)&sendCounts[id()]); int32* p = (int32*)(int32(insts()) + patt->limit_offset); assert(*p == patt->initial_limit, "???"); fint limit = nm->agingLimit(); *p = limit; set_count(1); }
void ComparingStub::init(nmethod* nm) { CountCodePattern* patt = CountStub::pattern[Comparing]; set_recompile_addr((pc_t)Recompile_stub); set_count_addr(patt, (int32)&sendCounts[id()]); int32* p = (int32*)(int32(insts()) + patt->limit_offset); assert(*p == patt->initial_limit, "???"); fint limit = recompileLimit(nm->level()); *p = limit; }
PcDesc* nmethod::containingPcDescOrNULL(char* pc) { // returns PcDesc that is closest one before or == to pc, or NULL if // no stored pcDesc exists // called a lot, so watch out for performance bugs assert(contains(pc), "nmethod must contain pc into frame"); int32 offset = pc - insts(); PcDesc* start = pcs(); PcDesc* end = pcsEnd() - 1; // Skim the cream if only one pcDesc is present. if (start == end) return start; assert(start < end, "no PcDescs to search"); if (start->pc > offset) // in prologue; caller has to deal with this return NULL; // binary search to find approx. location PcDesc* middle; int32 l = 0, h = end - start; do { // avoid pointer arithmetic -- gcc uses a division for PcDesc* - PcDesc* int32 m = l + (h - l) / 2; middle = &start[m]; if (middle->pc < offset) { l = m + 1; } else { h = m - 1; } } while (middle->pc != offset && l < h); // may not have found exact offset, so search for closest match while (middle->pc <= offset && middle < end ) middle++; while (middle->pc > offset && middle > start) middle--; assert(start <= middle && middle <= end, "should have found a pcDesc"); # if GENERATE_DEBUGGING_AIDS if (CheckAssertions) { PcDesc* d = pcs(); PcDesc* closest = d; for (; d <= end; d ++) { if (d->pc <= offset && (closest == NULL || closest->pc <= d->pc)) { closest = d; } } assert(closest == middle, "found different pcDesc"); } # endif return middle; }
void AgingStub::init(nmethod* nm) { CountCodePattern* patt = CountStub::pattern[Comparing]; int32* p = (int32*)insts(); set_recompile_addr(first_inst_addr(MakeOld_stub)); set_count_addr(patt, (int32)&sendCounts[id()]); fint limit = nm->agingLimit(); if (limit > 1023) { setSetHiImm(p + patt->limit_sethi_offset, limit); } else { // setHi would set to 0, so use an add instead p[patt->limit_sethi_offset] = add_inst; setArithImm(p + patt->limit_sethi_offset, limit); } set_count(1); }
void toAWR::instanceRead(void) { dbid->setCurrentIndex(0); try { QVariant vdbid = dbid->itemData(dbid->currentIndex()); if (vdbid.toStringList().size() < 2) return; QString dbids( vdbid.toStringList().at(0) ); QString insts( vdbid.toStringList().at(1) ); toQueryParams params; params << dbids << insts << QDate::currentDate().toString("yyyy:MM:dd") << QDate::currentDate().toString("yyyy:MM:dd"); //fsnap->setSelectionPolicy(toResultCombo::None); fsnap->refreshWithParams(params); tsnap->refreshWithParams(params); } TOCATCH; };
nmethod::nmethod(AbstractCompiler* c, bool generateDebugCode) { CHECK_VTBL_VALUE; _instsLen = roundTo(iLen, oopSize); _locsLen = ilLen; depsLen = dLen; // backpointer is just before deps depsAddr = (nmln*) ((char*)dAddr + sizeof(nmethod*)); *dBackLinkAddr() = this; // Copy the nmethodScopes scopeDescs generated by the ScopeDescRecorder // to the allocation area. c->scopeDescRecorder()->copyTo((VtblPtr_t*)sAddr, (int32)this); this->scopes = (nmethodScopes*) sAddr; oldCount = 0; flags.clear(); flags.isDebug = generateDebugCode; setCompiler(c->name()); flags.isUncommonRecompiled = currentProcess->isUncommon(); verifiedOffset = c->verifiedOffset(); diCheckOffset = c->diCheckOffset(); frameCreationOffset = c->frameCreationOffset(); rememberLink.init(); codeTableLink= NULL; diLink.init(c->diLink); if (diLink.notEmpty()) flags.isDI = true; flags.level = c->level(); if (flags.level >= MaxRecompilationLevels) { // added = zzzz warning1("setting invalid nmethod level %ld", flags.level); // fix this flags.level = 0; } flags.version = c->version(); if (c->nmName() == nm_nic && ((FCompiler*)c)->isImpure) makeImpureNIC(); key.set_from(c->L->key); check_store(); clear_frame_chain(); assert(c->frameSize() >= 0, "frame size cannot be negative"); frame_size = c->frameSize(); _incoming_arg_count = c->incoming_arg_count(); get_platform_specific_data(c); Assembler* instsA = c->instructions(); copy_bytes( instsA->instsStart, insts(), instsLen()); copy_words((int32*)instsA->locsStart, (int32*)locs(), ilLen/4); copy_words((int32*)depsStart, (int32*)deps(), depsLen/4); addrDesc *l, *lend; for (l = locs(), lend = locsEnd(); l < lend; l++) { l->initialShift(this, (char*)insts() - (char*)instsA->instsStart, 0); } char* bound = Memory->new_gen->boundary(); for (l = locs(), lend = locsEnd(); l < lend; l++) { if (l->isOop()) OopNCode::check_store(oop(l->referent(this)), bound); // cfront garbage else if (l->isSendDesc()) { l->asSendDesc(this)->dependency()->init(); } else if (l->isDIDesc()) { l->asDIDesc(this)->dependency()->init(); flags.isDI = true; } } for (nmln* d = deps(), *dend = depsEnd(); d < dend; d++) { d->relocate(); } MachineCache::flush_instruction_cache_range(insts(), instsEnd()); MachineCache::flush_instruction_cache_for_debugging(); if (this == (nmethod*)catchThisOne) warning("caught nmethod"); }
bool nmethod::verify() { bool r = true; ResourceMark rm; r &= OopNCode::verify2("nmethod"); if (insts() != (char*)(this + 1)) { error1("nmethod at 0x%lx has incorrect insts pointer", this); r = false; } if (!Memory->code->contains(this)) { error1("nmethod at 0x%lx not in zone", this); r = false; } if (!zoneLink.verify_list_integrity()) { lprintf("\tof zoneLink of nmethod 0x%lx\n", this); r = false; } { FOR_MY_CODETABLE_ENTRIES(e) if (e->nm != this) { error1("bad code table link for nmethod %#lx\n", this); r = false; } } bool isAligned = (frame_size & (frame_word_alignment-1)) == 0; if (!isAligned) { lprintf("nmethod at %#lx: frame size is not multiple of %d words\n", (long unsigned)this, frame_word_alignment); r = false; } if (codeTableLink != NULL) { nmethod *tableResult = isDebug() ? Memory->code->debugTable->lookup(key) : Memory->code->table ->lookup(key); if (tableResult != this) { error1("nmethod at %#lx: code table lookup failed", this); r = false; } } if (!key.verify()) { lprintf("\tof key of nmethod 0x%lx\n", this); r = false; } { FOR_MY_CODETABLE_ENTRIES(e) if (!e->key.verify()) { lprintf("\tof code table key %#lx of nmethod 0x%lx\n", (long unsigned)&e->key, (long unsigned)this); r = false; } } if (!linkedSends.verify_list_integrity()) { lprintf("\tof linkedSends of nmethod 0x%lx\n", this); r = false; } if (!diLink.verify_list_integrity()) { lprintf("\tof diLink of nmethod 0x%lx\n", this); r = false; } r &= scopes->verify(); for (PcDesc* p = pcs(); p < pcsEnd(); p++) { if (! p->verify(this)) { lprintf("\t\tin nmethod at %#lx (pcs)\n", this); r = false; } } // more checks in ncode::verify called above bool shouldBeDI = diLink.notEmpty(); for (addrDesc* l = locs(); l < locsEnd(); l++) { if (l->isDIDesc()) { shouldBeDI = true; } } if (shouldBeDI && !isDI()) { error1("nmethod %#lx should be marked isDI", this); r = false; } else if (!shouldBeDI && isDI()) { error1("nmethod %#lx should not be marked isDI", this); r = false; } if (! key.receiverMap()->is_block() ) { for (nmln* d = deps(); d < depsEnd(); d++) { if (! d->verify_list_integrity()) { lprintf("\tin nmethod at %#lx (deps)\n", this); r = false; } } } if (frame_chain != NoFrameChain) { error1("nmethod %#lx has non-zero frame chain value", this); r = false; } if (findNMethod( instsEnd() - oopSize) != this) { error1("findNMethod did not find this nmethod (%#lx)", this); r = false; } return r; }
void nmethod::flush() { BlockProfilerTicks bpt(exclude_nmethod_flush); CSect cs(profilerSemaphore); // for profiler # if GENERATE_DEBUGGING_AIDS if (CheckAssertions) { // for debugging if (nmethodFlushCount && --nmethodFlushCount == 0) warning("nmethodFlushCount"); if (this == (nmethod*)catchThisOne) warning("caught nmethod"); } # endif // EventMarker em("flushing nmethod %#lx %s", this, ""); if (PrintMethodFlushing) { ResourceMark m; char *compilerName = VMString[compiler()]->copy_null_terminated(); lprintf("*flushing %s%s%s-nmethod 0x%lx %d\t(", isZombie() ? "zombie " : "", isAccess() ? "access " : "", compilerName, (void*)(long unsigned)this, (void*)useCount[id]); printName(0, key.selector); lprintf(")"); } // always check the following - tests are really cheap if (flags.flushed) fatal1("nmethod %#lx already flushed", this); if (zone::frame_chain_nesting == 0) fatal("frames must be chained when flushing"); if (frame_chain != NoFrameChain) { // Can't remove an nmethod from deps chains now, because later // programming changes may need to invalidate it. // That is, don't unlink() now. // See comment for makeZombie routine. The comment above is the // "original comment" referred to there. // -- dmu 1/12/03 if (this == recompilee) { // nmethod is being recompiled; cannot really flush yet // em.event.args[1] = "(being recompiled)"; if (PrintMethodFlushing) { lprintf(" (being recompiled)\n"); } } else { // nmethod is currently being executed; cannot flush yet // em.event.args[1] = "(currently active)"; if (PrintMethodFlushing) { lprintf(" (currently active)\n"); } } makeZombie(false); } else { unlink(); // nmethod is not being executed; completely throw away // em.event.args[1] = "(not currently active)"; if (PrintMethodFlushing) { lprintf("\n"); } flatProfiler->flush((char*)this, instsEnd()); zoneLink.remove(); rememberLink.remove(); for (addrDesc* p = locs(), *pend = locsEnd(); p < pend; p++) { if (p->isSendDesc()) { p->asSendDesc(this)->unlink(); } else if (p->isDIDesc()) { p->asDIDesc(this)->dependency()->flush(); } } flags.flushed = 1; // to detect flushing errors # if GENERATE_DEBUGGING_AIDS if (CheckAssertions) { set_oops((oop*)insts(), instsLen()/oopSize, 0); // for quicker detection } # endif Memory->code->free_nmethod(this); } MachineCache::flush_instruction_cache_for_debugging(); }
pc_t CountStub::jump_addr() { CountCodePattern* patt = CountStub::pattern[countType()]; int32* p = (int32*)(int32(insts()) + patt->nmAddr_offset); return (pc_t) *p + int32(p) + sizeof(int32); }
void ComparingStub::set_recompile_addr(pc_t addr) { CountCodePattern* patt = CountStub::pattern[Comparing]; int32* p = (int32*)(int32(insts()) + patt->recompileStub_offset); *p = int32(addr) - int32(p) - sizeof(int32); }
char* instsEnd() const { return insts() + instsLen(); }
void nmethod::printCode() { ResourceMark m; // in case methods get printed from gdb print_code(this, (char*)insts(), (char*)instsEnd()); }
void nmethod::print() { ResourceMark rm; printIndent(); lprintf("(nmethod*)%#lx", this); if (scopes->root()->isDataAccessScope()) { lprintf(" (data access)"); } else if (scopes->root()->isDataAssignmentScope()) { lprintf(" (data assignment)"); } else { lprintf(" for method %#lx", method()); } lprintf(" { "); if (isYoung()) lprintf("YOUNG "); switch (compiler()) { case NIC: lprintf("NIC "); if (isImpureNIC()) lprintf("impure "); break; case SIC: lprintf("SIC level %ld ", level()); break; default: lprintf("!?!unknown compiler!?! "); break; } if (version()) lprintf("v%d ", version()); if (isDI()) lprintf("DI "); if (isZombie()) lprintf("zombie "); if (isInvalid()) lprintf("INVALID "); if (isDebug()) lprintf("DEBUG "); if (isToBeRecompiled()) lprintf("TBR "); if (isUncommon() || isUncommonRecompiled()) lprintf("UNCOMMON "); lprintf("}:\n"); lprintf( "incoming_arg_count = %d\n", incoming_arg_count() ); print_platform_specific_data(); Indent ++; key.print(); printIndent(); lprintf("code table link: %#lx\n", codeTableLink); printIndent(); lprintf("remember link: "); rememberLink.print(); lprintf("\n"); printIndent(); lprintf("linked sends: "); linkedSends.print(); lprintf("\n"); printIndent(); lprintf("di link: "); diLink.print(); lprintf("\n"); printIndent(); lprintf("instructions (%ld bytes): %#lx,%#lx/i / x/%ldi %#lx\n", instsLen(), insts(), instsEnd() - oopSize, instsLen() / oopSize, insts()); printIndent(); lprintf("p ((nmethod*)%#lx)->printCode() \n", this); scopes->print(); // printLocs(); // printDeps(); Indent --; }
bool contains(void* p) const { return (void*)insts() <= p && p < (void*)instsEnd(); }
void toAWR::execute(void) { try { //QString sql=Statement->text(); //toQList params=toParamGet::getParam(this,sql); //Result->query(sql,params); //Result->query(sql,toQList()); QVariant vdbid = dbid->itemData(dbid->currentIndex()); QString dbids( vdbid.toStringList().at(0) ); QString insts( vdbid.toStringList().at(1) ); QVariant vf = fsnap->itemData(fsnap->currentIndex()); QVariant vt = tsnap->itemData(tsnap->currentIndex()); QString fsnaps( vf.toStringList().at(2) ); QString tsnaps( vt.toStringList().at(2) ); // toQList params; // params.push_back(fsnaps); // params.push_back(tsnaps); TLOG(0, toDecorator, __HERE__) << "Dbid:" << dbids.toLatin1().constData() << ' ' << "Inst:" << insts.toLatin1().constData() << ' ' << "fsnap:" << fsnaps.toLatin1().constData() << ' ' << "tsnap:" << tsnaps.toLatin1().constData() << std::endl; try { toConnectionSubLoan c(connection()); toQuery checkSnaps(c, SQLCheckSnaps, toQueryParams() << dbids << insts << fsnaps << tsnaps); toQuery report(c, "select NVL(output,' ') \n" //"from table(dbms_workload_repository.awr_report_text( \n" "from table(dbms_workload_repository.awr_report_html( \n" " :dbid<char[40],in>, \n" " :inst<char[40],in>, \n" " :f<char[40],in>, \n" " :t<char[40],in>, 0))", toQueryParams() << dbids << insts << fsnaps << tsnaps); QString reports; while (!report.eof()) { QString line = (QString)report.readValue(); reports += line; reports += '\n'; } std::cerr << reports.toLatin1().constData() << std::endl; QWidget *box = new QWidget(Tabs); QVBoxLayout *vbox = new QVBoxLayout; vbox->setSpacing(0); vbox->setContentsMargins(0, 0, 0, 0); box->setLayout(vbox); vbox->addWidget(new QLabel(tr("AWR report"), box)); toTextView *tb = new toTextView(box); tb->setFontFamily("monospace"); tb->setReadOnly(true); tb->setText(reports); vbox->addWidget(tb); Tabs->addTab(box, tr("AWR Report")); } catch (const toConnection::exception &t ) { TOMessageBox::information(this, t, t); } } TOCATCH }
void nmethod::moveTo_inner(NCodeBase* p, int32 delta, int32 size) { nmethod* to = (nmethod*)p; if (this == to) return; if (PrintCodeCompaction) { lprintf("*moving nmethod %#lx (", this); printName(0, key.selector); lprintf(") to %#lx\n", to); } OopNCode::moveTo_inner(to, delta, size); assert(iabs((char*)to - (char*)this) >= sizeof(NCodeBase), "nmethods overlap too much"); assert(sizeof(NCodeBase) % oopSize == 0, "should be word-aligned"); // init to's vtable copy_words((int32*)this, (int32*)to, sizeof(NCodeBase) / sizeof(int32)); scopes->_nmethod_backPointer = to; *dBackLinkAddr() = to; flatProfiler->move(insts(), instsEnd(), to->insts()); zoneLink.shift(delta); FOR_MY_CODETABLE_ENTRIES(e) { e->nm= to; } for (nmln *x = linkedSends.next, *y = x->next; x != &linkedSends; x = y, y = y->next) { NCodeBase* s = findThing(x); s->shift_target(x, delta); } linkedSends.shift(delta, this); if (diLink.notEmpty()) { assert(diLink.next->next == &diLink, "diLink should be a pair"); diLink.next->asDIDesc()->shift_jump_addr(delta); } diLink.shift(delta); for (addrDesc* q = locs(), *pend = locsEnd(); q < pend; q++) { if (q->isSendDesc()) { sendDesc* sd = q->asSendDesc(this); sd->shift(delta, this); } else if (q->isDIDesc()) { nmln* l = q->asDIDesc(this)->dependency(); l->shift(delta); } q->shift(this, delta); } if (frame_chain != NoFrameChain && frame_chain != SavedFrameChain) frame_chain->nmethod_moved_by(delta, this); }