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
c4ace2f9
Commit
c4ace2f9
authored
Feb 10, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kill off the old vref system. This is much easier now
parent
a68bb9e6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
57 deletions
+13
-57
src/asm_writing/rewriter.h
src/asm_writing/rewriter.h
+0
-41
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+1
-1
src/codegen/baseline_jit.cpp
src/codegen/baseline_jit.cpp
+1
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+8
-12
src/runtime/types.cpp
src/runtime/types.cpp
+3
-2
No files found.
src/asm_writing/rewriter.h
View file @
c4ace2f9
...
...
@@ -238,19 +238,6 @@ public:
RewriterVar
*
setType
(
RefType
type
);
// XXX convert callers back to setType
RewriterVar
*
asBorrowed
()
{
return
setType
(
RefType
::
BORROWED
);
}
RewriterVar
*
incvref
()
{
assert
(
0
&&
"don't call incvref anymore"
);
}
RewriterVar
*
decvref
()
{
assert
(
0
&&
"don't call decvref anymore"
);
}
// Call this to let the automatic refcount machinery know that a refcount
// got "consumed", ie passed off. Such as to a function that steals a reference,
// or when stored into a memory location that is an owned reference, etc.
...
...
@@ -259,10 +246,6 @@ public:
// r_val->refConsumed()
void
refConsumed
();
RewriterVar
*
stealRef
()
{
assert
(
0
&&
"don't call stealref anymore"
);
}
template
<
typename
Src
,
typename
Dst
>
inline
RewriterVar
*
getAttrCast
(
int
offset
,
Location
loc
=
Location
::
any
());
...
...
@@ -700,30 +683,6 @@ public:
friend
class
RewriterVar
;
};
struct
AutoDecvref
{
private:
RewriterVar
*
var
;
public:
AutoDecvref
(
RewriterVar
*
var
)
:
var
(
var
)
{}
~
AutoDecvref
()
{
if
(
var
)
var
->
decvref
();
}
operator
RewriterVar
*
()
{
return
var
;
}
RewriterVar
*
operator
->
()
{
return
var
;
}
void
operator
=
(
RewriterVar
*
new_var
)
{
assert
(
!
var
);
var
=
new_var
;
}
};
void
setSlowpathFunc
(
uint8_t
*
pp_addr
,
void
*
func
);
struct
GRCompare
{
...
...
src/codegen/ast_interpreter.cpp
View file @
c4ace2f9
...
...
@@ -1493,7 +1493,7 @@ Value ASTInterpreter::visit_num(AST_Num* node) {
Py_INCREF
(
o
);
RewriterVar
*
v
=
NULL
;
if
(
jit
)
{
v
=
jit
->
imm
(
o
)
->
asBorrowed
(
);
v
=
jit
->
imm
(
o
)
->
setType
(
RefType
::
BORROWED
);
}
return
Value
(
o
,
v
);
}
...
...
src/codegen/baseline_jit.cpp
View file @
c4ace2f9
...
...
@@ -521,8 +521,8 @@ void JitFragmentWriter::emitReturn(RewriterVar* v) {
}
void
JitFragmentWriter
::
emitSetAttr
(
AST_expr
*
node
,
RewriterVar
*
obj
,
BoxedString
*
s
,
STOLEN
(
RewriterVar
*
)
attr
)
{
attr
->
stealRef
();
emitPPCall
((
void
*
)
setattr
,
{
obj
,
imm
(
s
),
attr
},
2
,
512
,
node
);
attr
->
refConsumed
();
}
void
JitFragmentWriter
::
emitSetBlockLocal
(
InternedString
s
,
STOLEN
(
RewriterVar
*
)
v
)
{
...
...
src/runtime/objmodel.cpp
View file @
c4ace2f9
...
...
@@ -1176,7 +1176,7 @@ int assign_version_tag(PyTypeObject* type) noexcept {
return
1
;
}
template
<
Rewritable
rewritable
>
B
ox
*
typeLookup
(
BoxedClass
*
cls
,
BoxedString
*
attr
,
GetattrRewriteArgs
*
rewrite_args
)
{
template
<
Rewritable
rewritable
>
B
ORROWED
(
Box
*
)
typeLookup
(
BoxedClass
*
cls
,
BoxedString
*
attr
,
GetattrRewriteArgs
*
rewrite_args
)
{
if
(
rewritable
==
NOT_REWRITABLE
)
{
assert
(
!
rewrite_args
);
rewrite_args
=
NULL
;
...
...
@@ -2098,7 +2098,6 @@ Box* getattrInternalGeneric(Box* obj, BoxedString* attr, GetattrRewriteArgs* rew
Box
*
val
;
if
(
rewrite_args
)
{
RELEASE_ASSERT
(
0
,
"need to check the refcounting for this"
);
GetattrRewriteArgs
hrewrite_args
(
rewrite_args
->
rewriter
,
rewrite_args
->
obj
,
rewrite_args
->
destination
);
val
=
obj
->
getattr
(
attr
,
&
hrewrite_args
);
...
...
@@ -3597,11 +3596,11 @@ void rearrangeArgumentsInternal(ParamReceiveSpec paramspec, const ParamNames* pa
getArg
(
idx
,
oarg1
,
oarg2
,
oarg3
,
NULL
)
=
NULL
;
// pass NULL for kwargs
if
(
rewrite_args
)
{
if
(
idx
==
0
)
rewrite_args
->
arg1
=
rewrite_args
->
rewriter
->
loadConst
(
0
)
->
asBorrowed
(
);
rewrite_args
->
arg1
=
rewrite_args
->
rewriter
->
loadConst
(
0
)
->
setType
(
RefType
::
BORROWED
);
else
if
(
idx
==
1
)
rewrite_args
->
arg2
=
rewrite_args
->
rewriter
->
loadConst
(
0
)
->
asBorrowed
(
);
rewrite_args
->
arg2
=
rewrite_args
->
rewriter
->
loadConst
(
0
)
->
setType
(
RefType
::
BORROWED
);
else
if
(
idx
==
2
)
rewrite_args
->
arg3
=
rewrite_args
->
rewriter
->
loadConst
(
0
)
->
asBorrowed
(
);
rewrite_args
->
arg3
=
rewrite_args
->
rewriter
->
loadConst
(
0
)
->
setType
(
RefType
::
BORROWED
);
else
abort
();
}
...
...
@@ -3693,10 +3692,7 @@ void rearrangeArgumentsInternal(ParamReceiveSpec paramspec, const ParamNames* pa
getArg
(
i
,
oarg1
,
oarg2
,
oarg3
,
oargs
)
=
incref
(
getArg
(
i
,
arg1
,
arg2
,
arg3
,
args
));
}
if
(
rewrite_args
)
{
for
(
int
i
=
0
;
i
<
positional_to_positional
;
i
++
)
{
assert
(
i
<
3
&&
"figure this out"
);
getArg
(
i
,
rewrite_args
)
->
incvref
();
}
assert
(
positional_to_positional
<
3
&&
"figure this out"
);
}
int
varargs_to_positional
=
std
::
min
((
int
)
varargs_size
,
paramspec
.
num_args
-
positional_to_positional
);
...
...
@@ -3962,13 +3958,13 @@ void rearrangeArgumentsInternal(ParamReceiveSpec paramspec, const ParamNames* pa
if
(
rewrite_args
)
{
if
(
arg_idx
==
0
)
rewrite_args
->
arg1
=
rewrite_args
->
rewriter
->
loadConst
((
intptr_t
)
default_obj
,
Location
::
forArg
(
0
))
->
asBorrowed
(
);
=
rewrite_args
->
rewriter
->
loadConst
((
intptr_t
)
default_obj
,
Location
::
forArg
(
0
))
->
setType
(
RefType
::
BORROWED
);
else
if
(
arg_idx
==
1
)
rewrite_args
->
arg2
=
rewrite_args
->
rewriter
->
loadConst
((
intptr_t
)
default_obj
,
Location
::
forArg
(
1
))
->
asBorrowed
(
);
=
rewrite_args
->
rewriter
->
loadConst
((
intptr_t
)
default_obj
,
Location
::
forArg
(
1
))
->
setType
(
RefType
::
BORROWED
);
else
if
(
arg_idx
==
2
)
rewrite_args
->
arg3
=
rewrite_args
->
rewriter
->
loadConst
((
intptr_t
)
default_obj
,
Location
::
forArg
(
2
))
->
asBorrowed
(
);
=
rewrite_args
->
rewriter
->
loadConst
((
intptr_t
)
default_obj
,
Location
::
forArg
(
2
))
->
setType
(
RefType
::
BORROWED
);
else
{
assert
(
0
&&
"check refcounting"
);
rewrite_args
->
args
->
setAttr
((
arg_idx
-
3
)
*
sizeof
(
Box
*
),
...
...
src/runtime/types.cpp
View file @
c4ace2f9
...
...
@@ -795,6 +795,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
RewriterVar
*
r_ccls
=
NULL
;
RewriterVar
*
r_new
=
NULL
;
RewriterVar
*
r_init
=
NULL
;
// TODO: is this ok? what if new causes init to get freed?
BORROWED
(
Box
*
)
init_attr
=
NULL
;
if
(
rewrite_args
)
{
assert
(
!
argspec
.
has_starargs
);
...
...
@@ -830,10 +831,9 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
DecrefHandle
<
Box
,
true
>
new_attr
(
nullptr
);
static
BoxedString
*
new_str
=
getStaticString
(
"__new__"
);
if
(
rewrite_args
)
{
assert
(
0
&&
"check refcounting"
);
GetattrRewriteArgs
grewrite_args
(
rewrite_args
->
rewriter
,
r_ccls
,
rewrite_args
->
destination
);
// TODO: if tp_new != Py_CallPythonNew, call that instead?
new_attr
=
typeLookup
(
cls
,
new_str
,
&
grewrite_args
);
new_attr
=
incref
(
typeLookup
(
cls
,
new_str
,
&
grewrite_args
)
);
assert
(
new_attr
);
if
(
!
grewrite_args
.
isSuccessful
())
...
...
@@ -847,6 +847,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
if
(
new_attr
->
cls
!=
function_cls
)
{
try
{
Box
*
descr_r
=
processDescriptorOrNull
(
new_attr
,
None
,
cls
);
// TODO do we need to guard here on the class of new_attr (or that it's a class that can't change classes?)
if
(
descr_r
)
{
new_attr
=
descr_r
;
rewrite_args
=
NULL
;
...
...
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