1 //
2 //  m3_config.h
3 //
4 //  Created by Steven Massey on 5/4/19.
5 //  Copyright © 2019 Steven Massey. All rights reserved.
6 //
7 
8 #ifndef m3_config_h
9 #define m3_config_h
10 
11 #include "m3_config_platforms.h"
12 
13 // general --------------------------------------------------------------------
14 
15 # ifndef d_m3CodePageAlignSize
16 #   define d_m3CodePageAlignSize                4096
17 # endif
18 
19 # ifndef d_m3EnableCodePageRefCounting
20 #   define d_m3EnableCodePageRefCounting        0
21 # endif
22 
23 # ifndef d_m3MaxFunctionStackHeight
24 #   define d_m3MaxFunctionStackHeight           2000    // TODO: comment on upper limit
25 # endif
26 
27 # ifndef d_m3MaxLinearMemoryPages
28 #   define d_m3MaxLinearMemoryPages             32768
29 # endif
30 
31 # ifndef d_m3MaxFunctionSlots
32 #   define d_m3MaxFunctionSlots                 ((d_m3MaxFunctionStackHeight)*2)
33 # endif
34 
35 # ifndef d_m3MaxConstantTableSize
36 #   define d_m3MaxConstantTableSize             120
37 # endif
38 
39 # ifndef d_m3MaxDuplicateFunctionImpl
40 #   define d_m3MaxDuplicateFunctionImpl         3
41 # endif
42 
43 # ifndef d_m3EnableExtendedOpcodes
44 #   define d_m3EnableExtendedOpcodes            1
45 # endif
46 
47 # ifndef d_m3VerboseErrorMessages
48 #   define d_m3VerboseErrorMessages             1
49 # endif
50 
51 # ifndef d_m3FixedHeap
52 #   define d_m3FixedHeap                        false
53 //# define d_m3FixedHeap                        (32*1024)
54 # endif
55 
56 # ifndef d_m3FixedHeapAlign
57 #   define d_m3FixedHeapAlign                   16
58 # endif
59 
60 # ifndef d_m3Use32BitSlots
61 #   define d_m3Use32BitSlots                    1
62 # endif
63 
64 # ifndef d_m3ProfilerSlotMask
65 #   define d_m3ProfilerSlotMask                 0xFFFF
66 # endif
67 
68 # ifndef d_m3RecordBacktraces
69 #   define d_m3RecordBacktraces                 0
70 # endif
71 
72 # ifndef d_m3EnableExceptionBreakpoint
73 #   define d_m3EnableExceptionBreakpoint        0       // see m3_exception.h
74 # endif
75 
76 
77 // profiling and tracing ------------------------------------------------------
78 
79 # ifndef d_m3EnableOpProfiling
80 #   define d_m3EnableOpProfiling                0       // opcode usage counters
81 # endif
82 
83 # ifndef d_m3EnableOpTracing
84 #   define d_m3EnableOpTracing                  0       // only works with DEBUG
85 # endif
86 
87 # ifndef d_m3EnableStrace
88 #   define d_m3EnableStrace                     0       // 1 - trace exported function calls
89                                                         // 2 - trace all calls (structured) - requires DEBUG
90                                                         // 3 - all calls + loops + memory operations
91 # endif
92 
93 
94 // logging --------------------------------------------------------------------
95 
96 # ifndef d_m3LogParse
97 #   define d_m3LogParse                         0       // .wasm binary decoding info
98 # endif
99 
100 # ifndef d_m3LogModule
101 #   define d_m3LogModule                        0       // wasm module info
102 # endif
103 
104 # ifndef d_m3LogCompile
105 #   define d_m3LogCompile                       0       // wasm -> metacode generation phase
106 # endif
107 
108 # ifndef d_m3LogWasmStack
109 #   define d_m3LogWasmStack                     0       // dump the wasm stack when pushed or popped
110 # endif
111 
112 # ifndef d_m3LogEmit
113 #   define d_m3LogEmit                          0       // metacode generation info
114 # endif
115 
116 # ifndef d_m3LogCodePages
117 #   define d_m3LogCodePages                     0       // dump metacode pages when released
118 # endif
119 
120 # ifndef d_m3LogRuntime
121 #   define d_m3LogRuntime                       0       // higher-level runtime information
122 # endif
123 
124 # ifndef d_m3LogNativeStack
125 #   define d_m3LogNativeStack                   0       // track the memory usage of the C-stack
126 # endif
127 
128 
129 // other ----------------------------------------------------------------------
130 
131 # ifndef d_m3HasFloat
132 #   define d_m3HasFloat                         1       // implement floating point ops
133 # endif
134 
135 #if !d_m3HasFloat && !defined(d_m3NoFloatDynamic)
136 #   define d_m3NoFloatDynamic                   1       // if no floats, do not fail until flops are actually executed
137 #endif
138 
139 # ifndef d_m3SkipStackCheck
140 #   define d_m3SkipStackCheck                   0       // skip stack overrun checks
141 # endif
142 
143 # ifndef d_m3SkipMemoryBoundsCheck
144 #   define d_m3SkipMemoryBoundsCheck            0       // skip memory bounds checks
145 # endif
146 
147 #endif // m3_config_h
148