stringer := ctx.GetInterface(`fmt.Stringer`) // pointer to the captured, type, T -> *T ptr := types.NewPointer(ctx.Type) return types.Implements(ctx.Type, stringer) || types.Implements(ptr, stringer) } How to execute?
return x + y * 3 } LoadScalarConst local2 = 3 IntMul64 local1 = y local2 IntAdd64 local0 = x local1 ReturnScalar local0 fn2 frame x y local0 local1 local2
Scalar uint64 Scalar2 uint64 } 65 Small structs are stored directly inside the slot, if possible. Otherwise they’re heap allocated and we store a pointer to it.
but written in Go and with Go as a query language instead of Lua. It’s also possible to use Go scripts as custom filtering lambdas for your internal services. 85
• Harder to fine-tune runtime-related code without asm • Paying extra price to be Go GC friendly Overall, the raw performance can be ~20% slower for identically optimal interpreters of the same target language. 92 Cons:
to embed the interpreter • Getting a GC for free • Cheap interop with Go (in both directions) • Can use Go stdlib in the target language stdlib • Great benchmarking/testing/ profiling support 93 Pros:
(therefore, instructions) • Go has true integer type (and unboxed scalars in general) • For array-like data, slices are better than Lua tables • Structs are better than Lua tables The raw performance is lower, but Go is “faster” than Lua. 94
of Lua in your Go apps Go is a good interpretation target language Interpreters written in Go can be quite fast if done right Interpreters benefit from “unsafe” a lot