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
7529462c
Commit
7529462c
authored
Jun 20, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the TRACE_LOG helpers available to other files
and rename them to make it more clear that it's GC-related.
parent
085c18b9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
16 deletions
+38
-16
src/core/threading.cpp
src/core/threading.cpp
+6
-0
src/gc/collector.cpp
src/gc/collector.cpp
+24
-16
src/gc/collector.h
src/gc/collector.h
+8
-0
No files found.
src/core/threading.cpp
View file @
7529462c
...
@@ -167,8 +167,10 @@ static void pushThreadState(ThreadStateInternal* thread_state, ucontext_t* conte
...
@@ -167,8 +167,10 @@ static void pushThreadState(ThreadStateInternal* thread_state, ucontext_t* conte
#endif
#endif
assert
(
stack_low
<
stack_high
);
assert
(
stack_low
<
stack_high
);
GC_TRACE_LOG
(
"Visiting other thread's stack
\n
"
);
cur_visitor
->
visitPotentialRange
((
void
**
)
stack_low
,
(
void
**
)
stack_high
);
cur_visitor
->
visitPotentialRange
((
void
**
)
stack_low
,
(
void
**
)
stack_high
);
GC_TRACE_LOG
(
"Visiting other thread's threadstate + generator stacks
\n
"
);
thread_state
->
accept
(
cur_visitor
);
thread_state
->
accept
(
cur_visitor
);
}
}
...
@@ -195,8 +197,12 @@ static void visitLocalStack(gc::GCVisitor* v) {
...
@@ -195,8 +197,12 @@ static void visitLocalStack(gc::GCVisitor* v) {
#endif
#endif
assert
(
stack_low
<
stack_high
);
assert
(
stack_low
<
stack_high
);
GC_TRACE_LOG
(
"Visiting current stack from %p to %p
\n
"
,
stack_low
,
stack_high
);
v
->
visitPotentialRange
((
void
**
)
stack_low
,
(
void
**
)
stack_high
);
v
->
visitPotentialRange
((
void
**
)
stack_low
,
(
void
**
)
stack_high
);
GC_TRACE_LOG
(
"Visiting current thread's threadstate + generator stacks
\n
"
);
current_internal_thread_state
->
accept
(
v
);
current_internal_thread_state
->
accept
(
v
);
}
}
...
...
src/gc/collector.cpp
View file @
7529462c
...
@@ -35,8 +35,6 @@
...
@@ -35,8 +35,6 @@
//#undef VERBOSITY
//#undef VERBOSITY
//#define VERBOSITY(x) 2
//#define VERBOSITY(x) 2
#define DEBUG_MARK_PHASE 0
#ifndef NDEBUG
#ifndef NDEBUG
#define DEBUG 1
#define DEBUG 1
#else
#else
...
@@ -46,11 +44,8 @@
...
@@ -46,11 +44,8 @@
namespace
pyston
{
namespace
pyston
{
namespace
gc
{
namespace
gc
{
#if
DEBUG_MARK_PHASE
#if
TRACE_GC_MARKING
FILE
*
trace_fp
;
FILE
*
trace_fp
;
#define TRACE_LOG(...) fprintf(trace_fp, __VA_ARGS__)
#else
#define TRACE_LOG(...)
#endif
#endif
class
TraceStack
{
class
TraceStack
{
...
@@ -100,7 +95,7 @@ public:
...
@@ -100,7 +95,7 @@ public:
}
}
void
push
(
void
*
p
)
{
void
push
(
void
*
p
)
{
TRACE_LOG
(
"Pushing %p
\n
"
,
p
);
GC_
TRACE_LOG
(
"Pushing %p
\n
"
,
p
);
GCAllocation
*
al
=
GCAllocation
::
fromUserData
(
p
);
GCAllocation
*
al
=
GCAllocation
::
fromUserData
(
p
);
if
(
isMarked
(
al
))
if
(
isMarked
(
al
))
return
;
return
;
...
@@ -271,11 +266,19 @@ void GCVisitor::visitPotentialRange(void* const* start, void* const* end) {
...
@@ -271,11 +266,19 @@ void GCVisitor::visitPotentialRange(void* const* start, void* const* end) {
assert
((
uintptr_t
)
end
%
sizeof
(
void
*
)
==
0
);
assert
((
uintptr_t
)
end
%
sizeof
(
void
*
)
==
0
);
while
(
start
<
end
)
{
while
(
start
<
end
)
{
#if TRACE_GC_MARKING
if
(
global_heap
.
getAllocationFromInteriorPointer
(
*
start
))
{
GC_TRACE_LOG
(
"Found conservative reference to %p from %p
\n
"
,
*
start
,
start
);
}
#endif
visitPotential
(
*
start
);
visitPotential
(
*
start
);
start
++
;
start
++
;
}
}
}
}
static
int
ncollections
=
0
;
void
markPhase
()
{
void
markPhase
()
{
#ifndef NVALGRIND
#ifndef NVALGRIND
// Have valgrind close its eyes while we do the conservative stack and data scanning,
// Have valgrind close its eyes while we do the conservative stack and data scanning,
...
@@ -283,31 +286,37 @@ void markPhase() {
...
@@ -283,31 +286,37 @@ void markPhase() {
VALGRIND_DISABLE_ERROR_REPORTING
;
VALGRIND_DISABLE_ERROR_REPORTING
;
#endif
#endif
#if DEBUG_MARK_PHASE
#if TRACE_GC_MARKING
#if 1 // separate log file per collection
char
tracefn_buf
[
80
];
snprintf
(
tracefn_buf
,
sizeof
(
tracefn_buf
),
"gc_trace_%03d.txt"
,
ncollections
);
trace_fp
=
fopen
(
tracefn_buf
,
"w"
);
#else // overwrite previous log file with each collection
trace_fp
=
fopen
(
"gc_trace.txt"
,
"w"
);
trace_fp
=
fopen
(
"gc_trace.txt"
,
"w"
);
#endif
#endif
TRACE_LOG
(
"Starting collection
\n
"
);
#endif
GC_TRACE_LOG
(
"Starting collection %d
\n
"
,
ncollections
);
TRACE_LOG
(
"Looking at roots
\n
"
);
GC_
TRACE_LOG
(
"Looking at roots
\n
"
);
TraceStack
stack
(
roots
);
TraceStack
stack
(
roots
);
GCVisitor
visitor
(
&
stack
);
GCVisitor
visitor
(
&
stack
);
TRACE_LOG
(
"Looking at the stack
\n
"
);
GC_
TRACE_LOG
(
"Looking at the stack
\n
"
);
threading
::
visitAllStacks
(
&
visitor
);
threading
::
visitAllStacks
(
&
visitor
);
TRACE_LOG
(
"Looking at root handles
\n
"
);
GC_
TRACE_LOG
(
"Looking at root handles
\n
"
);
for
(
auto
h
:
*
getRootHandles
())
{
for
(
auto
h
:
*
getRootHandles
())
{
visitor
.
visit
(
h
->
value
);
visitor
.
visit
(
h
->
value
);
}
}
TRACE_LOG
(
"Looking at potential root ranges
\n
"
);
GC_
TRACE_LOG
(
"Looking at potential root ranges
\n
"
);
for
(
auto
&
e
:
potential_root_ranges
)
{
for
(
auto
&
e
:
potential_root_ranges
)
{
visitor
.
visitPotentialRange
((
void
*
const
*
)
e
.
first
,
(
void
*
const
*
)
e
.
second
);
visitor
.
visitPotentialRange
((
void
*
const
*
)
e
.
first
,
(
void
*
const
*
)
e
.
second
);
}
}
// if (VERBOSITY()) printf("Found %d roots\n", stack.size());
// if (VERBOSITY()) printf("Found %d roots\n", stack.size());
while
(
void
*
p
=
stack
.
pop
())
{
while
(
void
*
p
=
stack
.
pop
())
{
TRACE_LOG
(
"Looking at heap object %p
\n
"
,
p
);
GC_
TRACE_LOG
(
"Looking at heap object %p
\n
"
,
p
);
assert
(((
intptr_t
)
p
)
%
8
==
0
);
assert
(((
intptr_t
)
p
)
%
8
==
0
);
GCAllocation
*
al
=
GCAllocation
::
fromUserData
(
p
);
GCAllocation
*
al
=
GCAllocation
::
fromUserData
(
p
);
...
@@ -356,7 +365,7 @@ void markPhase() {
...
@@ -356,7 +365,7 @@ void markPhase() {
}
}
}
}
#if
DEBUG_MARK_PHASE
#if
TRACE_GC_MARKING
fclose
(
trace_fp
);
fclose
(
trace_fp
);
trace_fp
=
NULL
;
trace_fp
=
NULL
;
#endif
#endif
...
@@ -383,7 +392,6 @@ void disableGC() {
...
@@ -383,7 +392,6 @@ void disableGC() {
gc_enabled
=
false
;
gc_enabled
=
false
;
}
}
static
int
ncollections
=
0
;
static
bool
should_not_reenter_gc
=
false
;
static
bool
should_not_reenter_gc
=
false
;
void
startGCUnexpectedRegion
()
{
void
startGCUnexpectedRegion
()
{
...
...
src/gc/collector.h
View file @
7529462c
...
@@ -22,6 +22,14 @@
...
@@ -22,6 +22,14 @@
namespace
pyston
{
namespace
pyston
{
namespace
gc
{
namespace
gc
{
#define TRACE_GC_MARKING 0
#if TRACE_GC_MARKING
extern
FILE
*
trace_fp
;
#define GC_TRACE_LOG(...) fprintf(pyston::gc::trace_fp, __VA_ARGS__)
#else
#define GC_TRACE_LOG(...)
#endif
// Mark this gc-allocated object as being a root, even if there are no visible references to it.
// Mark this gc-allocated object as being a root, even if there are no visible references to it.
// (Note: this marks the gc allocation itself, not the pointer that points to one. For that, use
// (Note: this marks the gc allocation itself, not the pointer that points to one. For that, use
// a GCRootHandle)
// a GCRootHandle)
...
...
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