forked from M-Labs/artiq
1
0
Fork 0

compiler: Revert function call lifetime tracking fix

This reverts commits f8d1506922
and cf19c9512d.

While the commit just fixes a clear typo in the implementation,
it turns out the original algorithm isn't flexible enough to
capture functions that transitively return references to
long-lived data. For instance, while cache_get() is special-cased
in the compiler to be recognised as returning a value of Global()
lifetime, a function just forwarding to it (as seen in the
embedding tests) isn't anymore.

A separate issue is also that this makes implementing functions
that take lists and return references to global data in user code
impossible, which central parts of the Oxford codebase rely on.

Just reverting for now to unblock master; a fix is easily designed,
but needs testing.
This commit is contained in:
David Nadlinger 2020-07-30 16:40:23 +01:00
parent 709026d945
commit ae999db8f6
3 changed files with 1 additions and 18 deletions

View File

@ -24,9 +24,6 @@ Highlights:
* Core device: ``panic_reset 1`` now correctly resets the kernel CPU as well if * Core device: ``panic_reset 1`` now correctly resets the kernel CPU as well if
communication CPU panic occurs. communication CPU panic occurs.
* NumberValue accepts a ``type`` parameter specifying the output as ``int`` or ``float`` * NumberValue accepts a ``type`` parameter specifying the output as ``int`` or ``float``
* In kernels, lifetime of allocated values (e.g. lists) is now correctly tracked across
function calls (see #1497, #1394). Previous versions (since ARTIQ 1.0) would accept
illegal code that would result in silent memory corruption at runtime.
Breaking changes: Breaking changes:

View File

@ -103,7 +103,7 @@ class RegionOf(algorithm.Visitor):
# The cache is borrow checked dynamically # The cache is borrow checked dynamically
return Global() return Global()
else: else:
return self.visit_sometimes_allocating(node) self.visit_sometimes_allocating(node)
# Value lives as long as the object/container, if it's mutable, # Value lives as long as the object/container, if it's mutable,
# or else forever # or else forever

View File

@ -1,14 +0,0 @@
# RUN: %python -m artiq.compiler.testbench.embedding +diag %s 2>%t
# RUN: OutputCheck %s --file-to-check=%t
from artiq.experiment import *
@kernel
def leak(a):
return a
@kernel
def entrypoint():
# CHECK-L: ${LINE:+2}: error: cannot return an allocated value that does not live forever
# CHECK-L: ${LINE:+1}: note: ... to this point
return leak([1, 2, 3])