Commit 764b2da7 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #963 from kmod/callattr_rewrites

Try to fix "enforce return conventions" perf regression
parents cca56095 12955ffb
...@@ -1042,6 +1042,7 @@ $(FROM_CPYTHON_SRCS:.c=.prof.o): %.prof.o: %.c $(BUILD_SYSTEM_DEPS) ...@@ -1042,6 +1042,7 @@ $(FROM_CPYTHON_SRCS:.c=.prof.o): %.prof.o: %.c $(BUILD_SYSTEM_DEPS)
.PHONY: update_section_ordering .PHONY: update_section_ordering
update_section_ordering: pyston_release update_section_ordering: pyston_release
perf record -o perf_section_ordering.data -- ./pyston_release -q minibenchmarks/combined.py
perf record -o perf_section_ordering.data -- ./pyston_release -q minibenchmarks/combined.py perf record -o perf_section_ordering.data -- ./pyston_release -q minibenchmarks/combined.py
$(MAKE) pyston_pgo $(MAKE) pyston_pgo
python tools/generate_section_ordering_from_pgo_build.py pyston_pgo perf_section_ordering.data > section_ordering.txt python tools/generate_section_ordering_from_pgo_build.py pyston_pgo perf_section_ordering.data > section_ordering.txt
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2931,7 +2931,6 @@ Box* callattrInternal(Box* obj, BoxedString* attr, LookupScope scope, CallattrRe ...@@ -2931,7 +2931,6 @@ Box* callattrInternal(Box* obj, BoxedString* attr, LookupScope scope, CallattrRe
GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, rewrite_args->obj, Location::any()); GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, rewrite_args->obj, Location::any());
val = getattrInternalEx<S, REWRITABLE>(obj, attr, &grewrite_args, scope == CLASS_ONLY, true, &bind_obj, val = getattrInternalEx<S, REWRITABLE>(obj, attr, &grewrite_args, scope == CLASS_ONLY, true, &bind_obj,
&r_bind_obj); &r_bind_obj);
// TODO: maybe callattrs should have return conventions as well.
if (!grewrite_args.isSuccessful()) if (!grewrite_args.isSuccessful())
rewrite_args = NULL; rewrite_args = NULL;
...@@ -2939,6 +2938,12 @@ Box* callattrInternal(Box* obj, BoxedString* attr, LookupScope scope, CallattrRe ...@@ -2939,6 +2938,12 @@ Box* callattrInternal(Box* obj, BoxedString* attr, LookupScope scope, CallattrRe
RewriterVar* rtn; RewriterVar* rtn;
ReturnConvention return_convention; ReturnConvention return_convention;
std::tie(rtn, return_convention) = grewrite_args.getReturn(); std::tie(rtn, return_convention) = grewrite_args.getReturn();
if (S == CXX && return_convention == ReturnConvention::CAPI_RETURN) {
rewrite_args->rewriter->checkAndThrowCAPIException(rtn);
return_convention = ReturnConvention::HAS_RETURN;
}
if (return_convention != ReturnConvention::HAS_RETURN && return_convention != ReturnConvention::NO_RETURN) if (return_convention != ReturnConvention::HAS_RETURN && return_convention != ReturnConvention::NO_RETURN)
rewrite_args = NULL; rewrite_args = NULL;
else else
......
...@@ -55,14 +55,21 @@ private: ...@@ -55,14 +55,21 @@ private:
bool out_success; bool out_success;
RewriterVar* out_rtn; RewriterVar* out_rtn;
ReturnConvention out_return_convention; ReturnConvention out_return_convention;
#ifndef NDEBUG
bool return_convention_checked; bool return_convention_checked;
#endif
public: public:
_ReturnConventionBase() _ReturnConventionBase()
: out_success(false), : out_success(false),
out_rtn(NULL), out_rtn(NULL),
out_return_convention(ReturnConvention::UNSPECIFIED), out_return_convention(ReturnConvention::UNSPECIFIED)
return_convention_checked(false) {} #ifndef NDEBUG
,
return_convention_checked(false)
#endif
{
}
#ifndef NDEBUG #ifndef NDEBUG
~_ReturnConventionBase() { ~_ReturnConventionBase() {
...@@ -112,13 +119,17 @@ public: ...@@ -112,13 +119,17 @@ public:
out_success = false; out_success = false;
out_rtn = NULL; out_rtn = NULL;
out_return_convention = ReturnConvention::UNSPECIFIED; out_return_convention = ReturnConvention::UNSPECIFIED;
#ifndef NDEBUG
return_convention_checked = false; return_convention_checked = false;
#endif
} }
RewriterVar* getReturn(ReturnConvention required_convention) { RewriterVar* getReturn(ReturnConvention required_convention) {
assert(isSuccessful()); assert(isSuccessful());
assert(this->out_return_convention == required_convention); assert(this->out_return_convention == required_convention);
#ifndef NDEBUG
return_convention_checked = true; return_convention_checked = true;
#endif
return this->out_rtn; return this->out_rtn;
} }
...@@ -126,12 +137,16 @@ public: ...@@ -126,12 +137,16 @@ public:
assert(isSuccessful()); assert(isSuccessful());
ASSERT(this->out_return_convention == required_convention, "user asked for convention %d but got %d", ASSERT(this->out_return_convention == required_convention, "user asked for convention %d but got %d",
required_convention, this->out_return_convention); required_convention, this->out_return_convention);
#ifndef NDEBUG
return_convention_checked = true; return_convention_checked = true;
#endif
} }
std::pair<RewriterVar*, ReturnConvention> getReturn() { std::pair<RewriterVar*, ReturnConvention> getReturn() {
assert(isSuccessful()); assert(isSuccessful());
#ifndef NDEBUG
return_convention_checked = true; return_convention_checked = true;
#endif
return std::make_pair(this->out_rtn, this->out_return_convention); return std::make_pair(this->out_rtn, this->out_return_convention);
} }
......
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