Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
6d12a868
Commit
6d12a868
authored
Feb 06, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More refcounting fixes
Need to make setattr() stealing
parent
714969bc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
7 deletions
+20
-7
src/codegen/baseline_jit.cpp
src/codegen/baseline_jit.cpp
+7
-3
src/codegen/baseline_jit.h
src/codegen/baseline_jit.h
+2
-2
src/core/types.h
src/core/types.h
+1
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+9
-1
src/runtime/objmodel.h
src/runtime/objmodel.h
+1
-1
No files found.
src/codegen/baseline_jit.cpp
View file @
6d12a868
...
@@ -532,8 +532,10 @@ void JitFragmentWriter::emitReturn(RewriterVar* v) {
...
@@ -532,8 +532,10 @@ void JitFragmentWriter::emitReturn(RewriterVar* v) {
v
->
decvref
();
v
->
decvref
();
}
}
void
JitFragmentWriter
::
emitSetAttr
(
AST_expr
*
node
,
RewriterVar
*
obj
,
BoxedString
*
s
,
RewriterVar
*
attr
)
{
void
JitFragmentWriter
::
emitSetAttr
(
AST_expr
*
node
,
RewriterVar
*
obj
,
BoxedString
*
s
,
STOLEN
(
RewriterVar
*
)
attr
)
{
emitPPCall
((
void
*
)
setattr
,
{
obj
,
imm
(
s
),
attr
},
2
,
512
,
node
)
->
setType
(
RefType
::
OWNED
);
attr
->
stealRef
();
emitPPCall
((
void
*
)
setattr
,
{
obj
,
imm
(
s
),
attr
},
2
,
512
,
node
);
attr
->
decvref
();
}
}
void
JitFragmentWriter
::
emitSetBlockLocal
(
InternedString
s
,
STOLEN
(
RewriterVar
*
)
v
)
{
void
JitFragmentWriter
::
emitSetBlockLocal
(
InternedString
s
,
STOLEN
(
RewriterVar
*
)
v
)
{
...
@@ -555,8 +557,10 @@ void JitFragmentWriter::emitSetExcInfo(RewriterVar* type, RewriterVar* value, Re
...
@@ -555,8 +557,10 @@ void JitFragmentWriter::emitSetExcInfo(RewriterVar* type, RewriterVar* value, Re
call
(
false
,
(
void
*
)
ASTInterpreterJitInterface
::
setExcInfoHelper
,
getInterp
(),
type
,
value
,
traceback
);
call
(
false
,
(
void
*
)
ASTInterpreterJitInterface
::
setExcInfoHelper
,
getInterp
(),
type
,
value
,
traceback
);
}
}
void
JitFragmentWriter
::
emitSetGlobal
(
Box
*
global
,
BoxedString
*
s
,
RewriterVar
*
v
)
{
void
JitFragmentWriter
::
emitSetGlobal
(
Box
*
global
,
BoxedString
*
s
,
STOLEN
(
RewriterVar
*
)
v
)
{
v
->
stealRef
();
emitPPCall
((
void
*
)
setGlobal
,
{
imm
(
global
),
imm
(
s
),
v
},
2
,
512
);
emitPPCall
((
void
*
)
setGlobal
,
{
imm
(
global
),
imm
(
s
),
v
},
2
,
512
);
v
->
decvref
();
}
}
void
JitFragmentWriter
::
emitSetItem
(
RewriterVar
*
target
,
RewriterVar
*
slice
,
RewriterVar
*
value
)
{
void
JitFragmentWriter
::
emitSetItem
(
RewriterVar
*
target
,
RewriterVar
*
slice
,
RewriterVar
*
value
)
{
...
...
src/codegen/baseline_jit.h
View file @
6d12a868
...
@@ -257,11 +257,11 @@ public:
...
@@ -257,11 +257,11 @@ public:
void
emitRaise0
();
void
emitRaise0
();
void
emitRaise3
(
RewriterVar
*
arg0
,
RewriterVar
*
arg1
,
RewriterVar
*
arg2
);
void
emitRaise3
(
RewriterVar
*
arg0
,
RewriterVar
*
arg1
,
RewriterVar
*
arg2
);
void
emitReturn
(
RewriterVar
*
v
);
void
emitReturn
(
RewriterVar
*
v
);
void
emitSetAttr
(
AST_expr
*
node
,
RewriterVar
*
obj
,
BoxedString
*
s
,
RewriterVar
*
attr
);
void
emitSetAttr
(
AST_expr
*
node
,
RewriterVar
*
obj
,
BoxedString
*
s
,
STOLEN
(
RewriterVar
*
)
attr
);
void
emitSetBlockLocal
(
InternedString
s
,
STOLEN
(
RewriterVar
*
)
v
);
void
emitSetBlockLocal
(
InternedString
s
,
STOLEN
(
RewriterVar
*
)
v
);
void
emitSetCurrentInst
(
AST_stmt
*
node
);
void
emitSetCurrentInst
(
AST_stmt
*
node
);
void
emitSetExcInfo
(
RewriterVar
*
type
,
RewriterVar
*
value
,
RewriterVar
*
traceback
);
void
emitSetExcInfo
(
RewriterVar
*
type
,
RewriterVar
*
value
,
RewriterVar
*
traceback
);
void
emitSetGlobal
(
Box
*
global
,
BoxedString
*
s
,
RewriterVar
*
v
);
void
emitSetGlobal
(
Box
*
global
,
BoxedString
*
s
,
STOLEN
(
RewriterVar
*
)
v
);
void
emitSetItemName
(
BoxedString
*
s
,
RewriterVar
*
v
);
void
emitSetItemName
(
BoxedString
*
s
,
RewriterVar
*
v
);
void
emitSetItem
(
RewriterVar
*
target
,
RewriterVar
*
slice
,
RewriterVar
*
value
);
void
emitSetItem
(
RewriterVar
*
target
,
RewriterVar
*
slice
,
RewriterVar
*
value
);
void
emitSetLocal
(
InternedString
s
,
int
vreg
,
bool
set_closure
,
STOLEN
(
RewriterVar
*
)
v
);
void
emitSetLocal
(
InternedString
s
,
int
vreg
,
bool
set_closure
,
STOLEN
(
RewriterVar
*
)
v
);
...
...
src/core/types.h
View file @
6d12a868
...
@@ -659,6 +659,7 @@ public:
...
@@ -659,6 +659,7 @@ public:
void
setDict
(
BoxedDict
*
d
);
void
setDict
(
BoxedDict
*
d
);
// Note, setattr does *not* steal a reference, but it probably should
void
setattr
(
BoxedString
*
attr
,
Box
*
val
,
SetattrRewriteArgs
*
rewrite_args
);
void
setattr
(
BoxedString
*
attr
,
Box
*
val
,
SetattrRewriteArgs
*
rewrite_args
);
// giveAttr consumes a reference to val and attr
// giveAttr consumes a reference to val and attr
void
giveAttr
(
const
char
*
attr
,
Box
*
val
)
{
giveAttr
(
internStringMortal
(
attr
),
val
);
}
void
giveAttr
(
const
char
*
attr
,
Box
*
val
)
{
giveAttr
(
internStringMortal
(
attr
),
val
);
}
...
...
src/runtime/objmodel.cpp
View file @
6d12a868
...
@@ -1026,6 +1026,8 @@ void Box::setattr(BoxedString* attr, Box* val, SetattrRewriteArgs* rewrite_args)
...
@@ -1026,6 +1026,8 @@ void Box::setattr(BoxedString* attr, Box* val, SetattrRewriteArgs* rewrite_args)
r_hattrs
->
getAttr
(
offset
*
sizeof
(
Box
*
)
+
offsetof
(
HCAttrs
::
AttrList
,
attrs
))
r_hattrs
->
getAttr
(
offset
*
sizeof
(
Box
*
)
+
offsetof
(
HCAttrs
::
AttrList
,
attrs
))
->
setType
(
RefType
::
OWNED
)
->
setType
(
RefType
::
OWNED
)
->
decvref
();
->
decvref
();
// TODO make this stealing
rewrite_args
->
attrval
->
incvref
();
rewrite_args
->
attrval
->
stealRef
();
rewrite_args
->
attrval
->
stealRef
();
r_hattrs
->
setAttr
(
offset
*
sizeof
(
Box
*
)
+
offsetof
(
HCAttrs
::
AttrList
,
attrs
),
r_hattrs
->
setAttr
(
offset
*
sizeof
(
Box
*
)
+
offsetof
(
HCAttrs
::
AttrList
,
attrs
),
rewrite_args
->
attrval
);
rewrite_args
->
attrval
);
...
@@ -2544,9 +2546,13 @@ void setattrGeneric(Box* obj, BoxedString* attr, STOLEN(Box*) val, SetattrRewrit
...
@@ -2544,9 +2546,13 @@ void setattrGeneric(Box* obj, BoxedString* attr, STOLEN(Box*) val, SetattrRewrit
raiseAttributeError
(
obj
,
attr
->
s
());
raiseAttributeError
(
obj
,
attr
->
s
());
}
}
if
(
rewrite_args
)
rewrite_args
->
attrval
->
stealRef
();
obj
->
setattr
(
attr
,
val
,
rewrite_args
);
obj
->
setattr
(
attr
,
val
,
rewrite_args
);
// TODO: make setattr() stealing
// TODO: make setattr() stealing
Py_DECREF
(
val
);
Py_DECREF
(
val
);
if
(
rewrite_args
)
rewrite_args
->
attrval
->
decvref
();
}
}
// TODO this should be in type_setattro
// TODO this should be in type_setattro
...
@@ -2573,7 +2579,7 @@ void setattrGeneric(Box* obj, BoxedString* attr, STOLEN(Box*) val, SetattrRewrit
...
@@ -2573,7 +2579,7 @@ void setattrGeneric(Box* obj, BoxedString* attr, STOLEN(Box*) val, SetattrRewrit
template
void
setattrGeneric
<
NOT_REWRITABLE
>(
Box
*
obj
,
BoxedString
*
attr
,
Box
*
val
,
SetattrRewriteArgs
*
rewrite_args
);
template
void
setattrGeneric
<
NOT_REWRITABLE
>(
Box
*
obj
,
BoxedString
*
attr
,
Box
*
val
,
SetattrRewriteArgs
*
rewrite_args
);
template
void
setattrGeneric
<
REWRITABLE
>(
Box
*
obj
,
BoxedString
*
attr
,
Box
*
val
,
SetattrRewriteArgs
*
rewrite_args
);
template
void
setattrGeneric
<
REWRITABLE
>(
Box
*
obj
,
BoxedString
*
attr
,
Box
*
val
,
SetattrRewriteArgs
*
rewrite_args
);
extern
"C"
void
setattr
(
Box
*
obj
,
BoxedString
*
attr
,
Box
*
attr_val
)
{
extern
"C"
void
setattr
(
Box
*
obj
,
BoxedString
*
attr
,
STOLEN
(
Box
*
)
attr_val
)
{
STAT_TIMER
(
t0
,
"us_timer_slowpath_setattr"
,
10
);
STAT_TIMER
(
t0
,
"us_timer_slowpath_setattr"
,
10
);
static
StatCounter
slowpath_setattr
(
"slowpath_setattr"
);
static
StatCounter
slowpath_setattr
(
"slowpath_setattr"
);
...
@@ -4806,6 +4812,7 @@ Box* binopInternal(Box* lhs, Box* rhs, int op_type, bool inplace, BinopRewriteAr
...
@@ -4806,6 +4812,7 @@ Box* binopInternal(Box* lhs, Box* rhs, int op_type, bool inplace, BinopRewriteAr
}
}
return
lrtn
;
return
lrtn
;
}
}
Py_DECREF
(
lrtn
);
}
}
// TODO patch these cases
// TODO patch these cases
...
@@ -6536,6 +6543,7 @@ Box* getFromGlobals(Box* globals, BoxedString* name) {
...
@@ -6536,6 +6543,7 @@ Box* getFromGlobals(Box* globals, BoxedString* name) {
extern
"C"
void
setGlobal
(
Box
*
globals
,
BoxedString
*
name
,
STOLEN
(
Box
*
)
value
)
{
extern
"C"
void
setGlobal
(
Box
*
globals
,
BoxedString
*
name
,
STOLEN
(
Box
*
)
value
)
{
if
(
globals
->
cls
==
attrwrapper_cls
)
{
if
(
globals
->
cls
==
attrwrapper_cls
)
{
assert
(
0
&&
"check refcounting"
);
globals
=
unwrapAttrWrapper
(
globals
);
globals
=
unwrapAttrWrapper
(
globals
);
RELEASE_ASSERT
(
globals
->
cls
==
module_cls
,
"%s"
,
globals
->
cls
->
tp_name
);
RELEASE_ASSERT
(
globals
->
cls
==
module_cls
,
"%s"
,
globals
->
cls
->
tp_name
);
}
}
...
...
src/runtime/objmodel.h
View file @
6d12a868
...
@@ -55,7 +55,7 @@ extern "C" Box* getattr(Box* obj, BoxedString* attr);
...
@@ -55,7 +55,7 @@ extern "C" Box* getattr(Box* obj, BoxedString* attr);
extern
"C"
Box
*
getattr_capi
(
Box
*
obj
,
BoxedString
*
attr
)
noexcept
;
extern
"C"
Box
*
getattr_capi
(
Box
*
obj
,
BoxedString
*
attr
)
noexcept
;
extern
"C"
Box
*
getattrMaybeNonstring
(
Box
*
obj
,
Box
*
attr
);
extern
"C"
Box
*
getattrMaybeNonstring
(
Box
*
obj
,
Box
*
attr
);
// XXX: testing. this tail-calls in optimized builds so force it to inline for unoptimized as well to get the same behavior.
// XXX: testing. this tail-calls in optimized builds so force it to inline for unoptimized as well to get the same behavior.
extern
"C"
void
setattr
(
Box
*
obj
,
BoxedString
*
attr
,
Box
*
attr_val
)
__attribute__
((
always_inline
));
extern
"C"
void
setattr
(
Box
*
obj
,
BoxedString
*
attr
,
STOLEN
(
Box
*
)
attr_val
)
__attribute__
((
always_inline
));
extern
"C"
void
setattrMaybeNonstring
(
Box
*
obj
,
Box
*
attr
,
Box
*
attr_val
);
extern
"C"
void
setattrMaybeNonstring
(
Box
*
obj
,
Box
*
attr
,
Box
*
attr_val
);
extern
"C"
void
delattr
(
Box
*
obj
,
BoxedString
*
attr
);
extern
"C"
void
delattr
(
Box
*
obj
,
BoxedString
*
attr
);
extern
"C"
void
delattrMaybeNonstring
(
Box
*
obj
,
Box
*
attr
);
extern
"C"
void
delattrMaybeNonstring
(
Box
*
obj
,
Box
*
attr
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment