ast, topdown: Improve indexer to understand function args
This commit improves the rule indexer to understand function
args. Function arguments are stored via their argument index, to allow
for different variable names (as re-written by the compiler). So, for
f(x, y, z) = { x = 10; y = 12; z > 1 }
the indexer will store the rule at
- args[0]: scalar(10) args[1]: scalar(12)
The callsite-local function arguments are handed off to evalResolver,
which enhances eval's Resolve() method.
Benchmark results:
name old time/op new time/op delta
FunctionArgumentIndex/10-16 23.2µs ± 6% 6.1µs ± 1% -73.75% (p=0.008 n=5+5)
FunctionArgumentIndex/100-16 187µs ± 2% 6µs ± 1% -96.70% (p=0.008 n=5+5)
FunctionArgumentIndex/1000-16 2.23ms ± 3% 0.01ms ± 2% -99.68% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
FunctionArgumentIndex/10-16 20.3kB ± 0% 5.3kB ± 0% -74.13% (p=0.008 n=5+5)
FunctionArgumentIndex/100-16 174kB ± 0% 5kB ± 0% -96.98% (p=0.008 n=5+5)
FunctionArgumentIndex/1000-16 1.76MB ± 0% 0.01MB ± 0% -99.70% (p=0.008 n=5+5)
name old allocs/op new allocs/op delta
FunctionArgumentIndex/10-16 296 ± 0% 91 ± 0% -69.26% (p=0.008 n=5+5)
FunctionArgumentIndex/100-16 2.29k ± 0% 0.09k ± 0% -96.02% (p=0.008 n=5+5)
FunctionArgumentIndex/1000-16 22.1k ± 0% 0.1k ± 0% -99.59% (p=0.008 n=5+5
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Co-authored-by: Stephan Renatus <stephan.renatus@gmail.com>
Co-authored-by: Torin Sandall <torinsandall@gmail.com> S
Stephan Renatus committed
9bbc09e165ab2daf0e0aafce2e0c14c2a6a2977a
Parent: a60577d
Committed by Torin Sandall <torinsandall@gmail.com>
on 6/16/2021, 12:20:26 PM