Commit 3763b7b3 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Rewrite cases we know will always through AttributeErrors

Yes they exist, for example "try getting this attribute
and if it exists call it, otherwise do something else".
Probably not a huge perf improvement since the
exception-throwing will probably dominate.

Use the same "only do this for immortal strings" trick to get
around gc issues.
parent 68b5c5ea
......@@ -1920,11 +1920,15 @@ extern "C" Box* getattr(Box* obj, BoxedString* attr) {
GetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), dest);
val = getattrInternal(obj, attr, &rewrite_args);
// should make sure getattrInternal calls finishes using obj itself
// if it is successful
if (rewrite_args.out_success && val) {
if (recorder) {
if (rewrite_args.out_success) {
if (!val) {
if (attr->interned_state == SSTATE_INTERNED_IMMORTAL) {
rewriter->call(true, (void*)raiseAttributeError, rewriter->getArg(0),
rewriter->loadConst((intptr_t)attr->data(), Location::forArg(1)),
rewriter->loadConst(attr->size(), Location::forArg(2)));
rewriter->commit();
}
} else if (recorder) {
RewriterVar* record_rtn = rewriter->call(false, (void*)recordType,
rewriter->loadConst((intptr_t)recorder, Location::forArg(0)),
rewrite_args.out_rtn);
......
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