Commit bff16616 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Support passing generator objects through the args array in OSR

Only gets hit when there are >=3 !is_defined names also set (other
fake names might also count towards this).
parent 0b650c38
......@@ -402,6 +402,8 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
ptr = entry_emitter->getBuilder()->CreateBitCast(ptr, BOOL->llvmType()->getPointerTo());
} else if (p.second == FLOAT) {
ptr = entry_emitter->getBuilder()->CreateBitCast(ptr, g.double_->getPointerTo());
} else if (p.second == GENERATOR) {
ptr = entry_emitter->getBuilder()->CreateBitCast(ptr, g.llvm_generator_type_ptr->getPointerTo());
} else {
assert(p.second->llvmType() == g.llvm_value_type_ptr);
}
......
......@@ -196,7 +196,7 @@ extern "C" BoxedGenerator::BoxedGenerator(BoxedFunctionBase* function, Box* arg1
void* initial_stack_limit = (void*)(stack_high - INITIAL_STACK_SIZE);
void* p = mmap(initial_stack_limit, INITIAL_STACK_SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS | MAP_GROWSDOWN, -1, 0);
assert(p == initial_stack_limit);
ASSERT(p == initial_stack_limit, "%p %s", p, strerror(errno));
context.uc_stack.ss_sp = initial_stack_limit;
context.uc_stack.ss_size = INITIAL_STACK_SIZE;
......
......@@ -7,3 +7,45 @@ def f(x):
print list(f(5))
# Reduced form of the 'permutations' test:
def f2(x):
if 0:
a, b, c, d, e = range(5)
for i in xrange(20000):
pass
yield x
if 0:
print a, b, c, d, e
print list(f2(5))
# Regression test taken from bm_ai.py:
# Pure-Python implementation of itertools.permutations().
def permutations(iterable, r=None):
"""permutations(range(3), 2) --> (0,1) (0,2) (1,0) (1,2) (2,0) (2,1)"""
pool = tuple(iterable)
n = len(pool)
if r is None:
r = n
indices = range(n)
cycles = range(n-r+1, n+1)[::-1]
yield tuple(pool[i] for i in indices[:r])
while n:
for i in reversed(range(r)):
cycles[i] -= 1
if cycles[i] == 0:
indices[i:] = indices[i+1:] + indices[i:i+1]
cycles[i] = n - i
else:
j = cycles[i]
indices[i], indices[-j] = indices[-j], indices[i]
yield tuple(pool[i] for i in indices[:r])
break
else:
return
t = 0
for p in permutations(range(10), 3):
t += 1
print t
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