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
d8f36db5
Commit
d8f36db5
authored
Jul 02, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert unicode to a pyston type
parent
7ea2c6f9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
src/runtime/types.cpp
src/runtime/types.cpp
+16
-2
No files found.
src/runtime/types.cpp
View file @
d8f36db5
...
@@ -2850,6 +2850,14 @@ out:
...
@@ -2850,6 +2850,14 @@ out:
return
result
;
return
result
;
}
}
void
unicode_visit
(
GCVisitor
*
v
,
Box
*
b
)
{
boxGCHandler
(
v
,
b
);
PyUnicodeObject
*
u
=
(
PyUnicodeObject
*
)
b
;
v
->
visit
(
u
->
str
);
v
->
visit
(
u
->
defenc
);
}
extern
"C"
PyUnicodeObject
*
unicode_empty
;
extern
"C"
PyUnicodeObject
*
unicode_empty
;
extern
"C"
PyUnicodeObject
*
_PyUnicode_New
(
Py_ssize_t
length
)
noexcept
{
extern
"C"
PyUnicodeObject
*
_PyUnicode_New
(
Py_ssize_t
length
)
noexcept
{
PyUnicodeObject
*
unicode
;
PyUnicodeObject
*
unicode
;
...
@@ -2868,7 +2876,7 @@ extern "C" PyUnicodeObject* _PyUnicode_New(Py_ssize_t length) noexcept {
...
@@ -2868,7 +2876,7 @@ extern "C" PyUnicodeObject* _PyUnicode_New(Py_ssize_t length) noexcept {
// Do a bunch of inlining + constant folding of this line of CPython's:
// Do a bunch of inlining + constant folding of this line of CPython's:
// unicode = PyObject_New(PyUnicodeObject, &PyUnicode_Type);
// unicode = PyObject_New(PyUnicodeObject, &PyUnicode_Type);
assert
(
PyUnicode_Type
.
tp_basicsize
==
sizeof
(
PyUnicodeObject
));
// use the compile-time constant
assert
(
PyUnicode_Type
.
tp_basicsize
==
sizeof
(
PyUnicodeObject
));
// use the compile-time constant
unicode
=
(
PyUnicodeObject
*
)
gc_alloc
(
sizeof
(
PyUnicodeObject
),
gc
::
GCKind
::
CONSERVATIVE_
PYTHON
);
unicode
=
(
PyUnicodeObject
*
)
gc_alloc
(
sizeof
(
PyUnicodeObject
),
gc
::
GCKind
::
PYTHON
);
if
(
unicode
==
NULL
)
if
(
unicode
==
NULL
)
return
(
PyUnicodeObject
*
)
PyErr_NoMemory
();
return
(
PyUnicodeObject
*
)
PyErr_NoMemory
();
...
@@ -2879,12 +2887,13 @@ extern "C" PyUnicodeObject* _PyUnicode_New(Py_ssize_t length) noexcept {
...
@@ -2879,12 +2887,13 @@ extern "C" PyUnicodeObject* _PyUnicode_New(Py_ssize_t length) noexcept {
unicode
->
ob_type
=
(
struct
_typeobject
*
)
&
PyUnicode_Type
;
unicode
->
ob_type
=
(
struct
_typeobject
*
)
&
PyUnicode_Type
;
size_t
new_size
=
sizeof
(
Py_UNICODE
)
*
((
size_t
)
length
+
1
);
size_t
new_size
=
sizeof
(
Py_UNICODE
)
*
((
size_t
)
length
+
1
);
unicode
->
str
=
(
Py_UNICODE
*
)
PyMem_MALLOC
(
new_size
);
// why is this faster than gc_compat_malloc or gc_alloc??
unicode
->
str
=
(
Py_UNICODE
*
)
gc_alloc
(
new_size
,
gc
::
GCKind
::
UNTRACKED
);
if
(
!
unicode
->
str
)
{
if
(
!
unicode
->
str
)
{
PyErr_NoMemory
();
PyErr_NoMemory
();
goto
onError
;
goto
onError
;
}
}
/* Initialize the first element to guard against cases where
/* Initialize the first element to guard against cases where
* the caller fails before initializing str -- unicode_resize()
* the caller fails before initializing str -- unicode_resize()
* reads str[0], and the Keep-Alive optimization can keep memory
* reads str[0], and the Keep-Alive optimization can keep memory
...
@@ -3406,6 +3415,11 @@ void setupRuntime() {
...
@@ -3406,6 +3415,11 @@ void setupRuntime() {
weakref_callableproxy
->
simple_destructor
=
proxy_to_tp_clear
;
weakref_callableproxy
->
simple_destructor
=
proxy_to_tp_clear
;
weakref_callableproxy
->
is_pyston_class
=
true
;
weakref_callableproxy
->
is_pyston_class
=
true
;
unicode_cls
->
tp_alloc
=
PystonType_GenericAlloc
;
unicode_cls
->
gc_visit
=
unicode_visit
;
unicode_cls
->
tp_dealloc
=
NULL
;
unicode_cls
->
is_pyston_class
=
true
;
assert
(
object_cls
->
tp_setattro
==
PyObject_GenericSetAttr
);
assert
(
object_cls
->
tp_setattro
==
PyObject_GenericSetAttr
);
assert
(
none_cls
->
tp_setattro
==
PyObject_GenericSetAttr
);
assert
(
none_cls
->
tp_setattro
==
PyObject_GenericSetAttr
);
...
...
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