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
3b3e5863
Commit
3b3e5863
authored
May 19, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize PyObject_Malloc slightly
parent
4f9fa37b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
from_cpython/Objects/obmalloc.c
from_cpython/Objects/obmalloc.c
+12
-9
No files found.
from_cpython/Objects/obmalloc.c
View file @
3b3e5863
...
@@ -783,15 +783,6 @@ PyObject_Malloc(size_t nbytes)
...
@@ -783,15 +783,6 @@ PyObject_Malloc(size_t nbytes)
goto
redirect
;
goto
redirect
;
#endif
#endif
/*
* Limit ourselves to PY_SSIZE_T_MAX bytes to prevent security holes.
* Most python internals blindly use a signed Py_ssize_t to track
* things without checking for overflows or negatives.
* As size_t is unsigned, checking for nbytes < 0 is not required.
*/
if
(
UNLIKELY
(
nbytes
>
PY_SSIZE_T_MAX
))
return
NULL
;
/*
/*
* This implicitly redirects malloc(0).
* This implicitly redirects malloc(0).
*/
*/
...
@@ -955,6 +946,18 @@ PyObject_Malloc(size_t nbytes)
...
@@ -955,6 +946,18 @@ PyObject_Malloc(size_t nbytes)
goto
init_pool
;
goto
init_pool
;
}
}
// Pyston change: move this unlikely case below the likely one.
// This is ok because the two cases don't overlap.
/*
* Limit ourselves to PY_SSIZE_T_MAX bytes to prevent security holes.
* Most python internals blindly use a signed Py_ssize_t to track
* things without checking for overflows or negatives.
* As size_t is unsigned, checking for nbytes < 0 is not required.
*/
if
(
UNLIKELY
(
nbytes
>
PY_SSIZE_T_MAX
))
return
NULL
;
/* The small block allocator ends here. */
/* The small block allocator ends here. */
redirect:
redirect:
...
...
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