Expansions of call( and execute( words (original) (raw)
call( and execute( have complex expansions.
If the input quotation is a literal, or built up from curry and compose with terminal quotations literal, it is inlined at the call site.
For dynamic call sites, call( uses the following strategy:
• | Inline caching. If the quotation is the same as last time, just call it unsafely |
---|---|
• | Effect inference. Infer quotation's effect, caching it in the cached-effect slot, and compare it with declaration. If matches, call it unsafely. |
• | Fallback. If the above doesn't work, call it and compare the datastack before and after to make sure it didn't mess anything up. |
• | Inline caches and cached effects are invalidated whenever a macro is redefined, or a word's effect changes, by comparing a global counter against the counter value last observed. The counter is incremented by compiler.units. |
execute( uses a similar strategy.