Commit 7fd2c60c authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #1169 from kmod/enable_gcc

Enable the gcc build
parents a16e602b ec3339ba
......@@ -6,14 +6,12 @@ branches:
compiler:
- clang
# XXX: temporarily disable
# - gcc
- gcc
env:
matrix:
- TRAVIS_BUILD_TYPE=Debug CCACHE_DIR=$HOME/.ccache_debug
# XXX: temporarily disable
# - TRAVIS_BUILD_TYPE=Release CCACHE_DIR=$HOME/.ccache_release
- TRAVIS_BUILD_TYPE=Release CCACHE_DIR=$HOME/.ccache_release
global:
- PYSTON_RUN_ARGS=G
......
......@@ -339,7 +339,8 @@ endif()
add_pyston_test(defaults cpython --exit-code-only --skip-failing -t100)
add_pyston_test(defaults integration --exit-code-only --skip-failing -t600)
if(ENABLE_EXTRA_TESTS)
add_pyston_test(defaults extra -t900 --exit-code-only)
# XXX: reenable
# add_pyston_test(defaults extra -t900 --exit-code-only)
endif()
......
......@@ -600,7 +600,7 @@ _PyImport_FixupExtension(char *name, char *filename)
{
PyObject *modules, *mod, *dict, *copy;
if (extensions == NULL) {
extensions = PyGC_RegisterStaticConstant(PyDict_New());
extensions = PyDict_New();
if (extensions == NULL)
return NULL;
}
......
This diff is collapsed.
......@@ -3105,37 +3105,14 @@ void setattrGeneric(Box* obj, BoxedString* attr, STOLEN(Box*) val, SetattrRewrit
template void setattrGeneric<NOT_REWRITABLE>(Box* obj, BoxedString* attr, Box* val, SetattrRewriteArgs* rewrite_args);
template void setattrGeneric<REWRITABLE>(Box* obj, BoxedString* attr, Box* val, SetattrRewriteArgs* rewrite_args);
extern "C" void setattr(Box* obj, BoxedString* attr, STOLEN(Box*) attr_val) {
STAT_TIMER(t0, "us_timer_slowpath_setattr", 10);
static StatCounter slowpath_setattr("slowpath_setattr");
slowpath_setattr.log();
if (obj->cls->tp_setattr) {
STAT_TIMER(t1, "us_timer_slowpath_tpsetattr", 10);
assert(attr->data()[attr->size()] == '\0');
AUTO_DECREF(attr_val);
int rtn = obj->cls->tp_setattr(obj, const_cast<char*>(attr->data()), attr_val);
if (rtn)
throwCAPIException();
return;
}
std::unique_ptr<Rewriter> rewriter(
Rewriter::createRewriter(__builtin_extract_return_addr(__builtin_return_address(0)), 3, "setattr"));
void setattrInternal(Box* obj, BoxedString* attr, STOLEN(Box*) attr_val, SetattrRewriteArgs* rewrite_args) {
setattrofunc tp_setattro = obj->cls->tp_setattro;
assert(tp_setattro);
assert(!obj->cls->tp_setattr);
if (rewriter.get()) {
rewriter->getArg(0)->setType(RefType::BORROWED);
rewriter->getArg(1)->setType(RefType::BORROWED);
rewriter->getArg(2)->setType(RefType::OWNED);
auto r_cls = rewriter->getArg(0)->getAttr(offsetof(Box, cls));
if (rewrite_args) {
auto r_cls = rewrite_args->obj->getAttr(offsetof(Box, cls));
// rewriter->trap();
r_cls->addAttrGuard(offsetof(BoxedClass, tp_setattr), 0);
r_cls->addAttrGuard(offsetof(BoxedClass, tp_setattro), (intptr_t)tp_setattro);
......@@ -3147,19 +3124,14 @@ extern "C" void setattr(Box* obj, BoxedString* attr, STOLEN(Box*) attr_val) {
RewriterVar* r_setattr;
if (tp_setattro == instance_setattro) {
if (rewriter.get()) {
SetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getArg(2));
instanceSetattroInternal(obj, attr, attr_val, &rewrite_args);
if (rewrite_args.out_success)
rewriter->commit();
} else
instanceSetattroInternal(obj, attr, attr_val, NULL);
instanceSetattroInternal(obj, attr, attr_val, rewrite_args);
return;
} else if (tp_setattro != PyObject_GenericSetAttr) {
// TODO: rewrite these cases?
#if 0
static BoxedString* setattr_str = getStaticString("__setattr__");
if (rewriter.get()) {
GetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0)->getAttr(offsetof(Box, cls)),
if (rewrite_args) {
GetattrRewriteArgs rewrite_args(rewrite_args->rewriter, rewrite_args->obj->getAttr(offsetof(Box, cls)),
Location::any());
setattr = typeLookup(obj->cls, setattr_str, &rewrite_args);
assert(setattr);
......@@ -3174,37 +3146,28 @@ extern "C" void setattr(Box* obj, BoxedString* attr, STOLEN(Box*) attr_val) {
} else {
// setattr = typeLookup(obj->cls, setattr_str);
}
#endif
}
// This is a borrowed reference so we don't need to register it
static Box* object_setattr = object_cls->getattr(getStaticString("__setattr__"));
// I guess this check makes it ok for us to just rely on having guarded on the value of setattr without
// invalidating on deallocation, since we assume that object.__setattr__ will never get deallocated.
if (tp_setattro == PyObject_GenericSetAttr) {
if (rewriter.get()) {
// rewriter->trap();
SetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getArg(2));
setattrGeneric<REWRITABLE>(obj, attr, attr_val, &rewrite_args);
if (rewrite_args.out_success)
rewriter->commit();
} else {
setattrGeneric<NOT_REWRITABLE>(obj, attr, attr_val, NULL);
}
setattrGeneric<REWRITABLE>(obj, attr, attr_val, rewrite_args);
return;
}
AUTO_DECREF(attr_val);
if (rewriter.get()) {
// TODO actually rewrite this?
#if 0
if (rewrite_args) {
assert(setattr);
// TODO actually rewrite this?
setattr = processDescriptor(setattr, obj, obj->cls);
AUTO_DECREF(setattr);
autoDecref(
runtimeCallInternal<CXX, REWRITABLE>(setattr, NULL, ArgPassSpec(2), attr, attr_val, NULL, NULL, NULL));
} else {
} else
#endif
{
STAT_TIMER(t0, "us_timer_slowpath_tpsetattro", 10);
int r = tp_setattro(obj, attr, attr_val);
if (r)
......@@ -3212,6 +3175,39 @@ extern "C" void setattr(Box* obj, BoxedString* attr, STOLEN(Box*) attr_val) {
}
}
extern "C" void setattr(Box* obj, BoxedString* attr, STOLEN(Box*) attr_val) {
STAT_TIMER(t0, "us_timer_slowpath_setattr", 10);
static StatCounter slowpath_setattr("slowpath_setattr");
slowpath_setattr.log();
if (obj->cls->tp_setattr) {
STAT_TIMER(t1, "us_timer_slowpath_tpsetattr", 10);
assert(attr->data()[attr->size()] == '\0');
AUTO_DECREF(attr_val);
int rtn = obj->cls->tp_setattr(obj, const_cast<char*>(attr->data()), attr_val);
if (rtn)
throwCAPIException();
return;
}
std::unique_ptr<Rewriter> rewriter(
Rewriter::createRewriter(__builtin_extract_return_addr(__builtin_return_address(0)), 3, "setattr"));
if (rewriter.get()) {
SetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0)->setType(RefType::BORROWED),
rewriter->getArg(2)->setType(RefType::OWNED));
rewriter->getArg(1)->setType(RefType::BORROWED);
setattrInternal(obj, attr, attr_val, &rewrite_args);
if (rewrite_args.out_success)
rewriter->commit();
} else {
setattrInternal(obj, attr, attr_val, NULL);
}
}
static bool nonzeroHelper(STOLEN(Box*) r) {
AUTO_DECREF(r);
......@@ -4217,6 +4213,9 @@ void rearrangeArgumentsInternal(ParamReceiveSpec paramspec, const ParamNames* pa
Box* arg3 = oarg3;
oarg1 = oarg2 = oarg3 = NULL;
if (oargs)
memset(oargs, 0, sizeof(Box*) * (num_output_args - 3));
// Clear any increfs we did for when we throw an exception:
auto clear_refs = [&]() {
Py_XDECREF(oarg1);
......@@ -7284,14 +7283,23 @@ extern "C" void setGlobal(Box* globals, BoxedString* name, STOLEN(Box*) value) {
}
if (globals->cls == module_cls) {
// Note: in optimized builds, this will be a tail call, which will
// preserve the return address, letting the setattr() call rewrite itself.
// XXX this isn't really safe in general, since the guards that led to this
// path need to end up in the rewrite. I think this is safe for now since
// writing the module case won't accidentally work for the dict case, but
// we should make all the entrypoints (the ones that look at the return address)
// be noinline.
setattr(static_cast<BoxedModule*>(globals), name, value);
std::unique_ptr<Rewriter> rewriter(
Rewriter::createRewriter(__builtin_extract_return_addr(__builtin_return_address(0)), 3, "setattr"));
if (rewriter.get()) {
SetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0)->setType(RefType::BORROWED),
rewriter->getArg(2)->setType(RefType::OWNED));
rewriter->getArg(1)->setType(RefType::BORROWED);
rewrite_args.obj->addAttrGuard(offsetof(Box, cls), (uint64_t)globals->cls);
setattrInternal(globals, name, value, &rewrite_args);
if (rewrite_args.out_success)
rewriter->commit();
} else {
setattrInternal(globals, name, value, NULL);
}
} else {
RELEASE_ASSERT(globals->cls == dict_cls, "%s", globals->cls->tp_name);
int r = PyDict_SetItem(globals, name, value);
......
......@@ -41,7 +41,7 @@ extern "C" void rawReraise(Box*, Box*, Box*) __attribute__((__noreturn__));
void raiseExc(STOLEN(Box*) exc_obj) __attribute__((__noreturn__));
void _printStacktrace();
extern "C" Box* deopt(AST_expr* expr, Box* value);
extern "C" Box* deopt(AST_expr* expr, Box* value) __attribute__((noinline));
// helper function for raising from the runtime:
void raiseExcHelper(BoxedClass*, const char* fmt, ...) __attribute__((__noreturn__))
......@@ -51,45 +51,46 @@ void raiseExcHelper(BoxedClass*, Box* arg) __attribute__((__noreturn__));
// TODO sort this
extern "C" void printHelper(Box* dest, Box* var, bool nl);
extern "C" void my_assert(bool b);
extern "C" Box* getattr(Box* obj, BoxedString* attr);
extern "C" Box* getattr_capi(Box* obj, BoxedString* attr) noexcept;
extern "C" Box* getattr(Box* obj, BoxedString* attr) __attribute__((noinline));
extern "C" Box* getattr_capi(Box* obj, BoxedString* attr) noexcept __attribute__((noinline));
extern "C" Box* getattrMaybeNonstring(Box* obj, Box* attr);
// XXX: testing. this tail-calls in optimized builds so force it to inline for unoptimized as well to get the same
// behavior.
extern "C" void setattr(Box* obj, BoxedString* attr, STOLEN(Box*) attr_val) __attribute__((always_inline));
extern "C" void setattrMaybeNonstring(Box* obj, Box* attr, Box* attr_val);
extern "C" void delattr(Box* obj, BoxedString* attr);
extern "C" void delattrMaybeNonstring(Box* obj, Box* attr);
extern "C" void setattr(Box* obj, BoxedString* attr, STOLEN(Box*) attr_val) __attribute__((noinline));
extern "C" void delattr(Box* obj, BoxedString* attr) __attribute__((noinline));
extern "C" void delattrGeneric(Box* obj, BoxedString* attr, DelattrRewriteArgs* rewrite_args);
extern "C" bool nonzero(Box* obj);
extern "C" Box* runtimeCall(Box*, ArgPassSpec, Box*, Box*, Box*, Box**, const std::vector<BoxedString*>*);
extern "C" Box* runtimeCallCapi(Box*, ArgPassSpec, Box*, Box*, Box*, Box**, const std::vector<BoxedString*>*) noexcept;
extern "C" Box* callattr(Box*, BoxedString*, CallattrFlags, Box*, Box*, Box*, Box**, const std::vector<BoxedString*>*);
extern "C" bool nonzero(Box* obj) __attribute__((noinline));
extern "C" Box* runtimeCall(Box*, ArgPassSpec, Box*, Box*, Box*, Box**, const std::vector<BoxedString*>*)
__attribute__((noinline));
extern "C" Box* runtimeCallCapi(Box*, ArgPassSpec, Box*, Box*, Box*, Box**, const std::vector<BoxedString*>*) noexcept
__attribute__((noinline));
extern "C" Box* callattr(Box*, BoxedString*, CallattrFlags, Box*, Box*, Box*, Box**, const std::vector<BoxedString*>*)
__attribute__((noinline));
extern "C" Box* callattrCapi(Box*, BoxedString*, CallattrFlags, Box*, Box*, Box*, Box**,
const std::vector<BoxedString*>*) noexcept;
extern "C" BoxedString* str(Box* obj);
extern "C" BoxedString* repr(Box* obj);
extern "C" bool exceptionMatches(Box* obj, Box* cls);
extern "C" BoxedInt* hash(Box* obj);
extern "C" int64_t hashUnboxed(Box* obj);
const std::vector<BoxedString*>*) noexcept __attribute__((noinline));
extern "C" BoxedString* str(Box* obj) __attribute__((noinline));
extern "C" BoxedString* repr(Box* obj) __attribute__((noinline));
extern "C" bool exceptionMatches(Box* obj, Box* cls) __attribute__((noinline));
extern "C" BoxedInt* hash(Box* obj) __attribute__((noinline));
extern "C" int64_t hashUnboxed(Box* obj) __attribute__((noinline));
extern "C" Box* abs_(Box* obj);
// extern "C" Box* chr(Box* arg);
extern "C" Box* compare(Box*, Box*, int);
extern "C" BoxedInt* len(Box* obj);
extern "C" Box* compare(Box*, Box*, int) __attribute__((noinline));
extern "C" BoxedInt* len(Box* obj) __attribute__((noinline));
// extern "C" Box* trap();
extern "C" i64 unboxedLen(Box* obj);
extern "C" Box* binop(Box* lhs, Box* rhs, int op_type);
extern "C" Box* augbinop(Box* lhs, Box* rhs, int op_type);
extern "C" Box* getitem(Box* value, Box* slice);
extern "C" Box* getitem_capi(Box* value, Box* slice) noexcept;
extern "C" void setitem(Box* target, Box* slice, Box* value);
extern "C" void delitem(Box* target, Box* slice);
extern "C" i64 unboxedLen(Box* obj) __attribute__((noinline));
extern "C" Box* binop(Box* lhs, Box* rhs, int op_type) __attribute__((noinline));
extern "C" Box* augbinop(Box* lhs, Box* rhs, int op_type) __attribute__((noinline));
extern "C" Box* getitem(Box* value, Box* slice) __attribute__((noinline));
extern "C" Box* getitem_capi(Box* value, Box* slice) noexcept __attribute__((noinline));
extern "C" void setitem(Box* target, Box* slice, Box* value) __attribute__((noinline));
extern "C" void delitem(Box* target, Box* slice) __attribute__((noinline));
extern "C" PyObject* apply_slice(PyObject* u, PyObject* v, PyObject* w) noexcept;
extern "C" Box* getclsattr(Box* obj, BoxedString* attr);
extern "C" Box* getclsattrMaybeNonstring(Box* obj, Box* attr);
extern "C" Box* unaryop(Box* operand, int op_type);
extern "C" Box* importFrom(Box* obj, BoxedString* attr);
extern "C" Box* importStar(Box* from_module, Box* to_globals);
extern "C" Box* getclsattr(Box* obj, BoxedString* attr) __attribute__((noinline));
extern "C" Box* getclsattrMaybeNonstring(Box* obj, Box* attr) __attribute__((noinline));
extern "C" Box* unaryop(Box* operand, int op_type) __attribute__((noinline));
extern "C" Box* importFrom(Box* obj, BoxedString* attr) __attribute__((noinline));
extern "C" Box* importStar(Box* from_module, Box* to_globals) __attribute__((noinline));
extern "C" Box** unpackIntoArray(Box* obj, int64_t expected_size, Box** out_keep_alive);
extern "C" void assertNameDefined(bool b, const char* name, BoxedClass* exc_cls, bool local_var_msg);
extern "C" void assertFailDerefNameDefined(const char* name);
......@@ -105,7 +106,7 @@ extern "C" BoxedClosure* createClosure(BoxedClosure* parent_closure, size_t size
Box* getiter(Box* o);
extern "C" Box* getPystonIter(Box* o);
extern "C" Box* getiterHelper(Box* o);
extern "C" Box* createBoxedIterWrapperIfNeeded(Box* o);
extern "C" Box* createBoxedIterWrapperIfNeeded(Box* o) __attribute__((noinline));
struct SetattrRewriteArgs;
template <Rewritable rewritable>
......@@ -220,9 +221,9 @@ inline std::tuple<Box*, Box*, Box*, Box**> getTupleFromArgsArray(Box** args, int
// Corresponds to a name lookup with GLOBAL scope. Checks the passed globals object, then the builtins,
// and if not found raises an exception.
extern "C" Box* getGlobal(Box* globals, BoxedString* name);
extern "C" void setGlobal(Box* globals, BoxedString* name, STOLEN(Box*) value);
extern "C" void delGlobal(Box* globals, BoxedString* name);
extern "C" Box* getGlobal(Box* globals, BoxedString* name) __attribute__((noinline));
extern "C" void setGlobal(Box* globals, BoxedString* name, STOLEN(Box*) value) __attribute__((noinline));
extern "C" void delGlobal(Box* globals, BoxedString* name) __attribute__((noinline));
extern "C" void boxedLocalsSet(Box* boxedLocals, BoxedString* attr, Box* val);
extern "C" Box* boxedLocalsGet(Box* boxedLocals, BoxedString* attr, Box* globals);
......
......@@ -4811,6 +4811,7 @@ extern "C" void Py_Finalize() noexcept {
PyGC_Collect();
PyImport_Cleanup();
_PyImport_Fini();
#ifdef Py_REF_DEBUG
IN_SHUTDOWN = true;
......
# skip-if: '-O' in EXTRA_JIT_ARGS
# skip-if: '-O' in EXTRA_JIT_ARGS or '-n' in EXTRA_JIT_ARGS
# statcheck: 4 <= noninit_count('num_deopt') < 50
# statcheck: 1 <= stats["num_osr_exits"] <= 2
......
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