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
2538f588
Commit
2538f588
authored
Nov 12, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor: move BoxedClass from core/ to runtime/
parent
9a246340
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
62 deletions
+68
-62
include/object.h
include/object.h
+1
-1
src/core/types.h
src/core/types.h
+1
-61
src/gc/collector.cpp
src/gc/collector.cpp
+1
-0
src/gc/heap.cpp
src/gc/heap.cpp
+1
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+1
-0
src/runtime/types.h
src/runtime/types.h
+63
-0
No files found.
include/object.h
View file @
2538f588
...
...
@@ -455,7 +455,7 @@ struct _typeobject {
void
*
_hcls
;
void
*
_hcattrs
;
char
_dep_getattrs
[
56
];
// FIXME: this is hardcoding the size of this particular implementation of std::unordered_map
char
_ics
[
48
];
char
_ics
[
24
];
void
*
_base
;
void
*
_gcvisit_func
;
int
_attrs_offset
;
...
...
src/core/types.h
View file @
2538f588
...
...
@@ -452,67 +452,7 @@ std::string getFullTypeName(Box* o);
class
BoxedClass
:
public
BoxVar
{
public:
PyTypeObject_BODY
;
HCAttrs
attrs
;
// If the user sets __getattribute__ or __getattr__, we will have to invalidate
// all getattr IC entries that relied on the fact that those functions didn't exist.
// Doing this via invalidation means that instance attr lookups don't have
// to guard on anything about the class.
ICInvalidator
dependent_icgetattrs
;
// TODO: these don't actually get deallocated right now
std
::
shared_ptr
<
CallattrIC
>
hasnext_ic
,
next_ic
;
std
::
shared_ptr
<
NonzeroIC
>
nonzero_ic
;
CallattrIC
*
getHasnextIC
();
CallattrIC
*
getNextIC
();
NonzeroIC
*
getNonzeroIC
();
// Only a single base supported for now.
// Is NULL iff this is object_cls
BoxedClass
*
base
;
typedef
void
(
*
gcvisit_func
)(
GCVisitor
*
,
Box
*
);
gcvisit_func
gc_visit
;
// Offset of the HCAttrs object or 0 if there are no hcattrs.
// Analogous to tp_dictoffset
const
int
attrs_offset
;
bool
instancesHaveAttrs
()
{
return
attrs_offset
!=
0
;
}
// Whether this class object is constant or not, ie whether or not class-level
// attributes can be changed or added.
// Does not necessarily imply that the instances of this class are constant,
// though for now (is_constant && !hasattrs) does imply that the instances are constant.
bool
is_constant
;
// Whether this class was defined by the user or is a builtin type.
// this is used mostly for debugging.
const
bool
is_user_defined
;
// will need to update this once we support tp_getattr-style overriding:
bool
hasGenericGetattr
()
{
return
true
;
}
BoxedClass
(
BoxedClass
*
metaclass
,
BoxedClass
*
base
,
gcvisit_func
gc_visit
,
int
attrs_offset
,
int
instance_size
,
bool
is_user_defined
);
void
freeze
();
};
static_assert
(
sizeof
(
pyston
::
Box
)
==
sizeof
(
struct
_object
),
""
);
static_assert
(
offsetof
(
pyston
::
Box
,
cls
)
==
offsetof
(
struct
_object
,
ob_type
),
""
);
static_assert
(
offsetof
(
pyston
::
BoxedClass
,
cls
)
==
offsetof
(
struct
_typeobject
,
ob_type
),
""
);
static_assert
(
offsetof
(
pyston
::
BoxedClass
,
tp_name
)
==
offsetof
(
struct
_typeobject
,
tp_name
),
""
);
static_assert
(
offsetof
(
pyston
::
BoxedClass
,
attrs
)
==
offsetof
(
struct
_typeobject
,
_hcls
),
""
);
static_assert
(
offsetof
(
pyston
::
BoxedClass
,
dependent_icgetattrs
)
==
offsetof
(
struct
_typeobject
,
_dep_getattrs
),
""
);
static_assert
(
offsetof
(
pyston
::
BoxedClass
,
base
)
==
offsetof
(
struct
_typeobject
,
_base
),
""
);
static_assert
(
offsetof
(
pyston
::
BoxedClass
,
gc_visit
)
==
offsetof
(
struct
_typeobject
,
_gcvisit_func
),
""
);
static_assert
(
sizeof
(
pyston
::
BoxedClass
)
==
sizeof
(
struct
_typeobject
),
""
);
class
BoxedClass
;
// TODO these shouldn't be here
void
setupRuntime
();
...
...
src/gc/collector.cpp
View file @
2538f588
...
...
@@ -25,6 +25,7 @@
#include "core/util.h"
#include "gc/heap.h"
#include "gc/root_finder.h"
#include "runtime/types.h"
#ifndef NVALGRIND
#include "valgrind.h"
...
...
src/gc/heap.cpp
View file @
2538f588
...
...
@@ -22,6 +22,7 @@
#include "core/common.h"
#include "core/util.h"
#include "gc/gc_alloc.h"
#include "runtime/types.h"
#ifndef NVALGRIND
#include "valgrind.h"
...
...
src/runtime/objmodel.cpp
View file @
2538f588
...
...
@@ -39,6 +39,7 @@
#include "runtime/classobj.h"
#include "runtime/float.h"
#include "runtime/generator.h"
#include "runtime/ics.h"
#include "runtime/iterobject.h"
#include "runtime/long.h"
#include "runtime/types.h"
...
...
src/runtime/types.h
View file @
2538f588
...
...
@@ -167,6 +167,69 @@ template <typename K, typename V, typename Hash = std::hash<K>, typename KeyEqua
class
conservative_unordered_map
:
public
std
::
unordered_map
<
K
,
V
,
Hash
,
KeyEqual
,
StlCompatAllocator
<
std
::
pair
<
const
K
,
V
>
>
>
{};
class
BoxedClass
:
public
BoxVar
{
public:
PyTypeObject_BODY
;
HCAttrs
attrs
;
// If the user sets __getattribute__ or __getattr__, we will have to invalidate
// all getattr IC entries that relied on the fact that those functions didn't exist.
// Doing this via invalidation means that instance attr lookups don't have
// to guard on anything about the class.
ICInvalidator
dependent_icgetattrs
;
// TODO: these don't actually get deallocated right now
std
::
unique_ptr
<
CallattrIC
>
hasnext_ic
,
next_ic
;
std
::
unique_ptr
<
NonzeroIC
>
nonzero_ic
;
CallattrIC
*
getHasnextIC
();
CallattrIC
*
getNextIC
();
NonzeroIC
*
getNonzeroIC
();
// Only a single base supported for now.
// Is NULL iff this is object_cls
BoxedClass
*
base
;
typedef
void
(
*
gcvisit_func
)(
GCVisitor
*
,
Box
*
);
gcvisit_func
gc_visit
;
// Offset of the HCAttrs object or 0 if there are no hcattrs.
// Analogous to tp_dictoffset
const
int
attrs_offset
;
bool
instancesHaveAttrs
()
{
return
attrs_offset
!=
0
;
}
// Whether this class object is constant or not, ie whether or not class-level
// attributes can be changed or added.
// Does not necessarily imply that the instances of this class are constant,
// though for now (is_constant && !hasattrs) does imply that the instances are constant.
bool
is_constant
;
// Whether this class was defined by the user or is a builtin type.
// this is used mostly for debugging.
const
bool
is_user_defined
;
// will need to update this once we support tp_getattr-style overriding:
bool
hasGenericGetattr
()
{
return
true
;
}
BoxedClass
(
BoxedClass
*
metaclass
,
BoxedClass
*
base
,
gcvisit_func
gc_visit
,
int
attrs_offset
,
int
instance_size
,
bool
is_user_defined
);
void
freeze
();
};
static_assert
(
sizeof
(
pyston
::
Box
)
==
sizeof
(
struct
_object
),
""
);
static_assert
(
offsetof
(
pyston
::
Box
,
cls
)
==
offsetof
(
struct
_object
,
ob_type
),
""
);
static_assert
(
offsetof
(
pyston
::
BoxedClass
,
cls
)
==
offsetof
(
struct
_typeobject
,
ob_type
),
""
);
static_assert
(
offsetof
(
pyston
::
BoxedClass
,
tp_name
)
==
offsetof
(
struct
_typeobject
,
tp_name
),
""
);
static_assert
(
offsetof
(
pyston
::
BoxedClass
,
attrs
)
==
offsetof
(
struct
_typeobject
,
_hcls
),
""
);
static_assert
(
offsetof
(
pyston
::
BoxedClass
,
dependent_icgetattrs
)
==
offsetof
(
struct
_typeobject
,
_dep_getattrs
),
""
);
static_assert
(
offsetof
(
pyston
::
BoxedClass
,
base
)
==
offsetof
(
struct
_typeobject
,
_base
),
""
);
static_assert
(
offsetof
(
pyston
::
BoxedClass
,
gc_visit
)
==
offsetof
(
struct
_typeobject
,
_gcvisit_func
),
""
);
static_assert
(
sizeof
(
pyston
::
BoxedClass
)
==
sizeof
(
struct
_typeobject
),
""
);
class
HiddenClass
:
public
ConservativeGCObject
{
private:
HiddenClass
()
{}
...
...
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