[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] feature/byte-switch 7c2d493: src/bytecode.c: Add optional
From: |
Vibhav Pant |
Subject: |
[Emacs-diffs] feature/byte-switch 7c2d493: src/bytecode.c: Add optional sanity check for jump tables. |
Date: |
Sat, 11 Feb 2017 09:44:59 -0500 (EST) |
branch: feature/byte-switch
commit 7c2d493540b6e2e1661397812c5ed9fcff04e36c
Author: Vibhav Pant <address@hidden>
Commit: Vibhav Pant <address@hidden>
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.
---
src/bytecode.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/bytecode.c b/src/bytecode.c
index f3eab60..29674a0 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,
Lisp_Object v1 = POP;
ptrdiff_t i;
struct Lisp_Hash_Table *h = XHASH_TABLE(jmp_table);
+ /* Hash tables for switch are declared with :size set to the
+ exact number of cases. */
+ if (BYTE_CODE_SAFE)
+ eassert (HASH_TABLE_SIZE (h) == h->count);
if (h->count <= 5)
{ /* Do a linear search if there are not many cases
FIXME: 5 is arbitrarily chosen. */
EMACS_UINT hash_code = h->test.hashfn (&h->test, v1);
- /* Hash tables for switch are declared with :size set to the
- exact number of cases, thus
- HASH_TABLE_SIZE (h) == h->count. */
for (i = 0; i < h->count; i++)
{
if (BYTE_CODE_SAFE)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] feature/byte-switch 7c2d493: src/bytecode.c: Add optional sanity check for jump tables.,
Vibhav Pant <=