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
779cb5b5
Commit
779cb5b5
authored
Aug 10, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch BoxedDict to llvm::DenseMap
parent
7c6b5218
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
5 deletions
+17
-5
from_cpython/Include/dictobject.h
from_cpython/Include/dictobject.h
+1
-1
src/runtime/dict.cpp
src/runtime/dict.cpp
+1
-1
src/runtime/types.h
src/runtime/types.h
+14
-1
src/runtime/util.cpp
src/runtime/util.cpp
+1
-1
test/tests/dict.py
test/tests/dict.py
+0
-1
No files found.
from_cpython/Include/dictobject.h
View file @
779cb5b5
...
...
@@ -94,7 +94,7 @@ struct _dictobject {
#endif
typedef
struct
{
PyObject_HEAD
;
char
_filler
[
SIZEOF_UNORDEREDMAP
];
char
_filler
[
24
];
}
PyDictObject
;
// Pyston change: these are no longer static objects:
...
...
src/runtime/dict.cpp
View file @
779cb5b5
...
...
@@ -479,7 +479,7 @@ Box* dictSetdefault(BoxedDict* self, Box* k, Box* v) {
if
(
it
!=
self
->
d
.
end
())
return
it
->
second
;
self
->
d
.
insert
(
it
,
std
::
make_pair
(
k
,
v
));
self
->
d
.
insert
(
std
::
make_pair
(
k
,
v
));
return
v
;
}
...
...
src/runtime/types.h
View file @
779cb5b5
...
...
@@ -659,9 +659,22 @@ struct PyLt {
bool
operator
()(
Box
*
,
Box
*
)
const
;
};
struct
PythonLevelEq
{
static
bool
isEqual
(
Box
*
lhs
,
Box
*
rhs
)
{
if
(
lhs
==
rhs
)
return
true
;
if
(
rhs
==
getEmptyKey
()
||
rhs
==
getTombstoneKey
())
return
false
;
return
PyEq
()(
lhs
,
rhs
);
}
static
Box
*
getEmptyKey
()
{
return
(
Box
*
)
-
1
;
}
static
Box
*
getTombstoneKey
()
{
return
(
Box
*
)
-
2
;
}
static
unsigned
getHashValue
(
Box
*
val
)
{
return
PyHasher
()(
val
);
}
};
class
BoxedDict
:
public
Box
{
public:
typedef
std
::
unordered_map
<
Box
*
,
Box
*
,
PyHasher
,
Py
Eq
>
DictMap
;
typedef
llvm
::
DenseMap
<
Box
*
,
Box
*
,
PythonLevel
Eq
>
DictMap
;
DictMap
d
;
...
...
src/runtime/util.cpp
View file @
779cb5b5
...
...
@@ -221,7 +221,7 @@ extern "C" void dumpEx(void* p, int levels) {
if
(
isSubclass
(
b
->
cls
,
dict_cls
))
{
BoxedDict
*
d
=
static_cast
<
BoxedDict
*>
(
b
);
printf
(
"%
l
d elements
\n
"
,
d
->
d
.
size
());
printf
(
"%d elements
\n
"
,
d
->
d
.
size
());
if
(
levels
>
0
)
{
int
i
=
0
;
...
...
test/tests/dict.py
View file @
779cb5b5
...
...
@@ -233,6 +233,5 @@ print sorted(l)
#recursive printing test
d
=
dict
()
d
[
'one'
]
=
'1'
d
[
'two'
]
=
d
print
d
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