Monday, November 23, 2026

SPARC V9 Register Windows

Introduction

One of the key features of the SPARC Instruction Set Architecture (ISA) is its use of register windows. This mechanism enables efficient parameter passing between functions, provided that the call chain does not become too deep. The idea is to pass data directly through fast registers, avoiding the need to store it on the stack in slower memory.

The SPARC architecture supports between 2 and 32 register windows, although a typical implementation provides 8. Each window consists of 8 in registers, 8 local registers, and 8 out registers. The register windows are arranged in a circular structure, wrapping around when the end is reached. With 8 register windows, the hardware can allocate up to 6 additional windows for nested function calls before exhausting the available register space and triggering a window overflow trap.

As of November 2026, when this article is being written, register windows are widely regarded as an obsolete design whose performance advantages are less compelling on modern hardware. This article examines the performance benefits and trade-offs of SPARC's register-window architecture and evaluates how they compare with the approaches adopted by more recent ISAs.

Register Windows and Parameter Passing

Before exploring the technical details of register windows, it is worth taking a brief detour to introduce the general-purpose registers in the SPARC V9 architecture.

During function execution, the following general-purpose registers are typically available:

  • 8 global registers (g0 to g7).
  • 8 in registers (i0 to i7). These overlap with the out registers from the previous window. The i0 to i5 are used as incoming integer arguments in a function. The i6 is used as a frame pointer. The i7 is used for the return address.
  • 8 local registers (l0 to l7). These are used for local variables and temporary values.
  • 8 out registers (o0 to o7). These overlap with the in registers from the next window. The o0 to o5 are used as outgoing integer arguments to a function. The o6 is used as a stack pointer. The o7 is used for the call instruction address.

In addition to the general-purpose registers, privileged system software can access the privileged register window state registers:

  • CWP - Current Window Pointer register. This indicates which register windows is currently active.
  • CANSAVE - Number of savable windows register. This indicates the number of register windows following CWP that are not in used and can be allocated by a save instruction without causing a window spill trap.
  • CANRESTORE - Number of restorable windows register. This indicates the number of register windows preceding CWP that are in use by the current program and can be restored by a restore instruction without causing a window fill trap.
  • CLEANWIN, OTHERWIN, WSTATE - Additional register window state registers, details of which are not relevant for now.

The diagram below illustrates the organisation of register windows:

The following details should be noted:

  • There are 8 register windows: 0 to 7. The CWP register indicates which register window is currently active.
  • Within each register window, the in and out registers overlap with those of adjacent register windows.
  • Register windows are organised in a circular arrangement, with the out registers of window 7 overlapping the in registers of window 0.
  • The local registers are unique to each register window and are not shared with any other window.
  • The out registers of one register window serve as the in registers of the next window.

A non-leaf SPARC V9 function has the following structure:

function_name:
  save %sp, -176, %sp
  ...
  ret
   restore

The save instruction creates a new stack frame by adjusting the sp (stack pointer) register while simultaneously allocating a new register window by incrementing the CWP register.

The restore instruction restores the previous register window by decrementing the CWP register. It is placed in the delay slot and completes execution before the ret instruction.

As function calls become nested, additional register windows are allocated until the windows wrap around, causing previously allocated windows to be spilled to stack memory. For example, if the processor has a total of 8 register windows and register window 0 is allocated to the currently executing function, up to 6 additional windows (1 to 6) can be allocated. Register window 7 cannot be allocated because it overlaps with previously allocated register window 0.

The first six integer arguments (ignoring floating-point arguments for now) passed to a function are placed in registers o0 to o5. Any additional arguments are passed on the stack. When the function executes save instruction, the register window is moved forward and the current out registers become function's in registers. This is how integer arguments are passed to non-leaf functions. Leaf functions, however, can use a special optimisation to avoid executing save and restore instructions. This optimisation is beyond the scope of this article.

Spill and Fill Traps

Deeply nested function calls can cause the register windows to wrap around. When this happens, previously allocated register windows must be spilled to the stack. A register window is spilled to the stack by storing its local and in registers to a previously reserved register window save area. This frees the register window for reuse by another function.

The reverse process occurs when deeply nested functions return to their callers. Previously spilled register windows must be restored from the stack. A register window is filled by loading its local and in registers from the corresponding register window save area. This restores the previously spilled register window, allowing the caller to resume execution with its original register values.

Register window spills and fills are triggered by hardware traps known as spill and fill traps. These traps are triggered by save and restore instructions when the CANSAVE or CANRESTORE register reaches zero, respectively.

Spill and fill traps are vectored to dedicated spill and fill trap handlers installed by the system software. The handlers are written in SPARC V9 assembly language and perform storing or loading of register window registers to and from the stack.

The diagram below illustrates the layout of a register window save area on the stack:

The following details should be noted:

  • The register window save area is preallocated on the stack by the save instruction, which updates the stack pointer (sp) register.
  • The SPARC V9 stack uses a bias of 2047 bytes. The register window save area therefore begins at sp+BIAS.
  • During register window spill and fill traps, the stack address is held in the sp register, which is an alias for the o6 register.

Let's examine how register windows behave in the following chain of nested function calls:
_start->main->f1->f2->f3->f4->f5->f6.

Ln  Function                  Register Window State Registers
---------------------------------------------------------------------------------------------
01  _start                    CWP   = 0,  CANSAVE   = 6,  CANRESTORE   = 0
02  _start:save               CWP++ = 1,  CANSAVE-- = 5,  CANRESTORE++ = 1
03    main                    CWP   = 1,  CANSAVE   = 5,  CANRESTORE   = 1
04    main:save               CWP++ = 2,  CANSAVE-- = 4,  CANRESTORE++ = 2
05      f1                    CWP   = 2,  CANSAVE   = 4,  CANRESTORE   = 2
06      f1:save               CWP++ = 3,  CANSAVE-- = 3,  CANRESTORE++ = 3
07        f2                  CWP   = 3,  CANSAVE   = 3,  CANRESTORE   = 3
08        f2:save             CWP++ = 4,  CANSAVE-- = 2,  CANRESTORE++ = 4
09          f3                CWP   = 4,  CANSAVE   = 2,  CANRESTORE   = 4
10          f3:save           CWP++ = 5,  CANSAVE-- = 1,  CANRESTORE++ = 5
11            f4              CWP   = 5,  CANSAVE   = 1,  CANRESTORE   = 5
12            f4:save         CWP++ = 6,  CANSAVE-- = 0,  CANRESTORE++ = 6
13              f5            CWP   = 6,  CANSAVE   = 0,  CANRESTORE   = 6
14              f5:save       Spill trap since CANSAVE = 0, spill window = CWP+2 = 6+2 = 0
                                          CANSAVE++ = 1,  CANRESTORE-- = 5
15              f5:save       CWP++ = 7,  CANSAVE   = 0,  CANRESTORE++ = 6
16                f6          CWP   = 7,  CANSAVE   = 0,  CANRESTORE   = 6
17                f6:save     Spill trap since CANSAVE = 0, spill window = CWP+2 = 7+2 = 1
                                          CANSAVE++ = 1,  CANRESTORE-- = 5
18                f6:save     CWP++ = 0,  CANSAVE   = 0,  CANRESTORE++ = 6
19                f6:restore  CWP-- = 7,  CANSAVE++ = 1,  CANRESTORE-- = 5
20              f5            CWP   = 7,  CANSAVE   = 1,  CANRESTORE   = 5
21              f5:restore    CWP-- = 6,  CANSAVE++ = 2,  CANRESTORE-- = 4
22            f4              CWP   = 6,  CANSAVE   = 2,  CANRESTORE   = 4
23            f4:restore      CWP-- = 5,  CANSAVE++ = 3,  CANRESTORE-- = 3
24          f3                CWP   = 5,  CANSAVE   = 3,  CANRESTORE   = 3
25          f3:restore        CWP-- = 4,  CANSAVE++ = 4,  CANRESTORE-- = 2
26        f2                  CWP   = 4,  CANSAVE   = 4,  CANRESTORE   = 2
27        f2:restore          CWP-- = 3,  CANSAVE++ = 5,  CANRESTORE-- = 1
28      f1                    CWP   = 3,  CANSAVE   = 5,  CANRESTORE   = 1
29      f1:restore            CWP-- = 2,  CANSAVE++ = 6,  CANRESTORE-- = 0
30    main                    CWP   = 2,  CANSAVE   = 6,  CANRESTORE   = 0
31    main:restore            Fill trap since CANRESTORE = 0, fill window = CWP-1 = 2-1 = 1
                                          CANSAVE-- = 5,  CANRESTORE++ = 1
32    main:restore            CWP-- = 1,  CANSAVE++ = 6,  CANRESTORE-- = 0


spill_trap_handler:
  ! Store %l0 to %l7 to stack
  ...
  ! Store %i0 to %i7 to stack
  ...
  saved    ! CANSAVE++, CANRESTORE--
  retry    ! Retry trapped save instruction. This restores original CWP from TSTATE[TL].


fill_trap_handler:
  ! Load %l0 to %l7 from stack
  ...
  ! Load %i0 to %i7 from stack
  ...
  restored ! CANSAVE--, CANRESTORE++
  retry    ! Retry trapped restore instruction. This restores original CWP from TSTATE[TL].

The following section provides a detailed, line-by-line breakdown of each function call:

01. The OpenBoot firmware loads the custom bootloader and transfers control to its _start() function. At this point, one register window is active (CWP=0), six additional register windows can be allocated without triggering a spill trap (CANSAVE=6), and no register windows can be restored (CANRESTORE=0), as no register windows have yet been spilled.

02. The _start() function executes the save instruction, allocating a new register window. This increments CWP, decrements CANSAVE, and increments CANRESTORE.

03. The _start() function calls main(). Upon entry to main(), the values of CWP, CANSAVE, and CANRESTORE remain unchanged.

04. The main() function executes the save instruction, allocating a new register window. This increments CWP, decrements CANSAVE, and increments CANRESTORE.

05-12. The same process is repeated for subsequent nested function calls, with each call allocating a new register window and updating CWP, CANSAVE, and CANRESTORE.

13. The f4() function calls f5(). Upon entry to f5(), the value of CANSAVE is zero, indicating that all available register windows have been allocated.

14. The f5() function executes the save instruction. Since CANSAVE is zero, this automatically triggers a spill trap, aborting the save instruction. Control is transferred to the spill trap handler, with CWP identifying the register window to be spilled. In this case, the target window is calculated as (CWP+2)%8=0. The spill trap handler saves the register window contents to the stack, then executes the saved instruction, which increments CANSAVE to 1 and decrements CANRESTORE to 5. Finally, it executes the retry instruction, which restores the original CWP from TSTATE[TL] and re-executes the previously aborted save instruction.

15. The f5() function re-executes the save instruction, allocating a new register window. This increments CWP, decrements CANSAVE to 0, and increments CANRESTORE to 6.

16. The f5() function calls f6(). Upon entry to f6(), the value of CANSAVE is zero, indicating that all available register windows have been allocated.

17. The f6() function executes the save instruction. Since CANSAVE is zero, this automatically triggers a spill trap, aborting the save instruction. Control is transferred to the spill trap handler, with CWP identifying the register window to be spilled. In this case, the target window is calculated as (CWP+2)%8=1. The spill trap handler saves the register window contents to the stack, then executes the saved instruction, which increments CANSAVE to 1 and decrements CANRESTORE to 5. Finally, it executes the retry instruction, which restores the original CWP from TSTATE[TL] and re-executes the previously aborted save instruction.

18. The f6() function re-executes the save instruction, allocating a new register window. This increments CWP, decrements CANSAVE to 0, and increments CANRESTORE to 6.

19. The f6() function is the last in the nested call chain. It executes the restore instruction just before returning, restoring the previous register window. This decrements CWP, increments CANSAVE, and decrements CANRESTORE.

20. Control is transfered back to f5(). Upon return to f5(), the register window is restored to its original state, with its registers retaining the values previously set by f5().

21-29. The same process is repeated for subsequent nested function returns, with each restore instruction restoring the previous register window and updating CWP, CANSAVE, and CANRESTORE..

30. The f1() function returns to main(). Upon return to main(), the value of CANRESTORE is zero, indicating that all previously saved register windows have been restored.

31. The main() function executes the restore instruction. Since CANRESTORE is zero, this automatically triggers a fill trap, aborting the restore instruction. Control is transferred to the fill trap handler, with CWP identifying the register window to be filled. In this case, the target window is calculated as (CWP-1)%8=1. The fill trap handler restores the register window contents from the stack, then executes the restored instruction, which decrements CANSAVE to 5 and increments CANRESTORE to 1. Finally, it executes the retry instruction, which restores the original CWP from TSTATE[TL] and re-executes the previously aborted restore instruction.

32. The main() function re-executes the restore instruction, restoring the previous register window. This decrements CWP, increments CANSAVE to 6, and decrements CANRESTORE to 0.

It is important to note that, when calculating the CWP, the arithmetic wraps around upon reaching the final window. For example, with 8 register windows (numbered 0 to 7), the calculation wraps from window 7 back to window 0.

Register Windows Design – Innovative or Misguided?

Whichever way you look at it, SPARC register windows are undeniably a clever solution to mitigating memory latency, albeit at the cost of increased design complexity. In my view, the design is not as flawed as some critics suggest. It achieves its intended goals, provided the software is structured to avoid deeply nested function calls that could trigger register window spill and fill traps.

At this point, it is worth summarising the advantages and disadvantages of SPARC register windows.

Advantages:

  • Efficient parameter passing between function calls, provided register window spill and fill traps are avoided.
  • A dedicated set of local registers for each function, reducing register pressure and mitigating the memory access latency associated with storing local variables on the stack.
  • Scalable design. The number of register windows can be increased from 8 to 24, or even 32 to improve performance when dealing with deeply nested function calls. This requires a change to the CPU's hardware microarchitecture but has little or no impact on existing software. Existing applications would continue to run without requiring redesign or recompilation.
  • Flexibility. Software is not required to use register windows. Hard real-time systems, where predictable execution latency is essential, can avoid register window spill and fill traps by adopting a custom ABI (Application Binary Interface) that uses a flat register address space. GCC, for example, supports the -mflat compiler option, which generates code without using the save and restore instructions.

Disadvantages:

  • Hardware and software complexity. The hardware must implement a large register file and maintain the state of the register windows. System software must also be aware of the register window architecture and provide dedicated trap handlers to manage register window spill and fill traps.
  • Increased latency during register window spill and fill traps. Executing spill and fill trap handlers introduces additional overhead, partly due to the need to save and restore a set of 16 registers to and from the stack. The compiler cannot dynamically optimise this process or eliminate unnecessary register transfers. For example, even if a function uses only a single argument, all 16 registers may still need to be spilled to or filled from the stack, including those that are unused and contain meaningless data.

Performance Evaluation

The rationale is quite simple: to compare function call latency across different CPU architectures and designs. There are a few important factors to consider to ensure that the test results are as accurate and reliable as possible.

Function call depth. One test should evaluate performance of parameter-passing in the absence of SPARC spill and fill traps. Another test should evaluate performance of parameter-passing in the presence of SPARC spill and fill traps. This is controlled by the function call depth, which is set to 4 and 16 nested function calls, respectively.

Number of parameters. We aim to avoid copying function parameters onto the stack, as this introduces additional latency and could skew the test results. The SPARC V9 ISA supports passing up to six integer parameters directly through registers; therefore, we use six parameters in our tests.

Register usage. We also aim to emulate a typical register usage pattern found in most non-trivial programs. This generally involves allocating values across a set of registers, moving the required values into the parameter-passing registers, and executing a nested function call. Upon returning from the function, the previously allocated values are reused in subsequent calculations.

CPU frequency normalisation. Different platforms use CPUs operating at different clock frequencies. To enable meaningful comparisons, the test results must therefore be normalised to a common reference clock frequency.

With a maximum nesting depth of 16 function calls, the resulting call chain is as follows:
fn01 -> fn02 -> fn03 -> . . . -> fn16

A nesting depth of 4 function calls is achieved as follows:
main -> fn13 -> . . . -> fn16

A nesting depth of 16 function calls is achieved as follows:
main -> fn01 -> . . . -> fn16

Each nested function has the following structure:

#include <stdint.h>
#include "fn.h"

__attribute__((noinline))
uint64_t fn01(uint64_t n1, uint64_t n2, uint64_t n3, uint64_t n4, uint64_t n5, uint64_t n6)
{
	n1 ^= fn02(n2, n1, n4, n3, n6, n5);
	n2 += n1;
	n3 ^= n2;
	n4 += n3;
	n5 ^= n4;
	n6 += n5;

	return n6;
}

The following details should be noted:

  • When invoking a nested function, each pair of adjacent parameters is swapped. This emulates the behaviour of non-trivial programs, in which parameter values are moved across registers before a nested function call.
  • When returning from a nested function, each of the previous parameters are reused in a new calculation. This emulates the register pressure that arises when allocating and maintaining local variables.

The main program has the following structure:

#include <assert.h>
#include <inttypes.h>
#include <stdio.h>
#include <time.h>

#include "fn.h"

/* Convert timespec to 64-bit microseconds value */
static inline uint64_t timespec_to_usec(const struct timespec *ts)
{
	return (ts->tv_sec * UINT64_C(1000000)) + (ts->tv_nsec / UINT64_C(1000));
}

int main(void)
{
	int             int_val;
	const uint32_t  nloop = 10000000;
	uint64_t        ret = 0, tdiff_usec;
	struct timespec ts1, ts2;

	/* Get start time */
	int_val = clock_gettime(CLOCK_MONOTONIC, &ts1);
	assert(int_val == 0);

	/* Call nested functions in a loop */
	for (uint32_t i = 0; i < nloop; i++)
	{
		/* Call depth of 4 */
		ret += fn13(1, 2, 3, 4, 5, 6);

		/* Call depth of 16 */
		/* ret += fn1(1, 2, 3, 4, 5, 6); */
	}

	/* Get end time */
	int_val = clock_gettime(CLOCK_MONOTONIC, &ts2);
	assert(int_val == 0);

	/* Calculate time difference */
	tdiff_usec = timespec_to_usec(&ts2) - timespec_to_usec(&ts1);
	printf("tdiff_usec = %"PRIu64"\n", tdiff_usec);

	return (int)ret;
}

The nested functions are invoked in a loop that executes 10 million iterations, and the total elapsed time is reported in microseconds.

The following GCC compiler commands were used to create test executables:

# Compile functions with save/restore instructions
gcc -O2 -Wall -pedantic -c \
  fn01.c fn02.c fn03.c fn04.c fn05.c fn06.c fn07.c fn08.c \
  fn09.c fn10.c fn11.c fn12.c fn13.c fn14.c fn15.c fn16.c &&
gcc -O2 -Wall -pedantic \
  -fno-tree-vectorize -fno-tree-loop-vectorize -fno-unroll-loops \
  -o call_depth_04 call_depth_04.c \
  fn01.o fn02.o fn03.o fn04.o fn05.o fn06.o fn07.o fn08.o \
  fn09.o fn10.o fn11.o fn12.o fn13.o fn14.o fn15.o fn16.o &&
gcc -O2 -Wall -pedantic \
  -fno-tree-vectorize -fno-tree-loop-vectorize -fno-unroll-loops \
  -o call_depth_16 call_depth_16.c \
  fn01.o fn02.o fn03.o fn04.o fn05.o fn06.o fn07.o fn08.o \
  fn09.o fn10.o fn11.o fn12.o fn13.o fn14.o fn15.o fn16.o

# Compile functions without save/restore instructions
gcc -O2 -Wall -pedantic -mflat -c \
  fn01.c fn02.c fn03.c fn04.c fn05.c fn06.c fn07.c fn08.c \
  fn09.c fn10.c fn11.c fn12.c fn13.c fn14.c fn15.c fn16.c &&
gcc -O2 -Wall -pedantic \
  -fno-tree-vectorize -fno-tree-loop-vectorize -fno-unroll-loops \
  -o call_depth_04.mflat call_depth_04.c \
  fn01.o fn02.o fn03.o fn04.o fn05.o fn06.o fn07.o fn08.o \
  fn09.o fn10.o fn11.o fn12.o fn13.o fn14.o fn15.o fn16.o &&
gcc -O2 -Wall -pedantic \
  -fno-tree-vectorize -fno-tree-loop-vectorize -fno-unroll-loops \
  -o call_depth_16.mflat call_depth_16.c \
  fn01.o fn02.o fn03.o fn04.o fn05.o fn06.o fn07.o fn08.o \
  fn09.o fn10.o fn11.o fn12.o fn13.o fn14.o fn15.o fn16.o

Performance was evaluated across the following platforms:

  • Raspberry Pi 4 with ARM Cortex-A72 CPU. The machine was running Linux, with all CPU cores operating at a fixed clock frequency of 1500 MHz.
  • Ultra 10 with UltraSPARC IIi. The machine was running NetBSD with CPU frequency of 440 MHz.
  • T2 with UltraSPARC T2. The machine was running Solaris with CPU frequency of 1415 MHz.
  • T4 with SPARC T4. The machine was running Solaris with CPU frequency of 2848 MHz.
  • S7 with SPARC S7. The machine was running Solaris with CPU frequency of 4267 MHz.

All test results were normalised to a reference clock frequency of 1 MHz. This approach ignores other factors such as memory latency and extrapolates the results as if all CPUs were operating at the same fixed clock frequency of 1 MHz. For example, if a test completed in T microseconds on a 100 MHz CPU, then the normalised result in seconds for 1 MHz clock frequency would be: (T_usec / 1,000,000) x 100 MHz. In other words, the test latency in seconds is assumed to be 100 times greater if the CPU were to be downclocked to 1 MHz.

The table below summarises the test results, including the CPU clock frequency, the measured latency in microseconds at the native frequency, and the normalised latency in seconds at a reference frequency of 1 MHz.

 Function call depth of 4
+-------------------------+-----------+-------------------+-------------------+
| CPU                     | CPU freq  | Latency (usec)    | Latency (sec)     |
|                         | in MHz    | (Native MHz freq) | (Norm 1 MHz freq) |
+=========================+===========+===================+===================+
| ARM Cortex-A72          | 1,500     | 314,388           | 472               |
+-------------------------+-----------+-------------------+-------------------+
| UltraSPARC IIi          | 440       | 959,104           | 422               |
| UltraSPARC IIi (-mflat) | 440       | 1,690,714         | 744               |
+-------------------------+-----------+-------------------+-------------------+
| UltraSPARC T2           | 1,415     | 1,024,836         | 1,450             |
| UltraSPARC T2 (-mflat)  | 1,415     | 1,685,019         | 2,384             |
+-------------------------+-----------+-------------------+-------------------+
| SPARC T4                | 2,848     | 108,974           | 310               |
| SPARC T4 (-mflat)       | 2,848     | 307,910           | 877               |
+-------------------------+-----------+-------------------+-------------------+
| SPARC S7                | 4,267     | 70,109            | 299               |
| SPARC S7 (-mflat)       | 4,267     | 203,267           | 867               |
+-------------------------+-----------+-------------------+-------------------+


 Function call depth of 16
+-------------------------+-----------+-------------------+-------------------+
| CPU                     | CPU freq  | Latency (usec)    | Latency (sec)     |
|                         | in MHz    | (Native MHz freq) | (Norm 1 MHz freq) |
+=========================+===========+===================+===================+
| ARM Cortex-A72          | 1,500     | 1,498,842         | 2,248             |
+-------------------------+-----------+-------------------+-------------------+
| UltraSPARC IIi          | 440       | 28,484,167        | 12,533            |
| UltraSPARC IIi (-mflat) | 440       | 10,272,791        | 4,520             |
+-------------------------+-----------+-------------------+-------------------+
| UltraSPARC T2           | 1,415     | 14,406,162        | 20,385            |
| UltraSPARC T2 (-mflat)  | 1,415     | 7,898,987         | 11,177            |
+-------------------------+-----------+-------------------+-------------------+
| SPARC T4                | 2,848     | 5,651,128         | 16,094            |
| SPARC T4 (-mflat)       | 2,848     | 1,285,177         | 3,660             |
+-------------------------+-----------+-------------------+-------------------+
| SPARC S7                | 4,267     | 3,756,298         | 16,028            |
| SPARC S7 (-mflat)       | 4,267     | 853,644           | 3,642             |
+-------------------------+-----------+-------------------+-------------------+

The -mflat test results show the latency without the register window spill and fill traps. The difference indicates the overhead associated with handling those traps.

The results can now be visualised using a set of graphs to facilitate comparison and analysis.

The graph below displays normalised test results obtained with a function call depth of 4. The following details are interesting to note:

  • No register window spill or fill traps occur during this test, allowing the SPARC hardware to operate under optimal conditions.
  • All SPARC V9 CPUs, with the exception of the UltraSPARC T2, outperform the AArch64 Cortex-A72, as they exhibit lower normalised latency.
  • Using the GCC -mflat compiler option results in significantly higher execution latency due to the additional memory accesses required to save and restore registers to and from the stack.
  • The UltraSPARC T2 exhibits the highest normalised latency and consequently the poorest performance. This is likely attributable primarily to its lower instructions-per-cycle (IPC) throughput, rather than to the overhead associated with register windows.

The graph below displays normalised test results obtained with a function call depth of 4. The following details are interesting to note:

  • This test triggers multiple register window spill and fill traps. As expected, the overhead associated with handling these traps introduces a significant increase in execution latency. Consequently, the SPARC V9 CPUs exhibit approximately 6-8 times higher latency than the AArch64 Cortex-A72.
  • Using the GCC -mflat compiler option results in significantly lower execution latency as this completely avoids save and restore instructions which trigger register window spill and fill traps.
  • Code generated using the -mflat compiler option still exhibits slightly higher execution latency than the AArch64 Cortex-A72. This is likely due to the need to maintain compatibility and interoperability with the SPARC V9 ABI. Adopting a custom ABI could remove some of these constraints and provide further opportunities for optimisation, potentially achieving lower execution latency.

Closing Remarks

SPARC V9 register windows represent an effective architectural design, offering excellent performance even when compared with more recent CPU architectures. However, this comes at the cost of increased hardware complexity and reduced performance when function call nesting exceeds the available register windows.

The traditional allocation of 8 register windows in many SPARC CPUs appears somewhat limited for modern software workloads. Increasing the number of register windows could improve performance without requiring most existing software to be recompiled.

A hybrid approach could also be adopted by introducing two distinct ABIs. Highly optimised system software could use an ABI based on register windows, while unprivileged user applications could use an alternative ABI with a flat register layout. With careful orchestration, both ABIs could potentially coexist and operate concurrently.