diff options
| author | Vibhav Pant | 2017-02-11 20:13:54 +0530 |
|---|---|---|
| committer | Vibhav Pant | 2017-02-11 20:13:54 +0530 |
| commit | 7c2d493540b6e2e1661397812c5ed9fcff04e36c (patch) | |
| tree | 1dd0415bf2e6972dce2594f9459f5c51754ae045 /src/bytecode.c | |
| parent | c1a9b5db0e2985e7c46fb3b1e50e9d17785f7fa3 (diff) | |
| download | emacs-7c2d493540b6e2e1661397812c5ed9fcff04e36c.tar.gz emacs-7c2d493540b6e2e1661397812c5ed9fcff04e36c.zip | |
src/bytecode.c: Add optional sanity check for jump tables.
* src/bytecode.c (exec_byte_code): When sanity checks are enabled,
check that the jump table's size is equal to it's count.
Diffstat (limited to 'src/bytecode.c')
| -rw-r--r-- | src/bytecode.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index f3eab60c593..29674a0d9de 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -1422,14 +1422,15 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 1422 | Lisp_Object v1 = POP; | 1422 | Lisp_Object v1 = POP; |
| 1423 | ptrdiff_t i; | 1423 | ptrdiff_t i; |
| 1424 | struct Lisp_Hash_Table *h = XHASH_TABLE(jmp_table); | 1424 | struct Lisp_Hash_Table *h = XHASH_TABLE(jmp_table); |
| 1425 | /* Hash tables for switch are declared with :size set to the | ||
| 1426 | exact number of cases. */ | ||
| 1427 | if (BYTE_CODE_SAFE) | ||
| 1428 | eassert (HASH_TABLE_SIZE (h) == h->count); | ||
| 1425 | 1429 | ||
| 1426 | if (h->count <= 5) | 1430 | if (h->count <= 5) |
| 1427 | { /* Do a linear search if there are not many cases | 1431 | { /* Do a linear search if there are not many cases |
| 1428 | FIXME: 5 is arbitrarily chosen. */ | 1432 | FIXME: 5 is arbitrarily chosen. */ |
| 1429 | EMACS_UINT hash_code = h->test.hashfn (&h->test, v1); | 1433 | EMACS_UINT hash_code = h->test.hashfn (&h->test, v1); |
| 1430 | /* Hash tables for switch are declared with :size set to the | ||
| 1431 | exact number of cases, thus | ||
| 1432 | HASH_TABLE_SIZE (h) == h->count. */ | ||
| 1433 | for (i = 0; i < h->count; i++) | 1434 | for (i = 0; i < h->count; i++) |
| 1434 | { | 1435 | { |
| 1435 | if (BYTE_CODE_SAFE) | 1436 | if (BYTE_CODE_SAFE) |