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
03aedad4
Commit
03aedad4
authored
Jul 13, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #653 from tjhance/dont-guard-builtin
Don't guard types sometimes
parents
fc8b1d26
ede5b9a9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
3 deletions
+14
-3
src/asm_writing/rewriter.h
src/asm_writing/rewriter.h
+2
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+9
-2
src/runtime/rewrite_args.h
src/runtime/rewrite_args.h
+3
-1
No files found.
src/asm_writing/rewriter.h
View file @
03aedad4
...
...
@@ -218,6 +218,8 @@ public:
template
<
typename
Src
,
typename
Dst
>
inline
RewriterVar
*
getAttrCast
(
int
offset
,
Location
loc
=
Location
::
any
());
bool
isConstant
()
{
return
is_constant
;
}
private:
Rewriter
*
rewriter
;
...
...
src/runtime/objmodel.cpp
View file @
03aedad4
...
...
@@ -683,7 +683,7 @@ BoxedDict* Box::getDict() {
static
StatCounter
box_getattr_slowpath
(
"slowpath_box_getattr"
);
Box
*
Box
::
getattr
(
llvm
::
StringRef
attr
,
GetattrRewriteArgs
*
rewrite_args
)
{
if
(
rewrite_args
)
if
(
rewrite_args
&&
!
rewrite_args
->
obj_cls_guarded
)
rewrite_args
->
obj
->
addAttrGuard
(
offsetof
(
Box
,
cls
),
(
intptr_t
)
cls
);
#if 0
...
...
@@ -733,7 +733,10 @@ Box* Box::getattr(llvm::StringRef attr, GetattrRewriteArgs* rewrite_args) {
REWRITE_ABORTED
(
""
);
rewrite_args
=
NULL
;
}
else
{
rewrite_args
->
obj
->
addAttrGuard
(
cls
->
attrs_offset
+
offsetof
(
HCAttrs
,
hcls
),
(
intptr_t
)
hcls
);
if
(
!
(
rewrite_args
->
obj
->
isConstant
()
&&
cls
==
type_cls
&&
static_cast
<
BoxedClass
*>
(
this
)
->
is_constant
))
{
rewrite_args
->
obj
->
addAttrGuard
(
cls
->
attrs_offset
+
offsetof
(
HCAttrs
,
hcls
),
(
intptr_t
)
hcls
);
}
if
(
hcls
->
type
==
HiddenClass
::
SINGLETON
)
hcls
->
addDependence
(
rewrite_args
->
rewriter
);
}
...
...
@@ -985,6 +988,9 @@ Box* typeLookup(BoxedClass* cls, llvm::StringRef attr, GetattrRewriteArgs* rewri
assert
(
rewrite_args
->
obj
==
obj_saved
);
}
else
{
rewrite_args
->
obj
=
rewrite_args
->
rewriter
->
loadConst
((
intptr_t
)
base
,
Location
::
any
());
if
(
static_cast
<
BoxedClass
*>
(
base
)
->
is_constant
)
{
rewrite_args
->
obj_cls_guarded
=
true
;
}
}
val
=
base
->
getattr
(
attr
,
rewrite_args
);
assert
(
rewrite_args
->
out_success
);
...
...
@@ -5042,6 +5048,7 @@ extern "C" Box* getGlobal(Box* globals, BoxedString* name) {
if
(
rewriter
.
get
())
{
RewriterVar
*
builtins
=
rewriter
->
loadConst
((
intptr_t
)
builtins_module
,
Location
::
any
());
GetattrRewriteArgs
rewrite_args
(
rewriter
.
get
(),
builtins
,
rewriter
->
getReturnDestination
());
rewrite_args
.
obj_cls_guarded
=
true
;
// always builtin module
rtn
=
builtins_module
->
getattr
(
name
->
s
(),
&
rewrite_args
);
if
(
!
rtn
||
!
rewrite_args
.
out_success
)
{
...
...
src/runtime/rewrite_args.h
View file @
03aedad4
...
...
@@ -28,6 +28,7 @@ struct GetattrRewriteArgs {
RewriterVar
*
out_rtn
;
bool
obj_hcls_guarded
;
bool
obj_cls_guarded
;
GetattrRewriteArgs
(
Rewriter
*
rewriter
,
RewriterVar
*
obj
,
Location
destination
)
:
rewriter
(
rewriter
),
...
...
@@ -35,7 +36,8 @@ struct GetattrRewriteArgs {
destination
(
destination
),
out_success
(
false
),
out_rtn
(
NULL
),
obj_hcls_guarded
(
false
)
{}
obj_hcls_guarded
(
false
),
obj_cls_guarded
(
false
)
{}
};
struct
SetattrRewriteArgs
{
...
...
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