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
18b34c5f
Commit
18b34c5f
authored
May 16, 2014
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve BoxIterator performance by reducing number of const char* / std::string conversions.
parent
a6aee748
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
16 deletions
+16
-16
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+2
-2
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+12
-12
src/runtime/objmodel.h
src/runtime/objmodel.h
+2
-2
No files found.
src/runtime/builtin_modules/builtins.cpp
View file @
18b34c5f
...
...
@@ -255,7 +255,7 @@ Box* getattr2(Box* obj, Box* _str) {
}
BoxedString
*
str
=
static_cast
<
BoxedString
*>
(
_str
);
Box
*
rtn
=
getattr_internal
(
obj
,
str
->
s
.
c_str
()
,
true
,
true
,
NULL
,
NULL
);
Box
*
rtn
=
getattr_internal
(
obj
,
str
->
s
,
true
,
true
,
NULL
,
NULL
);
if
(
!
rtn
)
{
fprintf
(
stderr
,
"AttributeError: '%s' object has no attribute '%s'
\n
"
,
getTypeName
(
obj
)
->
c_str
(),
...
...
@@ -273,7 +273,7 @@ Box* getattr3(Box* obj, Box* _str, Box* default_value) {
}
BoxedString
*
str
=
static_cast
<
BoxedString
*>
(
_str
);
Box
*
rtn
=
getattr_internal
(
obj
,
str
->
s
.
c_str
()
,
true
,
true
,
NULL
,
NULL
);
Box
*
rtn
=
getattr_internal
(
obj
,
str
->
s
,
true
,
true
,
NULL
,
NULL
);
if
(
!
rtn
)
{
return
default_value
;
...
...
src/runtime/objmodel.cpp
View file @
18b34c5f
...
...
@@ -534,7 +534,7 @@ static Box* _handleClsAttr(Box* obj, Box* attr) {
return
attr
;
}
Box
*
getclsattr_internal
(
Box
*
obj
,
const
char
*
attr
,
GetattrRewriteArgs
*
rewrite_args
,
Box
*
getclsattr_internal
(
Box
*
obj
,
const
std
::
string
&
attr
,
GetattrRewriteArgs
*
rewrite_args
,
GetattrRewriteArgs2
*
rewrite_args2
)
{
Box
*
val
;
...
...
@@ -653,15 +653,15 @@ static Box* (*runtimeCall1)(Box*, int64_t, Box*) = (Box * (*)(Box*, int64_t, Box
static
Box
*
(
*
runtimeCall2
)(
Box
*
,
int64_t
,
Box
*
,
Box
*
)
=
(
Box
*
(
*
)(
Box
*
,
int64_t
,
Box
*
,
Box
*
))
runtimeCall
;
static
Box
*
(
*
runtimeCall3
)(
Box
*
,
int64_t
,
Box
*
,
Box
*
,
Box
*
)
=
(
Box
*
(
*
)(
Box
*
,
int64_t
,
Box
*
,
Box
*
,
Box
*
))
runtimeCall
;
Box
*
getattr_internal
(
Box
*
obj
,
const
char
*
attr
,
bool
check_cls
,
bool
allow_custom
,
GetattrRewriteArgs
*
rewrite_args
,
GetattrRewriteArgs2
*
rewrite_args2
)
{
Box
*
getattr_internal
(
Box
*
obj
,
const
std
::
string
&
attr
,
bool
check_cls
,
bool
allow_custom
,
GetattrRewriteArgs
*
rewrite_args
,
GetattrRewriteArgs
2
*
rewrite_args2
)
{
if
(
allow_custom
)
{
// Don't need to pass icentry args, since we special-case __getattribtue__ and __getattr__ to use
// invalidation rather than guards
Box
*
getattribute
=
getclsattr_internal
(
obj
,
"__getattribute__"
,
NULL
,
NULL
);
if
(
getattribute
)
{
// TODO this is a good candidate for interning?
Box
*
boxstr
=
boxStr
Constant
(
attr
);
Box
*
boxstr
=
boxStr
ing
(
attr
);
Box
*
rtn
=
runtimeCall1
(
getattribute
,
1
,
boxstr
);
return
rtn
;
}
...
...
@@ -720,7 +720,7 @@ Box* getattr_internal(Box* obj, const char* attr, bool check_cls, bool allow_cus
// invalidation rather than guards
Box
*
getattr
=
getclsattr_internal
(
obj
,
"__getattr__"
,
NULL
,
NULL
);
if
(
getattr
)
{
Box
*
boxstr
=
boxStr
Constant
(
attr
);
Box
*
boxstr
=
boxStr
ing
(
attr
);
Box
*
rtn
=
runtimeCall1
(
getattr
,
1
,
boxstr
);
return
rtn
;
}
...
...
@@ -1173,14 +1173,14 @@ extern "C" Box* callattrInternal(Box* obj, const std::string* attr, LookupScope
if
(
rewrite_args
)
{
GetattrRewriteArgs
ga_rewrite_args
(
rewrite_args
->
rewriter
,
rewrite_args
->
obj
);
inst_attr
=
getattr_internal
(
obj
,
attr
->
c_str
()
,
false
,
true
,
&
ga_rewrite_args
,
NULL
);
inst_attr
=
getattr_internal
(
obj
,
*
attr
,
false
,
true
,
&
ga_rewrite_args
,
NULL
);
if
(
!
ga_rewrite_args
.
out_success
)
rewrite_args
=
NULL
;
else
if
(
inst_attr
)
r_instattr
=
ga_rewrite_args
.
out_rtn
;
}
else
{
inst_attr
=
getattr_internal
(
obj
,
attr
->
c_str
()
,
false
,
true
,
NULL
,
NULL
);
inst_attr
=
getattr_internal
(
obj
,
*
attr
,
false
,
true
,
NULL
,
NULL
);
}
if
(
inst_attr
)
{
...
...
@@ -1223,14 +1223,14 @@ extern "C" Box* callattrInternal(Box* obj, const std::string* attr, LookupScope
GetattrRewriteArgs
ga_rewrite_args
(
rewrite_args
->
rewriter
,
r_cls
);
r_cls
.
assertValid
();
clsattr
=
getattr_internal
(
obj
->
cls
,
attr
->
c_str
()
,
false
,
false
,
&
ga_rewrite_args
,
NULL
);
clsattr
=
getattr_internal
(
obj
->
cls
,
*
attr
,
false
,
false
,
&
ga_rewrite_args
,
NULL
);
if
(
!
ga_rewrite_args
.
out_success
)
rewrite_args
=
NULL
;
else
if
(
clsattr
)
r_clsattr
=
ga_rewrite_args
.
out_rtn
.
move
(
-
1
);
}
else
{
clsattr
=
getattr_internal
(
obj
->
cls
,
attr
->
c_str
()
,
false
,
false
,
NULL
,
NULL
);
clsattr
=
getattr_internal
(
obj
->
cls
,
*
attr
,
false
,
false
,
NULL
,
NULL
);
}
}
...
...
@@ -1731,7 +1731,7 @@ extern "C" Box* binopInternal(Box* lhs, Box* rhs, int op_type, bool inplace, Bin
// TODO patch these cases
std
::
string
rop_name
=
getReverseOpName
(
op_type
);
Box
*
rattr_func
=
getattr_internal
(
rhs
->
cls
,
rop_name
.
c_str
()
,
false
,
false
,
NULL
,
NULL
);
Box
*
rattr_func
=
getattr_internal
(
rhs
->
cls
,
rop_name
,
false
,
false
,
NULL
,
NULL
);
if
(
rattr_func
)
{
Box
*
rtn
=
runtimeCall2
(
rattr_func
,
2
,
rhs
,
lhs
);
if
(
rtn
!=
NotImplemented
)
{
...
...
@@ -1929,7 +1929,7 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
}
std
::
string
rop_name
=
getReverseOpName
(
op_type
);
Box
*
rattr_func
=
getattr_internal
(
rhs
->
cls
,
rop_name
.
c_str
()
,
false
,
false
,
NULL
,
NULL
);
Box
*
rattr_func
=
getattr_internal
(
rhs
->
cls
,
rop_name
,
false
,
false
,
NULL
,
NULL
);
if
(
rattr_func
)
{
Box
*
rtn
=
runtimeCall2
(
rattr_func
,
2
,
rhs
,
lhs
);
if
(
rtn
!=
NotImplemented
)
{
...
...
@@ -2020,7 +2020,7 @@ extern "C" Box* unaryop(Box* operand, int op_type) {
std
::
string
op_name
=
getOpName
(
op_type
);
Box
*
attr_func
=
getclsattr_internal
(
operand
,
op_name
.
c_str
()
,
NULL
,
NULL
);
Box
*
attr_func
=
getclsattr_internal
(
operand
,
op_name
,
NULL
,
NULL
);
ASSERT
(
attr_func
,
"%s.%s"
,
getTypeName
(
operand
)
->
c_str
(),
op_name
.
c_str
());
...
...
src/runtime/objmodel.h
View file @
18b34c5f
...
...
@@ -65,8 +65,8 @@ extern "C" void assertFail(BoxedModule* inModule, Box* msg);
struct
CompareRewriteArgs
;
Box
*
compareInternal
(
Box
*
lhs
,
Box
*
rhs
,
int
op_type
,
CompareRewriteArgs
*
rewrite_args
);
Box
*
getattr_internal
(
Box
*
obj
,
const
char
*
attr
,
bool
check_cls
,
bool
allow_custom
,
GetattrRewriteArgs
*
rewrite_args
,
GetattrRewriteArgs2
*
rewrite_args2
);
Box
*
getattr_internal
(
Box
*
obj
,
const
std
::
string
&
attr
,
bool
check_cls
,
bool
allow_custom
,
GetattrRewriteArgs
*
rewrite_args
,
GetattrRewriteArgs
2
*
rewrite_args2
);
extern
"C"
void
raiseAttributeErrorStr
(
const
char
*
typeName
,
const
char
*
attr
)
__attribute__
((
__noreturn__
));
extern
"C"
void
raiseAttributeError
(
Box
*
obj
,
const
char
*
attr
)
__attribute__
((
__noreturn__
));
...
...
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