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: 47f13bf921d9
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: bb5fe601378b
Choose a head ref
  • 4 commits
  • 9 files changed
  • 2 contributors

Commits on Jul 26, 2015

  1. Copy the full SHA
    d65d303 View commit details

Commits on Jul 27, 2015

  1. get-toolchain.sh: be less verbose.

    whitequark committed Jul 27, 2015
    Copy the full SHA
    905abd6 View commit details
  2. Merge branch 'master' into new-py2llvm

    whitequark committed Jul 27, 2015
    Copy the full SHA
    ef4a06a View commit details
  3. Implement exception raising.

    whitequark committed Jul 27, 2015
    Copy the full SHA
    bb5fe60 View commit details
2 changes: 1 addition & 1 deletion .travis/get-toolchain.sh
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ done
for a in $archives
do
wget $a
(cd packages && tar xvf ../$(basename $a))
(cd packages && tar xf ../$(basename $a))
done

export PATH=$PWD/packages/usr/local/llvm-or1k/bin:$PWD/packages/usr/local/bin:$PWD/packages/usr/bin:$PATH
4 changes: 2 additions & 2 deletions lit-test/libartiq_personality/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CC ?= clang

libartiq_personality.so: ../../soc/runtime/artiq_personality.c
$(CC) -Wall -Werror -I. -fPIC -shared -o $@ $<
libartiq_personality.so: ../../soc/runtime/artiq_personality.c artiq_terminate.c
$(CC) -Wall -Werror -I. -I../../soc/runtime -fPIC -shared -o $@ $^
14 changes: 14 additions & 0 deletions lit-test/libartiq_personality/artiq_terminate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <unwind.h>
#include <artiq_personality.h>

void __artiq_terminate(struct artiq_exception *exn) {
printf("Uncaught %s: %s (%"PRIi64", %"PRIi64", %"PRIi64")\n"
"at %s:%"PRIi32":%"PRIi32"",
exn->name, exn->message,
exn->param[0], exn->param[1], exn->param[1],
exn->file, exn->line, exn->column + 1);
exit(1);
}
2 changes: 2 additions & 0 deletions lit-test/not.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import sys, subprocess
exit(not subprocess.call(sys.argv[1:]))
4 changes: 3 additions & 1 deletion lit-test/test/exceptions/raise.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# RUN: %python -m artiq.compiler.testbench.jit %s
# RUN: %not %python -m artiq.compiler.testbench.jit %s
# REQUIRES: exceptions

# CHECK-L: Uncaught ZeroDivisionError: cannot divide by zero (0, 0, 0)
# CHECK-L: at input.py:${LINE:+1}:0
1/0
4 changes: 4 additions & 0 deletions lit-test/test/lit.cfg
Original file line number Diff line number Diff line change
@@ -9,9 +9,13 @@ config.test_format = lit.formats.ShTest()
config.suffixes = ['.py']

python_executable = 'python3'

harness = '{} {}'.format(python_executable, os.path.join(root, 'harness.py'))
config.substitutions.append( ('%python', harness) )

not_ = '{} {}'.format(python_executable, os.path.join(root, 'not.py'))
config.substitutions.append( ('%not', not_) )

if os.name == 'posix':
personality_build = os.path.join(root, 'libartiq_personality')
if subprocess.call(['make', '-sC', personality_build]) != 0:
42 changes: 29 additions & 13 deletions soc/runtime/artiq_personality.c
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unwind.h>
#include "artiq_personality.h"

struct artiq_exception {
const char *name;
const char *file;
int32_t line;
int32_t column;
const char *message;
int64_t param[3];
#define ARTIQ_EXCEPTION_CLASS 0x4152545141525451LL // 'ARTQARTQ'

struct artiq_raised_exception {
struct _Unwind_Exception unwind;
struct artiq_exception artiq;
};

static void __artiq_cleanup(_Unwind_Reason_Code reason, struct _Unwind_Exception *exc) {
struct artiq_raised_exception *inflight = (struct artiq_raised_exception*) exc;
// The in-flight exception is statically allocated, so we don't need to free it.
// But, we clear it to mark it as processed.
memset(&inflight->artiq, 0, sizeof(struct artiq_exception));
}

void __artiq_raise(struct artiq_exception *artiq_exn) {
printf("raised %s\n", artiq_exn->name);
abort();
static struct artiq_raised_exception inflight;
memcpy(&inflight.artiq, artiq_exn, sizeof(struct artiq_exception));
inflight.unwind.exception_class = ARTIQ_EXCEPTION_CLASS;
inflight.unwind.exception_cleanup = &__artiq_cleanup;

_Unwind_Reason_Code result = _Unwind_RaiseException(&inflight.unwind);
if(result == _URC_END_OF_STACK) {
__artiq_terminate(&inflight.artiq);
} else {
fprintf(stderr, "__artiq_raise: unexpected error (%d)\n", result);
abort();
}
}

_Unwind_Reason_Code __artiq_personality(int version,
_Unwind_Action actions, uint64_t exceptionClass,
struct _Unwind_Exception *exceptionObject,
struct _Unwind_Context *context) {
_Unwind_Reason_Code __artiq_personality(
int version, _Unwind_Action actions, uint64_t exceptionClass,
struct _Unwind_Exception *exceptionObject, struct _Unwind_Context *context) {
abort();
}
31 changes: 31 additions & 0 deletions soc/runtime/artiq_personality.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef __ARTIQ_PERSONALITY_H
#define __ARTIQ_PERSONALITY_H

#include <stdint.h>

struct artiq_exception {
union {
void *typeinfo;
const char *name;
};
const char *file;
int32_t line;
int32_t column;
const char *message;
int64_t param[3];
};

#ifdef __cplusplus
extern "C" {
#endif

void __artiq_terminate(struct artiq_exception *artiq_exn)
__attribute__((noreturn));

void __artiq_raise(struct artiq_exception *artiq_exn);

#ifdef __cplusplus
}
#endif

#endif /* __ARTIQ_PERSONALITY_H */
2 changes: 1 addition & 1 deletion soc/targets/artiq_pipistrello.py
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ def __init__(self, platform, clk_freq):
NET "sys_clk" TNM_NET = "GRPsys_clk";
TIMESPEC "TSfix_ise1" = FROM "GRPint_clk" TO "GRPsys_clk" TIG;
TIMESPEC "TSfix_ise2" = FROM "GRPsys_clk" TO "GRPint_clk" TIG;
""", int_clk=rtio_internal_clk, ext_clk=rtio_external_clk)
""", int_clk=rtio_internal_clk)


class NIST_QC1(BaseSoC, AMPSoC):