Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

39 lines (25 sloc) 1.469 kB
One major step that will be part of bytecode generation, is copy analysis.
For each function, we'll analyze when we need to make value copies and when we don't.
Prevent unnecessary duplicated values. Optimize for time & space
Predictability & transparent rules. User should be able to write copy-free code.
For each function input, we can say:
- Function only wants to read value. No use in reusing value in output.
- Function wants to reuse most/all of the value in its output
- Similarly, function is indented to 'modify' the input (use a touched version as output)
These two behaviors are ReadOnly or Consume.
For each call site:
- Term value will be used again - ValueNeededLater
- Term value will not be used again - ValueNotNeededLater
So, our decision:
ReadOnly Consume
ValueNeededLater Do not make a copy. Make a copy. Also,
Unless we're worried about consider reordering.
function's purity.
ValueNotNeededLater Do not make a copy Do not make a copy
In some cases we can further decrease copying, if we move ReadOnly calls in
front of Consume calls. The ReadOnly call can get a chance to use the value
before the Consume call destroys it. (Of course, if both functions have effects
then the reorder is not allowed).
Reordering is something I probably won't do in the first pass.
Jump to Line
Something went wrong with that request. Please try again.