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
4db15e2a
Commit
4db15e2a
authored
Nov 20, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lots more fixes
parent
fbff808d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
21 deletions
+43
-21
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+1
-1
src/codegen/irgen/hooks.cpp
src/codegen/irgen/hooks.cpp
+4
-4
src/core/stringpool.h
src/core/stringpool.h
+2
-1
src/runtime/inline/xrange.cpp
src/runtime/inline/xrange.cpp
+12
-5
src/runtime/iterators.cpp
src/runtime/iterators.cpp
+6
-1
src/runtime/list.cpp
src/runtime/list.cpp
+13
-4
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+1
-1
src/runtime/types.cpp
src/runtime/types.cpp
+4
-4
No files found.
src/codegen/ast_interpreter.cpp
View file @
4db15e2a
...
...
@@ -1112,7 +1112,7 @@ Value ASTInterpreter::visit_makeFunction(AST_MakeFunction* mkfn) {
for
(
int
i
=
decorators
.
size
()
-
1
;
i
>=
0
;
i
--
)
{
if
(
jit
)
func
.
var
=
jit
->
emitRuntimeCall
(
NULL
,
decorators
[
i
],
ArgPassSpec
(
1
),
{
func
},
NULL
);
func
.
o
=
runtimeCall
(
decorators
[
i
].
o
,
ArgPassSpec
(
1
),
func
.
o
,
0
,
0
,
0
,
0
);
func
.
o
=
runtimeCall
(
autoDecref
(
decorators
[
i
].
o
),
ArgPassSpec
(
1
),
autoDecref
(
func
.
o
)
,
0
,
0
,
0
,
0
);
}
return
func
;
}
...
...
src/codegen/irgen/hooks.cpp
View file @
4db15e2a
...
...
@@ -115,15 +115,15 @@ BoxedString* SourceInfo::getName() {
switch
(
ast
->
type
)
{
case
AST_TYPE
:
:
ClassDef
:
return
ast_cast
<
AST_ClassDef
>
(
ast
)
->
name
;
return
incref
(
ast_cast
<
AST_ClassDef
>
(
ast
)
->
name
.
getBox
())
;
case
AST_TYPE
:
:
FunctionDef
:
return
ast_cast
<
AST_FunctionDef
>
(
ast
)
->
name
;
return
incref
(
ast_cast
<
AST_FunctionDef
>
(
ast
)
->
name
.
getBox
())
;
case
AST_TYPE
:
:
Lambda
:
return
lambda_name
;
return
incref
(
lambda_name
)
;
case
AST_TYPE
:
:
Module
:
case
AST_TYPE
:
:
Expression
:
case
AST_TYPE
:
:
Suite
:
return
module_name
;
return
incref
(
module_name
)
;
default:
RELEASE_ASSERT
(
0
,
"%d"
,
ast
->
type
);
}
...
...
src/core/stringpool.h
View file @
4db15e2a
...
...
@@ -22,6 +22,7 @@
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringRef.h"
#include "Python.h"
#include "core/common.h"
...
...
@@ -61,7 +62,7 @@ public:
InternedString
()
:
_str
(
NULL
)
{}
#endif
B
oxedString
*
getBox
()
const
{
B
ORROWED
(
BoxedString
*
)
getBox
()
const
{
assert
(
this
->
_str
);
return
_str
;
}
...
...
src/runtime/inline/xrange.cpp
View file @
4db15e2a
...
...
@@ -70,6 +70,8 @@ private:
public:
BoxedXrangeIterator
(
BoxedXrange
*
xrange
,
bool
reversed
)
:
xrange
(
xrange
)
{
Py_INCREF
(
xrange
);
int64_t
start
=
xrange
->
start
;
step
=
xrange
->
step
;
...
...
@@ -132,10 +134,13 @@ public:
}
static
void
dealloc
(
Box
*
b
)
noexcept
{
Py_FatalError
(
"unimplemented"
);
BoxedXrangeIterator
*
self
=
static_cast
<
BoxedXrangeIterator
*>
(
b
);
Py_DECREF
(
self
->
xrange
);
}
static
int
traverse
(
Box
*
self
,
visitproc
visit
,
void
*
arg
)
noexcept
{
Py_FatalError
(
"unimplemented"
);
static
int
traverse
(
Box
*
s
,
visitproc
visit
,
void
*
arg
)
noexcept
{
BoxedXrangeIterator
*
self
=
static_cast
<
BoxedXrangeIterator
*>
(
s
);
Py_VISIT
(
self
->
xrange
);
return
0
;
}
};
...
...
@@ -177,6 +182,7 @@ Box* xrange(Box* cls, Box* start, Box* stop, Box** args) {
Box
*
xrangeIterIter
(
Box
*
self
)
{
assert
(
self
->
cls
==
xrange_iterator_cls
);
Py_INCREF
(
self
);
return
self
;
}
...
...
@@ -237,9 +243,10 @@ Box* xrangeReduce(Box* self) {
return
None
;
}
BoxedXrange
*
r
=
static_cast
<
BoxedXrange
*>
(
self
);
BoxedTuple
*
range
=
BoxedTuple
::
create
({
boxInt
(
r
->
start
),
boxInt
(
r
->
stop
),
boxInt
(
r
->
step
)
});
BoxedTuple
*
range
=
BoxedTuple
::
create
(
{
autoDecref
(
boxInt
(
r
->
start
)),
autoDecref
(
boxInt
(
r
->
stop
)),
autoDecref
(
boxInt
(
r
->
step
))
});
return
BoxedTuple
::
create
({
r
->
cls
,
range
});
return
BoxedTuple
::
create
({
r
->
cls
,
autoDecref
(
range
)
});
}
void
setupXrange
()
{
...
...
src/runtime/iterators.cpp
View file @
4db15e2a
...
...
@@ -50,7 +50,12 @@ public:
}
}
Box
*
getValue
()
override
{
return
value
;
}
Box
*
getValue
()
override
{
Box
*
r
=
value
;
assert
(
r
);
value
=
NULL
;
return
r
;
}
bool
isSame
(
const
BoxIteratorImpl
*
_rhs
)
override
{
const
BoxIteratorGeneric
*
rhs
=
(
const
BoxIteratorGeneric
*
)
_rhs
;
...
...
src/runtime/list.cpp
View file @
4db15e2a
...
...
@@ -543,9 +543,11 @@ static inline void listSetitemSliceInt64(BoxedList* self, i64 start, i64 stop, i
int
remaining_elts
=
self
->
size
-
stop
;
self
->
ensure
(
delts
);
// XXX should make a copy here in case a destructor gets run
for
(
int
i
=
start
;
i
<
step
;
i
++
)
{
Py_CLEAR
(
self
->
elts
->
elts
[
i
]);
Box
**
removed_elts
=
NULL
;
if
(
stop
>
start
)
{
removed_elts
=
(
Box
**
)
PyMem_MALLOC
((
stop
-
start
)
*
sizeof
(
Box
*
));
RELEASE_ASSERT
(
removed_elts
,
""
);
memcpy
(
removed_elts
,
self
->
elts
->
elts
+
start
,
(
stop
-
start
)
*
sizeof
(
Box
*
));
}
memmove
(
self
->
elts
->
elts
+
start
+
v_size
,
self
->
elts
->
elts
+
stop
,
remaining_elts
*
sizeof
(
Box
*
));
...
...
@@ -557,6 +559,12 @@ static inline void listSetitemSliceInt64(BoxedList* self, i64 start, i64 stop, i
self
->
size
+=
delts
;
for
(
int
i
=
0
;
i
<
stop
-
start
;
i
++
)
{
Py_DECREF
(
removed_elts
[
i
]);
}
if
(
removed_elts
)
PyMem_FREE
(
removed_elts
);
Py_XDECREF
(
v_as_seq
);
}
...
...
@@ -1108,7 +1116,8 @@ Box* listInit(BoxedList* self, Box* container) {
assert
(
PyList_Check
(
self
));
if
(
container
)
{
listIAdd
(
self
,
container
);
Box
*
r
=
listIAdd
(
self
,
container
);
Py_DECREF
(
r
);
}
Py_RETURN_NONE
;
...
...
src/runtime/objmodel.cpp
View file @
4db15e2a
...
...
@@ -4100,7 +4100,7 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe
Py_XDECREF
(
arg2
);
Py_XDECREF
(
arg3
);
for
(
int
i
=
0
;
i
<
num_output_args
-
3
;
i
++
)
{
Py_DECREF
(
oargs
[
i
]);
Py_
X
DECREF
(
oargs
[
i
]);
}
return
res
;
...
...
src/runtime/types.cpp
View file @
4db15e2a
...
...
@@ -793,7 +793,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
RewriterVar
*
r_ccls
=
NULL
;
RewriterVar
*
r_new
=
NULL
;
RewriterVar
*
r_init
=
NULL
;
B
ox
*
init_attr
=
NULL
;
B
ORROWED
(
Box
*
)
init_attr
=
NULL
;
if
(
rewrite_args
)
{
assert
(
!
argspec
.
has_starargs
);
assert
(
!
argspec
.
has_kwargs
);
...
...
@@ -1154,7 +1154,6 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
Box
*
initrtn
;
// If there's a Python-level __init__ function, try calling it.
if
(
init_attr
&&
init_attr
->
cls
==
function_cls
)
{
assert
(
0
&&
"check refcounting"
);
if
(
rewrite_args
)
{
// We are going to rewrite as a call to cls.init:
assert
(
which_init
==
MAKES_CLS
);
...
...
@@ -1163,6 +1162,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
// Note: this code path includes the descriptor logic
if
(
rewrite_args
)
{
assert
(
0
&&
"check refcounting"
);
CallRewriteArgs
srewrite_args
(
rewrite_args
->
rewriter
,
r_init
,
rewrite_args
->
destination
);
srewrite_args
.
arg1
=
r_made
;
if
(
npassed_args
>=
2
)
...
...
@@ -1197,11 +1197,11 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
if
(
S
==
CAPI
)
{
if
(
initrtn
!=
None
)
{
PyErr_Format
(
TypeError
,
"__init__() should return None, not '%s'"
,
getTypeName
(
initrtn
));
PyErr_Format
(
TypeError
,
"__init__() should return None, not '%s'"
,
getTypeName
(
autoDecref
(
initrtn
)
));
return
NULL
;
}
}
else
assertInitNone
(
initrtn
);
assertInitNone
(
autoDecref
(
initrtn
)
);
}
else
{
// Otherwise, just call tp_init. This will work out well for extension classes, and no worse
// than failing the rewrite for Python non-extension non-functions (when does that happen?).
...
...
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