modify-code-heap ( alist update-existing? reset-pics? -- )
Factor handbook » The implementation » Definitions » Compilation units » Compilation units internals

Prev:recompile ( words -- alist )
Next:changed-definitions


Vocabulary
compiler.units

Inputs
alistan association list with words as keys
update-existing?a boolean
reset-pics?a boolean


Outputs
None

Word description
Lowest-level primitive for defining words. Associates words with code blocks in the code heap.

The alist maps words to one of the following:
a quotation - in this case, the quotation is compiled with the non-optimizing compiler and the word will call the quotation when executed.
a 6-element array { parameters literals relocation labels code stack-frame-size } - in this case, a code heap block is allocated with the given data and the word will call the code block when executed. This is used by the optimizing compiler.

If any of the redefined words may already be referenced by other words in the code heap, from outside of the compilation unit, then a scan of the code heap must be performed to update all word call sites. Passing t as the update-existing? parameter enables this code path.

If classes, methods or generic words were redefined, then inline cache call sites need to be updated as well. Passing t as the reset-pics? parameter enables this code path.

Examples
Manually creating a word using the non-optimizing compiler:
USING: compiler.units io ; IN: scratchpad : foo ( -- ) ; { { foo [ "hello!" print ] } } t t modify-code-heap foo
hello!


Notes
This word is called at the end of with-compilation-unit.

Definition

PRIMITIVE: modify-code-heap
( alist update-existing? reset-pics? -- )