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
6f55634f
Commit
6f55634f
authored
Jul 29, 2015
by
Rudi Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the isUserDefined helper function which is no longer useful.
All it does is a field access.
parent
215bef6a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
20 deletions
+9
-20
src/codegen/compvars.cpp
src/codegen/compvars.cpp
+1
-6
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+7
-12
src/runtime/objmodel.h
src/runtime/objmodel.h
+0
-1
src/runtime/types.cpp
src/runtime/types.cpp
+1
-1
No files found.
src/codegen/compvars.cpp
View file @
6f55634f
...
...
@@ -1415,12 +1415,7 @@ private:
static
std
::
unordered_map
<
BoxedClass
*
,
NormalObjectType
*>
made
;
NormalObjectType
(
BoxedClass
*
cls
)
:
cls
(
cls
)
{
// ASSERT(!isUserDefined(cls) && "instances of user-defined classes can change their __class__, plus even if
// they couldn't we couldn't statically resolve their attributes", "%s", getNameOfClass(cls)->c_str());
assert
(
cls
);
}
NormalObjectType
(
BoxedClass
*
cls
)
:
cls
(
cls
)
{
assert
(
cls
);
}
public:
llvm
::
Type
*
llvmType
()
override
{
return
g
.
llvm_value_type_ptr
;
}
...
...
src/runtime/objmodel.cpp
View file @
6f55634f
...
...
@@ -2159,7 +2159,7 @@ void setattrGeneric(Box* obj, BoxedString* attr, Box* val, SetattrRewriteArgs* r
// TODO this should be in type_setattro
if
(
obj
->
cls
==
type_cls
)
{
BoxedClass
*
cobj
=
static_cast
<
BoxedClass
*>
(
obj
);
if
(
!
isUserDefined
(
cobj
)
)
{
if
(
!
cobj
->
is_user_defined
)
{
raiseExcHelper
(
TypeError
,
"can't set attributes of built-in/extension type '%s'"
,
getNameOfClass
(
cobj
));
}
}
...
...
@@ -2340,11 +2340,6 @@ extern "C" void setattr(Box* obj, BoxedString* attr, Box* attr_val) {
}
}
bool
isUserDefined
(
BoxedClass
*
cls
)
{
return
cls
->
is_user_defined
;
// return cls->hasattrs && (cls != function_cls && cls != type_cls) && !cls->is_constant;
}
extern
"C"
bool
nonzero
(
Box
*
obj
)
{
STAT_TIMER
(
t0
,
"us_timer_slowpath_nonzero"
,
10
);
...
...
@@ -2453,7 +2448,7 @@ extern "C" bool nonzero(Box* obj) {
func
=
getclsattrInternal
(
obj
,
len_str
,
NULL
);
if
(
func
==
NULL
)
{
ASSERT
(
isUserDefined
(
obj
->
cls
)
||
obj
->
cls
==
classobj_cls
||
obj
->
cls
==
type_cls
ASSERT
(
obj
->
cls
->
is_user_defined
||
obj
->
cls
==
classobj_cls
||
obj
->
cls
==
type_cls
||
isSubclass
(
obj
->
cls
,
Exception
)
||
obj
->
cls
==
file_cls
||
obj
->
cls
==
traceback_cls
||
obj
->
cls
==
instancemethod_cls
||
obj
->
cls
==
module_cls
||
obj
->
cls
==
capifunc_cls
||
obj
->
cls
==
builtin_function_or_method_cls
||
obj
->
cls
==
method_cls
||
obj
->
cls
==
frame_cls
...
...
@@ -4211,7 +4206,7 @@ extern "C" Box* binopInternal(Box* lhs, Box* rhs, int op_type, bool inplace, Bin
extern
"C"
Box
*
binop
(
Box
*
lhs
,
Box
*
rhs
,
int
op_type
)
{
STAT_TIMER
(
t0
,
"us_timer_slowpath_binop"
,
10
);
bool
can_patchpoint
=
!
isUserDefined
(
lhs
->
cls
)
&&
!
isUserDefined
(
rhs
->
cls
)
;
bool
can_patchpoint
=
!
lhs
->
cls
->
is_user_defined
&&
!
rhs
->
cls
->
is_user_defined
;
#if 0
static uint64_t* st_id = Stats::getStatCounter("us_timer_slowpath_binop_patchable");
static uint64_t* st_id_nopatch = Stats::getStatCounter("us_timer_slowpath_binop_nopatch");
...
...
@@ -4268,7 +4263,7 @@ extern "C" Box* augbinop(Box* lhs, Box* rhs, int op_type) {
// resolving it one way right now (ex, using the value from lhs.__add__) means that later
// we'll resolve it the same way, even for the same argument types.
// TODO implement full resolving semantics inside the rewrite?
bool
can_patchpoint
=
!
isUserDefined
(
lhs
->
cls
)
&&
!
isUserDefined
(
rhs
->
cls
)
;
bool
can_patchpoint
=
!
lhs
->
cls
->
is_user_defined
&&
!
rhs
->
cls
->
is_user_defined
;
if
(
can_patchpoint
)
rewriter
.
reset
(
Rewriter
::
createRewriter
(
__builtin_extract_return_addr
(
__builtin_return_address
(
0
)),
3
,
"binop"
));
...
...
@@ -4427,7 +4422,7 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
return
boxBool
(
b
);
}
bool
any_user_defined
=
isUserDefined
(
lhs
->
cls
)
||
isUserDefined
(
rhs
->
cls
)
;
bool
any_user_defined
=
lhs
->
cls
->
is_user_defined
||
rhs
->
cls
->
is_user_defined
;
if
(
any_user_defined
)
{
rewrite_args
=
NULL
;
REWRITE_ABORTED
(
""
);
...
...
@@ -4476,7 +4471,7 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
// simplified by using the assumption that tp_richcompare exists and never returns NotImplemented
// for builtin types when both arguments are the right type.
assert
(
!
isUserDefined
(
lhs
->
cls
)
);
assert
(
!
lhs
->
cls
->
is_user_defined
);
Box
*
r
=
lhs
->
cls
->
tp_richcompare
(
lhs
,
rhs
,
cpython_op_type
);
RELEASE_ASSERT
(
r
!=
NotImplemented
,
"%s returned notimplemented?"
,
lhs
->
cls
->
tp_name
);
...
...
@@ -5052,7 +5047,7 @@ extern "C" void delattr(Box* obj, BoxedString* attr) {
if
(
obj
->
cls
==
type_cls
)
{
BoxedClass
*
cobj
=
static_cast
<
BoxedClass
*>
(
obj
);
if
(
!
isUserDefined
(
cobj
)
)
{
if
(
!
cobj
->
is_user_defined
)
{
raiseExcHelper
(
TypeError
,
"can't set attributes of built-in/extension type '%s'
\n
"
,
getNameOfClass
(
cobj
));
}
}
...
...
src/runtime/objmodel.h
View file @
6f55634f
...
...
@@ -165,7 +165,6 @@ extern "C" void raiseIndexErrorStr(const char* typeName) __attribute__((__noretu
Box
*
typeCall
(
Box
*
,
BoxedTuple
*
,
BoxedDict
*
);
Box
*
typeNew
(
Box
*
cls
,
Box
*
arg1
,
Box
*
arg2
,
Box
**
_args
);
bool
isUserDefined
(
BoxedClass
*
cls
);
// These process a potential descriptor, differing in their behavior if the object was not a descriptor.
// the OrNull variant returns NULL to signify it wasn't a descriptor, and the processDescriptor version
...
...
src/runtime/types.cpp
View file @
6f55634f
...
...
@@ -1832,7 +1832,7 @@ Box* typeRepr(BoxedClass* self) {
std
::
string
O
(
""
);
llvm
::
raw_string_ostream
os
(
O
);
if
((
self
->
tp_flags
&
Py_TPFLAGS_HEAPTYPE
)
&&
isUserDefined
(
self
)
)
if
((
self
->
tp_flags
&
Py_TPFLAGS_HEAPTYPE
)
&&
self
->
is_user_defined
)
os
<<
"<class '"
;
else
os
<<
"<type '"
;
...
...
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