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
3132de84
Commit
3132de84
authored
Aug 25, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #866 from undingen/perf_pyxl
parents
02f3513a
368c76f7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
28 deletions
+52
-28
from_cpython/Modules/_sre.c
from_cpython/Modules/_sre.c
+6
-2
src/core/types.h
src/core/types.h
+1
-0
src/runtime/ics.h
src/runtime/ics.h
+11
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+15
-3
src/runtime/types.cpp
src/runtime/types.cpp
+16
-21
src/runtime/types.h
src/runtime/types.h
+3
-2
No files found.
from_cpython/Modules/_sre.c
View file @
3132de84
...
@@ -257,7 +257,9 @@ static void
...
@@ -257,7 +257,9 @@ static void
data_stack_dealloc
(
SRE_STATE
*
state
)
data_stack_dealloc
(
SRE_STATE
*
state
)
{
{
if
(
state
->
data_stack
)
{
if
(
state
->
data_stack
)
{
PyMem_FREE
(
state
->
data_stack
);
// Pyston change: use malloc
// PyMem_FREE(state->data_stack);
free
(
state
->
data_stack
);
state
->
data_stack
=
NULL
;
state
->
data_stack
=
NULL
;
}
}
state
->
data_stack_size
=
state
->
data_stack_base
=
0
;
state
->
data_stack_size
=
state
->
data_stack_base
=
0
;
...
@@ -273,7 +275,9 @@ data_stack_grow(SRE_STATE* state, Py_ssize_t size)
...
@@ -273,7 +275,9 @@ data_stack_grow(SRE_STATE* state, Py_ssize_t size)
void
*
stack
;
void
*
stack
;
cursize
=
minsize
+
minsize
/
4
+
1024
;
cursize
=
minsize
+
minsize
/
4
+
1024
;
TRACE
((
"allocate/grow stack %"
PY_FORMAT_SIZE_T
"d
\n
"
,
cursize
));
TRACE
((
"allocate/grow stack %"
PY_FORMAT_SIZE_T
"d
\n
"
,
cursize
));
stack
=
PyMem_REALLOC
(
state
->
data_stack
,
cursize
);
// Pyston change: use malloc
// stack = PyMem_REALLOC(state->data_stack, cursize);
stack
=
realloc
(
state
->
data_stack
,
cursize
);
if
(
!
stack
)
{
if
(
!
stack
)
{
data_stack_dealloc
(
state
);
data_stack_dealloc
(
state
);
return
SRE_ERROR_MEMORY
;
return
SRE_ERROR_MEMORY
;
...
...
src/core/types.h
View file @
3132de84
...
@@ -435,6 +435,7 @@ class Rewriter;
...
@@ -435,6 +435,7 @@ class Rewriter;
class
RewriterVar
;
class
RewriterVar
;
class
RuntimeIC
;
class
RuntimeIC
;
class
CallattrIC
;
class
CallattrIC
;
class
CallattrCapiIC
;
class
NonzeroIC
;
class
NonzeroIC
;
class
BinopIC
;
class
BinopIC
;
...
...
src/runtime/ics.h
View file @
3132de84
...
@@ -77,6 +77,17 @@ public:
...
@@ -77,6 +77,17 @@ public:
}
}
};
};
class
CallattrCapiIC
:
public
RuntimeIC
{
public:
CallattrCapiIC
()
:
RuntimeIC
((
void
*
)
callattrCapi
,
1
,
320
)
{}
Box
*
call
(
Box
*
obj
,
BoxedString
*
attr
,
CallattrFlags
flags
,
Box
*
arg0
,
Box
*
arg1
,
Box
*
arg2
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
{
return
(
Box
*
)
call_ptr
(
obj
,
attr
,
flags
,
arg0
,
arg1
,
arg2
,
args
,
keyword_names
);
}
};
class
BinopIC
:
public
RuntimeIC
{
class
BinopIC
:
public
RuntimeIC
{
public:
public:
BinopIC
()
:
RuntimeIC
((
void
*
)
binop
,
2
,
240
)
{}
BinopIC
()
:
RuntimeIC
((
void
*
)
binop
,
2
,
240
)
{}
...
...
src/runtime/objmodel.cpp
View file @
3132de84
...
@@ -3574,6 +3574,16 @@ static Box* astInterpretHelper(CLFunction* f, int num_args, BoxedClosure* closur
...
@@ -3574,6 +3574,16 @@ static Box* astInterpretHelper(CLFunction* f, int num_args, BoxedClosure* closur
return
astInterpretFunction
(
f
,
num_args
,
closure
,
generator
,
globals
,
arg1
,
arg2
,
arg3
,
(
Box
**
)
args
);
return
astInterpretFunction
(
f
,
num_args
,
closure
,
generator
,
globals
,
arg1
,
arg2
,
arg3
,
(
Box
**
)
args
);
}
}
static
Box
*
astInterpretHelperCapi
(
CLFunction
*
f
,
int
num_args
,
BoxedClosure
*
closure
,
BoxedGenerator
*
generator
,
Box
*
globals
,
Box
**
_args
)
noexcept
{
try
{
return
astInterpretHelper
(
f
,
num_args
,
closure
,
generator
,
globals
,
_args
);
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
return
NULL
;
}
}
// TODO: is it better to take the func_ptr last (requiring passing all the args), or is it better to put it
// TODO: is it better to take the func_ptr last (requiring passing all the args), or is it better to put it
// first (requiring moving all the args)?
// first (requiring moving all the args)?
static
Box
*
capiCallCxxHelper
(
Box
*
(
*
func_ptr
)(
void
*
,
void
*
,
void
*
,
void
*
,
void
*
),
void
*
a
,
void
*
b
,
void
*
c
,
void
*
d
,
static
Box
*
capiCallCxxHelper
(
Box
*
(
*
func_ptr
)(
void
*
,
void
*
,
void
*
,
void
*
,
void
*
),
void
*
a
,
void
*
b
,
void
*
c
,
void
*
d
,
...
@@ -3593,7 +3603,7 @@ Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_arg
...
@@ -3593,7 +3603,7 @@ Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_arg
CompiledFunction
*
chosen_cf
=
pickVersion
(
f
,
S
,
num_output_args
,
oarg1
,
oarg2
,
oarg3
,
oargs
);
CompiledFunction
*
chosen_cf
=
pickVersion
(
f
,
S
,
num_output_args
,
oarg1
,
oarg2
,
oarg3
,
oargs
);
if
(
!
chosen_cf
)
{
if
(
!
chosen_cf
)
{
if
(
rewrite_args
&&
S
==
CXX
)
{
if
(
rewrite_args
)
{
RewriterVar
::
SmallVector
arg_vec
;
RewriterVar
::
SmallVector
arg_vec
;
rewrite_args
->
rewriter
->
addDependenceOn
(
f
->
dependent_interp_callsites
);
rewrite_args
->
rewriter
->
addDependenceOn
(
f
->
dependent_interp_callsites
);
...
@@ -3620,8 +3630,10 @@ Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_arg
...
@@ -3620,8 +3630,10 @@ Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_arg
if
(
num_output_args
>=
4
)
if
(
num_output_args
>=
4
)
arg_array
->
setAttr
(
24
,
rewrite_args
->
args
);
arg_array
->
setAttr
(
24
,
rewrite_args
->
args
);
assert
(
S
==
CXX
);
if
(
S
==
CXX
)
rewrite_args
->
out_rtn
=
rewrite_args
->
rewriter
->
call
(
true
,
(
void
*
)
astInterpretHelper
,
arg_vec
);
rewrite_args
->
out_rtn
=
rewrite_args
->
rewriter
->
call
(
true
,
(
void
*
)
astInterpretHelper
,
arg_vec
);
else
rewrite_args
->
out_rtn
=
rewrite_args
->
rewriter
->
call
(
true
,
(
void
*
)
astInterpretHelperCapi
,
arg_vec
);
rewrite_args
->
out_success
=
true
;
rewrite_args
->
out_success
=
true
;
}
}
...
...
src/runtime/types.cpp
View file @
3132de84
...
@@ -239,32 +239,27 @@ Box* BoxedClass::callHasnextIC(Box* obj, bool null_on_nonexistent) {
...
@@ -239,32 +239,27 @@ Box* BoxedClass::callHasnextIC(Box* obj, bool null_on_nonexistent) {
}
}
extern
"C"
PyObject
*
PyIter_Next
(
PyObject
*
iter
)
noexcept
{
extern
"C"
PyObject
*
PyIter_Next
(
PyObject
*
iter
)
noexcept
{
if
(
iter
->
cls
->
tp_iternext
!=
slot_tp_iternext
)
{
Box
*
result
=
NULL
;
PyObject
*
result
;
if
(
iter
->
cls
->
tp_iternext
!=
slot_tp_iternext
)
result
=
(
*
iter
->
cls
->
tp_iternext
)(
iter
);
result
=
(
*
iter
->
cls
->
tp_iternext
)(
iter
);
if
(
result
==
NULL
&&
PyErr_Occurred
()
&&
PyErr_ExceptionMatches
(
PyExc_StopIteration
))
else
{
PyErr_Clear
();
try
{
return
result
;
Box
*
hasnext
=
iter
->
hasnextOrNullIC
();
}
if
(
hasnext
&&
!
hasnext
->
nonzeroIC
())
try
{
Box
*
hasnext
=
iter
->
hasnextOrNullIC
();
if
(
hasnext
)
{
if
(
hasnext
->
nonzeroIC
())
return
iter
->
cls
->
callNextIC
(
iter
);
else
return
NULL
;
return
NULL
;
}
else
{
}
catch
(
ExcInfo
e
)
{
return
iter
->
cls
->
callNextIC
(
iter
);
}
}
catch
(
ExcInfo
e
)
{
if
(
!
e
.
matches
(
StopIteration
))
setCAPIException
(
e
);
setCAPIException
(
e
);
return
NULL
;
return
NULL
;
}
result
=
iter
->
cls
->
call_nextIC
(
iter
);
}
}
if
(
result
==
NULL
&&
PyErr_Occurred
()
&&
PyErr_ExceptionMatches
(
PyExc_StopIteration
))
PyErr_Clear
();
return
result
;
}
}
Box
*
BoxedClass
::
call
NextIC
(
Box
*
obj
)
{
Box
*
BoxedClass
::
call
_nextIC
(
Box
*
obj
)
noexcept
{
assert
(
obj
->
cls
==
this
);
assert
(
obj
->
cls
==
this
);
// This would work, but it would have been better to just call tp_iternext
// This would work, but it would have been better to just call tp_iternext
...
@@ -272,7 +267,7 @@ Box* BoxedClass::callNextIC(Box* obj) {
...
@@ -272,7 +267,7 @@ Box* BoxedClass::callNextIC(Box* obj) {
auto
ic
=
next_ic
.
get
();
auto
ic
=
next_ic
.
get
();
if
(
!
ic
)
{
if
(
!
ic
)
{
ic
=
new
CallattrIC
();
ic
=
new
Callattr
Capi
IC
();
next_ic
.
reset
(
ic
);
next_ic
.
reset
(
ic
);
}
}
...
...
src/runtime/types.h
View file @
3132de84
...
@@ -186,10 +186,11 @@ public:
...
@@ -186,10 +186,11 @@ public:
HCAttrs
attrs
;
HCAttrs
attrs
;
// TODO: these don't actually get deallocated right now
// TODO: these don't actually get deallocated right now
std
::
unique_ptr
<
CallattrIC
>
hasnext_ic
,
next_ic
,
repr_ic
;
std
::
unique_ptr
<
CallattrCapiIC
>
next_ic
;
std
::
unique_ptr
<
CallattrIC
>
hasnext_ic
,
repr_ic
;
std
::
unique_ptr
<
NonzeroIC
>
nonzero_ic
;
std
::
unique_ptr
<
NonzeroIC
>
nonzero_ic
;
Box
*
callHasnextIC
(
Box
*
obj
,
bool
null_on_nonexistent
);
Box
*
callHasnextIC
(
Box
*
obj
,
bool
null_on_nonexistent
);
Box
*
call
NextIC
(
Box
*
obj
)
;
Box
*
call
_nextIC
(
Box
*
obj
)
noexcept
;
Box
*
callReprIC
(
Box
*
obj
);
Box
*
callReprIC
(
Box
*
obj
);
bool
callNonzeroIC
(
Box
*
obj
);
bool
callNonzeroIC
(
Box
*
obj
);
...
...
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