Verified Commit f6e5ccd4 authored by Camil Staps's avatar Camil Staps 🚀

Remove garbage collection marking test (because the gc algorithm is simpler...

Remove garbage collection marking test (because the gc algorithm is simpler now); move gc/mark.c to debug_find_nodes.c (as it is only used in the debugger now)
parent a73edd38
Pipeline #20212 passed with stages
in 10 minutes and 2 seconds
......@@ -31,14 +31,6 @@ build-windows:
script:
- CC=x86_64-w64-mingw32-gcc OS=Windows_NT make -B -C src ByteCodeGenerator.exe ByteCodeLinker.exe interpret.exe
test-gc:
extends: .base
stage: test-interpreter
script:
- cd test
- CFLAGS=-DDEBUG_GARBAGE_COLLECTOR_MARKING ./run_tests.sh -o weird_types
- CFLAGS=-DDEBUG_GARBAGE_COLLECTOR_MARKING ./run_tests.sh -3 -o weird_types
benchmark-x64:
extends: .base
stage: test-interpreter
......
......@@ -44,12 +44,6 @@ preprocessor options on Windows.
As with `DEBUG_CLEAN_LINKS`, a higher value increases verbosity, with 0
turning off debugging output.
- `DEBUG_GARBAGE_COLLECTOR_MARKING`:
Try the garbage collector marking phase after each instruction cycle, to test
that it can deal (does not crash) with many different kinds of types. This is
very slow, and is only meant to be used in CI (see
[.gitlab-ci.yml](/.gitlab-ci.yml)).
- `STDERR_TO_FILE`:
Write output to `stderr` to a file called `stderr`. This is useful on
platforms with a slow console (e.g. Windows) to read back debugging
......
......@@ -14,12 +14,10 @@ import code from "bcgen_instructions."
import code from "bytecode."
import code from "copy_host_to_interpreter."
import code from "copy_interpreter_to_host."
import code from "copy."
import code from "finalizers."
import code from "gc."
import code from "interface."
import code from "interpret."
import code from "mark."
import code from "parse."
import code from "strip."
import code from "util."
......
......@@ -91,13 +91,12 @@ DEP_BCSTRIP:=$(subst .c,.h,$(SRC_BCSTRIP)) settings.h
SRC_INTERPRET:=\
abc_instructions.c\
bytecode.c\
debug_find_nodes.c\
gc.c\
gc/mark.c\
interpret.c\
parse.c\
util.c
DEP_INTERPRET:=$(subst .c,.h,$(SRC_INTERPRET))\
gc/util.h\
interpret_instructions.h\
interpret_instructions_interworking.h\
settings.h
......@@ -111,7 +110,6 @@ SRC_INTERPRET_LIB:=$(SRC_INTERPRET)\
ASM_INTERPRET_LIB:=$(subst .c,.s,$(SRC_INTERPRET_LIB))
OBJ_INTERPRET_LIB:=$(subst .c,.o,$(SRC_INTERPRET_LIB))
DEP_INTERPRET_LIB:=$(subst .c,.h,$(SRC_INTERPRET_LIB))\
gc/util.h\
interpret_instructions.h\
interpret_instructions_interworking.h\
settings.h
......
......@@ -48,8 +48,6 @@ library: .FORCE
copy_interpreter_to_host.c \
finalizers.c \
gc.c \
gc\copy.c \
gc\mark.c \
interpret.c \
parse.c \
strip.c \
......@@ -63,8 +61,6 @@ library: .FORCE
move copy_interpreter_to_host.obj "..\lib\Clean System Files" >nul
move finalizers.obj "..\lib\Clean System Files" >nul
move gc.obj "..\lib\Clean System Files" >nul
move copy.obj "..\lib\Clean System Files" >nul
move mark.obj "..\lib\Clean System Files" >nul
move interface.obj "..\lib\Clean System Files" >nul
move interpret.obj "..\lib\Clean System Files" >nul
move parse.obj "..\lib\Clean System Files" >nul
......
......@@ -12,7 +12,6 @@
#include "copy_interpreter_to_host.h"
#include "finalizers.h"
#include "gc.h"
#include "gc/util.h"
#include "interpret.h"
#include "util.h"
......
......@@ -5,8 +5,7 @@
#include <string.h>
#include "abc_instructions.h"
#include "gc/mark.h"
#include "gc/util.h"
#include "debug_find_nodes.h"
#include "interpret.h"
#include "util.h"
......@@ -561,7 +560,7 @@ void debugger_show_node_as_tree_(WINDOW *win, BC_WORD *node, int indent, uint64_
wprintw(win, " %s", _tmp);
}
if (on_heap((BC_WORD) node, hp, heap_size))
if (hp<=node && node<hp+heap_size)
wprintw(win, " {%d}", node - hp);
waddch(win, '\n');
......
#include <stdlib.h>
#include "mark.h"
#include "debug_find_nodes.h"
#include "interpret.h"
#include "util.h"
#include "../interpret.h"
#include "../util.h"
#ifdef LINK_CLEAN_RUNTIME
# include "../copy_interpreter_to_host.h"
# include "../finalizers.h"
#endif
#define GREY_NODES_INITIAL 100
#define GREY_NODES_ENLARGE 2
......@@ -22,9 +16,6 @@ void init_nodes_set(struct nodes_set *set, size_t heap_size) {
set->black.bitmap = safe_calloc(1, (heap_size / 8 / sizeof(BC_WORD) + 2) * sizeof(BC_WORD));
set->black.size = heap_size / 8 / sizeof(BC_WORD) + 1;
#if DEBUG_GARBAGE_COLLECTOR > 4
EPRINTF("\tBitmap size = %d\n", (int) set->black.size);
#endif
set->black.ptr_i = 0;
set->black.ptr_j = 0;
}
......@@ -34,19 +25,11 @@ void free_nodes_set(struct nodes_set *set) {
free(set->black.bitmap);
}
void reset_black_nodes_set(struct nodes_set *set) {
set->black.ptr_i = 0;
set->black.ptr_j = 0;
}
/* Returns 1 if the node is new; 0 if it was already black */
int add_black_node(struct nodes_set *set, BC_WORD *node, BC_WORD *heap) {
BC_WORD val = ((BC_WORD) node - (BC_WORD) heap) / sizeof(BC_WORD);
BC_WORD i = val / 8 / sizeof(BC_WORD);
BC_WORD m = (BC_WORD) 1 << (val % (8 * sizeof(BC_WORD)));
#if DEBUG_GARBAGE_COLLECTOR > 4
EPRINTF("\t\tbitmap[%d] |= %x\n", (int) i, (int) m);
#endif
if (set->black.bitmap[i] & m) {
return 0;
} else {
......@@ -56,9 +39,6 @@ int add_black_node(struct nodes_set *set, BC_WORD *node, BC_WORD *heap) {
}
BC_WORD next_black_node(struct nodes_set *set) {
#if DEBUG_GARBAGE_COLLECTOR > 4
EPRINTF("\tSearching with %d/%d\n", (int) set->black.ptr_i, (int) set->black.ptr_j);
#endif
if (set->black.ptr_i > set->black.size)
return -1;
while (!(set->black.bitmap[set->black.ptr_i] & ((BC_WORD) 1 << set->black.ptr_j))) {
......@@ -71,9 +51,6 @@ BC_WORD next_black_node(struct nodes_set *set) {
return -1;
} while (!set->black.bitmap[set->black.ptr_i]);
}
#if DEBUG_GARBAGE_COLLECTOR > 4
EPRINTF("\tSearching with %d/%d\n", (int) set->black.ptr_i, (int) set->black.ptr_j);
#endif
}
BC_WORD ret = 8 * sizeof(BC_WORD) * set->black.ptr_i + set->black.ptr_j;
......@@ -88,9 +65,6 @@ BC_WORD next_black_node(struct nodes_set *set) {
}
void realloc_grey_nodes_set(struct nodes_set *set) {
#if DEBUG_GARBAGE_COLLECTOR > 1
EPRINTF("\tReallocating grey nodes set\n");
#endif
set->grey.write_ptr = set->grey.size;
set->grey.read_ptr = 0;
set->grey.size *= GREY_NODES_ENLARGE;
......@@ -99,16 +73,10 @@ void realloc_grey_nodes_set(struct nodes_set *set) {
void add_grey_node(struct nodes_set *set, BC_WORD *node, BC_WORD *heap, size_t heap_size) {
if (node < heap || node >= heap + heap_size) {
#if DEBUG_GARBAGE_COLLECTOR > 2
EPRINTF("\t%p is not on the heap...\n", (void*) node);
#endif
return;
}
if (!add_black_node(set, node, heap)) { /* Already black */
#if DEBUG_GARBAGE_COLLECTOR > 2
EPRINTF("\t%p is already black...\n", (void*) node);
#endif
return;
}
......@@ -116,9 +84,6 @@ void add_grey_node(struct nodes_set *set, BC_WORD *node, BC_WORD *heap, size_t h
realloc_grey_nodes_set(set);
}
#if DEBUG_GARBAGE_COLLECTOR > 2
EPRINTF("\t%p -> grey\n", (void*) node);
#endif
set->grey.nodes[set->grey.write_ptr++] = node;
if (set->grey.write_ptr == set->grey.size)
set->grey.write_ptr = 0;
......@@ -143,32 +108,10 @@ BC_WORD *get_grey_node(struct nodes_set *set) {
void mark_a_stack(BC_WORD *stack, BC_WORD *asp, BC_WORD *heap, size_t heap_size, struct nodes_set *set) {
BC_WORD *asp_temp;
#ifdef LINK_CLEAN_RUNTIME
for (asp_temp = asp; asp_temp >= stack; asp_temp--)
#else
for (asp_temp = asp; asp_temp > stack; asp_temp--)
#endif
add_grey_node(set, (BC_WORD*) *asp_temp, heap, heap_size);
}
void mark_cafs(void **cafs, BC_WORD *heap, size_t heap_size, struct nodes_set *set) {
BC_WORD **cafptr=(BC_WORD**)&cafs[1];
while (cafptr[-1]!=0) {
cafptr=(BC_WORD**)cafptr[-1];
int n_a=(int)(BC_WORD)cafptr[0];
for (; n_a>0; n_a--)
add_grey_node(set, cafptr[n_a], heap, heap_size);
}
}
#ifdef LINK_CLEAN_RUNTIME
void mark_host_references(BC_WORD *heap, size_t heap_size, struct nodes_set *set) {
struct finalizers *finalizers = NULL;
while ((finalizers = next_interpreter_finalizer(finalizers)) != NULL)
add_grey_node(set, (BC_WORD*)(finalizers->cur->arg&-2), heap, heap_size);
}
#endif
void evaluate_grey_nodes(BC_WORD *heap, size_t heap_size, struct nodes_set *set) {
BC_WORD *node;
while ((node = get_grey_node(set)) != NULL) {
......@@ -182,10 +125,6 @@ void evaluate_grey_nodes(BC_WORD *heap, size_t heap_size, struct nodes_set *set)
b_arity = ((int16_t*)(node[0]))[-1] - 256 - a_arity;
}
#if DEBUG_GARBAGE_COLLECTOR > 2
EPRINTF("\t%p -> black: "BC_WORD_FMT_HEX"; HNF with arity %d/%d\n", (void*) node, node[0], a_arity, b_arity);
#endif
if (node[0] == (BC_WORD) &INT + 2 ||
node[0] == (BC_WORD) &CHAR + 2 ||
node[0] == (BC_WORD) &BOOL + 2 ||
......@@ -237,10 +176,6 @@ void evaluate_grey_nodes(BC_WORD *heap, size_t heap_size, struct nodes_set *set)
a_arity = (arity & 0xff) - b_arity;
}
#if DEBUG_GARBAGE_COLLECTOR > 2
EPRINTF("\t%p -> black: "BC_WORD_FMT_HEX"; thunk with arity %d/%d\n", (void*) node, node[0], a_arity, b_arity);
#endif
int i;
for (i = 1; i <= a_arity; i++)
add_grey_node(set, (BC_WORD*) node[i], heap, heap_size);
......
#pragma once
#include "../bytecode.h"
#include "bytecode.h"
struct nodes_set {
struct {
......@@ -22,18 +22,7 @@ struct nodes_set {
void init_nodes_set(struct nodes_set *set, size_t heap_size);
void free_nodes_set(struct nodes_set *set);
void reset_black_nodes_set(struct nodes_set *set);
/* Returns 1 if the node is new; 0 if it was already black */
int add_black_node(struct nodes_set *set, BC_WORD *node, BC_WORD *heap);
BC_WORD next_black_node(struct nodes_set *set);
void add_grey_node(struct nodes_set *set, BC_WORD *node, BC_WORD *heap, size_t heap_size);
BC_WORD *get_grey_node(struct nodes_set *set);
void mark_a_stack(BC_WORD *stack, BC_WORD *asp, BC_WORD *heap, size_t heap_size, struct nodes_set *set);
void mark_cafs(void **cafs, BC_WORD *heap, size_t heap_size, struct nodes_set *set);
#ifdef LINK_CLEAN_RUNTIME
void mark_host_references(BC_WORD *heap, size_t heap_size, struct nodes_set *set);
#endif
void evaluate_grey_nodes(BC_WORD *heap, size_t heap_size, struct nodes_set *set);
#include "../bytecode.h"
static inline int on_heap(BC_WORD node, BC_WORD *heap, size_t heap_size) {
return (BC_WORD) heap <= node && node < (BC_WORD) (heap + heap_size);
}
......@@ -25,10 +25,6 @@
# include "debug_curses.h"
#endif
#ifdef DEBUG_GARBAGE_COLLECTOR_MARKING
# include "gc/mark.h"
#endif
/* Used to store the return address when evaluating a node on the heap */
#define EVAL_TO_HNF_LABEL CMAX
......@@ -449,13 +445,6 @@ eval_to_hnf_return_failure:
# include "interpret_instructions.h"
#else
for (;;) {
# ifdef DEBUG_GARBAGE_COLLECTOR_MARKING
struct nodes_set nodes_set;
init_nodes_set(&nodes_set, heap_size);
mark_a_stack(stack, asp, heap, heap_size, &nodes_set);
evaluate_grey_nodes(heap, heap_size, &nodes_set);
free_nodes_set(&nodes_set);
# endif
# if defined(DEBUG_ALL_INSTRUCTIONS) && !defined(DEBUG_CURSES)
if (program->data <= pc && pc < program->data + program->data_size)
EPRINTF("D:%d\t%s\n", (int) (pc-program->data), instruction_name(*pc));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment