Commit 51cf8080 authored by Kevin Modzelewski's avatar Kevin Modzelewski

A variety of GC fixes

parent 4da376b5
......@@ -87,6 +87,9 @@ int main(int argc, char** argv) {
const char* fn = NULL;
threading::registerMainThread();
threading::GLReadRegion _glock;
{
Timer _t("for initCodegen");
initCodegen();
......@@ -108,9 +111,6 @@ int main(int argc, char** argv) {
// end of argument parsing
threading::registerMainThread();
threading::GLReadRegion _glock;
_t.split("to run");
if (fn != NULL) {
BoxedModule* main = createModule("__main__", fn);
......
......@@ -14,6 +14,7 @@
#include <algorithm>
#include <cstddef>
#include <err.h>
#include "codegen/compvars.h"
#include "core/ast.h"
......@@ -195,7 +196,8 @@ Box* open(Box* arg1, Box* arg2) {
const std::string& mode = static_cast<BoxedString*>(arg2)->s;
FILE* f = fopen(fn.c_str(), mode.c_str());
RELEASE_ASSERT(f, "");
if (!f)
raiseExcHelper(IOError, "%s: '%s' '%s'", strerror(errno), fn.c_str());
return new BoxedFile(f);
}
......
......@@ -300,6 +300,9 @@ BoxedClass::BoxedClass(BoxedClass* base, int attrs_offset, int instance_size, bo
assert(instance_size >= attrs_offset + sizeof(HCAttrs));
assert(attrs_offset % sizeof(void*) == 0); // Not critical I suppose, but probably signals a bug
}
if (!is_user_defined)
gc::registerStaticRootObj(this);
}
extern "C" const std::string* getNameOfClass(BoxedClass* cls) {
......
......@@ -110,8 +110,8 @@ extern "C" void functionGCHandler(GCVisitor* v, void* p) {
assert(f->defaults);
v->visit(f->defaults);
// do a conservative scan since there can be NULLs in there:
v->visitPotentialRange(reinterpret_cast<void* const*>(&f->defaults[0]),
reinterpret_cast<void* const*>(&f->defaults[f->ndefaults]));
v->visitPotentialRange(reinterpret_cast<void* const*>(&f->defaults->elts[0]),
reinterpret_cast<void* const*>(&f->defaults->elts[f->ndefaults]));
}
}
......@@ -443,7 +443,7 @@ Box* objectNew(BoxedClass* cls, BoxedTuple* args) {
bool TRACK_ALLOCATIONS = false;
void setupRuntime() {
HiddenClass::getRoot();
gc::registerStaticRootObj(HiddenClass::getRoot());
object_cls = new BoxedClass(NULL, 0, sizeof(Box), false);
type_cls = new BoxedClass(object_cls, offsetof(BoxedClass, attrs), sizeof(BoxedClass), false);
......
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