2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-24 19:04:02 +08:00

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
communication CPU panic occurs.
* 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:

View File

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