Commit 464c98e7 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #969 from kmod/unboxed3

Reenable unboxed values
parents 40c4e710 96555a1e
......@@ -57,15 +57,13 @@ ConcreteCompilerType* NullTypeAnalysis::getTypeAtBlockEnd(InternedString name, C
// Note: the behavior of this function must match irgenerator.cpp::unboxVar()
static ConcreteCompilerType* unboxedType(ConcreteCompilerType* t) {
static CompilerType* unboxedType(ConcreteCompilerType* t) {
if (t == BOXED_BOOL)
return BOOL;
#if ENABLE_UNBOXED_VALUES
if (t == BOXED_INT)
return INT;
if (t == BOXED_FLOAT)
return FLOAT;
#endif
return t;
}
......@@ -117,17 +115,17 @@ private:
assert(speculation != TypeAnalysis::NONE);
if (speculated_cls != NULL && speculated_cls->is_constant) {
ConcreteCompilerType* speculated_type = unboxedType(typeFromClass(speculated_cls));
CompilerType* speculated_type = unboxedType(typeFromClass(speculated_cls));
if (!old_type->canConvertTo(speculated_type)) {
if (VERBOSITY() >= 2) {
printf("in propagator, speculating that %s would actually be %s, at ", old_type->debugName().c_str(),
speculated_type->debugName().c_str());
printf("in propagator, speculating that %s would actually be %s, at ",
old_type->debugName().c_str(), speculated_type->debugName().c_str());
fflush(stdout);
print_ast(node);
llvm::outs().flush();
printf("\n");
}
if (!old_type->canConvertTo(speculated_type)) {
type_speculations[node] = speculated_cls;
return speculated_type;
}
......@@ -147,6 +145,7 @@ private:
}
expr_types[node] = rtn;
assert(rtn->isUsable());
return rtn;
}
......@@ -163,10 +162,12 @@ private:
}
expr_types[node] = rtn;
assert(rtn->isUsable());
return rtn;
}
void _doSet(InternedString target, CompilerType* t) {
assert(t->isUsable());
if (t)
sym_table[target] = t;
}
......@@ -196,7 +197,7 @@ private:
}
}
void* visit_ellipsis(AST_Ellipsis* node) override { return ELLIPSIS; }
void* visit_ellipsis(AST_Ellipsis* node) override { return typeFromClass(ellipsis_cls); }
void* visit_attribute(AST_Attribute* node) override {
CompilerType* t = getType(node->value);
......
This diff is collapsed.
......@@ -47,7 +47,7 @@ public:
virtual std::string debugName() = 0;
virtual ConcreteCompilerType* getConcreteType() = 0;
virtual ConcreteCompilerType* getBoxType() = 0;
virtual bool canConvertTo(ConcreteCompilerType* other_type) = 0;
virtual bool canConvertTo(CompilerType* other_type) = 0;
virtual CompilerType* getattrType(BoxedString* attr, bool cls_only) = 0;
virtual CompilerType* getPystonIterType();
virtual Result hasattr(BoxedString* attr);
......@@ -58,6 +58,13 @@ public:
virtual Box* deserializeFromFrame(const FrameVals& vals) = 0;
virtual int numFrameArgs() = 0;
virtual std::vector<CompilerType*> unpackTypes(int num_into);
// Some types are not "usable" even if they are "concrete". Concrete means that it's possible to
// represent the value as an llvm::Value*; usable means that we are allowed to use it as a variable's
// type. Some concrete types are not usable; for example unboxed ints are concrete (can be represented
// as an i64) but are not usable, since we need to use the form that remembers what it gets boxed to.
virtual CompilerType* getUsableType() { return this; }
bool isUsable() { return this == getUsableType(); }
};
typedef std::unordered_map<CompilerVariable*, CompilerVariable*> DupCache;
......@@ -94,7 +101,7 @@ public:
printf("grab not defined for %s\n", debugName().c_str());
abort();
}
bool canConvertTo(ConcreteCompilerType* other_type) override {
bool canConvertTo(CompilerType* other_type) override {
printf("canConvertTo not defined for %s\n", debugName().c_str());
abort();
}
......@@ -102,13 +109,12 @@ public:
printf("makeConverted not defined for %s\n", debugName().c_str());
abort();
}
virtual ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, VAR* var) {
virtual CompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, VAR* var) {
printf("nonzero not defined for %s\n", debugName().c_str());
abort();
}
virtual ConcreteCompilerVariable* unaryop(IREmitter& emitter, const OpInfo& info, VAR* var,
AST_TYPE::AST_TYPE op_type);
virtual ConcreteCompilerVariable* hasnext(IREmitter& emitter, const OpInfo& info, VAR* var) {
virtual CompilerVariable* unaryop(IREmitter& emitter, const OpInfo& info, VAR* var, AST_TYPE::AST_TYPE op_type);
virtual CompilerVariable* hasnext(IREmitter& emitter, const OpInfo& info, VAR* var) {
printf("hasnext not defined for %s\n", debugName().c_str());
abort();
}
......@@ -139,7 +145,7 @@ public:
printf("call not defined for %s\n", debugName().c_str());
abort();
}
virtual ConcreteCompilerVariable* len(IREmitter& emitter, const OpInfo& info, VAR* var) {
virtual CompilerVariable* len(IREmitter& emitter, const OpInfo& info, VAR* var) {
printf("len not defined for %s\n", debugName().c_str());
abort();
}
......@@ -202,7 +208,7 @@ public:
CompilerVariable* dup(ConcreteCompilerVariable* v, DupCache& cache) override;
ConcreteCompilerType* getConcreteType() override { return this; }
bool canConvertTo(ConcreteCompilerType* other_type) override { return other_type == this || other_type == UNKNOWN; }
bool canConvertTo(CompilerType* other_type) override { return other_type == this || other_type == UNKNOWN; }
ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerVariable* var,
ConcreteCompilerType* other_type) override;
void serializeToFrame(VAR* var, std::vector<llvm::Value*>& stackmap_args) override;
......@@ -261,14 +267,14 @@ public:
virtual CompilerType* getType() = 0;
virtual ConcreteCompilerType* getConcreteType() = 0;
virtual ConcreteCompilerType* getBoxType() = 0;
virtual bool canConvertTo(ConcreteCompilerType* other_type) = 0;
virtual bool canConvertTo(CompilerType* other_type) = 0;
virtual ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerType* other_type) = 0;
virtual llvm::Value* makeClassCheck(IREmitter& emitter, BoxedClass* cls) = 0;
virtual BoxedClass* guaranteedClass() = 0;
virtual ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info) = 0;
virtual ConcreteCompilerVariable* unaryop(IREmitter& emitter, const OpInfo& info, AST_TYPE::AST_TYPE op_type) = 0;
virtual ConcreteCompilerVariable* hasnext(IREmitter& emitter, const OpInfo& info) = 0;
virtual CompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info) = 0;
virtual CompilerVariable* unaryop(IREmitter& emitter, const OpInfo& info, AST_TYPE::AST_TYPE op_type) = 0;
virtual CompilerVariable* hasnext(IREmitter& emitter, const OpInfo& info) = 0;
virtual CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, BoxedString* attr, bool cls_only) = 0;
virtual void setattr(IREmitter& emitter, const OpInfo& info, BoxedString* attr, CompilerVariable* v) = 0;
virtual void delattr(IREmitter& emitter, const OpInfo& info, BoxedString* attr) = 0;
......@@ -278,7 +284,7 @@ public:
virtual CompilerVariable* call(IREmitter& emitter, const OpInfo& info, struct ArgPassSpec argspec,
const std::vector<CompilerVariable*>& args,
const std::vector<BoxedString*>* keyword_names) = 0;
virtual ConcreteCompilerVariable* len(IREmitter& emitter, const OpInfo& info) = 0;
virtual CompilerVariable* len(IREmitter& emitter, const OpInfo& info) = 0;
virtual CompilerVariable* getitem(IREmitter& emitter, const OpInfo& info, CompilerVariable*) = 0;
virtual CompilerVariable* getPystonIter(IREmitter& emitter, const OpInfo& info) = 0;
virtual CompilerVariable* binexp(IREmitter& emitter, const OpInfo& info, CompilerVariable* rhs,
......@@ -330,19 +336,19 @@ public:
return rtn;
}
bool canConvertTo(ConcreteCompilerType* other_type) override { return type->canConvertTo(other_type); }
bool canConvertTo(CompilerType* other_type) override { return type->canConvertTo(other_type); }
ConcreteCompilerVariable* makeConverted(IREmitter& emitter, ConcreteCompilerType* other_type) override {
ConcreteCompilerVariable* rtn = type->makeConverted(emitter, this, other_type);
ASSERT(rtn->getType() == other_type, "%s", type->debugName().c_str());
return rtn;
}
ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info) override {
CompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info) override {
return type->nonzero(emitter, info, this);
}
ConcreteCompilerVariable* unaryop(IREmitter& emitter, const OpInfo& info, AST_TYPE::AST_TYPE op_type) override {
CompilerVariable* unaryop(IREmitter& emitter, const OpInfo& info, AST_TYPE::AST_TYPE op_type) override {
return type->unaryop(emitter, info, this, op_type);
}
ConcreteCompilerVariable* hasnext(IREmitter& emitter, const OpInfo& info) override {
CompilerVariable* hasnext(IREmitter& emitter, const OpInfo& info) override {
return type->hasnext(emitter, info, this);
}
CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, BoxedString* attr, bool cls_only) override {
......@@ -366,9 +372,7 @@ public:
const std::vector<BoxedString*>* keyword_names) override {
return type->call(emitter, info, this, argspec, args, keyword_names);
}
ConcreteCompilerVariable* len(IREmitter& emitter, const OpInfo& info) override {
return type->len(emitter, info, this);
}
CompilerVariable* len(IREmitter& emitter, const OpInfo& info) override { return type->len(emitter, info, this); }
CompilerVariable* getitem(IREmitter& emitter, const OpInfo& info, CompilerVariable* slice) override {
return type->getitem(emitter, info, this, slice);
}
......@@ -407,9 +411,20 @@ public:
// Emit the test for whether one variable 'is' another one.
ConcreteCompilerVariable* doIs(IREmitter& emitter, CompilerVariable* lhs, CompilerVariable* rhs, bool negate);
// These functions all return an INT variable, from either an unboxed representation (makeInt) or
// a boxed representation (makeUnboxedInt)
CompilerVariable* makeInt(int64_t);
CompilerVariable* makeInt(llvm::Value*);
CompilerVariable* makeUnboxedInt(IREmitter&, ConcreteCompilerVariable*);
CompilerVariable* makeUnboxedInt(IREmitter&, llvm::Value*);
// Same for floats:
CompilerVariable* makeFloat(llvm::Value*);
CompilerVariable* makeFloat(double);
CompilerVariable* makeUnboxedFloat(IREmitter&, ConcreteCompilerVariable*);
CompilerVariable* makeUnboxedFloat(IREmitter&, llvm::Value*);
ConcreteCompilerVariable* makeBool(bool);
ConcreteCompilerVariable* makeInt(int64_t);
ConcreteCompilerVariable* makeFloat(double);
ConcreteCompilerVariable* makeLong(Box*);
ConcreteCompilerVariable* makePureImaginary(Box*);
CompilerVariable* makeStr(BoxedString*);
......@@ -447,7 +462,7 @@ CompilerVariable* _ValuedCompilerType<V>::contains(IREmitter& emitter, const OpI
}
template <typename V>
ConcreteCompilerVariable* _ValuedCompilerType<V>::unaryop(IREmitter& emitter, const OpInfo& info, VAR* var,
CompilerVariable* _ValuedCompilerType<V>::unaryop(IREmitter& emitter, const OpInfo& info, VAR* var,
AST_TYPE::AST_TYPE op_type) {
ConcreteCompilerVariable* converted = makeConverted(emitter, var, getBoxType());
auto r = UNKNOWN->unaryop(emitter, info, converted, op_type);
......
......@@ -799,7 +799,7 @@ private:
assert(node->args.size() == 1);
CompilerVariable* obj = evalExpr(node->args[0], unw_info);
ConcreteCompilerVariable* rtn = obj->nonzero(emitter, getOpInfoForNode(node, unw_info));
CompilerVariable* rtn = obj->nonzero(emitter, getOpInfoForNode(node, unw_info));
obj->decvref(emitter);
return rtn;
}
......@@ -807,7 +807,7 @@ private:
assert(node->args.size() == 1);
CompilerVariable* obj = evalExpr(node->args[0], unw_info);
ConcreteCompilerVariable* rtn = obj->hasnext(emitter, getOpInfoForNode(node, unw_info));
CompilerVariable* rtn = obj->hasnext(emitter, getOpInfoForNode(node, unw_info));
obj->decvref(emitter);
return rtn;
}
......@@ -1348,18 +1348,18 @@ private:
CompilerVariable* operand = evalExpr(node->operand, unw_info);
if (node->op_type == AST_TYPE::Not) {
ConcreteCompilerVariable* rtn = operand->nonzero(emitter, getOpInfoForNode(node, unw_info));
CompilerVariable* rtn = operand->nonzero(emitter, getOpInfoForNode(node, unw_info));
operand->decvref(emitter);
assert(rtn->getType() == BOOL);
llvm::Value* v = i1FromBool(emitter, rtn);
llvm::Value* v = i1FromBool(emitter, static_cast<ConcreteCompilerVariable*>(rtn));
assert(v->getType() == g.i1);
llvm::Value* negated = emitter.getBuilder()->CreateNot(v);
rtn->decvref(emitter);
return boolFromI1(emitter, negated);
} else {
ConcreteCompilerVariable* rtn = operand->unaryop(emitter, getOpInfoForNode(node, unw_info), node->op_type);
CompilerVariable* rtn = operand->unaryop(emitter, getOpInfoForNode(node, unw_info), node->op_type);
operand->decvref(emitter);
return rtn;
}
......@@ -1517,19 +1517,13 @@ private:
}
// Note: the behavior of this function must match type_analysis.cpp:unboxedType()
ConcreteCompilerVariable* unboxVar(ConcreteCompilerType* t, llvm::Value* v, bool grabbed) {
#if ENABLE_UNBOXED_VALUES
CompilerVariable* unboxVar(ConcreteCompilerType* t, llvm::Value* v, bool grabbed) {
if (t == BOXED_INT) {
llvm::Value* unboxed = emitter.getBuilder()->CreateCall(g.funcs.unboxInt, v);
ConcreteCompilerVariable* rtn = new ConcreteCompilerVariable(INT, unboxed, true);
return rtn;
return makeUnboxedInt(emitter, v);
}
if (t == BOXED_FLOAT) {
llvm::Value* unboxed = emitter.getBuilder()->CreateCall(g.funcs.unboxFloat, v);
ConcreteCompilerVariable* rtn = new ConcreteCompilerVariable(FLOAT, unboxed, true);
return rtn;
return makeUnboxedFloat(emitter, v);
}
#endif
if (t == BOXED_BOOL) {
llvm::Value* unboxed = emitter.getBuilder()->CreateCall(g.funcs.unboxBool, v);
return boolFromI1(emitter, unboxed);
......@@ -1548,7 +1542,7 @@ private:
ConcreteCompilerType* speculated_type = typeFromClass(speculated_class);
if (VERBOSITY("irgen") >= 2) {
printf("Speculating that %s is actually %s, at ", rtn->getConcreteType()->debugName().c_str(),
printf("Speculating that %s is actually %s, at ", rtn->getType()->debugName().c_str(),
speculated_type->debugName().c_str());
fflush(stdout);
print_ast(node);
......@@ -1580,6 +1574,7 @@ private:
}
assert(rtn);
assert(rtn->getType()->isUsable());
return rtn;
}
......@@ -1728,6 +1723,7 @@ private:
void _doSet(InternedString name, CompilerVariable* val, const UnwindInfo& unw_info) {
assert(name.s() != "None");
assert(name.s() != FRAME_INFO_PTR_NAME);
assert(val->getType()->isUsable());
auto scope_info = irstate->getScopeInfo();
ScopeInfo::VarScopeType vst = scope_info->getScopeTypeOfName(name);
......@@ -2210,11 +2206,9 @@ private:
ConcreteCompilerVariable* var = p.second->makeConverted(emitter, p.second->getConcreteType());
converted_args.push_back(var);
#if ENABLE_UNBOXED_VALUES
assert(var->getType() != BOXED_INT && "should probably unbox it, but why is it boxed in the first place?");
assert(var->getType() != BOXED_INT);
assert(var->getType() != BOXED_FLOAT
&& "should probably unbox it, but why is it boxed in the first place?");
#endif
// This line can never get hit right now for the same reason that the variables must already be
// concrete,
......@@ -2438,13 +2432,13 @@ private:
void loadArgument(InternedString name, ConcreteCompilerType* t, llvm::Value* v, const UnwindInfo& unw_info) {
assert(name.s() != FRAME_INFO_PTR_NAME);
ConcreteCompilerVariable* var = unboxVar(t, v, false);
CompilerVariable* var = unboxVar(t, v, false);
_doSet(name, var, unw_info);
var->decvref(emitter);
}
void loadArgument(AST_expr* name, ConcreteCompilerType* t, llvm::Value* v, const UnwindInfo& unw_info) {
ConcreteCompilerVariable* var = unboxVar(t, v, false);
CompilerVariable* var = unboxVar(t, v, false);
_doSet(name, var, unw_info);
var->decvref(emitter);
}
......@@ -2467,6 +2461,7 @@ private:
std::map<InternedString, CompilerVariable*> sorted_symbol_table(symbol_table.begin(), symbol_table.end());
for (const auto& p : sorted_symbol_table) {
assert(p.first.s() != FRAME_INFO_PTR_NAME);
assert(p.second->getType()->isUsable());
if (allowableFakeEndingSymbol(p.first))
continue;
......@@ -2483,6 +2478,7 @@ private:
} else if (irstate->getPhis()->isRequiredAfter(p.first, myblock)) {
assert(scope_info->getScopeTypeOfName(p.first) != ScopeInfo::VarScopeType::GLOBAL);
ConcreteCompilerType* phi_type = types->getTypeAtBlockEnd(p.first, myblock);
assert(phi_type->isUsable());
// printf("Converting %s from %s to %s\n", p.first.c_str(),
// p.second->getType()->debugName().c_str(), phi_type->debugName().c_str());
// printf("have to convert %s from %s to %s\n", p.first.c_str(),
......@@ -2533,6 +2529,7 @@ private:
} else {
// printf("no st entry, setting undefined\n");
ConcreteCompilerType* phi_type = types->getTypeAtBlockEnd(*it, myblock);
assert(phi_type->isUsable());
cur = new ConcreteCompilerVariable(phi_type, llvm::UndefValue::get(phi_type->llvmType()), true);
_setFake(defined_name, makeBool(0));
}
......@@ -2553,7 +2550,7 @@ public:
pp->addFrameVar(PASSED_GLOBALS_NAME, UNKNOWN);
}
assert(INT->llvmType() == g.i64);
assert(UNBOXED_INT->llvmType() == g.i64);
if (ENABLE_JIT_OBJECT_CACHE) {
llvm::Value* v;
if (current_stmt)
......@@ -2565,7 +2562,7 @@ public:
stackmap_args.push_back(getConstantInt((uint64_t)current_stmt, g.i64));
}
pp->addFrameVar("!current_stmt", INT);
pp->addFrameVar("!current_stmt", UNBOXED_INT);
if (ENABLE_FRAME_INTROSPECTION) {
// TODO: don't need to use a sorted symbol table if we're explicitly recording the names!
......@@ -2600,6 +2597,10 @@ public:
// This should have been consumed:
assert(incoming_exc_state.empty());
for (auto&& p : symbol_table) {
ASSERT(p.second->getType()->isUsable(), "%s", p.first.c_str());
}
if (myblock->successors.size() == 0) {
for (auto& p : *st) {
p.second->decvref(emitter);
......@@ -2645,6 +2646,7 @@ public:
} else {
ending_type = types->getTypeAtBlockEnd(it->first, myblock);
}
assert(ending_type->isUsable());
//(*phi_st)[it->first] = it->second->makeConverted(emitter, it->second->getConcreteType());
// printf("%s %p %d\n", it->first.c_str(), it->second, it->second->getVrefs());
(*phi_st)[it->first] = it->second->split(emitter)->makeConverted(emitter, ending_type);
......@@ -2661,10 +2663,9 @@ public:
assert(name.s() != FRAME_INFO_PTR_NAME);
ASSERT(irstate->getScopeInfo()->getScopeTypeOfName(name) != ScopeInfo::VarScopeType::GLOBAL, "%s",
name.c_str());
#if ENABLE_UNBOXED_VALUES
assert(var->getType() != BOXED_INT);
assert(var->getType() != BOXED_FLOAT);
#endif
ASSERT(var->getType()->isUsable(), "%s", name.c_str());
CompilerVariable*& cur = symbol_table[name];
assert(cur == NULL);
cur = var;
......@@ -2675,7 +2676,9 @@ public:
DupCache cache;
for (SymbolTable::iterator it = st->begin(); it != st->end(); ++it) {
// printf("Copying in %s: %p, %d\n", it->first.c_str(), it->second, it->second->getVrefs());
// printf("Copying in %s, a %s\n", it->first.c_str(), it->second->getType()->debugName().c_str());
symbol_table[it->first] = it->second->dup(cache);
assert(symbol_table[it->first]->getType()->isUsable());
// printf("got: %p, %d\n", symbol_table[it->first], symbol_table[it->first]->getVrefs());
}
}
......
......@@ -51,12 +51,6 @@ extern bool ENABLE_ICS, ENABLE_ICGENERICS, ENABLE_ICGETITEMS, ENABLE_ICSETITEMS,
extern bool BOOLS_AS_I64;
#define ENABLE_SAMPLING_PROFILER 0
// Our current implementation of unbox values has some minor compatibility issues, where it can
// change the apparent id() / is-equality of a boxed value (by inserting extra unbox+box pairs).
// I think it can be rescued (we need the unboxed compilertype to remember the boxed value),
// but for now it's just turned off with this flag.
#define ENABLE_UNBOXED_VALUES 0
}
}
......
......@@ -93,10 +93,10 @@ template <class V> class ValuedCompilerType;
typedef ValuedCompilerType<llvm::Value*> ConcreteCompilerType;
ConcreteCompilerType* typeFromClass(BoxedClass*);
extern ConcreteCompilerType* INT, *BOXED_INT, *LONG, *FLOAT, *BOXED_FLOAT, *UNKNOWN, *BOOL, *STR, *NONE, *LIST, *SLICE,*ELLIPSIS,
*MODULE, *DICT, *BOOL, *BOXED_BOOL, *BOXED_TUPLE, *SET, *FROZENSET, *CLOSURE, *GENERATOR, *BOXED_COMPLEX,
*FRAME_INFO;
extern CompilerType* UNDEF;
extern ConcreteCompilerType* UNBOXED_INT, *BOXED_INT, *LONG, *UNBOXED_FLOAT, *BOXED_FLOAT, *UNKNOWN, *BOOL, *STR, *NONE,
*LIST, *SLICE, *MODULE, *DICT, *BOOL, *BOXED_BOOL, *BOXED_TUPLE, *SET, *FROZENSET, *CLOSURE, *GENERATOR,
*BOXED_COMPLEX, *FRAME_INFO;
extern CompilerType* UNDEF, *INT, *FLOAT;
class CompilerVariable;
template <class V> class ValuedCompilerVariable;
......
......@@ -1524,12 +1524,16 @@ Box* builtinFormat(Box* value, Box* format_spec) {
return res;
}
extern "C" {
BoxedClass* ellipsis_cls;
}
void setupBuiltins() {
builtins_module = createModule(boxString("__builtin__"), NULL,
"Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is "
"the `nil' object; Ellipsis represents `...' in slices.");
BoxedClass* ellipsis_cls = BoxedClass::create(type_cls, object_cls, NULL, 0, 0, sizeof(Box), false, "ellipsis");
ellipsis_cls = BoxedClass::create(type_cls, object_cls, NULL, 0, 0, sizeof(Box), false, "ellipsis");
ellipsis_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)ellipsisRepr, STR, 1)));
Ellipsis = new (ellipsis_cls) Box();
assert(Ellipsis->cls);
......
......@@ -270,7 +270,7 @@ void setupXrange() {
"__iter__", new BoxedFunction(boxRTFunction((void*)xrangeIterIter, typeFromClass(xrange_iterator_cls), 1)));
xrange_iterator_cls->giveAttr("__hasnext__", new BoxedFunction(hasnext));
CLFunction* next = boxRTFunction((void*)BoxedXrangeIterator::xrangeIteratorNextUnboxed, INT, 1);
CLFunction* next = boxRTFunction((void*)BoxedXrangeIterator::xrangeIteratorNextUnboxed, UNBOXED_INT, 1);
addRTFunction(next, (void*)BoxedXrangeIterator::xrangeIteratorNext, BOXED_INT);
xrange_iterator_cls->giveAttr("next", new BoxedFunction(next));
......
......@@ -42,6 +42,14 @@ def f4(a, b):
for i in xrange(11000):
f4(1000, 1000)
def f6():
for i in xrange(11000):
a = b = 1000
if True:
pass
f4(a, b)
f6()
# This applies to other data types as well. (maybe should call this test file something else)
def ident(x):
......@@ -49,7 +57,7 @@ def ident(x):
def f5():
t = (1, 2, 3)
print ident(t) is t
assert ident(t) is t
for i in xrange(10):
f5()
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