Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
b51e6d18
Commit
b51e6d18
authored
27 years ago
by
Fredrik Hübinette (Hubbe)
Browse files
Options
Downloads
Patches
Plain Diff
locate_references added for debugging perposes
Rev: src/gc.c:1.28
parent
091f7892
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/gc.c
+68
-46
68 additions, 46 deletions
src/gc.c
with
68 additions
and
46 deletions
src/gc.c
+
68
−
46
View file @
b51e6d18
...
@@ -378,21 +378,43 @@ INT32 gc_check(void *a)
...
@@ -378,21 +378,43 @@ INT32 gc_check(void *a)
return
getmark
(
a
)
->
refs
++
;
return
getmark
(
a
)
->
refs
++
;
}
}
int
gc_is_referenced
(
void
*
a
)
static
void
init_gc
(
void
)
{
{
struct
marker
*
m
;
INT32
tmp3
;
m
=
getmark
(
a
);
/* init hash , hashsize will be a prime between num_objects/8 and
#ifdef DEBUG
* num_objects/4, this will assure that no re-hashing is needed.
if
(
m
->
refs
+
m
->
xrefs
>
*
(
INT32
*
)
a
)
*/
tmp3
=
my_log2
(
num_objects
);
if
(
!
d_flag
)
tmp3
-=
2
;
if
(
tmp3
<
0
)
tmp3
=
0
;
if
(
tmp3
>=
(
long
)
NELEM
(
hashprimes
))
tmp3
=
NELEM
(
hashprimes
)
-
1
;
hashsize
=
hashprimes
[
tmp3
];
hash
=
(
struct
marker
**
)
xalloc
(
sizeof
(
struct
marker
**
)
*
hashsize
);
MEMSET
((
char
*
)
hash
,
0
,
sizeof
(
struct
marker
**
)
*
hashsize
);
markers_left_in_chunk
=
0
;
}
static
void
exit_gc
(
void
)
{
{
INT32
refs
=
m
->
refs
;
struct
marker_chunk
*
m
;
INT32
xrefs
=
m
->
xrefs
;
/* Free hash table */
TYPE_T
t
=
attempt_to_identify
(
a
);
free
((
char
*
)
hash
);
while
((
m
=
chunk
))
{
chunk
=
m
->
next
;
free
((
char
*
)
m
);
}
}
fprintf
(
stderr
,
"**Something has %ld references, while gc() found %ld + %ld external.
\n
"
,(
long
)
*
(
INT32
*
)
a
,(
long
)
refs
,(
long
)
xrefs
);
void
locate_references
(
void
*
a
)
describe_something
(
a
,
t
);
{
if
(
!
in_gc
)
init_gc
();
fprintf
(
stderr
,
"**Looking for references:
\n
"
);
fprintf
(
stderr
,
"**Looking for references:
\n
"
);
check_for
=
a
;
check_for
=
a
;
found_where
=
" in an array"
;
found_where
=
" in an array"
;
...
@@ -416,6 +438,26 @@ int gc_is_referenced(void *a)
...
@@ -416,6 +438,26 @@ int gc_is_referenced(void *a)
found_where
=
""
;
found_where
=
""
;
check_for
=
0
;
check_for
=
0
;
if
(
!
in_gc
)
exit_gc
();
}
int
gc_is_referenced
(
void
*
a
)
{
struct
marker
*
m
;
m
=
getmark
(
a
);
#ifdef DEBUG
if
(
m
->
refs
+
m
->
xrefs
>
*
(
INT32
*
)
a
)
{
INT32
refs
=
m
->
refs
;
INT32
xrefs
=
m
->
xrefs
;
TYPE_T
t
=
attempt_to_identify
(
a
);
fprintf
(
stderr
,
"**Something has %ld references, while gc() found %ld + %ld external.
\n
"
,(
long
)
*
(
INT32
*
)
a
,(
long
)
refs
,(
long
)
xrefs
);
describe_something
(
a
,
t
);
locate_references
(
a
);
fatal
(
"Ref counts are wrong (has %d, found %d + %d external)
\n
"
,
fatal
(
"Ref counts are wrong (has %d, found %d + %d external)
\n
"
,
*
(
INT32
*
)
a
,
*
(
INT32
*
)
a
,
refs
,
refs
,
...
@@ -474,8 +516,7 @@ int gc_do_free(void *a)
...
@@ -474,8 +516,7 @@ int gc_do_free(void *a)
void
do_gc
(
void
)
void
do_gc
(
void
)
{
{
double
tmp
;
double
tmp
;
INT32
tmp2
,
tmp3
;
INT32
tmp2
;
struct
marker_chunk
*
m
;
double
multiplier
;
double
multiplier
;
if
(
in_gc
)
return
;
if
(
in_gc
)
return
;
...
@@ -507,19 +548,7 @@ void do_gc(void)
...
@@ -507,19 +548,7 @@ void do_gc(void)
objects_freed
+=
(
double
)
num_objects
;
objects_freed
+=
(
double
)
num_objects
;
/* init hash , hashsize will be a prime between num_objects/8 and
init_gc
();
* num_objects/4, this will assure that no re-hashing is needed.
*/
tmp3
=
my_log2
(
num_objects
);
if
(
!
d_flag
)
tmp3
-=
2
;
if
(
tmp3
<
0
)
tmp3
=
0
;
if
(
tmp3
>=
(
long
)
NELEM
(
hashprimes
))
tmp3
=
NELEM
(
hashprimes
)
-
1
;
hashsize
=
hashprimes
[
tmp3
];
hash
=
(
struct
marker
**
)
xalloc
(
sizeof
(
struct
marker
**
)
*
hashsize
);
MEMSET
((
char
*
)
hash
,
0
,
sizeof
(
struct
marker
**
)
*
hashsize
);
markers_left_in_chunk
=
0
;
/* First we count internal references */
/* First we count internal references */
gc_check_all_arrays
();
gc_check_all_arrays
();
...
@@ -546,14 +575,7 @@ void do_gc(void)
...
@@ -546,14 +575,7 @@ void do_gc(void)
gc_free_all_unreferenced_programs
();
gc_free_all_unreferenced_programs
();
gc_free_all_unreferenced_objects
();
gc_free_all_unreferenced_objects
();
exit_gc
();
/* Free hash table */
free
((
char
*
)
hash
);
while
((
m
=
chunk
))
{
chunk
=
m
->
next
;
free
((
char
*
)
m
);
}
destruct_objects_to_destruct
();
destruct_objects_to_destruct
();
...
...
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