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
268f275f
Commit
268f275f
authored
Jun 09, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #600 from kmod/str_padding
Use the padding bytes at the end of BoxedString
parents
bc36f5df
da8b25c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
src/runtime/types.cpp
src/runtime/types.cpp
+3
-1
src/runtime/types.h
src/runtime/types.h
+4
-2
No files found.
src/runtime/types.cpp
View file @
268f275f
...
...
@@ -2394,7 +2394,9 @@ void setupRuntime() {
basestring_cls
=
new
(
0
)
BoxedHeapClass
(
object_cls
,
NULL
,
0
,
0
,
sizeof
(
Box
),
false
,
NULL
);
// We add 1 to the tp_basicsize of the BoxedString in order to hold the null byte at the end.
str_cls
=
new
(
0
)
BoxedHeapClass
(
basestring_cls
,
NULL
,
0
,
0
,
sizeof
(
BoxedString
)
+
1
,
false
,
NULL
);
// We use offsetof(BoxedString, s_data) as opposed to sizeof(BoxedString) so that we can
// use the extra padding bytes at the end of the BoxedString.
str_cls
=
new
(
0
)
BoxedHeapClass
(
basestring_cls
,
NULL
,
0
,
0
,
offsetof
(
BoxedString
,
s_data
)
+
1
,
false
,
NULL
);
str_cls
->
tp_flags
|=
Py_TPFLAGS_STRING_SUBCLASS
;
str_cls
->
tp_itemsize
=
sizeof
(
char
);
...
...
src/runtime/types.h
View file @
268f275f
...
...
@@ -440,7 +440,7 @@ public:
assert
(
str_cls
->
tp_alloc
==
PystonType_GenericAlloc
);
assert
(
str_cls
->
tp_itemsize
==
1
);
assert
(
str_cls
->
tp_basicsize
==
sizeof
(
BoxedString
)
+
1
);
assert
(
str_cls
->
tp_basicsize
==
offsetof
(
BoxedString
,
s_data
)
+
1
);
assert
(
str_cls
->
is_pyston_class
);
assert
(
str_cls
->
attrs_offset
==
0
);
...
...
@@ -453,7 +453,7 @@ public:
return
rtn
;
}
// these should be private, but str
New
needs them
// these should be private, but str
.cpp
needs them
BoxedString
(
const
char
*
s
,
size_t
n
)
__attribute__
((
visibility
(
"default"
)));
explicit
BoxedString
(
size_t
n
,
char
c
)
__attribute__
((
visibility
(
"default"
)));
explicit
BoxedString
(
llvm
::
StringRef
s
)
__attribute__
((
visibility
(
"default"
)));
...
...
@@ -463,6 +463,8 @@ private:
void
*
operator
new
(
size_t
size
)
=
delete
;
char
s_data
[
0
];
friend
void
setupRuntime
();
};
template
<
typename
T
>
struct
StringHash
{
...
...
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