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
59c8721b
Commit
59c8721b
authored
Feb 03, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renable ICs and the int freelist
parent
c2e7665b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
18 deletions
+43
-18
src/asm_writing/rewriter.cpp
src/asm_writing/rewriter.cpp
+15
-0
src/asm_writing/rewriter.h
src/asm_writing/rewriter.h
+1
-0
src/core/options.cpp
src/core/options.cpp
+1
-1
src/runtime/int.cpp
src/runtime/int.cpp
+10
-4
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+11
-11
src/runtime/types.h
src/runtime/types.h
+5
-2
No files found.
src/asm_writing/rewriter.cpp
View file @
59c8721b
...
@@ -1511,6 +1511,7 @@ bool Rewriter::finishAssembly(int continue_offset) {
...
@@ -1511,6 +1511,7 @@ bool Rewriter::finishAssembly(int continue_offset) {
void
Rewriter
::
commitReturning
(
RewriterVar
*
var
)
{
void
Rewriter
::
commitReturning
(
RewriterVar
*
var
)
{
STAT_TIMER
(
t0
,
"us_timer_rewriter"
,
10
);
STAT_TIMER
(
t0
,
"us_timer_rewriter"
,
10
);
assert
(
var
->
reftype
!=
RefType
::
UNKNOWN
);
assert
(
var
->
vrefcount
==
1
);
assert
(
var
->
vrefcount
==
1
);
var
->
stealRef
();
var
->
stealRef
();
...
@@ -1525,6 +1526,20 @@ void Rewriter::commitReturning(RewriterVar* var) {
...
@@ -1525,6 +1526,20 @@ void Rewriter::commitReturning(RewriterVar* var) {
commit
();
commit
();
}
}
void
Rewriter
::
commitReturningNonPython
(
RewriterVar
*
var
)
{
STAT_TIMER
(
t0
,
"us_timer_rewriter"
,
10
);
assert
(
var
->
reftype
==
RefType
::
UNKNOWN
);
addAction
([
=
]()
{
if
(
LOG_IC_ASSEMBLY
)
assembler
->
comment
(
"commitReturning"
);
var
->
getInReg
(
getReturnDestination
(),
true
/* allow_constant_in_reg */
);
var
->
bumpUse
();
},
{
var
},
ActionType
::
NORMAL
);
commit
();
}
void
Rewriter
::
addDependenceOn
(
ICInvalidator
&
invalidator
)
{
void
Rewriter
::
addDependenceOn
(
ICInvalidator
&
invalidator
)
{
rewrite
->
addDependenceOn
(
invalidator
);
rewrite
->
addDependenceOn
(
invalidator
);
}
}
...
...
src/asm_writing/rewriter.h
View file @
59c8721b
...
@@ -722,6 +722,7 @@ public:
...
@@ -722,6 +722,7 @@ public:
void
abort
();
void
abort
();
void
commit
();
void
commit
();
void
commitReturning
(
RewriterVar
*
rtn
);
void
commitReturning
(
RewriterVar
*
rtn
);
void
commitReturningNonPython
(
RewriterVar
*
rtn
);
void
addDependenceOn
(
ICInvalidator
&
);
void
addDependenceOn
(
ICInvalidator
&
);
...
...
src/core/options.cpp
View file @
59c8721b
...
@@ -59,7 +59,7 @@ int SPECULATION_THRESHOLD = 100;
...
@@ -59,7 +59,7 @@ int SPECULATION_THRESHOLD = 100;
int
MAX_OBJECT_CACHE_ENTRIES
=
500
;
int
MAX_OBJECT_CACHE_ENTRIES
=
500
;
static
bool
_GLOBAL_ENABLE
=
1
;
static
bool
_GLOBAL_ENABLE
=
1
;
bool
ENABLE_ICS
=
0
&&
_GLOBAL_ENABLE
;
bool
ENABLE_ICS
=
1
&&
_GLOBAL_ENABLE
;
bool
ENABLE_ICGENERICS
=
1
&&
ENABLE_ICS
;
bool
ENABLE_ICGENERICS
=
1
&&
ENABLE_ICS
;
bool
ENABLE_ICGETITEMS
=
1
&&
ENABLE_ICS
;
bool
ENABLE_ICGETITEMS
=
1
&&
ENABLE_ICS
;
bool
ENABLE_ICSETITEMS
=
1
&&
ENABLE_ICS
;
bool
ENABLE_ICSETITEMS
=
1
&&
ENABLE_ICS
;
...
...
src/runtime/int.cpp
View file @
59c8721b
...
@@ -88,15 +88,21 @@ PyIntObject* BoxedInt::fill_free_list(void) {
...
@@ -88,15 +88,21 @@ PyIntObject* BoxedInt::fill_free_list(void) {
}
}
void
BoxedInt
::
tp_dealloc
(
Box
*
v
)
{
void
BoxedInt
::
tp_dealloc
(
Box
*
v
)
{
//if (PyInt_CheckExact(v)) {
#ifdef DISABLE_INT_FREELIST
//BoxedInt::tp_free(v);
v
->
cls
->
tp_free
(
v
);
//} else {
#else
if
(
PyInt_CheckExact
(
v
))
{
BoxedInt
::
tp_free
(
v
);
}
else
{
v
->
cls
->
tp_free
(
v
);
v
->
cls
->
tp_free
(
v
);
//}
}
#endif
}
}
void
BoxedInt
::
tp_free
(
void
*
b
)
{
void
BoxedInt
::
tp_free
(
void
*
b
)
{
#ifdef DISABLE_INT_FREELIST
assert
(
0
);
assert
(
0
);
#endif
PyIntObject
*
v
=
static_cast
<
PyIntObject
*>
(
b
);
PyIntObject
*
v
=
static_cast
<
PyIntObject
*>
(
b
);
v
->
ob_type
=
(
struct
_typeobject
*
)
free_list
;
v
->
ob_type
=
(
struct
_typeobject
*
)
free_list
;
free_list
=
v
;
free_list
=
v
;
...
...
src/runtime/objmodel.cpp
View file @
59c8721b
...
@@ -2709,7 +2709,7 @@ extern "C" bool nonzero(Box* obj) {
...
@@ -2709,7 +2709,7 @@ extern "C" bool nonzero(Box* obj) {
// TODO: is it faster to compare to True? (especially since it will be a constant we can embed in the rewrite)
// TODO: is it faster to compare to True? (especially since it will be a constant we can embed in the rewrite)
if
(
rewriter
.
get
())
{
if
(
rewriter
.
get
())
{
RewriterVar
*
b
=
r_obj
->
getAttr
(
offsetof
(
BoxedBool
,
n
),
rewriter
->
getReturnDestination
());
RewriterVar
*
b
=
r_obj
->
getAttr
(
offsetof
(
BoxedBool
,
n
),
rewriter
->
getReturnDestination
());
rewriter
->
commitReturning
(
b
);
rewriter
->
commitReturning
NonPython
(
b
);
}
}
BoxedBool
*
bool_obj
=
static_cast
<
BoxedBool
*>
(
obj
);
BoxedBool
*
bool_obj
=
static_cast
<
BoxedBool
*>
(
obj
);
...
@@ -2718,7 +2718,7 @@ extern "C" bool nonzero(Box* obj) {
...
@@ -2718,7 +2718,7 @@ extern "C" bool nonzero(Box* obj) {
if
(
rewriter
.
get
())
{
if
(
rewriter
.
get
())
{
RewriterVar
*
n
=
r_obj
->
getAttr
(
offsetof
(
BoxedInt
,
n
),
rewriter
->
getReturnDestination
());
RewriterVar
*
n
=
r_obj
->
getAttr
(
offsetof
(
BoxedInt
,
n
),
rewriter
->
getReturnDestination
());
RewriterVar
*
b
=
n
->
toBool
(
rewriter
->
getReturnDestination
());
RewriterVar
*
b
=
n
->
toBool
(
rewriter
->
getReturnDestination
());
rewriter
->
commitReturning
(
b
);
rewriter
->
commitReturning
NonPython
(
b
);
}
}
BoxedInt
*
int_obj
=
static_cast
<
BoxedInt
*>
(
obj
);
BoxedInt
*
int_obj
=
static_cast
<
BoxedInt
*>
(
obj
);
...
@@ -2726,13 +2726,13 @@ extern "C" bool nonzero(Box* obj) {
...
@@ -2726,13 +2726,13 @@ extern "C" bool nonzero(Box* obj) {
}
else
if
(
obj
->
cls
==
float_cls
)
{
}
else
if
(
obj
->
cls
==
float_cls
)
{
if
(
rewriter
.
get
())
{
if
(
rewriter
.
get
())
{
RewriterVar
*
b
=
rewriter
->
call
(
false
,
(
void
*
)
floatNonzeroUnboxed
,
r_obj
);
RewriterVar
*
b
=
rewriter
->
call
(
false
,
(
void
*
)
floatNonzeroUnboxed
,
r_obj
);
rewriter
->
commitReturning
(
b
);
rewriter
->
commitReturning
NonPython
(
b
);
}
}
return
static_cast
<
BoxedFloat
*>
(
obj
)
->
d
!=
0
;
return
static_cast
<
BoxedFloat
*>
(
obj
)
->
d
!=
0
;
}
else
if
(
obj
->
cls
==
none_cls
)
{
}
else
if
(
obj
->
cls
==
none_cls
)
{
if
(
rewriter
.
get
())
{
if
(
rewriter
.
get
())
{
RewriterVar
*
b
=
rewriter
->
loadConst
(
0
,
rewriter
->
getReturnDestination
());
RewriterVar
*
b
=
rewriter
->
loadConst
(
0
,
rewriter
->
getReturnDestination
());
rewriter
->
commitReturning
(
b
);
rewriter
->
commitReturning
NonPython
(
b
);
}
}
return
false
;
return
false
;
}
else
if
(
obj
->
cls
==
long_cls
)
{
}
else
if
(
obj
->
cls
==
long_cls
)
{
...
@@ -2741,7 +2741,7 @@ extern "C" bool nonzero(Box* obj) {
...
@@ -2741,7 +2741,7 @@ extern "C" bool nonzero(Box* obj) {
if
(
rewriter
.
get
())
{
if
(
rewriter
.
get
())
{
RewriterVar
*
r_rtn
=
rewriter
->
call
(
false
,
(
void
*
)
longNonzeroUnboxed
,
r_obj
);
RewriterVar
*
r_rtn
=
rewriter
->
call
(
false
,
(
void
*
)
longNonzeroUnboxed
,
r_obj
);
rewriter
->
commitReturning
(
r_rtn
);
rewriter
->
commitReturning
NonPython
(
r_rtn
);
}
}
return
r
;
return
r
;
}
else
if
(
obj
->
cls
==
tuple_cls
)
{
}
else
if
(
obj
->
cls
==
tuple_cls
)
{
...
@@ -2751,7 +2751,7 @@ extern "C" bool nonzero(Box* obj) {
...
@@ -2751,7 +2751,7 @@ extern "C" bool nonzero(Box* obj) {
if
(
rewriter
.
get
())
{
if
(
rewriter
.
get
())
{
RewriterVar
*
r_rtn
RewriterVar
*
r_rtn
=
r_obj
->
getAttr
(
offsetof
(
BoxedTuple
,
ob_size
))
->
toBool
(
rewriter
->
getReturnDestination
());
=
r_obj
->
getAttr
(
offsetof
(
BoxedTuple
,
ob_size
))
->
toBool
(
rewriter
->
getReturnDestination
());
rewriter
->
commitReturning
(
r_rtn
);
rewriter
->
commitReturning
NonPython
(
r_rtn
);
}
}
return
r
;
return
r
;
}
else
if
(
obj
->
cls
==
list_cls
)
{
}
else
if
(
obj
->
cls
==
list_cls
)
{
...
@@ -2760,7 +2760,7 @@ extern "C" bool nonzero(Box* obj) {
...
@@ -2760,7 +2760,7 @@ extern "C" bool nonzero(Box* obj) {
if
(
rewriter
.
get
())
{
if
(
rewriter
.
get
())
{
RewriterVar
*
r_rtn
=
r_obj
->
getAttr
(
offsetof
(
BoxedList
,
size
))
->
toBool
(
rewriter
->
getReturnDestination
());
RewriterVar
*
r_rtn
=
r_obj
->
getAttr
(
offsetof
(
BoxedList
,
size
))
->
toBool
(
rewriter
->
getReturnDestination
());
rewriter
->
commitReturning
(
r_rtn
);
rewriter
->
commitReturning
NonPython
(
r_rtn
);
}
}
return
r
;
return
r
;
}
else
if
(
obj
->
cls
==
str_cls
)
{
}
else
if
(
obj
->
cls
==
str_cls
)
{
...
@@ -2770,7 +2770,7 @@ extern "C" bool nonzero(Box* obj) {
...
@@ -2770,7 +2770,7 @@ extern "C" bool nonzero(Box* obj) {
if
(
rewriter
.
get
())
{
if
(
rewriter
.
get
())
{
RewriterVar
*
r_rtn
RewriterVar
*
r_rtn
=
r_obj
->
getAttr
(
offsetof
(
BoxedString
,
ob_size
))
->
toBool
(
rewriter
->
getReturnDestination
());
=
r_obj
->
getAttr
(
offsetof
(
BoxedString
,
ob_size
))
->
toBool
(
rewriter
->
getReturnDestination
());
rewriter
->
commitReturning
(
r_rtn
);
rewriter
->
commitReturning
NonPython
(
r_rtn
);
}
}
return
r
;
return
r
;
}
else
if
(
obj
->
cls
==
unicode_cls
)
{
}
else
if
(
obj
->
cls
==
unicode_cls
)
{
...
@@ -2780,7 +2780,7 @@ extern "C" bool nonzero(Box* obj) {
...
@@ -2780,7 +2780,7 @@ extern "C" bool nonzero(Box* obj) {
if
(
rewriter
.
get
())
{
if
(
rewriter
.
get
())
{
RewriterVar
*
r_rtn
RewriterVar
*
r_rtn
=
r_obj
->
getAttr
(
offsetof
(
PyUnicodeObject
,
length
))
->
toBool
(
rewriter
->
getReturnDestination
());
=
r_obj
->
getAttr
(
offsetof
(
PyUnicodeObject
,
length
))
->
toBool
(
rewriter
->
getReturnDestination
());
rewriter
->
commitReturning
(
r_rtn
);
rewriter
->
commitReturning
NonPython
(
r_rtn
);
}
}
return
r
;
return
r
;
}
}
...
@@ -2823,7 +2823,7 @@ extern "C" bool nonzero(Box* obj) {
...
@@ -2823,7 +2823,7 @@ extern "C" bool nonzero(Box* obj) {
if
(
rewriter
.
get
())
{
if
(
rewriter
.
get
())
{
RewriterVar
*
b
=
rewriter
->
loadConst
(
1
,
rewriter
->
getReturnDestination
());
RewriterVar
*
b
=
rewriter
->
loadConst
(
1
,
rewriter
->
getReturnDestination
());
rewriter
->
commitReturning
(
b
);
rewriter
->
commitReturning
NonPython
(
b
);
}
}
return
true
;
return
true
;
}
}
...
@@ -2832,7 +2832,7 @@ extern "C" bool nonzero(Box* obj) {
...
@@ -2832,7 +2832,7 @@ extern "C" bool nonzero(Box* obj) {
if
(
crewrite_args
.
isSuccessful
())
{
if
(
crewrite_args
.
isSuccessful
())
{
RewriterVar
*
rtn
=
crewrite_args
.
getReturn
(
ReturnConvention
::
HAS_RETURN
);
RewriterVar
*
rtn
=
crewrite_args
.
getReturn
(
ReturnConvention
::
HAS_RETURN
);
RewriterVar
*
b
=
rewriter
->
call
(
false
,
(
void
*
)
nonzeroHelper
,
rtn
);
RewriterVar
*
b
=
rewriter
->
call
(
false
,
(
void
*
)
nonzeroHelper
,
rtn
);
rewriter
->
commitReturning
(
b
);
rewriter
->
commitReturning
NonPython
(
b
);
}
}
return
nonzeroHelper
(
rtn
);
return
nonzeroHelper
(
rtn
);
}
}
...
...
src/runtime/types.h
View file @
59c8721b
...
@@ -403,6 +403,8 @@ template <typename B> B* xincref(B* b) {
...
@@ -403,6 +403,8 @@ template <typename B> B* xincref(B* b) {
return
b
;
return
b
;
}
}
//#define DISABLE_INT_FREELIST
extern
"C"
int
PyInt_ClearFreeList
()
noexcept
;
extern
"C"
int
PyInt_ClearFreeList
()
noexcept
;
class
BoxedInt
:
public
Box
{
class
BoxedInt
:
public
Box
{
private:
private:
...
@@ -419,8 +421,9 @@ public:
...
@@ -419,8 +421,9 @@ public:
}
}
// int uses a customized allocator, so we can't use DEFAULT_CLASS_SIMPLE (which inlines the default allocator)
// int uses a customized allocator, so we can't use DEFAULT_CLASS_SIMPLE (which inlines the default allocator)
void
*
operator
new
(
size_t
size
)
__attribute__
((
visibility
(
"default"
)))
{
void
*
operator
new
(
size_t
size
)
__attribute__
((
visibility
(
"default"
)))
{
#ifdef DISABLE_INT_FREELIST
return
Box
::
operator
new
(
size
,
int_cls
);
return
Box
::
operator
new
(
size
,
int_cls
);
/*
#else
if
(
free_list
==
NULL
)
{
if
(
free_list
==
NULL
)
{
free_list
=
fill_free_list
();
free_list
=
fill_free_list
();
RELEASE_ASSERT
(
free_list
,
""
);
RELEASE_ASSERT
(
free_list
,
""
);
...
@@ -430,7 +433,7 @@ public:
...
@@ -430,7 +433,7 @@ public:
free_list
=
(
PyIntObject
*
)
v
->
ob_type
;
free_list
=
(
PyIntObject
*
)
v
->
ob_type
;
PyObject_INIT
((
BoxedInt
*
)
v
,
&
PyInt_Type
);
PyObject_INIT
((
BoxedInt
*
)
v
,
&
PyInt_Type
);
return
v
;
return
v
;
*/
#endif
}
}
static
void
tp_dealloc
(
Box
*
b
);
static
void
tp_dealloc
(
Box
*
b
);
...
...
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