📝 move andy_gc_test to test dir
This commit is contained in:
parent
ef09946fd6
commit
9b168b5d52
1
makefile
1
makefile
|
@ -255,6 +255,7 @@ clean:
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:nasal
|
test:nasal
|
||||||
|
@ ./nasal -t -d test/andy_gc_test.nas
|
||||||
@ ./nasal test/argparse_test.nas
|
@ ./nasal test/argparse_test.nas
|
||||||
@ ./nasal -e test/ascii-art.nas
|
@ ./nasal -e test/ascii-art.nas
|
||||||
@ ./nasal -t -d test/bfs.nas
|
@ ./nasal -t -d test/bfs.nas
|
||||||
|
|
|
@ -108,7 +108,7 @@ std::vector<std::string> dbg::parse(const std::string& cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 dbg::file_index(const std::string& filename) const {
|
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]) {
|
if (filename==files[i]) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -116,13 +116,13 @@ u16 dbg::file_index(const std::string& filename) const {
|
||||||
return UINT16_MAX;
|
return UINT16_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dbg::err() {
|
void dbg::err() const {
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "incorrect command\n"
|
<< "incorrect command\n"
|
||||||
<< "input \'h\' to get help\n";
|
<< "input \'h\' to get help\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void dbg::help() {
|
void dbg::help() const {
|
||||||
std::clog
|
std::clog
|
||||||
<< "<option>\n"
|
<< "<option>\n"
|
||||||
<< " h, help | get help\n"
|
<< " h, help | get help\n"
|
||||||
|
@ -141,7 +141,7 @@ void dbg::help() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dbg::list_file() const {
|
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";
|
std::clog << "[" << i << "] " << files[i] << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,8 @@ void dbg::run(const codegen& gen,
|
||||||
do_operand_count = profile || show_all_prof_result;
|
do_operand_count = profile || show_all_prof_result;
|
||||||
|
|
||||||
const auto& file_list = linker.get_file_list();
|
const auto& file_list = linker.get_file_list();
|
||||||
fsize = file_list.size();
|
file_list_size = file_list.size();
|
||||||
|
|
||||||
vm_init_enrty(
|
vm_init_enrty(
|
||||||
gen.strs(),
|
gen.strs(),
|
||||||
gen.nums(),
|
gen.nums(),
|
||||||
|
|
|
@ -140,7 +140,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool next;
|
bool next;
|
||||||
usize fsize;
|
usize file_list_size;
|
||||||
u16 break_file_index;
|
u16 break_file_index;
|
||||||
u64 break_line;
|
u64 break_line;
|
||||||
error src;
|
error src;
|
||||||
|
@ -152,17 +152,16 @@ private:
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> parse(const std::string&);
|
std::vector<std::string> parse(const std::string&);
|
||||||
u16 file_index(const std::string&) const;
|
u16 file_index(const std::string&) const;
|
||||||
void err();
|
void err() const;
|
||||||
void help();
|
void help() const;
|
||||||
void list_file() const;
|
void list_file() const;
|
||||||
void step_info();
|
void step_info();
|
||||||
void interact();
|
void interact();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
dbg():
|
dbg(): next(true), file_list_size(0),
|
||||||
next(true), fsize(0),
|
break_file_index(0), break_line(0),
|
||||||
break_file_index(0), break_line(0),
|
do_operand_count(false) {}
|
||||||
do_operand_count(false) {}
|
|
||||||
void run(const codegen&,
|
void run(const codegen&,
|
||||||
const linker&,
|
const linker&,
|
||||||
const std::vector<std::string>&,
|
const std::vector<std::string>&,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "nasal_gc.h"
|
#include "nasal_gc.h"
|
||||||
|
#include <omp.h>
|
||||||
|
|
||||||
namespace nasal {
|
namespace nasal {
|
||||||
|
|
||||||
|
@ -22,7 +23,10 @@ void gc::do_mark_sweep() {
|
||||||
void gc::mark() {
|
void gc::mark() {
|
||||||
std::vector<var> bfs;
|
std::vector<var> bfs;
|
||||||
mark_context_root(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();
|
usize size = bfs.size();
|
||||||
std::thread t0(&gc::concurrent_mark, this, std::ref(bfs), 0, size/4);
|
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);
|
std::thread t1(&gc::concurrent_mark, this, std::ref(bfs), size/4, size/2);
|
||||||
|
@ -35,6 +39,7 @@ void gc::mark() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// normal mark
|
||||||
while(!bfs.empty()) {
|
while(!bfs.empty()) {
|
||||||
var value = bfs.back();
|
var value = bfs.back();
|
||||||
bfs.pop_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 << " | " << max_mark_time*1.0/den*1000 << " ms\n";
|
||||||
std::clog << " " << left << setw(indent) << setfill(' ') << "max sweep";
|
std::clog << " " << left << setw(indent) << setfill(' ') << "max sweep";
|
||||||
std::clog << " | " << max_sweep_time*1.0/den*1000 << " ms\n";
|
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";
|
std::clog << last_line << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ struct gc {
|
||||||
i64 max_time = 0;
|
i64 max_time = 0;
|
||||||
i64 max_mark_time = 0;
|
i64 max_mark_time = 0;
|
||||||
i64 max_sweep_time = 0;
|
i64 max_sweep_time = 0;
|
||||||
|
bool flag_concurrent_mark_triggered = false;
|
||||||
|
|
||||||
void set(context* _ctx, var* _global, usize _size) {
|
void set(context* _ctx, var* _global, usize _size) {
|
||||||
running_context = _ctx;
|
running_context = _ctx;
|
||||||
|
|
|
@ -17,7 +17,7 @@ var test_func = func(test_processes...) {
|
||||||
info = runtime.gc.info();
|
info = runtime.gc.info();
|
||||||
println("[", os.time(), "] ", duration, " ms, gc ",
|
println("[", os.time(), "] ", duration, " ms, gc ",
|
||||||
(info.total-gc_total)*100/duration, "%, ",
|
(info.total-gc_total)*100/duration, "%, ",
|
||||||
int(1000/duration), " cps");
|
1000/duration, " cps");
|
||||||
gc_total = info.total;
|
gc_total = info.total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue