tinygo/src/runtime
Ayke van Laethem edcece33ca transform: refactor interrupt lowering
Instead of doing everything in the interrupt lowering pass, generate
some more code in gen-device to declare interrupt handler functions and
do some work in the compiler so that interrupt lowering becomes a lot
simpler.

This has several benefits:

  - Overall code is smaller, in particular the interrupt lowering pass.
  - The code should be a bit less "magical" and instead a bit easier to
    read. In particular, instead of having a magic
    runtime.callInterruptHandler (that is fully written by the interrupt
    lowering pass), the runtime calls a generated function like
    device/sifive.InterruptHandler where this switch already exists in
    code.
  - Debug information is improved. This can be helpful during actual
    debugging but is also useful for other uses of DWARF debug
    information.

For an example on debug information improvement, this is what a
backtrace might look like before this commit:

    Breakpoint 1, 0x00000b46 in UART0_IRQHandler ()
    (gdb) bt
    #0  0x00000b46 in UART0_IRQHandler ()
    #1  <signal handler called>
    [..etc]

Notice that the debugger doesn't see the source code location where it
has stopped.

After this commit, breaking at the same line might look like this:

    Breakpoint 1, (*machine.UART).handleInterrupt (arg1=..., uart=<optimized out>) at /home/ayke/src/github.com/tinygo-org/tinygo/src/machine/machine_nrf.go:200
    200			uart.Receive(byte(nrf.UART0.RXD.Get()))
    (gdb) bt
    #0  (*machine.UART).handleInterrupt (arg1=..., uart=<optimized out>) at /home/ayke/src/github.com/tinygo-org/tinygo/src/machine/machine_nrf.go:200
    #1  UART0_IRQHandler () at /home/ayke/src/github.com/tinygo-org/tinygo/src/device/nrf/nrf51.go:176
    #2  <signal handler called>
    [..etc]

By now, the debugger sees an actual source location for UART0_IRQHandler
(in the generated file) and an inlined function.
2021-11-06 09:40:15 +01:00
..
cgo runtime/cgo: go fmt 2018-09-14 20:58:00 +02:00
debug runtime: add dummy debug package 2021-03-09 16:09:51 +01:00
internal/sys all: check formatting on CI 2019-04-13 19:58:58 +02:00
interrupt transform: refactor interrupt lowering 2021-11-06 09:40:15 +01:00
pprof loader: rewrite/refactor much of the code to use go list directly 2020-09-03 22:10:14 +02:00
volatile Viable NXP/Teensy support 2020-07-08 21:58:15 +02:00
arch_386.go 386: bump minimum requirement to the Pentium 4 2021-08-10 20:08:27 +02:00
arch_amd64.go gc: use raw stack access whenever possible 2020-10-02 08:54:43 +02:00
arch_arm.go wasi: remove wasm build tag 2021-06-22 09:03:23 +02:00
arch_arm64.go gc: use raw stack access whenever possible 2020-10-02 08:54:43 +02:00
arch_avr.go runtime: add dummy getCurrentStackPointer functions 2019-08-25 13:12:27 +02:00
arch_cortexm.go nrf: call sd_app_evt_wait when the SoftDevice is enabled 2020-08-24 22:46:21 +02:00
arch_tinygoriscv.go riscv: implement 32-bit atomic operations 2021-10-04 21:27:00 +02:00
arch_tinygoriscv32.go runtime: reuse common code between 32 and 64-bit RISC-V 2020-07-08 00:21:59 +02:00
arch_tinygoriscv64.go runtime: reuse common code between 32 and 64-bit RISC-V 2020-07-08 00:21:59 +02:00
arch_tinygowasm.go compiler, runtime: add layout parameter to runtime.alloc 2021-11-02 22:16:15 +01:00
arch_xtensa.go esp32: implement task based scheduler 2020-12-05 09:02:11 +01:00
baremetal.go compiler, runtime: add layout parameter to runtime.alloc 2021-11-02 22:16:15 +01:00
chan.go compiler, runtime: add layout parameter to runtime.alloc 2021-11-02 22:16:15 +01:00
complex.go compiler: implement complex division 2019-05-11 15:33:37 +02:00
cond.go runtime: add cheap atomic condition variable 2020-10-14 13:35:00 +02:00
cond_nosched.go runtime: add cheap atomic condition variable 2020-10-14 13:35:00 +02:00
defer.go compiler: avoid function pointers in defer calls 2018-12-09 16:44:37 +01:00
dynamic_arm64.go nintendoswitch: Add env parser and removed unused stuff 2020-11-03 23:28:55 +01:00
error.go extend stdlib to allow import of more packages (#1099) 2020-06-23 11:56:28 +02:00
extern.go Add runtime stubs required for net/http 2021-06-01 15:15:12 +02:00
float.go compiler: implement complex division 2019-05-11 15:33:37 +02:00
func.go compiler: decouple func lowering from interface type codes 2021-04-12 12:07:42 +02:00
gc_386.S 386: bump minimum requirement to the Pentium 4 2021-08-10 20:08:27 +02:00
gc_amd64.S internal/task, runtime: add subsections_via_symbols to assembly files on darwin 2021-09-07 08:00:11 +02:00
gc_arm.S runtime: move/refactor some GC-related code 2020-10-02 08:54:43 +02:00
gc_arm64.S gc: use raw stack access whenever possible 2020-10-02 08:54:43 +02:00
gc_avr.S runtime: move/refactor some GC-related code 2020-10-02 08:54:43 +02:00
gc_conservative.go compiler, runtime: add layout parameter to runtime.alloc 2021-11-02 22:16:15 +01:00
gc_extalloc.go compiler, runtime: add layout parameter to runtime.alloc 2021-11-02 22:16:15 +01:00
gc_globals_conservative.go wasi: remove wasm build tag 2021-06-22 09:03:23 +02:00
gc_globals_precise.go wasi: remove wasm build tag 2021-06-22 09:03:23 +02:00
gc_leaking.go compiler, runtime: add layout parameter to runtime.alloc 2021-11-02 22:16:15 +01:00
gc_none.go compiler, runtime: add layout parameter to runtime.alloc 2021-11-02 22:16:15 +01:00
gc_riscv.S runtime: move/refactor some GC-related code 2020-10-02 08:54:43 +02:00
gc_stack_portable.go wasi: remove wasm build tag 2021-06-22 09:03:23 +02:00
gc_stack_raw.go wasi: remove wasm build tag 2021-06-22 09:03:23 +02:00
hashmap.go compiler, runtime: add layout parameter to runtime.alloc 2021-11-02 22:16:15 +01:00
hosted.go runtime (gc): do not scan the runqueue when the platform is not baremetal with a scheduler 2020-07-04 08:34:39 +02:00
interface.go compiler: simplify interface lowering 2021-10-31 14:17:25 +01:00
mstats.go runtime: expose memory stats 2021-06-10 22:03:00 +02:00
nonhosted.go runtime: only initialize os.runtime_args when needed 2021-11-05 08:50:36 +01:00
os_darwin.go runtime: fix time base for time.Now() 2021-07-20 22:19:13 +02:00
os_freebsd.go Add initial FreeBSD support 2019-12-29 10:48:28 +01:00
os_js.go Add runtime.GOOS 2018-08-30 05:48:16 +02:00
os_linux.go runtime: fix time base for time.Now() 2021-07-20 22:19:13 +02:00
panic.go compiler: properly implement div and rem operations 2021-10-28 15:55:02 +02:00
poll.go runtime: remove ctx param from stub code 2019-01-14 20:56:42 +01:00
print.go all: drop support for LLVM 10 2021-10-31 10:44:17 +01:00
runtime.go runtime: only initialize os.runtime_args when needed 2021-11-05 08:50:36 +01:00
runtime_arm7tdmi.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_atmega.go machine: define Serial as the default output 2021-05-13 16:43:37 +02:00
runtime_atsamd21.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_atsamd21e18.go machine/sam: Refactor all machine/runtime code to use new volatile package/API 2019-05-19 19:53:11 +02:00
runtime_atsamd21g18.go machine/sam: Refactor all machine/runtime code to use new volatile package/API 2019-05-19 19:53:11 +02:00
runtime_atsamd51.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_atsamd51g19.go runtime/atsamd51x: use PCHCTRL_GCLK_SERCOMX_SLOW for setting clocks on all SERCOM ports 2020-08-30 09:27:17 +02:00
runtime_atsamd51j19.go runtime/atsamd51x: use PCHCTRL_GCLK_SERCOMX_SLOW for setting clocks on all SERCOM ports 2020-08-30 09:27:17 +02:00
runtime_atsamd51j20.go runtime/atsamd51x: use PCHCTRL_GCLK_SERCOMX_SLOW for setting clocks on all SERCOM ports 2020-08-30 09:27:17 +02:00
runtime_atsamd51p19.go runtime/atsamd51x: use PCHCTRL_GCLK_SERCOMX_SLOW for setting clocks on all SERCOM ports 2020-08-30 09:27:17 +02:00
runtime_atsamd51p20.go Add board support for Adafruit Grand Central M4 (SAMD51) (#1714) 2021-03-15 14:06:09 +01:00
runtime_atsame5x_can.go atsame5x: add support for CAN 2021-05-10 12:27:10 +02:00
runtime_atsame51j19.go atsame51: add initial support for feather-m4-can 2021-04-16 17:49:46 +02:00
runtime_atsame54p20.go atsame54: add initial support for atsame54-xpro 2021-04-15 15:43:37 +02:00
runtime_attiny.go attiny: remove dummy UART 2021-03-10 22:28:58 +01:00
runtime_avr.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_cortexm.go Implement custom abort and fault handler for debugging 2020-07-08 21:58:15 +02:00
runtime_cortexm_abort.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_cortexm_hardfault.go add better fault identification for Cortex-M3/M33/M4/M7 hardfault handlers, add fault description registers to SCB_Type 2020-11-11 18:34:47 +01:00
runtime_cortexm_hardfault_debug.go add better fault identification for Cortex-M3/M33/M4/M7 hardfault handlers, add fault description registers to SCB_Type 2020-11-11 18:34:47 +01:00
runtime_cortexm_qemu.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_esp32.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_esp32c3.go add support for CPU interrupts for ESP32-C3 2021-10-23 03:31:37 +02:00
runtime_esp32xx.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_esp8266.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_fe310.go transform: refactor interrupt lowering 2021-11-06 09:40:15 +01:00
runtime_fe310_baremetal.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_fe310_qemu.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_k210.go transform: refactor interrupt lowering 2021-11-06 09:40:15 +01:00
runtime_k210_baremetal.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_mimxrt1062.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_mimxrt1062_clock.go teensy40: refactor to remove unnecessary code and constants 2020-11-11 18:34:47 +01:00
runtime_mimxrt1062_mpu.go teensy40: refactor to remove unnecessary code and constants 2020-11-11 18:34:47 +01:00
runtime_mimxrt1062_time.go teensy40: refactor to remove unnecessary code and constants 2020-11-11 18:34:47 +01:00
runtime_nintendoswitch.go runtime: remove the asyncScheduler constant 2021-05-08 23:08:12 +02:00
runtime_nintendoswitch.s nintendoswitch: Add env parser and removed unused stuff 2020-11-03 23:28:55 +01:00
runtime_nrf.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_nrf_bare.go nrf: call sd_app_evt_wait when the SoftDevice is enabled 2020-08-24 22:46:21 +02:00
runtime_nrf_softdevice.go nrf: avoid heap allocation in waitForEvent 2021-05-30 20:56:01 +02:00
runtime_nxpmk66f18.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_rp2040.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_stm32.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_stm32_timers.go stm32: Use TIM for runtime clock 2021-05-28 00:02:46 +02:00
runtime_stm32f7x2.go stm32: Use TIM for runtime clock 2021-05-28 00:02:46 +02:00
runtime_stm32f103.go stm32: Use TIM for runtime clock 2021-05-28 00:02:46 +02:00
runtime_stm32f405.go stm32: Use TIM for runtime clock 2021-05-28 00:02:46 +02:00
runtime_stm32f407.go stm32: Use TIM for runtime clock 2021-05-28 00:02:46 +02:00
runtime_stm32l0.go machine: define Serial as the default output 2021-05-13 16:43:37 +02:00
runtime_stm32l0x1.go stm32: Use TIM for runtime clock 2021-05-28 00:02:46 +02:00
runtime_stm32l0x2.go stm32: Use TIM for runtime clock 2021-05-28 00:02:46 +02:00
runtime_stm32l4x2.go stm32: Use TIM for runtime clock 2021-05-28 00:02:46 +02:00
runtime_stm32l5x2.go stm32: Use TIM for runtime clock 2021-05-28 00:02:46 +02:00
runtime_tinygoriscv.go maixbit (uart): serial is working with echo example 2020-07-08 00:21:59 +02:00
runtime_tinygoriscv64.go maixbit (uart): serial is working with echo example 2020-07-08 00:21:59 +02:00
runtime_tinygoriscv_qemu.go qemu: signal correct exit code to QEMU 2021-10-06 09:04:06 +02:00
runtime_tinygowasm.go runtime: fix time base for time.Now() 2021-07-20 22:19:13 +02:00
runtime_unix.go runtime: only initialize os.runtime_args when needed 2021-11-05 08:50:36 +01:00
runtime_unix_heap.go unix: check for mmap error and act accordingly 2021-09-15 17:06:21 +02:00
runtime_unix_noheap.go support WASI target (#1373) 2020-09-29 21:58:03 +02:00
runtime_wasm_js.go baremetal,wasm: support command line params and environment variables 2021-08-12 21:19:24 +02:00
runtime_wasm_wasi.go runtime: only initialize os.runtime_args when needed 2021-11-05 08:50:36 +01:00
scheduler.go scheduler: task.Data made 64bit to avoid overflow 2021-06-01 15:00:07 +02:00
scheduler_any.go runtime: make channels work in interrupts 2020-07-04 08:34:39 +02:00
scheduler_coroutines.go refactor coroutine lowering and tasks 2020-03-17 12:16:10 +01:00
scheduler_none.go runtime: make channels work in interrupts 2020-07-04 08:34:39 +02:00
scheduler_tasks.go runtime, internal/task: refactor to simplify stack switching 2020-12-05 09:02:11 +01:00
slice.go compiler, runtime: add layout parameter to runtime.alloc 2021-11-02 22:16:15 +01:00
stack.go extend stdlib to allow import of more packages (#1099) 2020-06-23 11:56:28 +02:00
string.go compiler, runtime: add layout parameter to runtime.alloc 2021-11-02 22:16:15 +01:00
symtab.go Add runtime stubs required for net/http 2021-06-01 15:15:12 +02:00
sync.go all: basic support for the os package 2018-09-16 13:01:03 +02:00
time_nxpmk66f18.go Viable NXP/Teensy support 2020-07-08 21:58:15 +02:00
wait_other.go runtime: make channels work in interrupts 2020-07-04 08:34:39 +02:00