本文整理汇总了C++中StatCounter::log方法的典型用法代码示例。如果您正苦于以下问题:C++ StatCounter::log方法的具体用法?C++ StatCounter::log怎么用?C++ StatCounter::log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatCounter
的用法示例。
在下文中一共展示了StatCounter::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jit_objectcache_hits
std::unique_ptr<llvm::MemoryBuffer> PystonObjectCache::getObject(const llvm::Module* M)
#endif
{
static StatCounter jit_objectcache_hits("num_jit_objectcache_hits");
static StatCounter jit_objectcache_misses("num_jit_objectcache_misses");
module_identifier = M->getModuleIdentifier();
RELEASE_ASSERT(!hash_before_codegen.empty(), "hash should have already got calculated");
if (!haveCacheFileForHash()) {
#if 0
// This code helps with identifying why we got a cache miss for a file.
// - clear the cache directory
// - run pyston
// - run pyston a second time
// - Now look for "*_second.ll" files in the cache directory and compare them to the "*_first.ll" IR dump
std::string llvm_ir;
llvm::raw_string_ostream sstr(llvm_ir);
M->print(sstr, 0);
sstr.flush();
llvm::sys::fs::create_directories(cache_dir.str());
std::string filename = cache_dir.str().str() + "/" + module_identifier + "_first.ll";
if (llvm::sys::fs::exists(filename))
filename = cache_dir.str().str() + "/" + module_identifier + "_second.ll";
FILE* f = fopen(filename.c_str(), "wt");
ASSERT(f, "%s", strerror(errno));
fwrite(llvm_ir.c_str(), 1, llvm_ir.size(), f);
fclose(f);
#endif
// This file isn't in our cache
jit_objectcache_misses.log();
return NULL;
}
llvm::SmallString<128> cache_file = cache_dir;
llvm::sys::path::append(cache_file, hash_before_codegen);
std::unique_ptr<llvm::MemoryBuffer> mem_buff = CompressedFile::getFile(cache_file);
if (!mem_buff) {
jit_objectcache_misses.log();
return NULL;
}
jit_objectcache_hits.log();
return mem_buff;
}
示例2:
extern "C" void PyString_InternInPlace(PyObject** p) noexcept {
BoxedString* s = (BoxedString*)*p;
if (s == NULL || !PyString_Check(s))
Py_FatalError("PyString_InternInPlace: strings only please!");
/* If it's a string subclass, we don't really know what putting
it in the interned dict might do. */
if (!PyString_CheckExact(s))
return;
if (PyString_CHECK_INTERNED(s))
return;
auto it = interned_strings.find(s);
if (it != interned_strings.end()) {
auto entry = *it;
Py_INCREF(entry);
Py_DECREF(*p);
*p = entry;
} else {
// TODO: do CPython's refcounting here
num_interned_strings.log();
interned_strings.insert(s);
Py_INCREF(s);
// CPython returns mortal but in our current implementation they are inmortal
s->interned_state = SSTATE_INTERNED_IMMORTAL;
}
}
示例3: _t
PhiAnalysis::PhiAnalysis(const SourceInfo::ArgNames& arg_names, CFG* cfg, LivenessAnalysis* liveness,
ScopeInfo* scope_info)
: definedness(arg_names, cfg, scope_info), liveness(liveness) {
Timer _t("PhiAnalysis()", 10);
for (CFGBlock* block : cfg->blocks) {
RequiredSet required;
if (block->predecessors.size() > 1) {
for (CFGBlock* pred : block->predecessors) {
const RequiredSet& defined = definedness.getDefinedNamesAtEnd(pred);
for (const auto& s : defined) {
if (required.count(s) == 0 && liveness->isLiveAtEnd(s, pred)) {
// printf("%d-%d %s\n", pred->idx, block->idx, s.c_str());
required.insert(s);
}
}
}
}
required_phis.insert(make_pair(block, std::move(required)));
}
static StatCounter us_phis("us_compiling_analysis_phis");
us_phis.log(_t.end());
}
示例4: compilePartialFunc
void* compilePartialFunc(OSRExit* exit) {
LOCK_REGION(codegen_rwlock.asWrite());
assert(exit);
assert(exit->parent_cf);
assert(exit->parent_cf->effort < EffortLevel::MAXIMAL);
stat_osrexits.log();
// if (VERBOSITY("irgen") >= 1) printf("In compilePartialFunc, handling %p\n", exit);
assert(exit->parent_cf->clfunc);
CompiledFunction*& new_cf = exit->parent_cf->clfunc->osr_versions[exit->entry];
if (new_cf == NULL) {
EffortLevel::EffortLevel new_effort = EffortLevel::MAXIMAL;
if (exit->parent_cf->effort == EffortLevel::INTERPRETED)
new_effort = EffortLevel::MINIMAL;
// EffortLevel::EffortLevel new_effort = (EffortLevel::EffortLevel)(exit->parent_cf->effort + 1);
// new_effort = EffortLevel::MAXIMAL;
CompiledFunction* compiled
= compileFunction(exit->parent_cf->clfunc, exit->parent_cf->spec, new_effort, exit->entry);
assert(compiled = new_cf);
}
return new_cf->code;
}
示例5: parse_file
AST_Module* parse_file(const char* fn) {
STAT_TIMER(t0, "us_timer_cpyton_parsing");
Timer _t("parsing");
if (ENABLE_PYPA_PARSER) {
AST_Module* rtn = pypa_parse(fn);
assert(rtn);
return rtn;
}
FILE* fp = popen(getParserCommandLine(fn).c_str(), "r");
BufferedReader* reader = new BufferedReader(fp);
AST* rtn = readASTMisc(reader);
reader->fill();
ASSERT(reader->bytesBuffered() == 0, "%d", reader->bytesBuffered());
delete reader;
int code = pclose(fp);
assert(code == 0);
assert(rtn->type == AST_TYPE::Module);
long us = _t.end();
static StatCounter us_parsing("us_parsing");
us_parsing.log(us);
return ast_cast<AST_Module>(rtn);
}
示例6: counter
std::unique_ptr<PhiAnalysis> computeRequiredPhis(const OSREntryDescriptor* entry_descriptor,
LivenessAnalysis* liveness) {
static StatCounter counter("num_phi_analysis");
counter.log();
auto cfg = entry_descriptor->code->source->cfg;
int num_vregs = cfg->getVRegInfo().getTotalNumOfVRegs();
VRegMap<DefinednessAnalysis::DefinitionLevel> initial_map(num_vregs);
for (int vreg = 0; vreg < num_vregs; vreg++) {
initial_map[vreg] = DefinednessAnalysis::Undefined;
}
for (const auto& p : entry_descriptor->args) {
int vreg = p.first;
ASSERT(initial_map[vreg] == DefinednessAnalysis::Undefined, "%d %d", vreg, initial_map[vreg]);
if (entry_descriptor->potentially_undefined[vreg])
initial_map[vreg] = DefinednessAnalysis::PotentiallyDefined;
else
initial_map[vreg] = DefinednessAnalysis::Defined;
}
return std::unique_ptr<PhiAnalysis>(
new PhiAnalysis(std::move(initial_map), entry_descriptor->backedge->target, true, liveness));
}
示例7: _t
PhiAnalysis::PhiAnalysis(VRegMap<DefinednessAnalysis::DefinitionLevel> initial_map, CFGBlock* initial_block,
bool initials_need_phis, LivenessAnalysis* liveness)
: definedness(), empty_set(initial_map.numVregs()), liveness(liveness) {
auto cfg = initial_block->cfg;
auto&& vreg_info = cfg->getVRegInfo();
// I think this should always be the case -- if we're going to generate phis for the initial block,
// then we should include the initial arguments as an extra entry point.
assert(initials_need_phis == (initial_block->predecessors.size() > 0));
int num_vregs = initial_map.numVregs();
assert(num_vregs == vreg_info.getTotalNumOfVRegs());
definedness.run(liveness->getCodeConstants(), std::move(initial_map), initial_block);
Timer _t("PhiAnalysis()", 10);
for (const auto& p : definedness.defined_at_end) {
CFGBlock* block = p.first;
assert(!required_phis.count(block));
VRegSet& required = required_phis.insert(std::make_pair(block, VRegSet(num_vregs))).first->second;
int npred = 0;
for (CFGBlock* pred : block->predecessors) {
if (definedness.defined_at_end.count(pred))
npred++;
}
if (npred > 1 || (initials_need_phis && block == initial_block)) {
for (CFGBlock* pred : block->predecessors) {
if (!definedness.defined_at_end.count(pred))
continue;
const VRegSet& defined = definedness.getDefinedVregsAtEnd(pred);
for (int vreg : defined) {
if (!required[vreg] && liveness->isLiveAtEnd(vreg, pred)) {
// printf("%d-%d %s\n", pred->idx, block->idx, vreg_info.getName(vreg).c_str());
required.set(vreg);
}
}
}
}
if (VERBOSITY() >= 3) {
printf("Phis required at end of %d:", block->idx);
for (auto vreg : required) {
printf(" %s", vreg_info.getName(vreg).c_str());
}
printf("\n");
}
}
static StatCounter us_phis("us_compiling_analysis_phis");
us_phis.log(_t.end());
}
示例8: commit
void ICSlotRewrite::commit(CommitHook* hook, std::vector<void*> gc_references) {
bool still_valid = true;
for (int i = 0; i < dependencies.size(); i++) {
int orig_version = dependencies[i].second;
ICInvalidator* invalidator = dependencies[i].first;
if (orig_version != invalidator->version()) {
still_valid = false;
break;
}
}
if (!still_valid) {
if (VERBOSITY() >= 3)
printf("not committing %s icentry since a dependency got updated before commit\n", debug_name);
return;
}
uint8_t* slot_start = getSlotStart();
uint8_t* continue_point = (uint8_t*)ic->continue_addr;
bool do_commit = hook->finishAssembly(continue_point - slot_start);
if (!do_commit)
return;
assert(!assembler.hasFailed());
for (int i = 0; i < dependencies.size(); i++) {
ICInvalidator* invalidator = dependencies[i].first;
invalidator->addDependent(ic_entry);
}
ic->next_slot_to_try++;
// if (VERBOSITY()) printf("Commiting to %p-%p\n", start, start + ic->slot_size);
memcpy(slot_start, buf, ic->getSlotSize());
for (auto p : ic_entry->gc_references) {
int& i = ic_gc_references[p];
if (i == 1)
ic_gc_references.erase(p);
else
--i;
}
ic_entry->gc_references = std::move(gc_references);
for (auto p : ic_entry->gc_references)
ic_gc_references[p]++;
ic->times_rewritten++;
if (ic->times_rewritten == IC_MEGAMORPHIC_THRESHOLD) {
static StatCounter megamorphic_ics("megamorphic_ics");
megamorphic_ics.log();
}
llvm::sys::Memory::InvalidateInstructionCache(slot_start, ic->getSlotSize());
}
示例9: commit
void Rewriter::commit() {
static StatCounter rewriter_commits("rewriter_commits");
rewriter_commits.log();
// make sure we left the stack the way we found it:
assert(pushes.size() == 0);
assert(alloca_bytes == 0);
rewrite->commit(decision_path, this);
}
示例10: reoptCompiledFunc
extern "C" char* reoptCompiledFunc(CompiledFunction *cf) {
if (VERBOSITY("irgen") >= 1) printf("In reoptCompiledFunc, %p, %ld\n", cf, cf->times_called);
stat_reopt.log();
assert(cf->effort < EffortLevel::MAXIMAL);
assert(cf->clfunc->versions.size());
CompiledFunction *new_cf = _doReopt(cf, (EffortLevel::EffortLevel(cf->effort + 1)));
assert(!new_cf->is_interpreted);
return (char*)new_cf->code;
}
示例11: runCollection
void runCollection() {
static StatCounter sc("gc_collections");
sc.log();
ncollections++;
if (VERBOSITY("gc") >= 2)
printf("Collection #%d\n", ncollections);
Timer _t("collecting", /*min_usec=*/10000);
markPhase();
sweepPhase();
if (VERBOSITY("gc") >= 2)
printf("Collection #%d done\n\n", ncollections);
long us = _t.end();
static StatCounter sc_us("gc_collections_us");
sc_us.log(us);
}
示例12: runOnFunction
virtual bool runOnFunction(llvm::Function& f) {
Timer _t("inlining");
bool rtn = _runOnFunction(f);
static StatCounter us_inlining("us_compiling_optimizing_inlining");
long us = _t.end();
us_inlining.log(us);
return rtn;
}
示例13: runCollection
void runCollection() {
static StatCounter sc("gc_collections");
sc.log();
ncollections++;
if (VERBOSITY("gc") >= 2)
printf("Collection #%d\n", ncollections);
Timer _t("collecting", /*min_usec=*/10000);
markPhase();
std::list<Box*, StlCompatAllocator<Box*>> weakly_referenced;
sweepPhase(weakly_referenced);
for (auto o : weakly_referenced) {
PyWeakReference** list = (PyWeakReference**)PyObject_GET_WEAKREFS_LISTPTR(o);
while (PyWeakReference* head = *list) {
assert(isValidGCObject(head));
if (head->wr_object != Py_None) {
_PyWeakref_ClearRef(head);
if (head->wr_callback) {
runtimeCall(head->wr_callback, ArgPassSpec(1), reinterpret_cast<Box*>(head), NULL, NULL, NULL,
NULL);
head->wr_callback = NULL;
}
}
}
}
if (VERBOSITY("gc") >= 2)
printf("Collection #%d done\n\n", ncollections);
long us = _t.end();
static StatCounter sc_us("gc_collections_us");
sc_us.log(us);
// dumpHeapStatistics();
}
示例14: compileIR
static void compileIR(CompiledFunction* cf, EffortLevel::EffortLevel effort) {
assert(cf);
assert(cf->func);
// g.engine->finalizeOBject();
if (VERBOSITY("irgen") >= 1) {
printf("Compiling...\n");
// g.cur_module->dump();
}
void* compiled = NULL;
if (effort > EffortLevel::INTERPRETED) {
Timer _t("to jit the IR");
#if LLVMREV < 215967
g.engine->addModule(cf->func->getParent());
#else
g.engine->addModule(std::unique_ptr<llvm::Module>(cf->func->getParent()));
#endif
compiled = (void*)g.engine->getFunctionAddress(cf->func->getName());
assert(compiled);
cf->llvm_code = embedConstantPtr(compiled, cf->func->getType());
long us = _t.end();
static StatCounter us_jitting("us_compiling_jitting");
us_jitting.log(us);
static StatCounter num_jits("num_jits");
num_jits.log();
} else {
// HAX just get it for now; this is just to make sure everything works
//(void*)g.func_registry.getFunctionAddress(cf->func->getName());
}
cf->code = compiled;
if (VERBOSITY("irgen") >= 1) {
printf("Compiled function to %p\n", compiled);
}
StackMap* stackmap = parseStackMap();
patchpoints::processStackmap(stackmap);
}
示例15: sc
// This probably belongs in list.cpp?
extern "C" void listGCHandler(GCVisitor *v, void* p) {
boxGCHandler(v, p);
BoxedList *l = (BoxedList*)p;
int size = l->size;
if (size) {
v->visit(l->elts);
v->visitRange((void**)&l->elts->elts[0], (void**)&l->elts->elts[size]);
}
static StatCounter sc("gc_listelts_visited");
sc.log(size);
}