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 32*1024
17# endif
18
19# ifndef d_m3EnableCodePageRefCounting
20# define d_m3EnableCodePageRefCounting 0
21# endif
22
23# ifndef d_m3MaxFunctionStackHeight
24# define d_m3MaxFunctionStackHeight 2000 // max: 32768
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_m3CascadedOpcodes // Cascaded opcodes are slightly faster at the expense of some memory
44# define d_m3CascadedOpcodes 1 // Adds ~3Kb to operations table in m3_compile.c
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# ifndef d_m3LogHeapOps
129# define d_m3LogHeapOps 0 // track heap usage
130# endif
131
132# ifndef d_m3LogTimestamps
133# define d_m3LogTimestamps 0 // track timestamps on heap logs
134# endif
135
136// other ----------------------------------------------------------------------
137
138# ifndef d_m3HasFloat
139# define d_m3HasFloat 1 // implement floating point ops
140# endif
141
142#if !d_m3HasFloat && !defined(d_m3NoFloatDynamic)
143# define d_m3NoFloatDynamic 1 // if no floats, do not fail until flops are actually executed
144#endif
145
146# ifndef d_m3SkipStackCheck
147# define d_m3SkipStackCheck 0 // skip stack overrun checks
148# endif
149
150# ifndef d_m3SkipMemoryBoundsCheck
151# define d_m3SkipMemoryBoundsCheck 0 // skip memory bounds checks
152# endif
153
154#endif // m3_config_h
155