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
99ff28d1
Commit
99ff28d1
authored
Nov 13, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Passes with malloc checking turned on
parent
163f4574
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
27 deletions
+26
-27
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+14
-9
src/runtime/types.cpp
src/runtime/types.cpp
+9
-15
src/runtime/types.h
src/runtime/types.h
+2
-2
src/runtime/util.cpp
src/runtime/util.cpp
+1
-1
No files found.
src/runtime/objmodel.cpp
View file @
99ff28d1
...
...
@@ -400,7 +400,7 @@ void BoxedClass::freeze() {
std
::
vector
<
BoxedClass
*>
classes
;
BoxedClass
::
BoxedClass
(
BoxedClass
*
base
,
int
attrs_offset
,
int
weaklist_offset
,
int
instance_size
,
bool
is_user_defined
,
const
char
*
name
,
destructor
dealloc
,
freefunc
free
)
const
char
*
name
,
destructor
dealloc
,
freefunc
free
,
bool
is_gc
)
:
attrs
(
HiddenClass
::
makeSingleton
()),
attrs_offset
(
attrs_offset
),
is_constant
(
false
),
...
...
@@ -421,7 +421,8 @@ BoxedClass::BoxedClass(BoxedClass* base, int attrs_offset, int weaklist_offset,
tp_flags
|=
Py_TPFLAGS_DEFAULT_CORE
;
tp_flags
|=
Py_TPFLAGS_CHECKTYPES
;
tp_flags
|=
Py_TPFLAGS_BASETYPE
;
tp_flags
|=
Py_TPFLAGS_HAVE_GC
;
if
(
is_gc
)
tp_flags
|=
Py_TPFLAGS_HAVE_GC
;
if
(
base
&&
(
base
->
tp_flags
&
Py_TPFLAGS_HAVE_NEWBUFFER
))
tp_flags
|=
Py_TPFLAGS_HAVE_NEWBUFFER
;
...
...
@@ -458,16 +459,20 @@ BoxedClass::BoxedClass(BoxedClass* base, int attrs_offset, int weaklist_offset,
assert
(
base
&&
base
->
tp_dealloc
);
tp_dealloc
=
base
->
tp_dealloc
;
}
if
(
PyType_IS_GC
(
this
))
assert
(
tp_free
!=
PyObject_Del
);
if
(
free
)
tp_free
=
free
;
else
{
assert
(
base
&&
base
->
tp_free
);
tp_free
=
base
->
tp_free
;
else
if
(
base
)
{
// Copied from PyType_Ready
if
(
PyType_IS_GC
(
this
)
==
PyType_IS_GC
(
base
))
tp_free
=
base
->
tp_free
;
else
if
(
PyType_IS_GC
(
this
)
&&
base
->
tp_free
==
PyObject_Del
)
this
->
tp_free
=
PyObject_GC_Del
;
}
if
(
PyType_IS_GC
(
this
))
assert
(
tp_free
!=
PyObject_Del
);
assert
(
tp_dealloc
);
assert
(
tp_free
);
...
...
@@ -495,10 +500,10 @@ BoxedClass::BoxedClass(BoxedClass* base, int attrs_offset, int weaklist_offset,
BoxedClass
*
BoxedClass
::
create
(
BoxedClass
*
metaclass
,
BoxedClass
*
base
,
int
attrs_offset
,
int
weaklist_offset
,
int
instance_size
,
bool
is_user_defined
,
const
char
*
name
,
destructor
dealloc
,
freefunc
free
)
{
freefunc
free
,
bool
is_gc
)
{
assert
(
!
is_user_defined
);
BoxedClass
*
made
=
new
(
metaclass
,
0
)
BoxedClass
(
base
,
attrs_offset
,
weaklist_offset
,
instance_size
,
is_user_defined
,
name
,
dealloc
,
free
);
BoxedClass
(
base
,
attrs_offset
,
weaklist_offset
,
instance_size
,
is_user_defined
,
name
,
dealloc
,
free
,
is_gc
);
// While it might be ok if these were set, it'd indicate a difference in
// expectations as to who was going to calculate them:
...
...
src/runtime/types.cpp
View file @
99ff28d1
...
...
@@ -3448,8 +3448,7 @@ void setupRuntime() {
type_cls
=
static_cast
<
BoxedClass
*>
(
PyObject_MALLOC
(
sizeof
(
BoxedClass
)));
PyObject_INIT
(
object_cls
,
type_cls
);
PyObject_INIT
(
type_cls
,
type_cls
);
::
new
(
object_cls
)
BoxedClass
(
NULL
,
0
,
0
,
sizeof
(
Box
),
false
,
"object"
,
object_dealloc
,
PyObject_Del
);
object_cls
->
tp_flags
&=
~
Py_TPFLAGS_HAVE_GC
;
::
new
(
object_cls
)
BoxedClass
(
NULL
,
0
,
0
,
sizeof
(
Box
),
false
,
"object"
,
object_dealloc
,
PyObject_Del
,
/* is_gc */
false
);
::
new
(
type_cls
)
BoxedClass
(
object_cls
,
offsetof
(
BoxedClass
,
attrs
),
offsetof
(
BoxedClass
,
tp_weaklist
),
sizeof
(
BoxedHeapClass
),
false
,
"type"
,
BoxedClass
::
dealloc
,
PyObject_GC_Del
);
...
...
@@ -3467,18 +3466,18 @@ void setupRuntime() {
object_cls
->
tp_new
=
object_new
;
type_cls
->
tp_getattro
=
type_getattro
;
none_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
0
,
0
,
sizeof
(
Box
),
false
,
"NoneType"
,
NULL
,
NULL
);
none_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
0
,
0
,
sizeof
(
Box
),
false
,
"NoneType"
,
NULL
,
NULL
,
/* is_gc */
false
);
None
=
new
(
none_cls
)
Box
();
constants
.
push_back
(
None
);
assert
(
None
->
cls
);
// You can't actually have an instance of basestring
basestring_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
0
,
0
,
sizeof
(
Box
),
false
,
"basestring"
,
NULL
,
NULL
);
basestring_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
0
,
0
,
sizeof
(
Box
),
false
,
"basestring"
,
NULL
,
NULL
,
false
);
// We add 1 to the tp_basicsize of the BoxedString in order to hold the null byte at the end.
// We use offsetof(BoxedString, s_data) as opposed to sizeof(BoxedString) so that we can
// use the extra padding bytes at the end of the BoxedString.
str_cls
=
new
(
0
)
BoxedClass
(
basestring_cls
,
0
,
0
,
offsetof
(
BoxedString
,
s_data
)
+
1
,
false
,
"str"
,
NULL
,
NULL
);
str_cls
=
new
(
0
)
BoxedClass
(
basestring_cls
,
0
,
0
,
offsetof
(
BoxedString
,
s_data
)
+
1
,
false
,
"str"
,
NULL
,
NULL
,
false
);
str_cls
->
tp_flags
|=
Py_TPFLAGS_STRING_SUBCLASS
;
str_cls
->
tp_itemsize
=
sizeof
(
char
);
...
...
@@ -3514,18 +3513,13 @@ void setupRuntime() {
dict_cls
->
tp_flags
|=
Py_TPFLAGS_DICT_SUBCLASS
;
file_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
0
,
offsetof
(
BoxedFile
,
weakreflist
),
sizeof
(
BoxedFile
),
false
,
"file"
,
file_dealloc
,
NULL
);
int_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
0
,
0
,
sizeof
(
BoxedInt
),
false
,
"int"
,
NULL
,
NULL
);
int_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
0
,
0
,
sizeof
(
BoxedInt
),
false
,
"int"
,
NULL
,
NULL
,
false
);
int_cls
->
tp_flags
|=
Py_TPFLAGS_INT_SUBCLASS
;
int_cls
->
tp_flags
&=
~
Py_TPFLAGS_HAVE_GC
;
bool_cls
=
new
(
0
)
BoxedClass
(
int_cls
,
0
,
0
,
sizeof
(
BoxedBool
),
false
,
"bool"
,
NULL
,
NULL
);
bool_cls
->
tp_flags
&=
~
Py_TPFLAGS_HAVE_GC
;
complex_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
0
,
0
,
sizeof
(
BoxedComplex
),
false
,
"complex"
,
NULL
,
NULL
);
complex_cls
->
tp_flags
&=
~
Py_TPFLAGS_HAVE_GC
;
long_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
0
,
0
,
sizeof
(
BoxedLong
),
false
,
"long"
,
NULL
,
NULL
);
bool_cls
=
new
(
0
)
BoxedClass
(
int_cls
,
0
,
0
,
sizeof
(
BoxedBool
),
false
,
"bool"
,
NULL
,
NULL
,
false
);
complex_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
0
,
0
,
sizeof
(
BoxedComplex
),
false
,
"complex"
,
NULL
,
NULL
,
false
);
long_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
0
,
0
,
sizeof
(
BoxedLong
),
false
,
"long"
,
NULL
,
NULL
,
false
);
long_cls
->
tp_flags
|=
Py_TPFLAGS_LONG_SUBCLASS
;
long_cls
->
tp_flags
&=
~
Py_TPFLAGS_HAVE_GC
;
float_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
0
,
0
,
sizeof
(
BoxedFloat
),
false
,
"float"
,
NULL
,
NULL
);
float_cls
->
tp_flags
&=
~
Py_TPFLAGS_HAVE_GC
;
float_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
0
,
0
,
sizeof
(
BoxedFloat
),
false
,
"float"
,
NULL
,
NULL
,
false
);
function_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
offsetof
(
BoxedFunction
,
attrs
),
offsetof
(
BoxedFunction
,
weakreflist
),
sizeof
(
BoxedFunction
),
false
,
"function"
,
functionDtor
,
NULL
);
...
...
src/runtime/types.h
View file @
99ff28d1
...
...
@@ -277,10 +277,10 @@ public:
// These should only be used for builtin types:
static
BoxedClass
*
create
(
BoxedClass
*
metatype
,
BoxedClass
*
base
,
int
attrs_offset
,
int
weaklist_offset
,
int
instance_size
,
bool
is_user_defined
,
const
char
*
name
,
destructor
dealloc
=
NULL
,
freefunc
free
=
NULL
);
freefunc
free
=
NULL
,
bool
is_gc
=
true
);
BoxedClass
(
BoxedClass
*
base
,
int
attrs_offset
,
int
weaklist_offset
,
int
instance_size
,
bool
is_user_defined
,
const
char
*
name
,
destructor
dealloc
,
freefunc
free
);
bool
is_user_defined
,
const
char
*
name
,
destructor
dealloc
,
freefunc
free
,
bool
is_gc
=
true
);
DEFAULT_CLASS_VAR
(
type_cls
,
sizeof
(
SlotOffset
));
...
...
src/runtime/util.cpp
View file @
99ff28d1
...
...
@@ -154,7 +154,7 @@ extern "C" void dumpEx(void* p, int levels) {
printf
(
"Guessing that it's a Python object
\n
"
);
Box
*
b
=
(
Box
*
)
p
;
printf
(
"Class: %s"
,
getFullTypeName
(
b
).
c_str
()
);
printf
(
"Class: %s"
,
b
->
cls
->
tp_name
);
if
(
b
->
cls
->
cls
!=
type_cls
)
{
printf
(
" (metaclass: %s)
\n
"
,
getFullTypeName
(
b
->
cls
).
c_str
());
}
else
{
...
...
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