typed and optimization #2428
Replies: 2 comments 1 reply
-
Typed words have two layers.
An outer word that checks the stack input type and throws an exception if the types are not correct at run-time. The compiler removes or reduces these checks if type information is known.
An inner word which declares the types on the stack (for purposes of more efficient code generation in the inner word). This uses the kernel.private:declare word to do so.
If all types are known at compile time then only the inner word is being called, which is efficient.
… On Feb 1, 2021, at 7:02 AM, kusumotonorio ***@***.***> wrote:
Do words defined with TYPED: tell the compiler at compile time the class information of the value it will put on the stack to optimize the words it concatenates?
It appears to be the case. How exactly does it do that?
I'm looking for a way to eliminate dispatching of the later word as much as possible when concatenating multi-generic words. I could do it like the word defined in TYPED:, but I suspect that inspecting the output would slow it down. I only want to make the multi-generic word tell the class information of the output.
Translated with www.DeepL.com/Translator (free version)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Beta Was this translation helpful? Give feedback.
-
As for how much of the type information on the stack is used by factor's optimizing compiler, apparently not as much as I had imagined. It would be nice to receive more information if If so, multi-generic words would have a better chance of removing dispatch code, and would be faster. It is faster to be able to remove the dispatch than any fast dispatch algorithm. |
Beta Was this translation helpful? Give feedback.
-
Do words defined with
TYPED:
tell the compiler at compile time the class information of the value it will put on the stack to optimize the words it concatenates?It appears to be the case. How exactly does it do that?
I'm looking for a way to eliminate dispatching of the later word as much as possible when concatenating multi-generic words. I could do it like the word defined in
TYPED:
, but I suspect that inspecting the output would slow it down. I only want to make the multi-generic word tell the class information of the output.Beta Was this translation helpful? Give feedback.
All reactions