Commit c02424de authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #537 from kmod/exec_in_other_module

Fix `exec s in other_module`
parents 7009ec5d e9843cfa
......@@ -441,9 +441,9 @@ Value ASTInterpreter::visit_jump(AST_Jump* node) {
if (backedge)
threading::allowGLReadPreemption();
if (ENABLE_OSR && backedge && (globals->cls == module_cls)) {
bool can_osr = !FORCE_INTERPRETER && (globals->cls == module_cls);
if (can_osr && edgecount++ == OSR_THRESHOLD_INTERPRETER) {
if (ENABLE_OSR && backedge && edgecount++ == OSR_THRESHOLD_INTERPRETER) {
bool can_osr = !FORCE_INTERPRETER && source_info->scoping->areGlobalsFromModule();
if (can_osr) {
static StatCounter ast_osrs("num_ast_osrs");
ast_osrs.log();
......
......@@ -310,7 +310,8 @@ public:
explicit IREmitterImpl(IRGenState* irstate, llvm::BasicBlock*& curblock, IRGenerator* irgenerator)
: irstate(irstate), builder(new IRBuilder(g.context)), curblock(curblock), irgenerator(irgenerator) {
ASSERT(irstate->getSourceInfo()->scoping->areGlobalsFromModule(), "jit doesn't support custom globals yet");
RELEASE_ASSERT(irstate->getSourceInfo()->scoping->areGlobalsFromModule(),
"jit doesn't support custom globals yet");
builder->setEmitter(this);
builder->SetInsertPoint(curblock);
......
......@@ -60,12 +60,7 @@ static bool unbuffered = false;
static const char* argv0;
static int pipefds[2];
static void handle_sigsegv(int signum) {
assert(signum == SIGSEGV);
// TODO: this should set a flag saying a KeyboardInterrupt is pending.
// For now, just call abort(), so that we get a traceback at least.
fprintf(stderr, "child encountered segfault! signalling parent watcher to backtrace.\n");
static void signal_parent_watcher() {
char buf[1];
int r = write(pipefds[1], buf, 1);
RELEASE_ASSERT(r == 1, "");
......@@ -75,6 +70,20 @@ static void handle_sigsegv(int signum) {
}
}
static void handle_sigsegv(int signum) {
assert(signum == SIGSEGV);
fprintf(stderr, "child encountered segfault! signalling parent watcher to backtrace.\n");
signal_parent_watcher();
}
static void handle_sigabrt(int signum) {
assert(signum == SIGABRT);
fprintf(stderr, "child aborted! signalling parent watcher to backtrace.\n");
signal_parent_watcher();
}
static int gdb_child_pid;
static void propagate_sig(int signum) {
// fprintf(stderr, "parent received signal %d, passing to child and then ignoring\n", signum);
......@@ -136,6 +145,7 @@ static void enableGdbSegfaultWatcher() {
close(pipefds[0]);
signal(SIGSEGV, &handle_sigsegv);
signal(SIGABRT, &handle_sigabrt);
}
int handleArg(char code) {
......
......@@ -29,7 +29,7 @@ python -c 'from PIL import Image; print "Pillow imports"'
""".strip()
# print sh_script
subprocess.check_call(["sh", "-c", sh_script])
subprocess.check_call(["sh", "-c", sh_script], stdout=sys.stderr)
print
print "PASSED"
......@@ -161,3 +161,20 @@ s = "from sys import *"
g = dict()
exec s in g
print "version" in g
# Test to make sure that 'exec s in other_module' is handled correctly:
import import_target
assert import_target.z == 2
z = 3
exec "print z" in import_target.__dict__, {}
exec "print z" in globals(), {}
# Try it with osr as well:
s = """
print z
for i in xrange(20000):
pass
print z
"""
exec s in import_target.__dict__, {}
exec s in globals(), {}
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