Interpreter: Cache CGC results instead of re-executing them

Bug #491697 reported by Matt Giuca
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mars
Fix Released
Low
Matt Giuca

Bug Description

Each time a computable global constant is mentioned, it is fully executed. Since CGCs (unlike nullary functions) are by definition constants, their value should be the same every time, and they should not perform side-effects. Therefore, the interpreter should cache their value after the first reference, and on subsequent references, simply re-use the same value.

This technically does *not* change the Mars language, as CGCs have always been specified as constants, but it will change the behaviour of some programs if they use impure constructs. Firstly CGCs which perform IO will change their behaviour to only execute the IO once. Secondly, CGCs which return objects (like arrays) will now return the same array reference each time, so impure array mutation constructs will actually mutate the global constant.

One reason to make this change is to force the upcoming uniqueness analysis to account for shared references to global constants.

Tags: interpreter

Related branches

Revision history for this message
Matt Giuca (mgiuca) wrote :

Fixed in trunk r1068.

Changed in mars:
status: Triaged → Fix Committed
Matt Giuca (mgiuca)
Changed in mars:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.