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
This issue is meant to specify and track the progress of the implementation of the compiler's cost-tracking feature.
To track the costs we've chosen to modify the output of the compiler to emit WebAssembly code that keeps track of costs during execution of the program. We do this by defining a set of integer globals, one for each tracked cost:
The compiler then emits code that, during execution, subtracts the appropriate cost for these globals according to the Clarity executed. If any of the globals falls below zero, an unreachable instruction is executed, with an appropriate return code set.
The host will become responsible for setting the globals to the allowed limit, and for handling the error codes on cost overrun.
Below an example of the code that can introduced before each word to track the cost.
global.get$clarity_cost_lefti64.const <pre-computed-cost>
i64.subglobal.set$clarity_cost_leftglobal.get$clarity_cost_lefti64.const0i64.lt_s
(if (thenunreachable))
end
Code generated for the `concat` word is changed to ensure both its
arguments are traversed *before* copying their contents onto the
resulting sequence.
This avoids a partially copied to return buffer should the code fail
during resolution of the second argument. It will also allow for a
cleaner implementation of cost tracking since we can then avoid copying
on a cost overrun.
See-also: #616
Code generated for the `concat` word is changed to ensure both its
arguments are traversed *before* copying their contents onto the
resulting sequence.
This avoids a partially copied to return buffer should the code fail
during resolution of the second argument. It will also allow for a
cleaner implementation of cost tracking since we can then also avoid
copying on a cost overrun.
See-also: #616
Cost Tracking
This issue is meant to specify and track the progress of the implementation of the compiler's cost-tracking feature.
To track the costs we've chosen to modify the output of the compiler to emit WebAssembly code that keeps track of costs during execution of the program. We do this by defining a set of integer globals, one for each tracked cost:
The compiler then emits code that, during execution, subtracts the appropriate cost for these globals according to the Clarity executed. If any of the globals falls below zero, an unreachable instruction is executed, with an appropriate return code set.
The host will become responsible for setting the globals to the allowed limit, and for handling the error codes on cost overrun.
Below an example of the code that can introduced before each word to track the cost.
Progress
Simple Variadic Words
Simple Words
Complex Words
The text was updated successfully, but these errors were encountered: