Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9605e8215fea
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6b8ef8c49062
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Aug 28, 2015

  1. compiler.embedding: actually use qualified name when embedding methods.

    Previous commit 6b55e3b only did this for embedded types.
    whitequark committed Aug 28, 2015
    Copy the full SHA
    677cc69 View commit details
  2. Copy the full SHA
    edf33f1 View commit details
  3. artiq_run: use "artiq_run_" as user code module prefix, not "file_imp…

    …ort_".
    whitequark committed Aug 28, 2015
    Copy the full SHA
    6b8ef8c View commit details
Showing with 15 additions and 11 deletions.
  1. +2 −2 artiq/compiler/embedding.py
  2. +10 −6 artiq/compiler/targets.py
  3. +1 −1 artiq/frontend/artiq_run.py
  4. +2 −2 artiq/tools.py
4 changes: 2 additions & 2 deletions artiq/compiler/embedding.py
Original file line number Diff line number Diff line change
@@ -420,7 +420,7 @@ def _quote_embedded_function(self, function):
embedded_function = function.artiq_embedded.function
source_code = textwrap.dedent(inspect.getsource(embedded_function))
filename = embedded_function.__code__.co_filename
module_name, _ = os.path.splitext(os.path.basename(filename))
module_name = embedded_function.__globals__['__name__']
first_line = embedded_function.__code__.co_firstlineno

# Extract function environment.
@@ -436,7 +436,7 @@ def _quote_embedded_function(self, function):
function_node = parsetree.body[0]

# Mangle the name, since we put everything into a single module.
function_node.name = "{}.{}".format(module_name, function_node.name)
function_node.name = "{}.{}".format(module_name, function.__qualname__)

# Normally, LocalExtractor would populate the typing environment
# of the module with the function name. However, since we run
16 changes: 10 additions & 6 deletions artiq/compiler/targets.py
Original file line number Diff line number Diff line change
@@ -69,7 +69,11 @@ def __init__(self):
def compile(self, module):
"""Compile the module to a relocatable object for this target."""

if os.getenv('ARTIQ_DUMP_IR'):
if os.getenv("ARTIQ_DUMP_SIG"):
print("====== MODULE_SIGNATURE DUMP ======", file=sys.stderr)
print(module, file=sys.stderr)

if os.getenv("ARTIQ_DUMP_IR"):
print("====== ARTIQ IR DUMP ======", file=sys.stderr)
for function in module.artiq_ir:
print(function, file=sys.stderr)
@@ -78,7 +82,7 @@ def compile(self, module):
llparsedmod = llvm.parse_assembly(str(llmod))
llparsedmod.verify()

if os.getenv('ARTIQ_DUMP_LLVM'):
if os.getenv("ARTIQ_DUMP_LLVM"):
print("====== LLVM IR DUMP ======", file=sys.stderr)
print(str(llparsedmod), file=sys.stderr)

@@ -90,7 +94,7 @@ def compile(self, module):
llpassmgrbuilder.populate(llpassmgr)
llpassmgr.run(llparsedmod)

if os.getenv('ARTIQ_DUMP_LLVM'):
if os.getenv("ARTIQ_DUMP_LLVM"):
print("====== LLVM IR DUMP (OPTIMIZED) ======", file=sys.stderr)
print(str(llparsedmod), file=sys.stderr)

@@ -99,7 +103,7 @@ def compile(self, module):
features=",".join(self.features),
reloc="pic", codemodel="default")

if os.getenv('ARTIQ_DUMP_ASSEMBLY'):
if os.getenv("ARTIQ_DUMP_ASSEMBLY"):
print("====== ASSEMBLY DUMP ======", file=sys.stderr)
print(llmachine.emit_assembly(llparsedmod), file=sys.stderr)

@@ -115,7 +119,7 @@ def link(self, objects, init_fn):
as results:
library = results["output"].read()

if os.getenv('ARTIQ_DUMP_ELF'):
if os.getenv("ARTIQ_DUMP_ELF"):
shlib_temp = tempfile.NamedTemporaryFile(suffix=".so", delete=False)
shlib_temp.write(library)
shlib_temp.close()
@@ -145,7 +149,7 @@ def symbolize(self, library, addresses):
backtrace = []
for function_name, location, address in zip(lines[::2], lines[1::2], addresses):
filename, line = location.rsplit(":", 1)
if filename == '??':
if filename == "??":
continue
# can't get column out of addr2line D:
backtrace.append((filename, int(line), -1, function_name, address))
2 changes: 1 addition & 1 deletion artiq/frontend/artiq_run.py
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ def _build_experiment(dmgr, pdb, rdb, args):
"for ELF kernels")
return ELFRunner(dmgr, pdb, rdb, file=args.file)
else:
module = file_import(args.file)
module = file_import(args.file, prefix="artiq_run_")
file = args.file
else:
module = sys.modules["__main__"]
4 changes: 2 additions & 2 deletions artiq/tools.py
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ def parse_arguments(arguments):
return d


def file_import(filename):
def file_import(filename, prefix="file_import_"):
linecache.checkcache(filename)

modname = filename
@@ -29,7 +29,7 @@ def file_import(filename):
i = modname.find(".")
if i > 0:
modname = modname[:i]
modname = "file_import_" + modname
modname = prefix + modname

path = os.path.dirname(os.path.realpath(filename))
sys.path.insert(0, path)