This speeds up build of bytecode_vm.c, and makes the binary smaller.
Török Edvin authored on 2010/03/29 05:46:41... | ... |
@@ -34,19 +34,23 @@ |
34 | 34 |
#endif |
35 | 35 |
|
36 | 36 |
/* Enable this to catch more bugs in the RC phase */ |
37 |
-#define CL_BYTECODE_DEBUG |
|
37 |
+#define CL_BYTECODE_SAFE |
|
38 | 38 |
|
39 |
+ |
|
40 |
+#ifdef CL_BYTECODE_SAFE |
|
39 | 41 |
/* These checks will also be done by the bytecode verifier, but for |
40 | 42 |
* debugging purposes we have explicit checks, these should never fail! */ |
41 |
-#ifdef CL_BYTECODE_DEBUG |
|
43 |
+#ifdef CL_DEBUG |
|
42 | 44 |
static int never_inline bcfail(const char *msg, long a, long b, |
43 | 45 |
const char *file, unsigned line) |
44 | 46 |
{ |
45 | 47 |
cli_warnmsg("bytecode: check failed %s (%lx and %lx) at %s:%u\n", msg, a, b, file, line); |
46 | 48 |
return CL_EARG; |
47 | 49 |
} |
50 |
+#else |
|
51 |
+#define bcfail(msg,a,b,f,l) CL_EBYTECODE |
|
52 |
+#endif |
|
48 | 53 |
|
49 |
-#define CHECK_UNREACHABLE do { cli_dbgmsg("bytecode: unreachable executed!\n"); return CL_EBYTECODE; } while(0) |
|
50 | 54 |
#define CHECK_FUNCID(funcid) do { if (funcid >= bc->num_func) return \ |
51 | 55 |
bcfail("funcid out of bounds!",funcid, bc->num_func,__FILE__,__LINE__); } while(0) |
52 | 56 |
#define CHECK_APIID(funcid) do { if (funcid >= cli_apicall_maxapi) return \ |
... | ... |
@@ -55,22 +59,28 @@ static int never_inline bcfail(const char *msg, long a, long b, |
55 | 55 |
bcfail("Values "#a" and "#b" don't match!",(a),(b),__FILE__,__LINE__); } while(0) |
56 | 56 |
#define CHECK_GT(a, b) do {if ((a) <= (b)) return \ |
57 | 57 |
bcfail("Condition failed "#a" > "#b,(a),(b), __FILE__, __LINE__); } while(0) |
58 |
-#define TRACE_R(x) cli_dbgmsg("bytecode trace: %u, read %llx\n", pc, (long long)x); |
|
59 |
-#define TRACE_W(x, w, p) cli_dbgmsg("bytecode trace: %u, write%d @%u %llx\n", pc, p, w, (long long)(x)); |
|
60 |
-#define TRACE_EXEC(id, dest, ty, stack) cli_dbgmsg("bytecode trace: executing %d, -> %u (%u); %u\n", id, dest, ty, stack) |
|
58 |
+ |
|
61 | 59 |
#else |
62 | 60 |
static inline int bcfail(const char *msg, long a, long b, |
63 | 61 |
const char *file, unsigned line) {} |
64 |
-#define TRACE_R(x) |
|
65 |
-#define TRACE_W(x, w, p) |
|
66 |
-#define TRACE_EXEC(id, dest, ty, stack) |
|
67 |
-#define CHECK_UNREACHABLE return CL_EBYTECODE |
|
68 | 62 |
#define CHECK_FUNCID(x); |
69 | 63 |
#define CHECK_APIID(x); |
70 | 64 |
#define CHECK_EQ(a,b) |
71 | 65 |
#define CHECK_GT(a,b) |
72 | 66 |
#endif |
73 | 67 |
|
68 |
+#ifdef CL_DEBUG |
|
69 |
+#define CHECK_UNREACHABLE do { cli_dbgmsg("bytecode: unreachable executed!\n"); return CL_EBYTECODE; } while(0) |
|
70 |
+#define TRACE_R(x) cli_dbgmsg("bytecode trace: %u, read %llx\n", pc, (long long)x); |
|
71 |
+#define TRACE_W(x, w, p) cli_dbgmsg("bytecode trace: %u, write%d @%u %llx\n", pc, p, w, (long long)(x)); |
|
72 |
+#define TRACE_EXEC(id, dest, ty, stack) cli_dbgmsg("bytecode trace: executing %d, -> %u (%u); %u\n", id, dest, ty, stack) |
|
73 |
+#else |
|
74 |
+#define CHECK_UNREACHABLE return CL_EBYTECODE |
|
75 |
+#define TRACE_R(x) |
|
76 |
+#define TRACE_W(x, w, p) |
|
77 |
+#define TRACE_EXEC(id, dest, ty, stack) |
|
78 |
+#endif |
|
79 |
+ |
|
74 | 80 |
#define SIGNEXT(a, from) CLI_SRS(((int64_t)(a)) << (64-(from)), (64-(from))) |
75 | 81 |
|
76 | 82 |
#ifdef CL_DEBUG |