Hardware Reference
In-Depth Information
Pitfall Designing A “High-level” Instruction Set Feature Specifically Oriented To
Supporting A High-level Language Structure.
Atempts to incorporate high-level language features in the instruction set have led architects
to provide powerful instructions with a wide range of flexibility. However, often these instruc-
tions do more work than is required in the frequent case, or they don't exactly match the re-
quirements of some languages. Many such efforts have been aimed at eliminating what in the
is was called the semantic gap . Although the idea is to supplement the instruction set with
additions that bring the hardware up to the level of the language, the additions can generate
what Wulf, Levin, and Harbison [1981] have called a semantic clash:
… by giving too much semantic content to the instruction, the computer designer made it pos-
sible to use the instruction only in limited contexts. [p. 43]
More often the instructions are simply overkill—they are too general for the most frequent
case, resulting in unneeded work and a slower instruction. Again, the VAX CALLS is a good ex-
ample. CALLS uses a callee save strategy (the registers to be saved are specified by the callee),
but the saving is done by the call instruction in the caller. The CALLS instruction begins with the
arguments pushed on the stack, and then takes the following steps:
1. Align the stack if needed.
2. Push the argument count on the stack.
3. Save the registers indicated by the procedure call mask on the stack (as mentioned in Sec-
tion A.8 ). The mask is kept in the called procedure's code—this permits the callee to spe-
cify the registers to be saved by the caller even with separate compilation.
4. Push the return address on the stack, and then push the top and base of stack pointers (for
the activation record).
5. Clear the condition codes, which sets the trap enable to a known state.
6. Push a word for status information and a zero word on the stack.
7. Update the two stack pointers.
8. Branch to the first instruction of the procedure.
The vast majority of calls in real programs do not require this amount of overhead. Most
procedures know their argument counts, and a much faster linkage convention can be estab-
lished using registers to pass arguments rather than the stack in memory. Furthermore, the
CALLS instruction forces two registers to be used for linkage, while many languages require only
one linkage register. Many atempts to support procedure call and activation stack manage-
ment have failed to be useful, either because they do not match the language needs or because
they are too general and hence too expensive to use.
The VAX designers provided a simpler instruction, JSB , that is much faster since it only
pushes the return PC on the stack and jumps to the procedure. However, most VAX compilers
use the more costly CALLS instructions. The call instructions were included in the architecture to
standardize the procedure linkage convention. Other computers have standardized their call-
ing convention by agreement among compiler writers and without requiring the overhead of
a complex, very general procedure call instruction.
Search WWH ::




Custom Search