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: cb90bf6ef398
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: ff0ab736e9c4
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Dec 31, 2015

  1. runtime/artiq_personality: add missing cast.

    whitequark committed Dec 31, 2015
    Copy the full SHA
    71d8cbb View commit details
  2. Copy the full SHA
    79d020d View commit details
  3. Commit missing parts of 8aa34ee.

    whitequark committed Dec 31, 2015
    Copy the full SHA
    ff0ab73 View commit details
Showing with 36 additions and 20 deletions.
  1. +22 −10 artiq/compiler/transforms/artiq_ir_generator.py
  2. +12 −9 artiq/coredevice/core.py
  3. +2 −1 artiq/runtime/artiq_personality.c
32 changes: 22 additions & 10 deletions artiq/compiler/transforms/artiq_ir_generator.py
Original file line number Diff line number Diff line change
@@ -150,14 +150,21 @@ def terminate(self, insn):
else:
insn.drop_references()

def warn_unreachable(self, node):
diag = diagnostic.Diagnostic("warning",
"unreachable code", {},
node.loc.begin())
self.engine.process(diag)

# Visitors

def visit(self, obj):
if isinstance(obj, list):
for elt in obj:
self.visit(elt)
if self.current_block.is_terminated():
self.warn_unreachable(elt)
break
self.visit(elt)
elif isinstance(obj, ast.AST):
try:
old_loc, self.current_loc = self.current_loc, _extract_loc(obj)
@@ -615,7 +622,10 @@ def visit_Try(self, node):
finally:
self.unwind_target = old_unwind

self.visit(node.orelse)
if not body.is_terminated():
self.visit(node.orelse)
elif any(node.orelse):
self.warn_unreachable(node.orelse[0])
body = self.current_block

if any(node.finalbody):
@@ -1435,18 +1445,20 @@ def visit_CompareT(self, node):

# Keep this function with builtins.TException.attributes.
def alloc_exn(self, typ, message=None, param0=None, param1=None, param2=None):
typ = typ.find()
attributes = [
ir.Constant(typ.find().name, ir.TExceptionTypeInfo()), # typeinfo
ir.Constant("<not thrown>", builtins.TStr()), # file
ir.Constant(0, builtins.TInt32()), # line
ir.Constant(0, builtins.TInt32()), # column
ir.Constant("<not thrown>", builtins.TStr()), # function
ir.Constant("{}:{}".format(typ.id, typ.name),
ir.TExceptionTypeInfo()), # typeinfo
ir.Constant("<not thrown>", builtins.TStr()), # file
ir.Constant(0, builtins.TInt32()), # line
ir.Constant(0, builtins.TInt32()), # column
ir.Constant("<not thrown>", builtins.TStr()), # function
]

if message is None:
attributes.append(ir.Constant(typ.find().name, builtins.TStr()))
attributes.append(ir.Constant(typ.name, builtins.TStr()))
else:
attributes.append(message) # message
attributes.append(message) # message

param_type = builtins.TInt64()
for param in [param0, param1, param2]:
@@ -1455,7 +1467,7 @@ def alloc_exn(self, typ, message=None, param0=None, param1=None, param2=None):
else:
if param.type != param_type:
param = self.append(ir.Coerce(param, param_type))
attributes.append(param) # paramN, N=0:2
attributes.append(param) # paramN, N=0:2

return self.append(ir.Alloc(attributes, typ))

21 changes: 12 additions & 9 deletions artiq/coredevice/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
import os, sys

from pythonparser import diagnostic

@@ -13,21 +13,24 @@
# Import for side effects (creating the exception classes).
from artiq.coredevice import exceptions

def _render_diagnostic(diagnostic):
def shorten_path(path):
return path.replace(os.path.normpath(os.path.join(__file__, "..", "..")), "<artiq>")
lines = [shorten_path(path) for path in diagnostic.render(colored=True)]
return "\n".join(lines)

class _DiagnosticEngine(diagnostic.Engine):
def print_diagnostic(self, diagnostic):
sys.stderr.write(_render_diagnostic(diagnostic) + "\n")

class CompileError(Exception):
def __init__(self, diagnostic):
self.diagnostic = diagnostic

def render_string(self, colored=False):
def shorten_path(path):
return path.replace(os.path.normpath(os.path.join(__file__, "..", "..")), "<artiq>")
lines = [shorten_path(path) for path in self.diagnostic.render(colored=colored)]
return "\n".join(lines)

def __str__(self):
# Prepend a newline so that the message shows up on after
# exception class name printed by Python.
return "\n" + self.render_string(colored=True)
return "\n" + _render_diagnostic(self.diagnostic)


@syscall
@@ -58,7 +61,7 @@ def __init__(self, dmgr, ref_period, external_clock=False, comm_device="comm"):

def compile(self, function, args, kwargs, set_result=None, with_attr_writeback=True):
try:
engine = diagnostic.Engine(all_errors_are_fatal=True)
engine = _DiagnosticEngine(all_errors_are_fatal=True)

stitcher = Stitcher(engine=engine)
stitcher.stitch_call(function, args, kwargs, set_result)
3 changes: 2 additions & 1 deletion artiq/runtime/artiq_personality.c
Original file line number Diff line number Diff line change
@@ -423,7 +423,8 @@ _Unwind_Reason_Code __artiq_personality(
encodingSize, typeInfoPtrPtr, (void*)typeInfoPtr);
EH_LOG("typeInfo=%s", (char*)typeInfoPtr);

if(typeInfoPtr == 0 || !strcmp(inflight->artiq.typeinfo, (char*)typeInfoPtr)) {
if(typeInfoPtr == 0 || !strcmp((char*)inflight->artiq.typeinfo,
(char*)typeInfoPtr)) {
EH_LOG0("matching action found");
exceptionMatched = 1;
break;