-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathDEVELOPMENT.txt
153 lines (102 loc) · 6.27 KB
/
DEVELOPMENT.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
DEVELOPERS NOTE
Tests
perl Makefile.PL
make
make test
Unit Tests
make && perl -Mblib t/default/convert.t
Cleanup
make clean
Create distribution
perl Makefile.PL
rm MANIFEST
make manifest
make disttest
make dist
SOLE TESTS
SPVM solo test command
# Normal run
yacc/bison.sh && perl Makefile.PL --no-build-spvm-modules && make && perl -Mblib blib/script/spvmcc -B solo/.spvm_build -I solo/lib/SPVM -o solo/.spvm_build/work/myapp -f --no-config solo/script/myapp.spvm && ./solo/.spvm_build/work/myapp foo bar
# Debug run
yacc/bison.sh && perl Makefile.PL --no-build-spvm-modules --OPTIMIZE="-O0 -g" && make && perl -Mblib blib/script/spvmcc -B solo/.spvm_build -I solo/lib/SPVM -o solo/.spvm_build/work/myapp --mode debug -f --no-config solo/script/myapp.spvm && ./solo/.spvm_build/work/myapp foo bar
# Debug run - Print memory count
yacc/bison.sh && perl Makefile.PL --no-build-spvm-modules --OPTIMIZE="-O0 -g" && make && perl -Mblib blib/script/spvmcc -B solo/.spvm_build -I solo/lib/SPVM -o solo/.spvm_build/work/myapp --mode debug_memory_count -f --no-config solo/script/myapp.spvm && ./solo/.spvm_build/work/myapp foo bar
# Debug run - Print AST, package information, operaion codes
yacc/bison.sh && perl Makefile.PL --no-build-spvm-modules --OPTIMIZE="-O0 -g" --DEFINE=SPVM_DEBUG_COMPILE && make && perl -Mblib blib/script/spvmcc -B solo/.spvm_build -I solo/lib/SPVM -o solo/.spvm_build/work/myapp --mode debug -f --no-config solo/script/myapp.spvm
# Debug run - Print yacc result
yacc/bison.sh && perl Makefile.PL --no-build-spvm-modules --DEFINE=SPVM_DEBUG_YACC --DEFINE=SPVM_DEBUG_COMPILE && make && perl -Mblib blib/script/spvmcc -B solo/.spvm_build -I solo/lib/SPVM -o solo/.spvm_build/work/myapp --mode debug -f --no-config solo/script/myapp.spvm
# Cleanup
rm solo/.spvm_build/work/myapp
See batcktrace of core dump
# Compilation for debug
perl Makefile.PL --OPTIMIZE="-O0 -g" && make
# Compiliation time stack trace
gdb perl core
# Runtime stack trace
gdb solo/.spvm_build/work/myapp core
bt
If core file is not output, set the following.
ulimit -c unlimited
PORTABILITY NOTE
SPVM is run on various environments.
Main compiler targets is gcc, clang, MinGW.
Main OS targets is Linux/Unix, Windows(MinGW), macOS.
To keep maxmam portability in SPVM, I have the following rule.
- don't use realloc.
- don't use global variables
- don't use inline keyword
- use -std=gnu99 always in core modules
- use fgetc instead of getc for FreeBSD compile error
- Don't use os error number(error.h defined values) outside of native subrsoutine.
- Don't contain os dependency features(for example unistd.h, windows.h)
- NOTE: In Windows/MinGW/Strawbery Perl, newline is always \x0A if mode is text mode
- Automatically loaded module must not be native or precompile
Currently, Byte, Short, Int, Long, Float, Double, Bool
- Don't use temporary directory in SPVM module, for example, using File::Temp.
Security risk is increased and, Windows dll file can't be removed by cleanuping temporary directory
- Feature_test_macros is allowed to use if the tests of gcc, clang, MinGW pass.
#define _XOPEN_SOURCE
#define _POSIX_SOURCE
#define _POSIX_C_SOURCE
- Don't implement timegm compatible method because the tests of Windows/MinGW 32bit fail.
undefined reference to _mkgmtime32
- Recommend the size of a module file is less than 50KB because SPVM itself has no problem
but in the small memory environment, the precompile by gcc fails by memory errors.
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
UTILITIES
Gets SPVM Core Perl module files
find lib | grep -P '(Builder|BlessedObject|ExchangeAPI|Global|SPVM\.pm)' | grep '\.pm' | perl -p -e 's|lib/||' | sort
Gets SPVM header files
find lib | grep Builder | grep -P '\.h$' | perl -p -e 's|lib/SPVM/Builder/include/||' | sort
Gets SPVM source files
find lib | grep Builder | grep -P '\.c$' | perl -p -e 's|lib/SPVM/Builder/src/||' | sort
Gets SPVM Compilation and Rintime module files
find lib | grep -P '(Native\b)' | grep -P '\.(spvm|c)$' | perl -p -e 's|lib/||' | sort
Print config
# All config
perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1; print Dumper \%Config;'
# ivsize
perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1; print Dumper \%Config;' | grep ivsize
# myuname
perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1; print Dumper \%Config;' | grep myuname
# make
perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1; print Dumper \%Config;' | grep make
# dlext
perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1; print Dumper \%Config;' | grep dlext
Gets all keywords
perl -n -e 'if (/strcmp\s*\(\s*symbol_name\s*,\s*"(.+?)"/) { print "$1\n" } ' lib/SPVM/Builder/src/spvm_toke.c
Gets the definition of syntax parsing
perl -n -e 'if (/^(%token|%type|%right|%nonassoc|%left|[a-zA-Z]|\s+:|\s+\|)(.+)/) { my $line = "$1$2"; if ($line =~ /^[a-zA-Z]/) { print "\n"; } print "$line\n" } ' yacc/spvm_yacc.y
Gets the linkgs of SPVM modules for POD
find lib | grep -P '\.pm$' | grep -v 'SPVM\.pm$' | perl -p -e 's/\.pm$//' | sort | grep -v -P '^lib/SPVM(\.pm|/(ExchangeAPI|Document|Builder|BlessedObject|Dist))' | perl -p -e 'chomp;s|lib/SPVM/||; s|/|::|g; $_ = "=item * L<$_|SPVM::$_>\n\n";'
Creates compile error test module
spvmdist --genlib TestCase::CompileError::Foo t/default/lib
Creates a SPVM distribution
spvmdist Foo