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
ddec8aee
Commit
ddec8aee
authored
Mar 18, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch hidden classes from std::unordered_map<string> to llvm::StringMap
parent
533ea58a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
19 deletions
+24
-19
src/codegen/unwinding.cpp
src/codegen/unwinding.cpp
+1
-1
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+2
-2
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+6
-6
src/runtime/types.cpp
src/runtime/types.cpp
+7
-7
src/runtime/types.h
src/runtime/types.h
+8
-3
No files found.
src/codegen/unwinding.cpp
View file @
ddec8aee
...
...
@@ -649,7 +649,7 @@ BoxedDict* getLocals(bool only_user_visible, bool includeClosure) {
for
(;
closure
!=
NULL
;
closure
=
closure
->
parent
)
{
assert
(
closure
->
cls
==
closure_cls
);
for
(
auto
&
attr_offset
:
closure
->
attrs
.
hcls
->
attr_offsets
)
{
const
std
::
string
&
name
=
attr_offset
.
first
;
const
std
::
string
&
name
=
attr_offset
.
first
()
;
int
offset
=
attr_offset
.
second
;
Box
*
val
=
closure
->
attrs
.
attr_list
->
attrs
[
offset
];
ScopeInfo
*
scope_info
=
cf
->
clfunc
->
source
->
getScopeInfo
();
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
ddec8aee
...
...
@@ -171,12 +171,12 @@ extern "C" Box* dir(Box* obj) {
}
for
(
auto
const
&
kv
:
obj
->
cls
->
attrs
.
hcls
->
attr_offsets
)
{
listAppend
(
result
,
boxString
(
kv
.
first
));
listAppend
(
result
,
boxString
(
kv
.
first
()
));
}
if
(
obj
->
cls
->
instancesHaveHCAttrs
())
{
HCAttrs
*
attrs
=
obj
->
getHCAttrsPtr
();
for
(
auto
const
&
kv
:
attrs
->
hcls
->
attr_offsets
)
{
listAppend
(
result
,
boxString
(
kv
.
first
));
listAppend
(
result
,
boxString
(
kv
.
first
()
));
}
}
if
(
obj
->
cls
->
instancesHaveDictAttrs
())
{
...
...
src/runtime/objmodel.cpp
View file @
ddec8aee
...
...
@@ -469,7 +469,7 @@ const char* getNameOfClass(BoxedClass* cls) {
}
HiddenClass
*
HiddenClass
::
getOrMakeChild
(
const
std
::
string
&
attr
)
{
std
::
unordered_map
<
std
::
string
,
HiddenClass
*>::
iterator
it
=
children
.
find
(
attr
);
auto
it
=
children
.
find
(
attr
);
if
(
it
!=
children
.
end
())
return
it
->
second
;
...
...
@@ -492,9 +492,9 @@ HiddenClass* HiddenClass::delAttrToMakeHC(const std::string& attr) {
std
::
vector
<
std
::
string
>
new_attrs
(
attr_offsets
.
size
()
-
1
);
for
(
auto
it
=
attr_offsets
.
begin
();
it
!=
attr_offsets
.
end
();
++
it
)
{
if
(
it
->
second
<
idx
)
new_attrs
[
it
->
second
]
=
it
->
first
;
new_attrs
[
it
->
second
]
=
it
->
first
()
;
else
if
(
it
->
second
>
idx
)
{
new_attrs
[
it
->
second
-
1
]
=
it
->
first
;
new_attrs
[
it
->
second
-
1
]
=
it
->
first
()
;
}
}
...
...
@@ -647,7 +647,7 @@ void Box::setattr(const std::string& attr, Box* val, SetattrRewriteArgs* rewrite
assert
(
new_hcls
->
attr_offsets
[
attr
]
==
numattrs
);
#ifndef NDEBUG
for
(
const
auto
&
p
:
hcls
->
attr_offsets
)
{
assert
(
new_hcls
->
attr_offsets
[
p
.
first
]
==
p
.
second
);
assert
(
new_hcls
->
attr_offsets
[
p
.
first
()
]
==
p
.
second
);
}
#endif
...
...
@@ -4254,10 +4254,10 @@ extern "C" Box* importStar(Box* _from_module, BoxedModule* to_module) {
HCAttrs
*
module_attrs
=
from_module
->
getHCAttrsPtr
();
for
(
auto
&
p
:
module_attrs
->
hcls
->
attr_offsets
)
{
if
(
p
.
first
[
0
]
==
'_'
)
if
(
p
.
first
()
[
0
]
==
'_'
)
continue
;
to_module
->
setattr
(
p
.
first
,
module_attrs
->
attr_list
->
attrs
[
p
.
second
],
NULL
);
to_module
->
setattr
(
p
.
first
()
,
module_attrs
->
attr_list
->
attrs
[
p
.
second
],
NULL
);
}
return
None
;
...
...
src/runtime/types.cpp
View file @
ddec8aee
...
...
@@ -981,7 +981,7 @@ private:
// Iterating over the an attrwrapper (~=dict) just gives the keys, which
// just depends on the hidden class of the object. Let's store only that:
HiddenClass
*
hcls
;
std
::
unordered_map
<
std
::
string
,
int
>
::
iterator
it
;
decltype
(
HiddenClass
::
attr_offsets
)
::
iterator
it
;
public:
AttrWrapperIter
(
AttrWrapper
*
aw
);
...
...
@@ -1088,7 +1088,7 @@ public:
first
=
false
;
BoxedString
*
v
=
attrs
->
attr_list
->
attrs
[
p
.
second
]
->
reprICAsString
();
os
<<
p
.
first
<<
": "
<<
v
->
s
;
os
<<
p
.
first
().
str
()
<<
": "
<<
v
->
s
;
}
os
<<
"})"
;
return
boxString
(
os
.
str
());
...
...
@@ -1114,7 +1114,7 @@ public:
HCAttrs
*
attrs
=
self
->
b
->
getHCAttrsPtr
();
for
(
const
auto
&
p
:
attrs
->
hcls
->
attr_offsets
)
{
listAppend
(
rtn
,
boxString
(
p
.
first
));
listAppend
(
rtn
,
boxString
(
p
.
first
()
));
}
return
rtn
;
}
...
...
@@ -1140,7 +1140,7 @@ public:
HCAttrs
*
attrs
=
self
->
b
->
getHCAttrsPtr
();
for
(
const
auto
&
p
:
attrs
->
hcls
->
attr_offsets
)
{
BoxedTuple
*
t
=
new
BoxedTuple
({
boxString
(
p
.
first
),
attrs
->
attr_list
->
attrs
[
p
.
second
]
});
BoxedTuple
*
t
=
new
BoxedTuple
({
boxString
(
p
.
first
()
),
attrs
->
attr_list
->
attrs
[
p
.
second
]
});
listAppend
(
rtn
,
t
);
}
return
rtn
;
...
...
@@ -1154,7 +1154,7 @@ public:
HCAttrs
*
attrs
=
self
->
b
->
getHCAttrsPtr
();
for
(
const
auto
&
p
:
attrs
->
hcls
->
attr_offsets
)
{
rtn
->
d
[
boxString
(
p
.
first
)]
=
attrs
->
attr_list
->
attrs
[
p
.
second
];
rtn
->
d
[
boxString
(
p
.
first
()
)]
=
attrs
->
attr_list
->
attrs
[
p
.
second
];
}
return
rtn
;
}
...
...
@@ -1176,7 +1176,7 @@ public:
HCAttrs
*
attrs
=
container
->
b
->
getHCAttrsPtr
();
for
(
const
auto
&
p
:
attrs
->
hcls
->
attr_offsets
)
{
self
->
b
->
setattr
(
p
.
first
,
attrs
->
attr_list
->
attrs
[
p
.
second
],
NULL
);
self
->
b
->
setattr
(
p
.
first
()
,
attrs
->
attr_list
->
attrs
[
p
.
second
],
NULL
);
}
}
else
if
(
_container
->
cls
==
dict_cls
)
{
BoxedDict
*
container
=
static_cast
<
BoxedDict
*>
(
_container
);
...
...
@@ -1218,7 +1218,7 @@ Box* AttrWrapperIter::next(Box* _self) {
AttrWrapperIter
*
self
=
static_cast
<
AttrWrapperIter
*>
(
_self
);
assert
(
self
->
it
!=
self
->
hcls
->
attr_offsets
.
end
());
Box
*
r
=
boxString
(
self
->
it
->
first
);
Box
*
r
=
boxString
(
self
->
it
->
first
()
);
++
self
->
it
;
return
r
;
}
...
...
src/runtime/types.h
View file @
ddec8aee
...
...
@@ -15,6 +15,7 @@
#ifndef PYSTON_RUNTIME_TYPES_H
#define PYSTON_RUNTIME_TYPES_H
#include <llvm/ADT/StringMap.h>
#include <ucontext.h>
#include "Python.h"
...
...
@@ -255,7 +256,11 @@ static_assert(sizeof(pyston::BoxedHeapClass) == sizeof(PyHeapTypeObject), "");
class
HiddenClass
:
public
GCAllocated
<
gc
::
GCKind
::
HIDDEN_CLASS
>
{
private:
HiddenClass
()
{}
HiddenClass
(
const
HiddenClass
*
parent
)
:
attr_offsets
(
parent
->
attr_offsets
)
{}
HiddenClass
(
HiddenClass
*
parent
)
:
attr_offsets
()
{
for
(
auto
&
p
:
parent
->
attr_offsets
)
{
this
->
attr_offsets
.
insert
(
&
p
);
}
}
public:
static
HiddenClass
*
makeRoot
()
{
...
...
@@ -267,8 +272,8 @@ public:
return
new
HiddenClass
();
}
std
::
unordered_map
<
std
::
string
,
int
>
attr_offsets
;
std
::
unordered_map
<
std
::
string
,
HiddenClass
*>
children
;
llvm
::
StringMap
<
int
>
attr_offsets
;
llvm
::
StringMap
<
HiddenClass
*>
children
;
HiddenClass
*
getOrMakeChild
(
const
std
::
string
&
attr
);
...
...
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