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
624bb03b
Commit
624bb03b
authored
Jun 30, 2015
by
Rudi Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup: move static variables to the top of the file.
parent
44b261bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
21 deletions
+22
-21
src/gc/collector.cpp
src/gc/collector.cpp
+22
-21
No files found.
src/gc/collector.cpp
View file @
624bb03b
...
...
@@ -39,6 +39,26 @@ namespace gc {
FILE
*
trace_fp
;
#endif
static
std
::
unordered_set
<
void
*>
roots
;
static
std
::
vector
<
std
::
pair
<
void
*
,
void
*>>
potential_root_ranges
;
static
std
::
unordered_set
<
void
*>
nonheap_roots
;
// Track the highest-addressed nonheap root; the assumption is that the nonheap roots will
// typically all have lower addresses than the heap roots, so this can serve as a cheap
// way to verify it's not a nonheap root (the full check requires a hashtable lookup).
static
void
*
max_nonheap_root
=
0
;
static
void
*
min_nonheap_root
=
(
void
*
)
~
0
;
static
std
::
unordered_set
<
GCRootHandle
*>*
getRootHandles
()
{
static
std
::
unordered_set
<
GCRootHandle
*>
root_handles
;
return
&
root_handles
;
}
static
int
ncollections
=
0
;
static
bool
gc_enabled
=
true
;
static
bool
should_not_reenter_gc
=
false
;
class
TraceStack
{
private:
const
int
CHUNK_SIZE
=
256
;
...
...
@@ -120,8 +140,6 @@ public:
};
std
::
vector
<
void
**>
TraceStack
::
free_chunks
;
static
std
::
unordered_set
<
void
*>
roots
;
void
registerPermanentRoot
(
void
*
obj
,
bool
allow_duplicates
)
{
assert
(
global_heap
.
getAllocationFromInteriorPointer
(
obj
));
...
...
@@ -138,7 +156,6 @@ void deregisterPermanentRoot(void* obj) {
roots
.
erase
(
obj
);
}
static
std
::
vector
<
std
::
pair
<
void
*
,
void
*>>
potential_root_ranges
;
void
registerPotentialRootRange
(
void
*
start
,
void
*
end
)
{
potential_root_ranges
.
push_back
(
std
::
make_pair
(
start
,
end
));
}
...
...
@@ -152,12 +169,6 @@ extern "C" PyObject* PyGC_AddRoot(PyObject* obj) noexcept {
return
obj
;
}
static
std
::
unordered_set
<
void
*>
nonheap_roots
;
// Track the highest-addressed nonheap root; the assumption is that the nonheap roots will
// typically all have lower addresses than the heap roots, so this can serve as a cheap
// way to verify it's not a nonheap root (the full check requires a hashtable lookup).
static
void
*
max_nonheap_root
=
0
;
static
void
*
min_nonheap_root
=
(
void
*
)
~
0
;
void
registerNonheapRootObject
(
void
*
obj
,
int
size
)
{
// I suppose that things could work fine even if this were true, but why would it happen?
assert
(
global_heap
.
getAllocationFromInteriorPointer
(
obj
)
==
NULL
);
...
...
@@ -200,11 +211,6 @@ void setIsPythonObject(Box* b) {
}
}
static
std
::
unordered_set
<
GCRootHandle
*>*
getRootHandles
()
{
static
std
::
unordered_set
<
GCRootHandle
*>
root_handles
;
return
&
root_handles
;
}
GCRootHandle
::
GCRootHandle
()
{
getRootHandles
()
->
insert
(
this
);
}
...
...
@@ -212,8 +218,6 @@ GCRootHandle::~GCRootHandle() {
getRootHandles
()
->
erase
(
this
);
}
bool
GCVisitor
::
isValid
(
void
*
p
)
{
return
global_heap
.
getAllocationFromInteriorPointer
(
p
)
!=
NULL
;
}
...
...
@@ -272,8 +276,6 @@ void GCVisitor::visitPotentialRange(void* const* start, void* const* end) {
}
}
static
int
ncollections
=
0
;
static
inline
void
visitByGCKind
(
void
*
p
,
GCVisitor
&
visitor
)
{
assert
(((
intptr_t
)
p
)
%
8
==
0
);
...
...
@@ -402,19 +404,18 @@ static void sweepPhase(std::vector<Box*>& weakly_referenced) {
sc_us
.
log
(
us
);
}
static
bool
gc_enabled
=
true
;
bool
gcIsEnabled
()
{
return
gc_enabled
;
}
void
enableGC
()
{
gc_enabled
=
true
;
}
void
disableGC
()
{
gc_enabled
=
false
;
}
static
bool
should_not_reenter_gc
=
false
;
void
startGCUnexpectedRegion
()
{
RELEASE_ASSERT
(
!
should_not_reenter_gc
,
""
);
should_not_reenter_gc
=
true
;
...
...
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