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
b566c2fc
Commit
b566c2fc
authored
Nov 15, 2016
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rearrange the newFast, to let sizeof(BoxedCode) could work
parent
5139d9a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
34 deletions
+37
-34
src/runtime/types.h
src/runtime/types.h
+37
-34
No files found.
src/runtime/types.h
View file @
b566c2fc
...
...
@@ -281,41 +281,7 @@ protected:
friend
void
setupThread
();
};
template
<
bool
is_gc
>
void
*
Box
::
newFast
(
size_t
size
,
BoxedClass
*
cls
)
{
ALLOC_STATS
(
cls
);
assert
(
cls
->
tp_alloc
==
PyType_GenericAlloc
);
assert
(
cls
->
tp_itemsize
==
0
);
assert
(
cls
->
tp_basicsize
==
size
);
assert
(
cls
->
is_pyston_class
);
assert
(
cls
->
attrs_offset
==
0
);
assert
(
is_gc
==
PyType_IS_GC
(
cls
));
bool
is_heaptype
=
false
;
assert
(
is_heaptype
==
(
bool
)(
cls
->
tp_flags
&
Py_TPFLAGS_HEAPTYPE
));
/* Don't allocate classes through this -- we need to keep track of all class objects. */
assert
(
cls
!=
type_cls
);
/* note: we want to use size instead of tp_basicsize, since size is a compile-time constant */
void
*
mem
;
if
(
is_gc
)
mem
=
_PyObject_GC_Malloc
(
size
);
else
mem
=
PyObject_MALLOC
(
size
);
assert
(
mem
);
Box
*
rtn
=
static_cast
<
Box
*>
(
mem
);
if
(
is_heaptype
)
Py_INCREF
(
cls
);
PyObject_INIT
(
rtn
,
cls
);
if
(
is_gc
)
_PyObject_GC_TRACK
(
rtn
);
return
rtn
;
/* TODO: there should be a way to not have to do this nested inlining by hand */
}
// Corresponds to PyHeapTypeObject. Very similar to BoxedClass, but allocates some extra space for
// structures that otherwise might get allocated statically. For instance, tp_as_number for builtin
...
...
@@ -1535,6 +1501,43 @@ inline BORROWED(BoxedString*) getStaticString(llvm::StringRef s) {
return
r
;
}
template
<
bool
is_gc
>
void
*
Box
::
newFast
(
size_t
size
,
BoxedClass
*
cls
)
{
ALLOC_STATS
(
cls
);
assert
(
cls
->
tp_alloc
==
PyType_GenericAlloc
);
assert
(
cls
->
tp_itemsize
==
0
);
ASSERT
(
cls
->
tp_basicsize
==
size
,
"%s: %ld %ld %ld"
,
cls
->
tp_name
,
cls
->
tp_basicsize
,
size
,
sizeof
(
BoxedCode
));
assert
(
cls
->
is_pyston_class
);
assert
(
cls
->
attrs_offset
==
0
);
assert
(
is_gc
==
PyType_IS_GC
(
cls
));
bool
is_heaptype
=
false
;
assert
(
is_heaptype
==
(
bool
)(
cls
->
tp_flags
&
Py_TPFLAGS_HEAPTYPE
));
/* Don't allocate classes through this -- we need to keep track of all class objects. */
assert
(
cls
!=
type_cls
);
/* note: we want to use size instead of tp_basicsize, since size is a compile-time constant */
void
*
mem
;
if
(
is_gc
)
mem
=
_PyObject_GC_Malloc
(
size
);
else
mem
=
PyObject_MALLOC
(
size
);
assert
(
mem
);
Box
*
rtn
=
static_cast
<
Box
*>
(
mem
);
if
(
is_heaptype
)
Py_INCREF
(
cls
);
PyObject_INIT
(
rtn
,
cls
);
if
(
is_gc
)
_PyObject_GC_TRACK
(
rtn
);
return
rtn
;
/* TODO: there should be a way to not have to do this nested inlining by hand */
}
// _stop_thread signals whether an executing thread should stop and check for one of a number of conditions.
// Such as: asynchronous exceptions that have been set, pending calls to do (ie signals), etc. These reasons
// all get combined into a single "should stop for some reason" variable so that only one check has to be done.
...
...
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