当前位置: 首页>>代码示例>>C++>>正文


C++ StatCounter类代码示例

本文整理汇总了C++中StatCounter的典型用法代码示例。如果您正苦于以下问题:C++ StatCounter类的具体用法?C++ StatCounter怎么用?C++ StatCounter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了StatCounter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: computeRequiredPhis

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));
}
开发者ID:Daetalus,项目名称:pyston,代码行数:25,代码来源:function_analysis.cpp

示例2: definedness

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());
}
开发者ID:DarrelHsu,项目名称:pyston,代码行数:27,代码来源:function_analysis.cpp

示例3: 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);
}
开发者ID:lyzardiar,项目名称:pyston,代码行数:29,代码来源:parser.cpp

示例4: definedness

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());
}
开发者ID:Daetalus,项目名称:pyston,代码行数:56,代码来源:function_analysis.cpp

示例5: printf

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());
}
开发者ID:nanwu,项目名称:pyston,代码行数:56,代码来源:icinfo.cpp

示例6: rewriter_commits

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);
}
开发者ID:errord,项目名称:pyston,代码行数:10,代码来源:rewriter.cpp

示例7: 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;
    }
开发者ID:guangwong,项目名称:pyston,代码行数:11,代码来源:inliner.cpp

示例8: listGCHandler

// 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);
}
开发者ID:Bassem450,项目名称:pyston,代码行数:14,代码来源:types.cpp

示例9: runCollection

void runCollection() {
    static StatCounter sc("gc_collections");
    sc.log();

    if (VERBOSITY("gc") >= 2) printf("Collection #%d\n", ++ncollections);

    //if (ncollections == 754) {
        //raise(SIGTRAP);
    //}

    markPhase();
    sweepPhase();
}
开发者ID:chenkaigithub,项目名称:pyston,代码行数:13,代码来源:collector.cpp

示例10: _t

bool LivenessAnalysis::isLiveAtEnd(const std::string& name, CFGBlock* block) {
    Timer _t("LivenessAnalysis()", 10);

    if (name[0] != '#')
        return true;

    if (block->successors.size() == 0)
        return false;

    int idx = getStringIndex(name);
    if (!result_cache.count(idx)) {
        std::unordered_map<CFGBlock*, bool>& map = result_cache[idx];

        // Approach:
        // - Find all uses (blocks where the status is USED)
        // - Trace backwards, marking all blocks as live-at-end
        // - If we hit a block that is KILLED, stop
        for (CFGBlock* b : cfg->blocks) {
            auto status = liveness_cache[b]->nameStatus(idx);

            if (status != LivenessBBVisitor::USED)
                continue;

            std::deque<CFGBlock*> q;
            for (CFGBlock* pred : b->predecessors) {
                q.push_back(pred);
            }

            while (q.size()) {
                CFGBlock* thisblock = q.front();
                q.pop_front();

                if (map[thisblock])
                    continue;

                map[thisblock] = true;
                if (liveness_cache[thisblock]->nameStatus(idx) != LivenessBBVisitor::KILLED) {
                    for (CFGBlock* pred : thisblock->predecessors) {
                        q.push_back(pred);
                    }
                }
            }
        }
    }

    // Note: this one gets counted as part of us_compiling_irgen as well:
    static StatCounter us_liveness("us_compiling_analysis_liveness");
    us_liveness.log(_t.end());

    return result_cache[idx][block];
}
开发者ID:DarrelHsu,项目名称:pyston,代码行数:51,代码来源:function_analysis.cpp

示例11: assert

Rewriter* Rewriter::createRewriter(void* ic_rtn_addr, int num_orig_args, int num_temp_regs, const char* debug_name) {
    assert(num_temp_regs <= 2 && "unsupported");

    static StatCounter rewriter_nopatch("rewriter_nopatch");

    ICInfo* ic = getICInfo(ic_rtn_addr);
    if (ic == NULL) {
        rewriter_nopatch.log();
        return NULL;
    }

    assert(ic->getCallingConvention() == llvm::CallingConv::C && "Rewriter[1] only supports the C calling convention!");
    return new Rewriter(ic->startRewrite(debug_name), num_orig_args, num_temp_regs);
}
开发者ID:errord,项目名称:pyston,代码行数:14,代码来源:rewriter.cpp

示例12: cfg

LivenessAnalysis::LivenessAnalysis(CFG* cfg) : cfg(cfg) {
    Timer _t("LivenessAnalysis()", 10);

    for (CFGBlock* b : cfg->blocks) {
        auto visitor = new LivenessBBVisitor(this); // livenessCache unique_ptr will delete it.
        for (AST_stmt* stmt : b->body) {
            stmt->accept(visitor);
        }
        liveness_cache.insert(std::make_pair(b, std::unique_ptr<LivenessBBVisitor>(visitor)));
    }

    static StatCounter us_liveness("us_compiling_analysis_liveness");
    us_liveness.log(_t.end());
}
开发者ID:DarrelHsu,项目名称:pyston,代码行数:14,代码来源:function_analysis.cpp

示例13: cfg

LivenessAnalysis::LivenessAnalysis(CFG* cfg, const CodeConstants& code_constants)
    : cfg(cfg), code_constants(code_constants), result_cache(cfg->getVRegInfo().getTotalNumOfVRegs()) {
    Timer _t("LivenessAnalysis()", 100);

    for (CFGBlock* b : cfg->blocks) {
        auto visitor = new LivenessBBVisitor(this); // livenessCache unique_ptr will delete it.
        for (BST_stmt* stmt : b->body) {
            stmt->accept(visitor);
        }
        liveness_cache.insert(std::make_pair(b, std::unique_ptr<LivenessBBVisitor>(visitor)));
    }

    static StatCounter us_liveness("us_compiling_analysis_liveness");
    us_liveness.log(_t.end());
}
开发者ID:Daetalus,项目名称:pyston,代码行数:15,代码来源:function_analysis.cpp

示例14: 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;
}
开发者ID:KrishMunot,项目名称:pyston,代码行数:48,代码来源:entry.cpp

示例15: printf

void ICSlotRewrite::commit(CommitHook* hook) {
    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;
    }

    ICSlotInfo* ic_entry = ic->pickEntryForRewrite(debug_name);
    if (ic_entry == NULL)
        return;

    uint8_t* slot_start = (uint8_t*)ic->start_addr + ic_entry->idx * ic->getSlotSize();
    uint8_t* continue_point = (uint8_t*)ic->continue_addr;

    bool do_commit = hook->finishAssembly(ic_entry, continue_point - slot_start);

    if (!do_commit)
        return;

    assert(assembler->isExactlyFull());
    assert(!assembler->hasFailed());

    for (int i = 0; i < dependencies.size(); i++) {
        ICInvalidator* invalidator = dependencies[i].first;
        invalidator->addDependent(ic_entry);
    }

    // if (VERBOSITY()) printf("Commiting to %p-%p\n", start, start + ic->slot_size);
    memcpy(slot_start, buf, ic->getSlotSize());

    ic->times_rewritten++;

    if (ic->times_rewritten == MEGAMORPHIC_THRESHOLD) {
        static StatCounter megamorphic_ics("megamorphic_ics");
        megamorphic_ics.log();
    }

    llvm::sys::Memory::InvalidateInstructionCache(slot_start, ic->getSlotSize());
}
开发者ID:lyzardiar,项目名称:pyston,代码行数:48,代码来源:icinfo.cpp


注:本文中的StatCounter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。