📝 move andy_gc_test to test dir

This commit is contained in:
ValKmjolnir 2024-05-14 00:16:02 +08:00
parent ef09946fd6
commit 9b168b5d52
7 changed files with 24 additions and 15 deletions

View File

@ -255,6 +255,7 @@ clean:
.PHONY: test
test:nasal
@ ./nasal -t -d test/andy_gc_test.nas
@ ./nasal test/argparse_test.nas
@ ./nasal -e test/ascii-art.nas
@ ./nasal -t -d test/bfs.nas

View File

@ -108,7 +108,7 @@ std::vector<std::string> dbg::parse(const std::string& cmd) {
}
u16 dbg::file_index(const std::string& filename) const {
for(u16 i = 0; i<fsize; ++i) {
for(u16 i = 0; i<file_list_size; ++i) {
if (filename==files[i]) {
return i;
}
@ -116,13 +116,13 @@ u16 dbg::file_index(const std::string& filename) const {
return UINT16_MAX;
}
void dbg::err() {
void dbg::err() const {
std::cerr
<< "incorrect command\n"
<< "input \'h\' to get help\n";
}
void dbg::help() {
void dbg::help() const {
std::clog
<< "<option>\n"
<< " h, help | get help\n"
@ -141,7 +141,7 @@ void dbg::help() {
}
void dbg::list_file() const {
for(usize i = 0; i<fsize; ++i) {
for(usize i = 0; i<file_list_size; ++i) {
std::clog << "[" << i << "] " << files[i] << "\n";
}
}
@ -247,7 +247,8 @@ void dbg::run(const codegen& gen,
do_operand_count = profile || show_all_prof_result;
const auto& file_list = linker.get_file_list();
fsize = file_list.size();
file_list_size = file_list.size();
vm_init_enrty(
gen.strs(),
gen.nums(),

View File

@ -140,7 +140,7 @@ private:
private:
bool next;
usize fsize;
usize file_list_size;
u16 break_file_index;
u64 break_line;
error src;
@ -152,17 +152,16 @@ private:
private:
std::vector<std::string> parse(const std::string&);
u16 file_index(const std::string&) const;
void err();
void help();
void err() const;
void help() const;
void list_file() const;
void step_info();
void interact();
public:
dbg():
next(true), fsize(0),
break_file_index(0), break_line(0),
do_operand_count(false) {}
dbg(): next(true), file_list_size(0),
break_file_index(0), break_line(0),
do_operand_count(false) {}
void run(const codegen&,
const linker&,
const std::vector<std::string>&,

View File

@ -1,4 +1,5 @@
#include "nasal_gc.h"
#include <omp.h>
namespace nasal {
@ -22,7 +23,10 @@ void gc::do_mark_sweep() {
void gc::mark() {
std::vector<var> bfs;
mark_context_root(bfs);
if (memory.size()>8192 && bfs.size()>4) {
// concurrent mark, experimental
if (memory.size()>UINT16_MAX && bfs.size()>8192) {
flag_concurrent_mark_triggered = true;
usize size = bfs.size();
std::thread t0(&gc::concurrent_mark, this, std::ref(bfs), 0, size/4);
std::thread t1(&gc::concurrent_mark, this, std::ref(bfs), size/4, size/2);
@ -34,7 +38,8 @@ void gc::mark() {
t3.join();
return;
}
// normal mark
while(!bfs.empty()) {
var value = bfs.back();
bfs.pop_back();
@ -340,6 +345,8 @@ void gc::info() const {
std::clog << " | " << max_mark_time*1.0/den*1000 << " ms\n";
std::clog << " " << left << setw(indent) << setfill(' ') << "max sweep";
std::clog << " | " << max_sweep_time*1.0/den*1000 << " ms\n";
std::clog << " " << left << setw(indent) << setfill(' ') << "concurrent";
std::clog << " | " << (flag_concurrent_mark_triggered? "true\n":"false\n");
std::clog << last_line << "\n";
}

View File

@ -60,6 +60,7 @@ struct gc {
i64 max_time = 0;
i64 max_mark_time = 0;
i64 max_sweep_time = 0;
bool flag_concurrent_mark_triggered = false;
void set(context* _ctx, var* _global, usize _size) {
running_context = _ctx;

View File

@ -17,7 +17,7 @@ var test_func = func(test_processes...) {
info = runtime.gc.info();
println("[", os.time(), "] ", duration, " ms, gc ",
(info.total-gc_total)*100/duration, "%, ",
int(1000/duration), " cps");
1000/duration, " cps");
gc_total = info.total;
}