Commit afec0555 authored by Marius Wachtler's avatar Marius Wachtler

llvm tier: remove type recorder usage

while this removes some disabled features I'm not a big fan of having disabled stuff around
because it will break and makes development harder.
parent 435131ee
...@@ -246,7 +246,7 @@ public: ...@@ -246,7 +246,7 @@ public:
bool do_patchpoint = ENABLE_ICSETATTRS; bool do_patchpoint = ENABLE_ICSETATTRS;
llvm::Instruction* inst; llvm::Instruction* inst;
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createSetattrIC(info.getTypeRecorder(), info.getBJitICInfo()); auto pp = createSetattrIC(info.getBJitICInfo());
std::vector<llvm::Value*> llvm_args; std::vector<llvm::Value*> llvm_args;
llvm_args.push_back(var->getValue()); llvm_args.push_back(var->getValue());
...@@ -269,7 +269,7 @@ public: ...@@ -269,7 +269,7 @@ public:
bool do_patchpoint = false; bool do_patchpoint = false;
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createDelattrIC(info.getTypeRecorder()); auto pp = createDelattrIC();
std::vector<llvm::Value*> llvm_args; std::vector<llvm::Value*> llvm_args;
llvm_args.push_back(var->getValue()); llvm_args.push_back(var->getValue());
...@@ -316,7 +316,7 @@ public: ...@@ -316,7 +316,7 @@ public:
bool do_patchpoint = ENABLE_ICGENERICS; bool do_patchpoint = ENABLE_ICGENERICS;
llvm::Value* rtn; llvm::Value* rtn;
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createGenericIC(info.getTypeRecorder(), true, 256); auto pp = createGenericIC(true, 256);
std::vector<llvm::Value*> llvm_args; std::vector<llvm::Value*> llvm_args;
llvm_args.push_back(var->getValue()); llvm_args.push_back(var->getValue());
...@@ -350,7 +350,7 @@ public: ...@@ -350,7 +350,7 @@ public:
: emitter.setType(getNullPtr(g.llvm_value_type_ptr), RefType::BORROWED); : emitter.setType(getNullPtr(g.llvm_value_type_ptr), RefType::BORROWED);
llvm::Value* r = NULL; llvm::Value* r = NULL;
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createGetitemIC(info.getTypeRecorder(), info.getBJitICInfo()); auto pp = createGetitemIC(info.getBJitICInfo());
llvm::Instruction* uncasted = emitter.createIC( llvm::Instruction* uncasted = emitter.createIC(
std::move(pp), std::move(pp),
(void*)(target_exception_style == CAPI ? pyston::apply_slice : pyston::applySlice), (void*)(target_exception_style == CAPI ? pyston::apply_slice : pyston::applySlice),
...@@ -377,7 +377,7 @@ public: ...@@ -377,7 +377,7 @@ public:
llvm::Value* rtn; llvm::Value* rtn;
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createGetitemIC(info.getTypeRecorder(), info.getBJitICInfo()); auto pp = createGetitemIC(info.getBJitICInfo());
std::vector<llvm::Value*> llvm_args; std::vector<llvm::Value*> llvm_args;
llvm_args.push_back(var->getValue()); llvm_args.push_back(var->getValue());
...@@ -428,7 +428,7 @@ public: ...@@ -428,7 +428,7 @@ public:
// var has __iter__() // var has __iter__()
emitter.setCurrentBasicBlock(bb_has_iter); emitter.setCurrentBasicBlock(bb_has_iter);
auto pp = createGenericIC(info.getTypeRecorder(), true, 128); auto pp = createGenericIC(true, 128);
llvm::Instruction* uncasted = emitter.createIC(std::move(pp), (void*)pyston::createBoxedIterWrapperIfNeeded, llvm::Instruction* uncasted = emitter.createIC(std::move(pp), (void*)pyston::createBoxedIterWrapperIfNeeded,
{ converted_iter_call->getValue() }, info.unw_info); { converted_iter_call->getValue() }, info.unw_info);
llvm::Value* value_has_iter = createAfter<llvm::IntToPtrInst>(uncasted, uncasted, g.llvm_value_type_ptr, ""); llvm::Value* value_has_iter = createAfter<llvm::IntToPtrInst>(uncasted, uncasted, g.llvm_value_type_ptr, "");
...@@ -440,7 +440,7 @@ public: ...@@ -440,7 +440,7 @@ public:
// TODO: we could create a patchpoint if this turns out to be hot // TODO: we could create a patchpoint if this turns out to be hot
emitter.setCurrentBasicBlock(bb_no_iter); emitter.setCurrentBasicBlock(bb_no_iter);
auto pp2 = createGenericIC(info.getTypeRecorder(), true, 128); auto pp2 = createGenericIC(true, 128);
llvm::Instruction* value_no_iter llvm::Instruction* value_no_iter
= emitter.createIC(std::move(pp2), (void*)getiterHelper, { var->getValue() }, info.unw_info); = emitter.createIC(std::move(pp2), (void*)getiterHelper, { var->getValue() }, info.unw_info);
value_no_iter = createAfter<llvm::IntToPtrInst>(value_no_iter, value_no_iter, g.llvm_value_type_ptr, ""); value_no_iter = createAfter<llvm::IntToPtrInst>(value_no_iter, value_no_iter, g.llvm_value_type_ptr, "");
...@@ -483,7 +483,7 @@ public: ...@@ -483,7 +483,7 @@ public:
} }
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createBinexpIC(info.getTypeRecorder(), info.getBJitICInfo()); auto pp = createBinexpIC(info.getBJitICInfo());
std::vector<llvm::Value*> llvm_args; std::vector<llvm::Value*> llvm_args;
llvm_args.push_back(var->getValue()); llvm_args.push_back(var->getValue());
...@@ -571,7 +571,7 @@ CompilerVariable* UnknownType::getattr(IREmitter& emitter, const OpInfo& info, C ...@@ -571,7 +571,7 @@ CompilerVariable* UnknownType::getattr(IREmitter& emitter, const OpInfo& info, C
bool do_patchpoint = ENABLE_ICGETATTRS; bool do_patchpoint = ENABLE_ICGETATTRS;
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createGetattrIC(info.getTypeRecorder(), info.getBJitICInfo()); auto pp = createGetattrIC(info.getBJitICInfo());
std::vector<llvm::Value*> llvm_args; std::vector<llvm::Value*> llvm_args;
llvm_args.push_back(var->getValue()); llvm_args.push_back(var->getValue());
...@@ -674,7 +674,7 @@ _call(IREmitter& emitter, const OpInfo& info, llvm::Value* func, ExceptionStyle ...@@ -674,7 +674,7 @@ _call(IREmitter& emitter, const OpInfo& info, llvm::Value* func, ExceptionStyle
if (do_patchpoint) { if (do_patchpoint) {
assert(func_addr); assert(func_addr);
auto pp = createCallsiteIC(info.getTypeRecorder(), args.size(), info.getBJitICInfo()); auto pp = createCallsiteIC(args.size(), info.getBJitICInfo());
llvm::Instruction* uncasted = emitter.createIC(std::move(pp), func_addr, llvm_args, info.unw_info, llvm::Instruction* uncasted = emitter.createIC(std::move(pp), func_addr, llvm_args, info.unw_info,
target_exception_style, getNullPtr(g.llvm_value_type_ptr)); target_exception_style, getNullPtr(g.llvm_value_type_ptr));
...@@ -782,7 +782,7 @@ ConcreteCompilerVariable* UnknownType::nonzero(IREmitter& emitter, const OpInfo& ...@@ -782,7 +782,7 @@ ConcreteCompilerVariable* UnknownType::nonzero(IREmitter& emitter, const OpInfo&
bool do_patchpoint = ENABLE_ICNONZEROS; bool do_patchpoint = ENABLE_ICNONZEROS;
llvm::Value* rtn_val; llvm::Value* rtn_val;
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createNonzeroIC(info.getTypeRecorder()); auto pp = createNonzeroIC();
std::vector<llvm::Value*> llvm_args; std::vector<llvm::Value*> llvm_args;
llvm_args.push_back(var->getValue()); llvm_args.push_back(var->getValue());
...@@ -802,7 +802,7 @@ ConcreteCompilerVariable* UnknownType::unaryop(IREmitter& emitter, const OpInfo& ...@@ -802,7 +802,7 @@ ConcreteCompilerVariable* UnknownType::unaryop(IREmitter& emitter, const OpInfo&
llvm::Value* rtn = NULL; llvm::Value* rtn = NULL;
bool do_patchpoint = ENABLE_ICGENERICS; bool do_patchpoint = ENABLE_ICGENERICS;
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createGenericIC(info.getTypeRecorder(), true, 256); auto pp = createGenericIC(true, 256);
std::vector<llvm::Value*> llvm_args; std::vector<llvm::Value*> llvm_args;
llvm_args.push_back(converted->getValue()); llvm_args.push_back(converted->getValue());
...@@ -824,7 +824,7 @@ ConcreteCompilerVariable* UnknownType::hasnext(IREmitter& emitter, const OpInfo& ...@@ -824,7 +824,7 @@ ConcreteCompilerVariable* UnknownType::hasnext(IREmitter& emitter, const OpInfo&
do_patchpoint = false; // we are currently using runtime ics for this do_patchpoint = false; // we are currently using runtime ics for this
llvm::Value* rtn_val; llvm::Value* rtn_val;
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createHasnextIC(info.getTypeRecorder()); auto pp = createHasnextIC();
std::vector<llvm::Value*> llvm_args; std::vector<llvm::Value*> llvm_args;
llvm_args.push_back(var->getValue()); llvm_args.push_back(var->getValue());
......
...@@ -163,20 +163,17 @@ llvm::Value* handlePotentiallyUndefined(ConcreteCompilerVariable* is_defined_var ...@@ -163,20 +163,17 @@ llvm::Value* handlePotentiallyUndefined(ConcreteCompilerVariable* is_defined_var
std::function<llvm::Value*(IREmitter&)> when_defined, std::function<llvm::Value*(IREmitter&)> when_defined,
std::function<llvm::Value*(IREmitter&)> when_undefined); std::function<llvm::Value*(IREmitter&)> when_undefined);
class TypeRecorder;
class OpInfo { class OpInfo {
private: private:
const EffortLevel effort; const EffortLevel effort;
TypeRecorder* const type_recorder;
ICInfo* bjit_ic_info; ICInfo* bjit_ic_info;
public: public:
const UnwindInfo unw_info; const UnwindInfo unw_info;
OpInfo(EffortLevel effort, TypeRecorder* type_recorder, const UnwindInfo& unw_info, ICInfo* bjit_ic_info) OpInfo(EffortLevel effort, const UnwindInfo& unw_info, ICInfo* bjit_ic_info)
: effort(effort), type_recorder(type_recorder), bjit_ic_info(bjit_ic_info), unw_info(unw_info) {} : effort(effort), bjit_ic_info(bjit_ic_info), unw_info(unw_info) {}
TypeRecorder* getTypeRecorder() const { return type_recorder; }
ICInfo* getBJitICInfo() const { return bjit_ic_info; } ICInfo* getBJitICInfo() const { return bjit_ic_info; }
ExceptionStyle preferredExceptionStyle() const { return unw_info.preferredExceptionStyle(); } ExceptionStyle preferredExceptionStyle() const { return unw_info.preferredExceptionStyle(); }
......
...@@ -834,25 +834,10 @@ private: ...@@ -834,25 +834,10 @@ private:
OpInfo getOpInfoForNode(AST* ast, const UnwindInfo& unw_info) { OpInfo getOpInfoForNode(AST* ast, const UnwindInfo& unw_info) {
assert(ast); assert(ast);
EffortLevel effort = irstate->getEffortLevel(); return OpInfo(irstate->getEffortLevel(), unw_info, ICInfo::getICInfoForNode(ast));
// This is the only place we create type recorders for the llvm tier;
// if we are ok with never doing that there's a bunch of code that could
// be removed.
bool record_types = false;
TypeRecorder* type_recorder;
if (record_types) {
type_recorder = getTypeRecorderForNode(ast);
} else {
type_recorder = NULL;
}
return OpInfo(irstate->getEffortLevel(), type_recorder, unw_info, ICInfo::getICInfoForNode(ast));
} }
OpInfo getEmptyOpInfo(const UnwindInfo& unw_info) { OpInfo getEmptyOpInfo(const UnwindInfo& unw_info) { return OpInfo(irstate->getEffortLevel(), unw_info, NULL); }
return OpInfo(irstate->getEffortLevel(), NULL, unw_info, NULL);
}
void createExprTypeGuard(llvm::Value* check_val, AST* node, llvm::Value* node_value, AST_stmt* current_statement) { void createExprTypeGuard(llvm::Value* check_val, AST* node, llvm::Value* node_value, AST_stmt* current_statement) {
assert(check_val->getType() == g.i1); assert(check_val->getType() == g.i1);
...@@ -1311,7 +1296,7 @@ private: ...@@ -1311,7 +1296,7 @@ private:
bool do_patchpoint = ENABLE_ICGETGLOBALS; bool do_patchpoint = ENABLE_ICGETGLOBALS;
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createGetGlobalIC(getOpInfoForNode(node, unw_info).getTypeRecorder()); auto pp = createGetGlobalIC();
std::vector<llvm::Value*> llvm_args; std::vector<llvm::Value*> llvm_args;
llvm_args.push_back(irstate->getGlobals()); llvm_args.push_back(irstate->getGlobals());
...@@ -2003,7 +1988,7 @@ private: ...@@ -2003,7 +1988,7 @@ private:
bool do_patchpoint = ENABLE_ICSETITEMS; bool do_patchpoint = ENABLE_ICSETITEMS;
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createSetitemIC(getEmptyOpInfo(unw_info).getTypeRecorder()); auto pp = createSetitemIC();
std::vector<llvm::Value*> llvm_args; std::vector<llvm::Value*> llvm_args;
llvm_args.push_back(target); llvm_args.push_back(target);
...@@ -2034,7 +2019,7 @@ private: ...@@ -2034,7 +2019,7 @@ private:
// patchpoints if it couldn't. // patchpoints if it couldn't.
bool do_patchpoint = ENABLE_ICSETITEMS; bool do_patchpoint = ENABLE_ICSETITEMS;
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createSetitemIC(getEmptyOpInfo(unw_info).getTypeRecorder()); auto pp = createSetitemIC();
std::vector<llvm::Value*> llvm_args; std::vector<llvm::Value*> llvm_args;
llvm_args.push_back(converted_target->getValue()); llvm_args.push_back(converted_target->getValue());
...@@ -2164,7 +2149,7 @@ private: ...@@ -2164,7 +2149,7 @@ private:
bool do_patchpoint = ENABLE_ICDELITEMS; bool do_patchpoint = ENABLE_ICDELITEMS;
if (do_patchpoint) { if (do_patchpoint) {
auto pp = createDelitemIC(getEmptyOpInfo(unw_info).getTypeRecorder()); auto pp = createDelitemIC();
std::vector<llvm::Value*> llvm_args; std::vector<llvm::Value*> llvm_args;
llvm_args.push_back(converted_target->getValue()); llvm_args.push_back(converted_target->getValue());
......
...@@ -382,53 +382,52 @@ int slotSize(ICInfo* bjit_ic_info, int default_size) { ...@@ -382,53 +382,52 @@ int slotSize(ICInfo* bjit_ic_info, int default_size) {
return suggested_size; return suggested_size;
} }
std::unique_ptr<ICSetupInfo> createGenericIC(TypeRecorder* type_recorder, bool has_return_value, int size) { std::unique_ptr<ICSetupInfo> createGenericIC(bool has_return_value, int size) {
return ICSetupInfo::initialize(has_return_value, size, ICSetupInfo::Generic, type_recorder); return ICSetupInfo::initialize(has_return_value, size, ICSetupInfo::Generic);
} }
std::unique_ptr<ICSetupInfo> createGetattrIC(TypeRecorder* type_recorder, ICInfo* bjit_ic_info) { std::unique_ptr<ICSetupInfo> createGetattrIC(ICInfo* bjit_ic_info) {
return ICSetupInfo::initialize(true, slotSize(bjit_ic_info, 1024), ICSetupInfo::Getattr, type_recorder); return ICSetupInfo::initialize(true, slotSize(bjit_ic_info, 1024), ICSetupInfo::Getattr);
} }
std::unique_ptr<ICSetupInfo> createGetitemIC(TypeRecorder* type_recorder, ICInfo* bjit_ic_info) { std::unique_ptr<ICSetupInfo> createGetitemIC(ICInfo* bjit_ic_info) {
return ICSetupInfo::initialize(true, slotSize(bjit_ic_info, 512), ICSetupInfo::Getitem, type_recorder); return ICSetupInfo::initialize(true, slotSize(bjit_ic_info, 512), ICSetupInfo::Getitem);
} }
std::unique_ptr<ICSetupInfo> createSetitemIC(TypeRecorder* type_recorder) { std::unique_ptr<ICSetupInfo> createSetitemIC() {
return ICSetupInfo::initialize(true, 512, ICSetupInfo::Setitem, type_recorder); return ICSetupInfo::initialize(true, 512, ICSetupInfo::Setitem);
} }
std::unique_ptr<ICSetupInfo> createDelitemIC(TypeRecorder* type_recorder) { std::unique_ptr<ICSetupInfo> createDelitemIC() {
return ICSetupInfo::initialize(false, 512, ICSetupInfo::Delitem, type_recorder); return ICSetupInfo::initialize(false, 512, ICSetupInfo::Delitem);
} }
std::unique_ptr<ICSetupInfo> createSetattrIC(TypeRecorder* type_recorder, ICInfo* bjit_ic_info) { std::unique_ptr<ICSetupInfo> createSetattrIC(ICInfo* bjit_ic_info) {
return ICSetupInfo::initialize(false, slotSize(bjit_ic_info, 1024), ICSetupInfo::Setattr, type_recorder); return ICSetupInfo::initialize(false, slotSize(bjit_ic_info, 1024), ICSetupInfo::Setattr);
} }
std::unique_ptr<ICSetupInfo> createDelattrIC(TypeRecorder* type_recorder) { std::unique_ptr<ICSetupInfo> createDelattrIC() {
return ICSetupInfo::initialize(false, 144, ICSetupInfo::Delattr, type_recorder); return ICSetupInfo::initialize(false, 144, ICSetupInfo::Delattr);
} }
std::unique_ptr<ICSetupInfo> createCallsiteIC(TypeRecorder* type_recorder, int num_args, ICInfo* bjit_ic_info) { std::unique_ptr<ICSetupInfo> createCallsiteIC(int num_args, ICInfo* bjit_ic_info) {
return ICSetupInfo::initialize(true, slotSize(bjit_ic_info, 4 * (640 + 48 * num_args)), ICSetupInfo::Callsite, return ICSetupInfo::initialize(true, slotSize(bjit_ic_info, 4 * (640 + 48 * num_args)), ICSetupInfo::Callsite);
type_recorder);
} }
std::unique_ptr<ICSetupInfo> createGetGlobalIC(TypeRecorder* type_recorder) { std::unique_ptr<ICSetupInfo> createGetGlobalIC() {
return ICSetupInfo::initialize(true, 128, ICSetupInfo::GetGlobal, type_recorder); return ICSetupInfo::initialize(true, 128, ICSetupInfo::GetGlobal);
} }
std::unique_ptr<ICSetupInfo> createBinexpIC(TypeRecorder* type_recorder, ICInfo* bjit_ic_info) { std::unique_ptr<ICSetupInfo> createBinexpIC(ICInfo* bjit_ic_info) {
return ICSetupInfo::initialize(true, slotSize(bjit_ic_info, 2048), ICSetupInfo::Binexp, type_recorder); return ICSetupInfo::initialize(true, slotSize(bjit_ic_info, 2048), ICSetupInfo::Binexp);
} }
std::unique_ptr<ICSetupInfo> createNonzeroIC(TypeRecorder* type_recorder) { std::unique_ptr<ICSetupInfo> createNonzeroIC() {
return ICSetupInfo::initialize(true, 1024, ICSetupInfo::Nonzero, type_recorder); return ICSetupInfo::initialize(true, 1024, ICSetupInfo::Nonzero);
} }
std::unique_ptr<ICSetupInfo> createHasnextIC(TypeRecorder* type_recorder) { std::unique_ptr<ICSetupInfo> createHasnextIC() {
return ICSetupInfo::initialize(true, 128, ICSetupInfo::Hasnext, type_recorder); return ICSetupInfo::initialize(true, 128, ICSetupInfo::Hasnext);
} }
std::unique_ptr<ICSetupInfo> createDeoptIC() { std::unique_ptr<ICSetupInfo> createDeoptIC() {
......
...@@ -98,7 +98,7 @@ public: ...@@ -98,7 +98,7 @@ public:
} }
static std::unique_ptr<ICSetupInfo> static std::unique_ptr<ICSetupInfo>
initialize(bool has_return_value, int size, ICType type, TypeRecorder* type_recorder, initialize(bool has_return_value, int size, ICType type, TypeRecorder* type_recorder = NULL,
assembler::RegisterSet allocatable_regs = assembler::RegisterSet::stdAllocatable()); assembler::RegisterSet allocatable_regs = assembler::RegisterSet::stdAllocatable());
}; };
...@@ -178,18 +178,18 @@ public: ...@@ -178,18 +178,18 @@ public:
}; };
class ICInfo; class ICInfo;
std::unique_ptr<ICSetupInfo> createGenericIC(TypeRecorder* type_recorder, bool has_return_value, int size); std::unique_ptr<ICSetupInfo> createGenericIC(bool has_return_value, int size);
std::unique_ptr<ICSetupInfo> createCallsiteIC(TypeRecorder* type_recorder, int num_args, ICInfo* bjit_ic_info); std::unique_ptr<ICSetupInfo> createCallsiteIC(int num_args, ICInfo* bjit_ic_info);
std::unique_ptr<ICSetupInfo> createGetGlobalIC(TypeRecorder* type_recorder); std::unique_ptr<ICSetupInfo> createGetGlobalIC();
std::unique_ptr<ICSetupInfo> createGetattrIC(TypeRecorder* type_recorder, ICInfo* bjit_ic_info); std::unique_ptr<ICSetupInfo> createGetattrIC(ICInfo* bjit_ic_info);
std::unique_ptr<ICSetupInfo> createSetattrIC(TypeRecorder* type_recorder, ICInfo* bjit_ic_info); std::unique_ptr<ICSetupInfo> createSetattrIC(ICInfo* bjit_ic_info);
std::unique_ptr<ICSetupInfo> createDelattrIC(TypeRecorder* type_recorder); std::unique_ptr<ICSetupInfo> createDelattrIC();
std::unique_ptr<ICSetupInfo> createGetitemIC(TypeRecorder* type_recorder, ICInfo* bjit_ic_info); std::unique_ptr<ICSetupInfo> createGetitemIC(ICInfo* bjit_ic_info);
std::unique_ptr<ICSetupInfo> createSetitemIC(TypeRecorder* type_recorder); std::unique_ptr<ICSetupInfo> createSetitemIC();
std::unique_ptr<ICSetupInfo> createDelitemIC(TypeRecorder* type_recorder); std::unique_ptr<ICSetupInfo> createDelitemIC();
std::unique_ptr<ICSetupInfo> createBinexpIC(TypeRecorder* type_recorder, ICInfo* bjit_ic_info); std::unique_ptr<ICSetupInfo> createBinexpIC(ICInfo* bjit_ic_info);
std::unique_ptr<ICSetupInfo> createNonzeroIC(TypeRecorder* type_recorder); std::unique_ptr<ICSetupInfo> createNonzeroIC();
std::unique_ptr<ICSetupInfo> createHasnextIC(TypeRecorder* type_recorder); std::unique_ptr<ICSetupInfo> createHasnextIC();
std::unique_ptr<ICSetupInfo> createDeoptIC(); std::unique_ptr<ICSetupInfo> createDeoptIC();
} // namespace pyston } // namespace pyston
......
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