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
a7653f03
Commit
a7653f03
authored
May 19, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1187 from kmod/perf9
Extract the logic from DEFAULT_CLASS_SIMPLE
parents
9c925c4e
4f83635c
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
132 additions
and
83 deletions
+132
-83
src/core/types.h
src/core/types.h
+89
-74
src/runtime/inline/dict.cpp
src/runtime/inline/dict.cpp
+3
-3
src/runtime/inline/list.cpp
src/runtime/inline/list.cpp
+2
-2
src/runtime/list.h
src/runtime/list.h
+0
-2
src/runtime/long.h
src/runtime/long.h
+1
-1
src/runtime/types.cpp
src/runtime/types.cpp
+1
-1
src/runtime/types.h
src/runtime/types.h
+36
-0
No files found.
src/core/types.h
View file @
a7653f03
This diff is collapsed.
Click to expand it.
src/runtime/inline/dict.cpp
View file @
a7653f03
...
...
@@ -26,7 +26,7 @@ BoxedDictIterator::BoxedDictIterator(BoxedDict* d) : d(d), it(d->d.begin()), itE
Box
*
dict_iter
(
Box
*
s
)
noexcept
{
assert
(
PyDict_Check
(
s
));
BoxedDict
*
self
=
static_cast
<
BoxedDict
*>
(
s
);
return
new
(
&
PyDictIterKey_Type
)
BoxedDictIterator
(
self
);
return
new
(
&
PyDictIterKey_Type
,
FAST_GC
)
BoxedDictIterator
(
self
);
}
Box
*
dictIterKeys
(
Box
*
s
)
{
...
...
@@ -36,13 +36,13 @@ Box* dictIterKeys(Box* s) {
Box
*
dictIterValues
(
Box
*
s
)
{
assert
(
PyDict_Check
(
s
));
BoxedDict
*
self
=
static_cast
<
BoxedDict
*>
(
s
);
return
new
(
&
PyDictIterValue_Type
)
BoxedDictIterator
(
self
);
return
new
(
&
PyDictIterValue_Type
,
FAST_GC
)
BoxedDictIterator
(
self
);
}
Box
*
dictIterItems
(
Box
*
s
)
{
assert
(
PyDict_Check
(
s
));
BoxedDict
*
self
=
static_cast
<
BoxedDict
*>
(
s
);
return
new
(
&
PyDictIterItem_Type
)
BoxedDictIterator
(
self
);
return
new
(
&
PyDictIterItem_Type
,
FAST_GC
)
BoxedDictIterator
(
self
);
}
Box
*
dictIterIter
(
Box
*
s
)
{
...
...
src/runtime/inline/list.cpp
View file @
a7653f03
...
...
@@ -33,7 +33,7 @@ Box* listIterIter(Box* s) {
Box
*
listIter
(
Box
*
s
)
noexcept
{
assert
(
PyList_Check
(
s
));
BoxedList
*
self
=
static_cast
<
BoxedList
*>
(
s
);
return
new
BoxedListIterator
(
self
,
0
);
return
new
(
list_iterator_cls
,
FAST_GC
)
BoxedListIterator
(
self
,
0
);
}
Box
*
listiterHasnext
(
Box
*
s
)
{
...
...
@@ -89,7 +89,7 @@ Box* listiter_next(Box* s) noexcept {
Box
*
listReversed
(
Box
*
s
)
{
assert
(
PyList_Check
(
s
));
BoxedList
*
self
=
static_cast
<
BoxedList
*>
(
s
);
return
new
(
list_reverse_iterator_cls
)
BoxedListIterator
(
self
,
self
->
size
-
1
);
return
new
(
list_reverse_iterator_cls
,
FAST_GC
)
BoxedListIterator
(
self
,
self
->
size
-
1
);
}
Box
*
listreviterHasnext
(
Box
*
s
)
{
...
...
src/runtime/list.h
View file @
a7653f03
...
...
@@ -28,8 +28,6 @@ public:
int
pos
;
BoxedListIterator
(
BoxedList
*
l
,
int
start
);
DEFAULT_CLASS
(
list_iterator_cls
);
static
void
dealloc
(
BoxedListIterator
*
o
)
noexcept
{
PyObject_GC_UnTrack
(
o
);
Py_XDECREF
(
o
->
l
);
...
...
src/runtime/long.h
View file @
a7653f03
...
...
@@ -33,7 +33,7 @@ public:
BoxedLong
()
__attribute__
((
visibility
(
"default"
)))
{}
DEFAULT_CLASS
(
long_cls
);
DEFAULT_CLASS
_SIMPLE
(
long_cls
,
false
);
};
extern
"C"
Box
*
createLong
(
llvm
::
StringRef
s
);
...
...
src/runtime/types.cpp
View file @
a7653f03
...
...
@@ -2217,7 +2217,7 @@ public:
b
=
NULL
;
}
DEFAULT_CLASS
(
attrwrapper_cls
);
DEFAULT_CLASS
_SIMPLE
(
attrwrapper_cls
,
true
);
BORROWED
(
Box
*
)
getUnderlying
()
{
...
...
src/runtime/types.h
View file @
a7653f03
...
...
@@ -281,6 +281,42 @@ 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
// types will usually point to a `static PyNumberMethods` object, but for a heap-allocated class it
...
...
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