SPVM
Static Perl Virtual Machine. Fast calculation & Easy C/C++ Binding
See SPVM document
https://metacpan.org/pod/SPVM
DEVELOPERS NOTE
TESTS
Do tests
perl Makefile.PL
make
make test
Cleanup
make clean
Create distribution
perl Makefile.PL
rm MANIFEST
make manifest
make disttest
make dist
Unit tests
make && perl -Mblib t/default/convert.t
SOLE TESTS
Create exe file by spvmcc command
yacc/bison.sh && perl Makefile.PL && make && perl -Mblib blib/script/spvmcc -B solo/spvm_build -I solo/lib -o solo/myexe TestCase && solo/myexe foo bar
SPVM solo test command
# Normal run
yacc/bison.sh && perl Makefile.PL && make && perl solo/solo_Makefile.PL && make -f solo/Makefile && ./solo/main foo bar
# Debug run - Print AST, package information, operaion codes
yacc/bison.sh && perl Makefile.PL --OPTIMIZE="-O0 -g" --DEFINE=SPVM_DEBUG_DUMP --DEFINE=SPVM_DEBUG_OBJECT_COUNT && make && perl solo/solo_Makefile.PL --OPTIMIZE="-O0 -g" --DEFINE=SPVM_DEBUG_DUMP --DEFINE=SPVM_DEBUG_OBJECT_COUNT && make -f solo/Makefile && ./solo/main foo bar
# Debug run - Only syntax check, don't use core library
yacc/bison.sh && perl Makefile.PL --OPTIMIZE="-O0 -g" --DEFINE=SPVM_DONT_USE_CORE_LIB && make && perl solo/solo_Makefile.PL --OPTIMIZE="-O0 -g" --DEFINE=SPVM_DONT_USE_CORE_LIB && make -f solo/Makefile && ./solo/main foo bar
# Debug run - Print yacc result
yacc/bison.sh && perl Makefile.PL --OPTIMIZE="-O0 -g" --DEFINE=SPVM_DEBUG_YACC --DEFINE=SPVM_DONT_USE_CORE_LIB && make && perl solo/solo_Makefile.PL --OPTIMIZE="-O0 -g" --DEFINE=SPVM_DEBUG_YACC --DEFINE=SPVM_DONT_USE_CORE_LIB && make -f solo/Makefile && ./solo/main foo bar
See batcktrace of core dump
gdb solo/main core.*
What is solo test command?
solo test is used for debgug.
SPVM is compiled to dynamic link library by -O3 option.
this is difficult to debug because debug information is removed and it is not simple machine code.
If you use the above solo test commands, you can create
solo/main
"solo/main" can execute SPVM module by the following way.
./solo/main
See core dump
If you use Debug run, you can see core dump and back trace by gdb command
gdb spvm core.*
bt
EXE TESTS
SPVM can create exe file.
perl Makefile.PL
make && perl -Mblib -- blib/script/spvmcc -I t/default/lib TestCase::MyExe
env LD_LIBRARY_PATH=spvm_build/work/exe spvm_build/work/exe/TestCase__MyExe
gdb spvm_build/work/exe/MyExe core.*
Debug mode
perl Makefile.PL --OPTIMIZE="-O0 -g" --DEFINE=SPVM_DEBUG_DUMP && \
make && perl -Mblib -- blib/script/spvmcc -I t/default/lib -B spvm_build/work/exe -n MyExe TestCase::MyExe && \
gcc -o spvm_build/work/exe/MyExe spvm_build/work/exe/libmy_main.so && \
spvm_build/work/exe/MyExe
EXTERNAL LIBRARY
For unicode processing, utf8proc is used. SPVM utf8proc is replaced utf8proc to spvm_utf8proc, UTF8PROC to SPVM_UTF8PROC
utf8proc
https://github.com/JuliaStrings/utf8proc
PORTABILITY NOTE
Compiler type, version and working is various in different environments.
Main compiler targets is gcc and clang.
Main OS targets is Linux/Unix, Windows, macOS.
To keep maxmam portability, I have the following rule.
- don't use realloc.
- don't use global variables
- don't use inline keyword
- use -std=c99
- use fgetc instead of getc for FreeBSD compile error
CODING GUIDE LINE
- use int8_t, int16_t, int32_t, int64_t instead of byte, short, int, long, _Bool.
- char is used for only character.
- char[] is used for only string.
- constant value is defined by enum { } syntax.
- constant name is ,for example, SPVM_TYPE_C_FLAG_REF.
all character is upper case or under score. need _C_ between package name and constant base name
- fix all warnings before CPAN release
=head1 COPYRIGHT & LICENSE
Copyright 2018-2019 Yuki Kimoto, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.