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
49ee07fa
Commit
49ee07fa
authored
Jan 08, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'tp_as_number'
parents
76210a33
b679d358
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
635 additions
and
31 deletions
+635
-31
Makefile
Makefile
+5
-1
from_cpython/Include/intobject.h
from_cpython/Include/intobject.h
+1
-1
src/capi/object.cpp
src/capi/object.cpp
+25
-0
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+327
-3
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+21
-20
test/test_extension/slots_test.c
test/test_extension/slots_test.c
+215
-2
test/tests/capi_slots.py
test/tests/capi_slots.py
+38
-3
tools/tester.py
tools/tester.py
+3
-1
No files found.
Makefile
View file @
49ee07fa
...
...
@@ -321,7 +321,7 @@ NONSTDLIB_SRCS := $(MAIN_SRCS) $(OPTIONAL_SRCS) $(TOOL_SRCS) $(UNITTEST_SRCS)
# all: pyston_dbg pyston_release pyston_oprof pyston_prof $(OPTIONAL_SRCS:.cpp=.o) ext_python ext_pyston
all
:
pyston_dbg pyston_release pyston_prof ext_python ext_pyston unittests
ALL_HEADERS
:=
$(
wildcard
src/
*
/
*
.h
)
$(
wildcard
src/
*
/
*
/
*
.h
)
$(
wildcard
cpython2.7
/Include/
*
.h
)
ALL_HEADERS
:=
$(
wildcard
src/
*
/
*
.h
)
$(
wildcard
src/
*
/
*
/
*
.h
)
$(
wildcard
from_cpython
/Include/
*
.h
)
tags
:
$(SRCS) $(OPTIONAL_SRCS) $(FROM_CPYTHON_SRCS) $(ALL_HEADERS)
$(ECHO)
Calculating tags...
$(VERB)
ctags
$^
...
...
@@ -865,6 +865,10 @@ $(call make_target,_grwl)
$(call
make_target,_grwl_dbg)
$(call
make_target,_nosync)
runpy_%
:
%.py ext_python
PYTHONPATH
=
test
/test_extension/build/lib.linux-x86_64-2.7 python
$<
$(call
make_search,runpy_%)
# "kill valgrind":
kv
:
ps aux |
awk
'/[v]algrind/ {print $$2}'
| xargs
kill
-9
;
true
...
...
from_cpython/Include/intobject.h
View file @
49ee07fa
...
...
@@ -42,7 +42,7 @@ PyAPI_FUNC(bool) PyInt_Check(PyObject*);
#define PyInt_Check(op) \
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_INT_SUBCLASS)
#endif
#define PyInt_CheckExact(op) (
(op)->ob_type
== &PyInt_Type)
#define PyInt_CheckExact(op) (
Py_TYPE(op)
== &PyInt_Type)
PyAPI_FUNC
(
PyObject
*
)
PyInt_FromString
(
char
*
,
char
**
,
int
);
#ifdef Py_USING_UNICODE
...
...
src/capi/object.cpp
View file @
49ee07fa
...
...
@@ -75,4 +75,29 @@ extern "C" int PyObject_GenericSetAttr(PyObject* obj, PyObject* name, PyObject*
extern
"C"
int
PyObject_AsWriteBuffer
(
PyObject
*
obj
,
void
**
buffer
,
Py_ssize_t
*
buffer_len
)
{
Py_FatalError
(
"unimplemented"
);
}
/* Return -1 if error; 1 if v op w; 0 if not (v op w). */
extern
"C"
int
PyObject_RichCompareBool
(
PyObject
*
v
,
PyObject
*
w
,
int
op
)
{
PyObject
*
res
;
int
ok
;
/* Quick result when objects are the same.
Guarantees that identity implies equality. */
if
(
v
==
w
)
{
if
(
op
==
Py_EQ
)
return
1
;
else
if
(
op
==
Py_NE
)
return
0
;
}
res
=
PyObject_RichCompare
(
v
,
w
,
op
);
if
(
res
==
NULL
)
return
-
1
;
if
(
PyBool_Check
(
res
))
ok
=
(
res
==
Py_True
);
else
ok
=
PyObject_IsTrue
(
res
);
Py_DECREF
(
res
);
return
ok
;
}
}
src/capi/typeobject.cpp
View file @
49ee07fa
This diff is collapsed.
Click to expand it.
src/runtime/objmodel.cpp
View file @
49ee07fa
...
...
@@ -353,6 +353,7 @@ BoxedClass::BoxedClass(BoxedClass* metaclass, BoxedClass* base, gcvisit_func gc_
tp_basicsize
=
instance_size
;
tp_flags
|=
Py_TPFLAGS_HEAPTYPE
;
tp_flags
|=
Py_TPFLAGS_CHECKTYPES
;
if
(
metaclass
==
NULL
)
{
assert
(
type_cls
==
NULL
);
...
...
@@ -1456,26 +1457,6 @@ void setattrInternal(Box* obj, const std::string& attr, Box* val, SetattrRewrite
descr
=
typeLookup
(
obj
->
cls
,
attr
,
NULL
);
}
if
(
isSubclass
(
obj
->
cls
,
type_cls
))
{
BoxedClass
*
self
=
static_cast
<
BoxedClass
*>
(
obj
);
if
(
attr
==
_getattr_str
||
attr
==
_getattribute_str
)
{
// Will have to embed the clear in the IC, so just disable the patching for now:
rewrite_args
=
NULL
;
// TODO should put this clearing behavior somewhere else, since there are probably more
// cases in which we want to do it.
self
->
dependent_icgetattrs
.
invalidateAll
();
}
if
(
attr
==
"__base__"
&&
self
->
getattr
(
"__base__"
))
raiseExcHelper
(
TypeError
,
"readonly attribute"
);
bool
touched_slot
=
update_slot
(
self
,
attr
);
if
(
touched_slot
)
rewrite_args
=
NULL
;
}
Box
*
_set_
=
NULL
;
RewriterVar
*
r_set
=
NULL
;
if
(
descr
)
{
...
...
@@ -1511,6 +1492,26 @@ void setattrInternal(Box* obj, const std::string& attr, Box* val, SetattrRewrite
}
else
{
obj
->
setattr
(
attr
,
val
,
rewrite_args
);
}
if
(
isSubclass
(
obj
->
cls
,
type_cls
))
{
BoxedClass
*
self
=
static_cast
<
BoxedClass
*>
(
obj
);
if
(
attr
==
_getattr_str
||
attr
==
_getattribute_str
)
{
// Will have to embed the clear in the IC, so just disable the patching for now:
rewrite_args
=
NULL
;
// TODO should put this clearing behavior somewhere else, since there are probably more
// cases in which we want to do it.
self
->
dependent_icgetattrs
.
invalidateAll
();
}
if
(
attr
==
"__base__"
&&
self
->
getattr
(
"__base__"
))
raiseExcHelper
(
TypeError
,
"readonly attribute"
);
bool
touched_slot
=
update_slot
(
self
,
attr
);
if
(
touched_slot
)
rewrite_args
=
NULL
;
}
}
extern
"C"
void
setattr
(
Box
*
obj
,
const
char
*
attr
,
Box
*
attr_val
)
{
...
...
test/test_extension/slots_test.c
View file @
49ee07fa
This diff is collapsed.
Click to expand it.
test/tests/capi_slots.py
View file @
49ee07fa
...
...
@@ -2,18 +2,43 @@ import slots_test
for
i
in
xrange
(
3
):
t
=
slots_test
.
SlotsTesterSeq
(
i
+
5
)
print
t
,
repr
(
t
),
t
(),
t
[
2
]
print
hash
(
t
),
t
<
1
,
t
>
2
,
t
!=
3
print
t
,
repr
(
t
),
str
(
t
),
t
(),
t
[
2
]
print
hash
(
t
),
t
<
1
,
t
>
2
,
t
!=
3
,
bool
(
t
)
# print slots_test.SlotsTesterSeq.__doc__
print
slots_test
.
SlotsTesterSeq
.
set_through_tpdict
,
slots_test
.
SlotsTesterSeq
(
5
).
set_through_tpdict
for
i
in
xrange
(
3
):
t
=
slots_test
.
SlotsTesterMap
(
i
+
5
)
print
len
(
t
),
t
[
2
]
print
len
(
t
),
t
[
2
]
,
repr
(
t
),
str
(
t
)
t
[
1
]
=
5
del
t
[
2
]
for
i
in
xrange
(
3
):
t
=
slots_test
.
SlotsTesterNum
(
i
)
print
bool
(
t
)
print
t
+
5
print
t
-
5
print
t
*
5
print
t
/
5
print
t
%
5
print
divmod
(
t
,
5
)
print
t
**
5
print
t
<<
5
print
t
>>
5
print
t
&
5
print
t
^
5
print
t
|
5
print
+
t
print
-
t
print
abs
(
t
)
print
~
t
print
int
(
t
)
print
long
(
t
)
print
float
(
t
)
print
hex
(
t
)
print
oct
(
t
)
class
C
(
object
):
def
__repr__
(
self
):
print
"__repr__()"
...
...
@@ -33,4 +58,14 @@ slots_test.call_funcs(C())
def
repr2
(
self
):
return
"repr2()"
C
.
__repr__
=
repr2
def
nonzero
(
self
):
print
"nonzero"
return
True
C
.
__nonzero__
=
nonzero
def
add
(
self
,
rhs
):
print
"add"
,
self
,
rhs
C
.
__add__
=
add
slots_test
.
call_funcs
(
C
())
tools/tester.py
View file @
49ee07fa
...
...
@@ -350,7 +350,7 @@ if __name__ == "__main__":
run_memcheck = False
start = 1
opts, patterns = getopt.gnu_getopt(sys.argv[1:], "j:a:t:mR:k")
opts, patterns = getopt.gnu_getopt(sys.argv[1:], "j:a:t:mR:k
K
")
for (t, v) in opts:
if t == '-m':
run_memcheck = True
...
...
@@ -361,6 +361,8 @@ if __name__ == "__main__":
IMAGE = v
elif t == '-k':
KEEP_GOING = True
elif t == '-K':
KEEP_GOING = False
elif t == '-a':
EXTRA_JIT_ARGS.append(v)
elif t == '-t':
...
...
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