You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my rewrite I'm using a Stack (similar to the Lua one) to store values of different types in a plain Vec. This allows me to save unnecessary allocations.
Every time you call a dynamic function, you push the arguments to the stack, the function pops them off again and pushes the return value.
In my current experimentations (PR will follow soon), I've used tuples with the intention to always expect a tuple for function args.
This, however has two disadvantages:
exposing the vnodes_push_* functions for tuples to C seems to be rather complicated
individually popping off only one element at a time is impossible, we need to pop the whole tuple at once
Why is that a problem? Each segment of a path is basically a u64. So let's say we search for a node /foo/bar/other/meaning/ful/words. The first segment we can pop (that's at the top of the stack) is "foo". So the root node knows it needs to go to the foo node. That's enough, we don't need to know any more. But if we need to pop the whole tuple, we can't pop just a single path segment. We'd need to pop the whole path, provide a rather large buffer for it or even allocate for it. That's not what we want.
Thus, I think we should simply allow to push and pop multiple values to the stack for the function parameters. However, this has a drawback. We can't check if we have all the right types upfront and a node might pop too many elements from the stack. How should we deal with that? Pass an integer indicating the number of arguments?
The text was updated successfully, but these errors were encountered:
I think I'll drop the current way tuples work and replace it by just using a tuple tag consisting of a type tag (Ty::Tuple) and the size, that way we only need to inspect the last element of the stack to see how many we may pop.
In my rewrite I'm using a
Stack
(similar to the Lua one) to store values of different types in a plainVec
. This allows me to save unnecessary allocations.Every time you call a dynamic function, you push the arguments to the stack, the function pops them off again and pushes the return value.
In my current experimentations (PR will follow soon), I've used tuples with the intention to always expect a tuple for function args.
This, however has two disadvantages:
vnodes_push_*
functions for tuples to C seems to be rather complicatedWhy is that a problem? Each segment of a path is basically a
u64
. So let's say we search for a node/foo/bar/other/meaning/ful/words
. The first segment we can pop (that's at the top of the stack) is"foo"
. So the root node knows it needs to go to thefoo
node. That's enough, we don't need to know any more. But if we need to pop the whole tuple, we can't pop just a single path segment. We'd need to pop the whole path, provide a rather large buffer for it or even allocate for it. That's not what we want.Thus, I think we should simply allow to push and pop multiple values to the stack for the function parameters. However, this has a drawback. We can't check if we have all the right types upfront and a node might pop too many elements from the stack. How should we deal with that? Pass an integer indicating the number of arguments?
The text was updated successfully, but these errors were encountered: