Commit 353e7876 authored by Kevin Modzelewski's avatar Kevin Modzelewski

gets pretty far

parent 62728299
......@@ -1769,7 +1769,7 @@ static void init_slotdefs() noexcept {
return;
for (int i = 0; i < sizeof(slotdefs) / sizeof(slotdefs[0]); i++) {
slotdefs[i].name_strobj = internStringImmortal(slotdefs[i].name.data());
slotdefs[i].name_strobj = getStringConstant(slotdefs[i].name.data());
if (i > 0) {
if (!slotdefs[i].name.size())
......@@ -1860,13 +1860,13 @@ static const slotdef* update_one_slot(BoxedClass* type, const slotdef* p) noexce
// there was only one:
assert((p + 1)->offset > p->offset);
static BoxedString* class_str = internStringImmortal("__class__");
static BoxedString* class_str = getStringConstant("__class__");
if (p->name_strobj == class_str) {
if (descr == object_cls->getattr(class_str))
descr = NULL;
}
static BoxedString* getattribute_str = internStringImmortal("__getattribute__");
static BoxedString* getattribute_str = getStringConstant("__getattribute__");
if (p->name_strobj == getattribute_str) {
if (descr && descr->cls == wrapperdescr_cls
&& ((BoxedWrapperDescriptor*)descr)->wrapped == PyObject_GenericGetAttr)
......@@ -2095,9 +2095,11 @@ void add_operators(BoxedClass* cls) noexcept {
continue;
if (*ptr == PyObject_HashNotImplemented) {
cls->giveAttr(p.name_strobj, None);
cls->setattr(p.name_strobj, None, NULL);
} else {
cls->giveAttr(p.name_strobj, new BoxedWrapperDescriptor(&p, cls, *ptr));
auto descr = new BoxedWrapperDescriptor(&p, cls, *ptr);
cls->setattr(p.name_strobj, descr, NULL);
Py_DECREF(descr);
}
}
......
......@@ -295,6 +295,8 @@ class ICInfo;
class LocationMap;
class JitCodeBlock;
extern std::vector<Box*> constants;
// A specific compilation of a FunctionMetadata. Usually these will be created by the LLVM JIT, which will take a FunctionMetadata
// and some compilation settings, and produce a CompiledFunction
// CompiledFunctions can also be created from raw function pointers, using FunctionMetadata::create.
......
......@@ -1172,8 +1172,6 @@ void setupInt() {
int_cls->giveAttr("__getnewargs__", new BoxedFunction(FunctionMetadata::create((void*)int_getnewargs, UNKNOWN, 1,
ParamNames::empty(), CAPI)));
return;
_addFuncIntFloatUnknown("__add__", (void*)intAddInt, (void*)intAddFloat, (void*)intAdd);
_addFuncIntUnknown("__and__", BOXED_INT, (void*)intAndInt, (void*)intAnd);
_addFuncIntUnknown("__or__", BOXED_INT, (void*)intOrInt, (void*)intOr);
......
......@@ -414,6 +414,7 @@ extern "C" BoxedFunctionBase::BoxedFunctionBase(FunctionMetadata* md, std::initi
int i = 0;
for (auto e : defaults) {
assert(!e || gc::isValidGCObject(e));
Py_XINCREF(e);
this->defaults->elts[i] = e;
++i;
}
......@@ -3676,10 +3677,10 @@ done:
#define PRINT_TOTAL_REFS() fprintf(stderr, "[%" PY_FORMAT_SIZE_T "d refs]\n", _Py_GetRefTotal())
#endif
std::vector<Box*> constants;
bool TRACK_ALLOCATIONS = false;
void setupRuntime() {
std::vector<Box*> constants;
root_hcls = HiddenClass::makeRoot();
gc::registerPermanentRoot(root_hcls);
HiddenClass::dict_backed = HiddenClass::makeDictBacked();
......
......@@ -1197,6 +1197,12 @@ inline Box*& getArg(int idx, Box*& arg1, Box*& arg2, Box*& arg3, Box** args) {
return arg3;
return args[idx - 3];
}
inline BoxedString* getStringConstant(llvm::StringRef s) {
BoxedString* r = internStringImmortal(s);
constants.push_back(r);
return r;
}
}
#endif
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