1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin,cgen: fix -gc boehm issues with maps; add a CI job for it to prevent regressions (#9453)

This commit is contained in:
Uwe Krüger 2021-03-24 18:49:16 +01:00 committed by GitHub
parent 5b2cec6c6b
commit 522d70b48d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 1 deletions

View File

@ -102,6 +102,45 @@ jobs:
run: |
./v tutorials/building_a_simple_web_blog_with_vweb/code/blog
ubuntu-tcc-boehm-gc:
runs-on: ubuntu-20.04
timeout-minutes: 30
env:
VFLAGS: -cc tcc -no-retry-compilation
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list; sudo apt-get update;
sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind
sudo apt-get install --quiet -y libglfw3 libglfw3-dev libfreetype6-dev libxi-dev libxcursor-dev libasound2-dev
sudo apt-get install --quiet -y libgc-dev
## sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev
## The following is needed for examples/wkhtmltopdf.v
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
sudo apt-get install xfonts-75dpi xfonts-base
sudo dpkg -i wkhtmltox_0.12.6-1.focal_amd64.deb
- name: Build v
run: |
echo $VFLAGS
make
- name: Test v->c
run: |
thirdparty/tcc/tcc.exe -version
./v -cg -o v cmd/v # Make sure vtcc can build itself twice
- name: v self compilation with -gc boehm
run: ./v -gc boehm -o v2 cmd/v && ./v2 -gc boehm -o v3 cmd/v && ./v3 -gc boehm -o v4 cmd/v
- name: v doctor
run: |
./v doctor
- name: Verify `v -gc boehm test` works
run: |
./v -gc boehm cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: Self tests with `-gc boehm`
## The test cases are run with non-gc `v` for now
run: ./v -gc boehm -silent test-self
misc-tooling:
runs-on: ubuntu-20.04
timeout-minutes: 30

View File

@ -108,7 +108,11 @@ mut:
[inline]
fn new_dense_array(key_bytes int, value_bytes int) DenseArray {
slot_bytes := key_bytes + value_bytes
mut slot_bytes := key_bytes + value_bytes
$if gcboehm ? {
align, mask := $if x64 { 7, int(0xfffffff8) } $else { 3, int(0xfffffffc) }
slot_bytes = (slot_bytes + align) & mask
}
cap := 8
return DenseArray{
key_bytes: key_bytes

View File

@ -67,6 +67,11 @@ fn (mut g Gen) gen_c_main_function_header() {
fn (mut g Gen) gen_c_main_header() {
g.gen_c_main_function_header()
if g.pref.gc_mode == .boehm {
g.writeln('#if defined(_VGCBOEHM)')
g.writeln('\tGC_INIT();')
g.writeln('#endif')
}
g.writeln('\t_vinit(___argc, (voidptr)___argv);')
if g.pref.is_prof {
g.writeln('')
@ -150,6 +155,11 @@ pub fn (mut g Gen) gen_c_main_for_tests() {
main_fn_start_pos := g.out.len
g.writeln('')
g.gen_c_main_function_header()
if g.pref.gc_mode == .boehm {
g.writeln('#if defined(_VGCBOEHM)')
g.writeln('\tGC_INIT();')
g.writeln('#endif')
}
g.writeln('\t_vinit(___argc, (voidptr)___argv);')
all_tfuncs := g.get_all_test_function_names()
if g.pref.is_stats {