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
2c20ac1d
Commit
2c20ac1d
authored
Nov 13, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get unicode working
parent
24d82a06
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
18 deletions
+10
-18
src/runtime/types.cpp
src/runtime/types.cpp
+10
-18
No files found.
src/runtime/types.cpp
View file @
2c20ac1d
...
@@ -3192,9 +3192,14 @@ extern "C" PyUnicodeObject* _PyUnicode_New(Py_ssize_t length) noexcept {
...
@@ -3192,9 +3192,14 @@ extern "C" PyUnicodeObject* _PyUnicode_New(Py_ssize_t length) noexcept {
// Pyston change: allocate ->str first, so that if this allocation
// Pyston change: allocate ->str first, so that if this allocation
// causes a collection, we don't see a half-created unicode object:
// causes a collection, we don't see a half-created unicode object:
size_t
new_size
=
sizeof
(
Py_UNICODE
)
*
((
size_t
)
length
+
1
);
size_t
new_size
=
sizeof
(
Py_UNICODE
)
*
((
size_t
)
length
+
1
);
Py_UNICODE
*
str
=
(
Py_UNICODE
*
)
PyObject_MALLOC
(
new_size
);
unicode
=
PyObject_New
(
PyUnicodeObject
,
&
PyUnicode_Type
);
if
(
!
str
)
if
(
unicode
==
NULL
)
return
NULL
;
unicode
->
str
=
(
Py_UNICODE
*
)
PyObject_MALLOC
(
new_size
);
if
(
!
unicode
->
str
)
{
Py_DECREF
(
unicode
);
return
(
PyUnicodeObject
*
)
PyErr_NoMemory
();
return
(
PyUnicodeObject
*
)
PyErr_NoMemory
();
}
#if STAT_ALLOCATIONS
#if STAT_ALLOCATIONS
{
{
...
@@ -3203,22 +3208,6 @@ extern "C" PyUnicodeObject* _PyUnicode_New(Py_ssize_t length) noexcept {
...
@@ -3203,22 +3208,6 @@ extern "C" PyUnicodeObject* _PyUnicode_New(Py_ssize_t length) noexcept {
}
}
#endif
#endif
// Do a bunch of inlining + constant folding of this line of CPython's:
// unicode = PyObject_New(PyUnicodeObject, &PyUnicode_Type);
assert
(
PyUnicode_Type
.
tp_basicsize
==
sizeof
(
PyUnicodeObject
));
// use the compile-time constant
RELEASE_ASSERT
(
0
,
" track the ref, but keep the inlining?"
);
unicode
=
(
PyUnicodeObject
*
)
PyObject_MALLOC
(
sizeof
(
PyUnicodeObject
));
if
(
unicode
==
NULL
)
return
(
PyUnicodeObject
*
)
PyErr_NoMemory
();
// Inline PyObject_INIT:
assert
(
!
PyType_SUPPORTS_WEAKREFS
(
&
PyUnicode_Type
));
assert
(
!
PyUnicode_Type
.
instancesHaveHCAttrs
());
assert
(
!
PyUnicode_Type
.
instancesHaveDictAttrs
());
unicode
->
ob_type
=
(
struct
_typeobject
*
)
&
PyUnicode_Type
;
unicode
->
str
=
str
;
/* 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
...
@@ -3443,6 +3432,8 @@ void BoxedClass::dealloc(Box* b) noexcept {
...
@@ -3443,6 +3432,8 @@ void BoxedClass::dealloc(Box* b) noexcept {
std
::
vector
<
Box
*>
constants
;
std
::
vector
<
Box
*>
constants
;
extern
"C"
void
_PyUnicode_Fini
(
void
);
bool
TRACK_ALLOCATIONS
=
false
;
bool
TRACK_ALLOCATIONS
=
false
;
void
setupRuntime
()
{
void
setupRuntime
()
{
root_hcls
=
HiddenClass
::
makeRoot
();
root_hcls
=
HiddenClass
::
makeRoot
();
...
@@ -3794,6 +3785,7 @@ void setupRuntime() {
...
@@ -3794,6 +3785,7 @@ void setupRuntime() {
// XXX
// XXX
PyType_ClearCache
();
PyType_ClearCache
();
_Py_ReleaseInternedStrings
();
_Py_ReleaseInternedStrings
();
_PyUnicode_Fini
();
for
(
auto
b
:
classes
)
for
(
auto
b
:
classes
)
b
->
clearAttrs
();
b
->
clearAttrs
();
for
(
auto
b
:
constants
)
{
for
(
auto
b
:
constants
)
{
...
...
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