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
d098297f
Commit
d098297f
authored
May 20, 2015
by
Rudi Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add extra GC flags to objects for finalization ordering.
parent
9d188a18
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
src/gc/heap.h
src/gc/heap.h
+40
-0
No files found.
src/gc/heap.h
View file @
d098297f
...
...
@@ -113,6 +113,20 @@ static_assert(sizeof(GCAllocation) <= sizeof(void*),
"we should try to make sure the gc header is word-sized or smaller"
);
#define MARK_BIT 0x1
// reserved bit - along with MARK_BIT, encodes the states of finalization order
#define ORDERING_EXTRA_BIT 0x2
#define FINALIZER_HAS_RUN_BIT 0x4
#define ORDERING_BITS (MARK_BIT | ORDERING_EXTRA_BIT)
enum
FinalizationState
{
UNREACHABLE
=
0x0
,
TEMPORARY
=
ORDERING_EXTRA_BIT
,
// Note that these two states have MARK_BIT set.
ALIVE
=
MARK_BIT
,
REACHABLE_FROM_FINALIZER
=
ORDERING_BITS
,
};
inline
bool
isMarked
(
GCAllocation
*
header
)
{
return
(
header
->
gc_flags
&
MARK_BIT
)
!=
0
;
...
...
@@ -128,7 +142,33 @@ inline void clearMark(GCAllocation* header) {
header
->
gc_flags
&=
~
MARK_BIT
;
}
inline
bool
hasFinalized
(
GCAllocation
*
header
)
{
return
(
header
->
gc_flags
&
FINALIZER_HAS_RUN_BIT
)
!=
0
;
}
inline
void
setFinalized
(
GCAllocation
*
header
)
{
assert
(
!
hasFinalized
(
header
));
header
->
gc_flags
|=
FINALIZER_HAS_RUN_BIT
;
}
inline
FinalizationState
orderingState
(
GCAllocation
*
header
)
{
int
state
=
header
->
gc_flags
&
ORDERING_BITS
;
assert
(
state
<=
static_cast
<
int
>
(
FinalizationState
::
REACHABLE_FROM_FINALIZER
));
return
static_cast
<
FinalizationState
>
(
state
);
}
inline
void
setOrderingState
(
GCAllocation
*
header
,
FinalizationState
state
)
{
header
->
gc_flags
=
(
header
->
gc_flags
&
~
ORDERING_BITS
)
|
static_cast
<
int
>
(
state
);
}
inline
void
clearOrderingState
(
GCAllocation
*
header
)
{
header
->
gc_flags
&=
~
ORDERING_EXTRA_BIT
;
}
#undef MARK_BIT
#undef ORDERING_EXTRA_BIT
#undef FINALIZER_HAS_RUN_BIT
#undef ORDERING_BITS
#define PAGE_SIZE 4096
...
...
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