From 395b3ffbebb4656fdc5096887bc1ca7df5180da3 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 30 Dec 2018 01:30:56 -0800 Subject: 4894 Done with kinda-safe pointers. In a real compiler the fast path of 'lookup' would ideally get inlined. Excluding procedure-call overhead, the current implementation consumes 2 registers besides the input, and requires 9 instructions (2 push, 2 load, compare, jump, increment, 2 pop). That's large enough that inlining may become a trade-off. Even if we somehow magically had the registers already loaded and available, we'd still need 4 instructions (1 pointer dereference, compare, jump and increment). The price of safety. --- subx/test_apps | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'subx/test_apps') diff --git a/subx/test_apps b/subx/test_apps index 4de0ce06..62df1fe4 100755 --- a/subx/test_apps +++ b/subx/test_apps @@ -126,6 +126,16 @@ CFLAGS=-g ./subx translate examples/ex12.subx -o examples/ex12 CFLAGS=-g ./subx run examples/ex12 # final byte of mmap'd address is well-nigh guaranteed to be 0 test `uname` = 'Linux' && examples/ex12 +echo handle +CFLAGS=-g ./subx translate *.subx apps/handle.subx -o apps/handle +[ "$1" != record ] && git diff --quiet apps/handle +CFLAGS=-g ./subx run apps/handle 2>&1 |grep -q 'lookup failed' +echo +test `uname` = 'Linux' && { + apps/handle test 2>&1 |grep -q 'lookup failed' + echo +} + echo factorial CFLAGS=-g ./subx translate *.subx apps/factorial.subx -o apps/factorial [ "$1" != record ] && git diff --quiet apps/factorial -- cgit 1.4.1-2-gfad0