This commit fixes a regression in std.manifestJsonEx that caused the
standard library function to error when the given value was an array.
Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
Fixes multiple issues with stack traces leading to missing
stack trace lines. Also, we no longer put builtin context
on the line which *calls* the builtin as if it was a part
of the builtin itself.
Code for stack trace handling was centralized. We no longer
need traceElement argument in ~every function. Now the stack
trace state is kept solely in the interpreter.
Desugar the locals in object comprehensions
"traditionally" instead of handling them manually.
Object comprehensions allow the locals to depend
on the index variable which means that they are separate
for each field. It doesn't make sense to treat them as
a property of the whole object.
Fixes#358.
❯ make benchmark FILTER=Builtin_manifestJsonEx
go build ./cmd/jsonnet
./benchmark.sh Builtin_manifestJsonEx
Running Before Test... (10s)
Running After Test... (10s)
benchmark old ns/op new ns/op delta
Benchmark_Builtin_manifestJsonEx-16 22656394 7502016 -66.89%
feat: improve std.base64Decode performance 97%+
Provides a Go-native implementation of std.base64Decode and std.base64DecodeBytes
benchmark old ns/op new ns/op delta
Benchmark_Builtin_base64Decode-16 10946388307 25004135 -99.77%
Benchmark_Builtin_base64DecodeBytes-16 6420742757 181513016 -97.17%
related to #111
Implements std.reverse in native Go, improving performance
benchmark old ns/op new ns/op delta
Benchmark_Builtin_reverse-16 869191619 231309458 -73.39%
part of #111
This pulls in the implementation of substr into native Go instead of interpretted Jsonnet.
benchmark old ns/op new ns/op delta
Benchmark_Builtin_substr-16 97121527 15115905 -84.44%
part of #111
When adding long strings, don't copy them immediately. Instead
build long strings only when their contents are requested.
This allows to build a long string from parts, using a regular
operator+ in linear time. This lets users to worry much less
about using std.join etc.
If indexing the string is mixed with building it using operator+
the behavior can still be quadratic. We may want to address it in
a later change.
Sort is something that is highly optimized in most languages
and users can expect it to be fast. We can piggyback on
the Go implementation.
This change results in 100x speedup on bench.06.jsonnet.
This change adds caching to objects fields, i.e. now subsequent
references to an object field are going to be served from cache.
Cache is kept within an object. Objects created with operator +
start with a clean cache (they have to, because in general all
the fields may have changed their values due to late binding).
This change comes naturally with a change of structure of objects,
now valueObject is a concrete struct which keeps "uncachedObject"
which is roughly equivalent to old objects.
We didn't set the environment (upvalues) for objects
created as comprehensions - we set them for each field
separately, but that meant missing the locals.
Keep object locals only once in AST
For example this reduces the size of stdlib ast file
roughly 3x. Note that this change doesn't regenerate the stdlib,
so that the diff here is sane.
It is likely to slightly improve performance of code using
a lot of locals (~10% on bench.05.gen.jsonnet).
The desugaring is more strightforward now, and we're back
to desugaring each node exactly once.