Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
723a6ed3
Commit
723a6ed3
authored
11 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
More GC debugging improvements.
parent
20632e4d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/gc.c
+10
-1
10 additions, 1 deletion
py/gc.c
unix/gccollect.c
+4
-8
4 additions, 8 deletions
unix/gccollect.c
with
14 additions
and
9 deletions
py/gc.c
+
10
−
1
View file @
723a6ed3
...
@@ -240,7 +240,7 @@ void gc_info(gc_info_t *info) {
...
@@ -240,7 +240,7 @@ void gc_info(gc_info_t *info) {
void
*
gc_alloc
(
machine_uint_t
n_bytes
)
{
void
*
gc_alloc
(
machine_uint_t
n_bytes
)
{
machine_uint_t
n_blocks
=
((
n_bytes
+
BYTES_PER_BLOCK
-
1
)
&
(
~
(
BYTES_PER_BLOCK
-
1
)))
/
BYTES_PER_BLOCK
;
machine_uint_t
n_blocks
=
((
n_bytes
+
BYTES_PER_BLOCK
-
1
)
&
(
~
(
BYTES_PER_BLOCK
-
1
)))
/
BYTES_PER_BLOCK
;
//
printf("gc_alloc(%u bytes -> %u blocks)\n", n_bytes, n_blocks);
DEBUG_
printf
(
"gc_alloc(%u bytes -> %u blocks)
\n
"
,
n_bytes
,
n_blocks
);
// check for 0 allocation
// check for 0 allocation
if
(
n_blocks
==
0
)
{
if
(
n_blocks
==
0
)
{
...
@@ -267,6 +267,7 @@ void *gc_alloc(machine_uint_t n_bytes) {
...
@@ -267,6 +267,7 @@ void *gc_alloc(machine_uint_t n_bytes) {
if
(
collected
)
{
if
(
collected
)
{
return
NULL
;
return
NULL
;
}
}
DEBUG_printf
(
"gc_alloc("
UINT_FMT
"): no free mem, triggering GC
\n
"
,
n_bytes
);
gc_collect
();
gc_collect
();
collected
=
1
;
collected
=
1
;
}
}
...
@@ -341,6 +342,14 @@ void *gc_realloc(void *ptr, machine_uint_t n_bytes) {
...
@@ -341,6 +342,14 @@ void *gc_realloc(void *ptr, machine_uint_t n_bytes) {
}
}
}
}
void
gc_dump_info
()
{
gc_info_t
info
;
gc_info
(
&
info
);
printf
(
"GC: total: "
UINT_FMT
", used: "
UINT_FMT
", free: "
UINT_FMT
"
\n
"
,
info
.
total
,
info
.
used
,
info
.
free
);
printf
(
" No. of 1-blocks: "
UINT_FMT
", 2-blocks: "
UINT_FMT
", max blk sz: "
UINT_FMT
"
\n
"
,
info
.
num_1block
,
info
.
num_2block
,
info
.
max_block
);
}
#if DEBUG_PRINT
#if DEBUG_PRINT
static
void
gc_dump_at
(
void
)
{
static
void
gc_dump_at
(
void
)
{
for
(
machine_uint_t
bl
=
0
;
bl
<
gc_alloc_table_byte_len
*
BLOCKS_PER_ATB
;
bl
++
)
{
for
(
machine_uint_t
bl
=
0
;
bl
<
gc_alloc_table_byte_len
*
BLOCKS_PER_ATB
;
bl
++
)
{
...
...
This diff is collapsed.
Click to expand it.
unix/gccollect.c
+
4
−
8
View file @
723a6ed3
...
@@ -48,6 +48,8 @@ void gc_helper_get_regs(regs_t arr) {
...
@@ -48,6 +48,8 @@ void gc_helper_get_regs(regs_t arr) {
#endif
#endif
void
gc_collect
(
void
)
{
void
gc_collect
(
void
)
{
//gc_dump_info();
gc_collect_start
();
gc_collect_start
();
// this traces .data and .bss sections
// this traces .data and .bss sections
extern
char
__bss_start
,
_end
;
extern
char
__bss_start
,
_end
;
...
@@ -59,14 +61,8 @@ void gc_collect(void) {
...
@@ -59,14 +61,8 @@ void gc_collect(void) {
gc_collect_root
((
void
**
)
&
regs
,
((
uint32_t
)
stack_top
-
(
uint32_t
)
&
regs
)
/
sizeof
(
uint32_t
));
gc_collect_root
((
void
**
)
&
regs
,
((
uint32_t
)
stack_top
-
(
uint32_t
)
&
regs
)
/
sizeof
(
uint32_t
));
gc_collect_end
();
gc_collect_end
();
if
(
0
)
{
//printf("-----\n");
// print GC info
//gc_dump_info();
gc_info_t
info
;
gc_info
(
&
info
);
printf
(
"GC: total: "
UINT_FMT
", used: "
UINT_FMT
", free: "
UINT_FMT
"
\n
"
,
info
.
total
,
info
.
used
,
info
.
free
);
printf
(
" No. of 1-blocks: "
UINT_FMT
", 2-blocks: "
UINT_FMT
", max blk sz: "
UINT_FMT
"
\n
"
,
info
.
num_1block
,
info
.
num_2block
,
info
.
max_block
);
}
}
}
#endif //MICROPY_ENABLE_GC
#endif //MICROPY_ENABLE_GC
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment