Commit a1100ede authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #457 from undingen/speedup

Speed-up analysis and irgen
parents 14990c7f 63eddb94
......@@ -169,8 +169,6 @@ bool LivenessAnalysis::isKill(AST_Name* node, CFGBlock* parent_block) {
}
bool LivenessAnalysis::isLiveAtEnd(InternedString name, CFGBlock* block) {
Timer _t("LivenessAnalysis()", 10);
if (name.str()[0] != '#')
return true;
......@@ -178,6 +176,8 @@ bool LivenessAnalysis::isLiveAtEnd(InternedString name, CFGBlock* block) {
return false;
if (!result_cache.count(name)) {
Timer _t("LivenessAnalysis()", 10);
llvm::DenseMap<CFGBlock*, bool>& map = result_cache[name];
// Approach:
......@@ -208,11 +208,11 @@ bool LivenessAnalysis::isLiveAtEnd(InternedString name, CFGBlock* block) {
}
}
}
}
// 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());
// 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[name][block];
}
......
......@@ -910,14 +910,13 @@ private:
}
ConcreteCompilerVariable* getNone() {
ConcreteCompilerVariable* v = new ConcreteCompilerVariable(
typeFromClass(none_cls), embedRelocatablePtr(None, g.llvm_value_type_ptr), false);
return v;
llvm::Constant* none = embedRelocatablePtr(None, g.llvm_value_type_ptr, "cNone");
return new ConcreteCompilerVariable(typeFromClass(none_cls), none, false);
}
llvm::Constant* embedParentModulePtr() {
// TODO: We could reuse the name to reduce the number of relocatable pointers.
return embedRelocatablePtr(irstate->getSourceInfo()->parent_module, g.llvm_module_type_ptr);
BoxedModule* parent_module = irstate->getSourceInfo()->parent_module;
return embedRelocatablePtr(parent_module, g.llvm_module_type_ptr, "cParentModule");
}
ConcreteCompilerVariable* _getGlobal(AST_Name* node, UnwindInfo unw_info) {
......@@ -2150,7 +2149,7 @@ private:
v->decvref(emitter);
args.push_back(converted->getValue());
} else {
args.push_back(embedRelocatablePtr(None, g.llvm_value_type_ptr));
args.push_back(embedRelocatablePtr(None, g.llvm_value_type_ptr, "cNone"));
}
}
......@@ -2363,11 +2362,12 @@ public:
if (ENABLE_FRAME_INTROSPECTION) {
// TODO: don't need to use a sorted symbol table if we're explicitly recording the names!
// nice for debugging though.
SortedSymbolTable sorted_symbol_table(symbol_table.begin(), symbol_table.end());
typedef std::pair<InternedString, CompilerVariable*> Entry;
std::vector<Entry> sorted_symbol_table(symbol_table.begin(), symbol_table.end());
std::sort(sorted_symbol_table.begin(), sorted_symbol_table.end(),
[](const Entry& lhs, const Entry& rhs) { return lhs.first < rhs.first; });
for (const auto& p : sorted_symbol_table) {
CompilerVariable* v = p.second;
v->serializeToFrame(stackmap_args);
pp->addFrameVar(p.first.str(), v->getType());
}
......
......@@ -106,13 +106,23 @@ const void* getValueOfRelocatableSym(const std::string& str) {
return NULL;
}
llvm::Constant* embedRelocatablePtr(const void* addr, llvm::Type* type) {
llvm::Constant* embedRelocatablePtr(const void* addr, llvm::Type* type, llvm::StringRef shared_name) {
assert(addr);
if (!ENABLE_JIT_OBJECT_CACHE)
return embedConstantPtr(addr, type);
std::string name = (llvm::Twine("c") + llvm::Twine(relocatable_syms.size())).str();
std::string name;
if (!shared_name.empty()) {
llvm::GlobalVariable* gv = g.cur_module->getGlobalVariable(shared_name, true);
if (gv)
return gv;
assert(!relocatable_syms.count(name));
name = shared_name;
} else {
name = (llvm::Twine("c") + llvm::Twine(relocatable_syms.size())).str();
}
relocatable_syms[name] = addr;
llvm::Type* var_type = type->getPointerElementType();
......
......@@ -17,6 +17,8 @@
#include <string>
#include "llvm/ADT/StringRef.h"
namespace llvm {
class Constant;
class Function;
......@@ -27,7 +29,7 @@ namespace pyston {
llvm::Constant* getStringConstantPtr(const std::string& str);
llvm::Constant* getStringConstantPtr(const char* str);
llvm::Constant* embedRelocatablePtr(const void* addr, llvm::Type*);
llvm::Constant* embedRelocatablePtr(const void* addr, llvm::Type*, llvm::StringRef shared_name = llvm::StringRef());
llvm::Constant* embedConstantPtr(const void* addr, llvm::Type*);
llvm::Constant* getConstantInt(int64_t val);
llvm::Constant* getConstantDouble(double val);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment