Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/capi/typeobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1915,8 +1915,8 @@ static const slotdef* update_one_slot(BoxedClass* type, const slotdef* p) noexce
sanity checks. I'll buy the first person to
point out a bug in this reasoning a beer. */
} else if (offset == offsetof(BoxedClass, tp_descr_get) && descr->cls == function_cls
&& static_cast<BoxedFunction*>(descr)->f->always_use_version) {
CompiledFunction* cf = static_cast<BoxedFunction*>(descr)->f->always_use_version;
&& static_cast<BoxedFunction*>(descr)->md->always_use_version) {
CompiledFunction* cf = static_cast<BoxedFunction*>(descr)->md->always_use_version;
if (cf->exception_style == CXX) {
type->tpp_descr_get = (descrgetfunc)cf->code;
specific = (void*)slot_tp_tpp_descr_get;
Expand Down
116 changes: 58 additions & 58 deletions src/codegen/ast_interpreter.cpp

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/codegen/ast_interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AST_Jump;
class Box;
class BoxedClosure;
class BoxedDict;
struct CLFunction;
struct FunctionMetadata;
struct LineInfo;

extern const void* interpreter_instr_addr;
Expand Down Expand Up @@ -70,15 +70,15 @@ struct Value {
Value(Box* o, RewriterVar* var) : o(o), var(var) {}
};

Box* astInterpretFunction(CLFunction* f, Box* closure, Box* generator, Box* globals, Box* arg1, Box* arg2, Box* arg3,
Box** args);
Box* astInterpretFunctionEval(CLFunction* cf, Box* globals, Box* boxedLocals);
Box* astInterpretDeopt(CLFunction* cf, AST_expr* after_expr, AST_stmt* enclosing_stmt, Box* expr_val,
Box* astInterpretFunction(FunctionMetadata* f, Box* closure, Box* generator, Box* globals, Box* arg1, Box* arg2,
Box* arg3, Box** args);
Box* astInterpretFunctionEval(FunctionMetadata* cf, Box* globals, Box* boxedLocals);
Box* astInterpretDeopt(FunctionMetadata* cf, AST_expr* after_expr, AST_stmt* enclosing_stmt, Box* expr_val,
FrameStackState frame_state);

AST_stmt* getCurrentStatementForInterpretedFrame(void* frame_ptr);
Box* getGlobalsForInterpretedFrame(void* frame_ptr);
CLFunction* getCLForInterpretedFrame(void* frame_ptr);
FunctionMetadata* getMDForInterpretedFrame(void* frame_ptr);
struct FrameInfo;
FrameInfo* getFrameInfoForInterpretedFrame(void* frame_ptr);
BoxedClosure* passedClosureForInterpretedFrame(void* frame_ptr);
Expand Down
15 changes: 8 additions & 7 deletions src/codegen/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ namespace pyston {

DS_DEFINE_RWLOCK(codegen_rwlock);

CLFunction::CLFunction(int num_args, bool takes_varargs, bool takes_kwargs, std::unique_ptr<SourceInfo> source)
FunctionMetadata::FunctionMetadata(int num_args, bool takes_varargs, bool takes_kwargs,
std::unique_ptr<SourceInfo> source)
: code_obj(NULL),
num_args(num_args),
takes_varargs(takes_varargs),
Expand All @@ -50,7 +51,7 @@ CLFunction::CLFunction(int num_args, bool takes_varargs, bool takes_kwargs, std:
internal_callable(NULL, NULL) {
}

CLFunction::CLFunction(int num_args, bool takes_varargs, bool takes_kwargs, const ParamNames& param_names)
FunctionMetadata::FunctionMetadata(int num_args, bool takes_varargs, bool takes_kwargs, const ParamNames& param_names)
: code_obj(NULL),
num_args(num_args),
takes_varargs(takes_varargs),
Expand All @@ -62,21 +63,21 @@ CLFunction::CLFunction(int num_args, bool takes_varargs, bool takes_kwargs, cons
internal_callable(NULL, NULL) {
}

BoxedCode* CLFunction::getCode() {
BoxedCode* FunctionMetadata::getCode() {
if (!code_obj) {
code_obj = new BoxedCode(this);
// CLFunctions don't currently participate in GC. They actually never get freed currently.
// FunctionMetadatas don't currently participate in GC. They actually never get freed currently.
gc::registerPermanentRoot(code_obj);
}
return code_obj;
}

void CLFunction::addVersion(CompiledFunction* compiled) {
void FunctionMetadata::addVersion(CompiledFunction* compiled) {
assert(compiled);
assert((compiled->spec != NULL) + (compiled->entry_descriptor != NULL) == 1);
assert(compiled->clfunc == NULL);
assert(compiled->md == NULL);
assert(compiled->code);
compiled->clfunc = this;
compiled->md = this;

if (compiled->entry_descriptor == NULL) {
bool could_have_speculations = (source.get() != NULL);
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct GlobalState {
llvm::Type* llvm_opaque_type;
llvm::Type* llvm_boxedstring_type_ptr, *llvm_dict_type_ptr, *llvm_aststmt_type_ptr, *llvm_astexpr_type_ptr;
llvm::Type* llvm_frame_info_type;
llvm::Type* llvm_clfunction_type_ptr, *llvm_closure_type_ptr, *llvm_generator_type_ptr;
llvm::Type* llvm_functionmetadata_type_ptr, *llvm_closure_type_ptr, *llvm_generator_type_ptr;
llvm::Type* llvm_module_type_ptr, *llvm_bool_type_ptr;
llvm::Type* llvm_excinfo_type;
llvm::Type* i1, *i8, *i8_ptr, *i32, *i64, *void_, *double_;
Expand Down
31 changes: 16 additions & 15 deletions src/codegen/compvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,9 @@ ConcreteCompilerVariable* UnknownType::hasnext(IREmitter& emitter, const OpInfo&
return boolFromI1(emitter, rtn_val);
}

CompilerVariable* makeFunction(IREmitter& emitter, CLFunction* f, CompilerVariable* closure, llvm::Value* globals,
CompilerVariable* makeFunction(IREmitter& emitter, FunctionMetadata* f, CompilerVariable* closure, llvm::Value* globals,
const std::vector<ConcreteCompilerVariable*>& defaults) {
// Unlike the CLFunction*, which can be shared between recompilations, the Box* around it
// Unlike the FunctionMetadata*, which can be shared between recompilations, the Box* around it
// should be created anew every time the functiondef is encountered

llvm::Value* closure_v;
Expand Down Expand Up @@ -844,8 +844,9 @@ CompilerVariable* makeFunction(IREmitter& emitter, CLFunction* f, CompilerVariab
// We know this function call can't throw, so it's safe to use emitter.getBuilder()->CreateCall() rather than
// emitter.createCall().
llvm::Value* boxed = emitter.getBuilder()->CreateCall(
g.funcs.boxCLFunction, std::vector<llvm::Value*>{ embedRelocatablePtr(f, g.llvm_clfunction_type_ptr), closure_v,
globals, scratch, getConstantInt(defaults.size(), g.i64) });
g.funcs.createFunctionFromMetadata,
std::vector<llvm::Value*>{ embedRelocatablePtr(f, g.llvm_functionmetadata_type_ptr), closure_v, globals,
scratch, getConstantInt(defaults.size(), g.i64) });

if (convertedClosure)
convertedClosure->decvref(emitter);
Expand Down Expand Up @@ -914,12 +915,12 @@ class AbstractFunctionType : public CompilerType {

static CompilerType* fromRT(BoxedFunction* rtfunc, bool stripfirst) {
std::vector<Sig*> sigs;
CLFunction* clf = rtfunc->f;
FunctionMetadata* md = rtfunc->md;

assert(!rtfunc->can_change_defaults);

for (int i = 0; i < clf->versions.size(); i++) {
CompiledFunction* cf = clf->versions[i];
for (int i = 0; i < md->versions.size(); i++) {
CompiledFunction* cf = md->versions[i];

FunctionSpecialization* fspec = cf->spec;

Expand Down Expand Up @@ -1864,14 +1865,14 @@ class NormalObjectType : public ConcreteCompilerType {
// but I don't think we should be running into that case.
RELEASE_ASSERT(!rtattr_func->can_change_defaults, "could handle this but unexpected");

CLFunction* cl = rtattr_func->f;
assert(cl);
FunctionMetadata* md = rtattr_func->md;
assert(md);

ParamReceiveSpec paramspec = rtattr_func->getParamspec();
if (cl->takes_varargs || paramspec.takes_kwargs)
if (md->takes_varargs || paramspec.takes_kwargs)
return NULL;

RELEASE_ASSERT(paramspec.num_args == cl->numReceivedArgs(), "");
RELEASE_ASSERT(paramspec.num_args == md->numReceivedArgs(), "");
RELEASE_ASSERT(args.size() + 1 >= paramspec.num_args - paramspec.num_defaults
&& args.size() + 1 <= paramspec.num_args,
"%d", info.unw_info.current_stmt->lineno);
Expand All @@ -1880,9 +1881,9 @@ class NormalObjectType : public ConcreteCompilerType {
CompiledFunction* best_exception_mismatch = NULL;
bool found = false;
// TODO have to find the right version.. similar to resolveclfunc?
for (int i = 0; i < cl->versions.size(); i++) {
cf = cl->versions[i];
assert(cf->spec->arg_types.size() == cl->numReceivedArgs());
for (int i = 0; i < md->versions.size(); i++) {
cf = md->versions[i];
assert(cf->spec->arg_types.size() == md->numReceivedArgs());

bool fits = true;
for (int j = 0; j < args.size(); j++) {
Expand Down Expand Up @@ -1914,7 +1915,7 @@ class NormalObjectType : public ConcreteCompilerType {
RELEASE_ASSERT(cf->code, "");

std::vector<llvm::Type*> arg_types;
RELEASE_ASSERT(paramspec.num_args == cl->numReceivedArgs(), "");
RELEASE_ASSERT(paramspec.num_args == md->numReceivedArgs(), "");
for (int i = 0; i < paramspec.num_args; i++) {
// TODO support passing unboxed values as arguments
assert(cf->spec->arg_types[i]->llvmType() == g.llvm_value_type_ptr);
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/compvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ UnboxedSlice extractSlice(CompilerVariable* slice);
#if 0
CompilerVariable* makeUnicode(IREmitter& emitter, llvm::StringRef);
#endif
CompilerVariable* makeFunction(IREmitter& emitter, CLFunction*, CompilerVariable* closure, llvm::Value* globals,
CompilerVariable* makeFunction(IREmitter& emitter, FunctionMetadata*, CompilerVariable* closure, llvm::Value* globals,
const std::vector<ConcreteCompilerVariable*>& defaults);
ConcreteCompilerVariable* undefVariable();
CompilerVariable* makeTuple(const std::vector<CompilerVariable*>& elts);
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/irgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ static std::string getUniqueFunctionName(std::string nameprefix, EffortLevel eff
return os.str();
}

CompiledFunction* doCompile(CLFunction* clfunc, SourceInfo* source, ParamNames* param_names,
CompiledFunction* doCompile(FunctionMetadata* md, SourceInfo* source, ParamNames* param_names,
const OSREntryDescriptor* entry_descriptor, EffortLevel effort,
ExceptionStyle exception_style, FunctionSpecialization* spec, llvm::StringRef nameprefix) {
Timer _t("in doCompile");
Expand Down Expand Up @@ -1093,7 +1093,7 @@ CompiledFunction* doCompile(CLFunction* clfunc, SourceInfo* source, ParamNames*
else
phis = computeRequiredPhis(*param_names, source->cfg, liveness, source->getScopeInfo());

IRGenState irstate(clfunc, cf, source, std::move(phis), param_names, getGCBuilder(), dbg_funcinfo);
IRGenState irstate(md, cf, source, std::move(phis), param_names, getGCBuilder(), dbg_funcinfo);

emitBBs(&irstate, types, entry_descriptor, blocks);

Expand Down
2 changes: 1 addition & 1 deletion src/codegen/irgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ extern const std::string PASSED_GENERATOR_NAME;
InternedString getIsDefinedName(InternedString name, InternedStringPool& interned_strings);
bool isIsDefinedName(llvm::StringRef name);

CompiledFunction* doCompile(CLFunction* clfunc, SourceInfo* source, ParamNames* param_names,
CompiledFunction* doCompile(FunctionMetadata* md, SourceInfo* source, ParamNames* param_names,
const OSREntryDescriptor* entry_descriptor, EffortLevel effort,
ExceptionStyle exception_style, FunctionSpecialization* spec, llvm::StringRef nameprefix);

Expand Down
Loading