Skip to content

Commit

Permalink
Merge pull request #1124 from undingen/instmeth_deopt
Browse files Browse the repository at this point in the history
deopt: support deserializing instance methods
  • Loading branch information
undingen committed Mar 16, 2016
2 parents 9a8eaf0 + b830092 commit 83f56df
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/codegen/compvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class InstanceMethodType : public ValuedCompilerType<RawInstanceMethod*> {
}

static InstanceMethodType* get(CompilerType* obj_type, CompilerType* function_type) {
InstanceMethodType* rtn = made[std::make_pair(obj_type, function_type)];
InstanceMethodType*& rtn = made[std::make_pair(obj_type, function_type)];
if (rtn == NULL)
rtn = new InstanceMethodType(obj_type, function_type);
return rtn;
Expand Down Expand Up @@ -195,14 +195,18 @@ class InstanceMethodType : public ValuedCompilerType<RawInstanceMethod*> {
void serializeToFrame(VAR* var, std::vector<llvm::Value*>& stackmap_args) override {
var->getValue()->obj->serializeToFrame(stackmap_args);
var->getValue()->func->serializeToFrame(stackmap_args);
var->getValue()->im_class->serializeToFrame(stackmap_args);
}

Box* deserializeFromFrame(const FrameVals& vals) override {
assert(vals.size() == numFrameArgs());
abort();
assert(vals.size() == numFrameArgs() && vals.size() == 3);
Box* obj = reinterpret_cast<Box*>(vals[0]);
Box* func = reinterpret_cast<Box*>(vals[1]);
Box* im_class = reinterpret_cast<Box*>(vals[2]);
return boxInstanceMethod(obj, func, im_class);
}

int numFrameArgs() override { return obj_type->numFrameArgs() + function_type->numFrameArgs(); }
int numFrameArgs() override { return obj_type->numFrameArgs() + function_type->numFrameArgs() + 1 /* im_class */; }
};
std::unordered_map<std::pair<CompilerType*, CompilerType*>, InstanceMethodType*> InstanceMethodType::made;

Expand Down
29 changes: 29 additions & 0 deletions test/tests/deopt_tests2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# skip-if: '-O' in EXTRA_JIT_ARGS or '-n' in EXTRA_JIT_ARGS
# statcheck: 4 == noninit_count('num_deopt')
# this used to hit an abort in our LLVM tier codegen
try:
import __pyston__
__pyston__.setOption("OSR_THRESHOLD_BASELINE", 50)
__pyston__.setOption("REOPT_THRESHOLD_BASELINE", 50)
__pyston__.setOption("SPECULATION_THRESHOLD", 10)
except ImportError:
pass

from thread import allocate_lock

def triggers_deopt(x):
if x < 90:
return ""
return unicode("")

class C():
def __init__(self):
self.l = allocate_lock()

def f(self, x):
with self.l:
triggers_deopt(x).isalnum

c = C()
for i in range(100):
c.f(i)

0 comments on commit 83f56df

Please sign in to comment.