-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Currently, sbe::vm::ByteCode exposes two helpers for reading values from the VM stack:
- getFromStack returns FastTuple<bool ownedOnStack, value::TypeTags, value::Value>. The ownedOnStack flag describes whether the stack slot owns the underlying value, not whether the caller does.
- getOwnedFromStack() pops from the stack and return an owned tag-value pair.
The intent is for getFromStack to behave as a peek (no ownership transfer, stack retains ownership) and for getOwnedFromStack to behave as a pop (ownership moves to the caller). However, the ownedOnStack flag in getFromStack is easy to misread as “the caller owns this value,” which is not true. In some cases, it may be necessary to read a value from the stack without moving its ownership, so we should introduce a new function getViewFromStack() which returns a value::TagValueView.
Call sites that need ownership should use the “pop” helper (getOwnedFromStack / moveOwnedFromStack).