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
6466fee0
Commit
6466fee0
authored
May 18, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some LIKELY annotations to obmalloc
parent
147549c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
from_cpython/Objects/obmalloc.c
from_cpython/Objects/obmalloc.c
+8
-3
No files found.
from_cpython/Objects/obmalloc.c
View file @
6466fee0
...
...
@@ -9,9 +9,13 @@
#endif
#endif
#define UNLIKELY(value) __builtin_expect((value), 0)
#define LIKELY(value) __builtin_expect((value), 1)
#ifdef WITH_VALGRIND
#include <valgrind/valgrind.h>
#if 0
/* If we're using GCC, use __builtin_expect() to reduce overhead of
the valgrind checks */
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
...
...
@@ -19,6 +23,7 @@
#else
# define UNLIKELY(value) (value)
#endif
#endif
/* -1 indicates that we haven't checked that we're running on valgrind yet. */
static
int
running_on_valgrind
=
-
1
;
...
...
@@ -784,20 +789,20 @@ PyObject_Malloc(size_t nbytes)
* things without checking for overflows or negatives.
* As size_t is unsigned, checking for nbytes < 0 is not required.
*/
if
(
nbytes
>
PY_SSIZE_T_MAX
)
if
(
UNLIKELY
(
nbytes
>
PY_SSIZE_T_MAX
)
)
return
NULL
;
/*
* This implicitly redirects malloc(0).
*/
if
(
(
nbytes
-
1
)
<
SMALL_REQUEST_THRESHOLD
)
{
if
(
LIKELY
((
nbytes
-
1
)
<
SMALL_REQUEST_THRESHOLD
)
)
{
LOCK
();
/*
* Most frequent paths first
*/
size
=
(
uint
)(
nbytes
-
1
)
>>
ALIGNMENT_SHIFT
;
pool
=
usedpools
[
size
+
size
];
if
(
pool
!=
pool
->
nextpool
)
{
if
(
LIKELY
(
pool
!=
pool
->
nextpool
)
)
{
/*
* There is a used pool for this size class.
* Pick up the head block of its free list.
...
...
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