[an error occurred while processing this directive]
HP OpenVMS Systems Documentation |
HP OpenVMS Calling Standard
3.5.3.4 LIB$GET_INVO_HANDLEA thread can obtain an invocation handle corresponding to any invocation context block by using the following function format:
Argument:
Function Value Returned:
3.5.3.5 LIB$GET_PREV_INVO_HANDLEA thread can obtain an invocation handle of the procedure context preceding that of a specified procedure context by using the following function format:
Argument:
Function Value Returned:
3.5.3.6 LIB$PUT_INVO_REGISTERSA given procedure invocation context's fields can be updated with new register contents by calling a system library function in following format:
Arguments:
Function Value Returned:
3.6 Transfer of ControlThis standard states that a standard call (see Section 1.4) may be accomplished in any way that presents the called routine with the required environment. However, typically, most standard-conforming external calls are implemented with a common sequence of instructions and conventions. Because a common set of call conventions is so pervasive, these conventions are included for reference as part of this standard.
One important feature of the calling standard is that the same
instruction sequence can be used to call each of the different types of
procedure. Specifically, the caller does not have to know which type of
procedure is being called.
The call conventions describe the rules and methods used to communicate certain information between the caller and the called procedure during invocation and return. For a standard call, these conventions include the following:
3.6.2 Linkage SectionBecause the Alpha hardware architecture has the property of instructions that cannot contain full virtual addresses, it is sometimes referred to as a base register architecture. In a base register architecture, normal memory references within a limited range from a given address are expressed by using displacements relative to the contents of a register containing that address (base register). Base registers for external program segments, either data or code, are usually loaded indirectly through a program segment of address constants. The fundamental program section containing address constants that a procedure uses to access other static storage, external procedures, and variables is termed a linkage section. Any register used to access the contents of the linkage section is termed a linkage pointer. A procedure's linkage section includes the procedure descriptor for the procedure, addresses of all external variables and procedures referenced by the procedure, and other constants a compiler may choose to reference using a linkage pointer. When a standard procedure is called, the caller must provide the procedure value for that procedure in R27. Static procedure values are defined to be the address of the procedure's descriptor. Because the procedure descriptor is part of the linkage section, calling this type of procedure value provides a pointer into the linkage section for that procedure in R27. This linkage pointer can then be used by the called procedure as a base register to address locations in its linkage section. For this reason, most compilers generate references to items in the linkage section as offsets from a pointer to the procedure's descriptor. Compilers usually arrange (as part of the environment setup) to have the environment setup code (for bound procedures) load R27 with the address of the procedure's descriptor so it can be used as a linkage pointer as previously described. For an example, see Section 3.6.4. Although not required, linkages to external procedures are typically represented in the calling procedure's linkage section as a linkage pair. As shown in Figure 3-11 and described in Table 3-8, a linkage pair (LKP) block with two fields should be octaword aligned and defined by LKP$K_SIZE as 16 bytes. Figure 3-11 Linkage Pair Block Format
In general, an object module contains a procedure descriptor for each entry point in the module. The descriptors are allocated in a linkage section. For each external procedure Q that is referenced in a module, the module's linkage section also contains a linkage pair denoting Q (which is a pointer to Q's procedure descriptor and entry code address). The following code example calls an external procedure Q as represented by a linkage pair. In this example, R4 is the register that currently contains the address of the current procedure's descriptor.
Because Q's procedure descriptor (statically defined procedure value)
is in Q's linkage section, Q can use the value in R27 as a base address
for accessing data in its linkage section. Q accesses external
procedures and data in other program sections through pointers in its
linkage section. Therefore, R27 serves as the root pointer through
which all data can be referenced.
Most calls are made to a fixed address whose value is determined by the time the program starts execution. However, certain cases are possible that cause the exact address to be unknown until the code is finally executed. In this case, the procedure value representing the procedure to be called is computed in a register. The following code example illustrates a call to a computed procedure value (simple or bound) that is contained in R4:
For interoperation with translated images, see Chapter 5
There are two distinct classes of procedures:
A simple procedure is a procedure that does not need direct access to the stack of its execution environment. A bound procedure is a procedure that does need direct access to the stack of its execution environment, typically to reference an up-level variable or to perform a nonlocal GOTO operation. Both a simple procedure and a bound procedure have an associated procedure descriptor, as described in previous sections. When a bound procedure is called, the caller must pass some kind of pointer to the called code that allows it to reference its up-level environment. Typically, this pointer is the frame pointer for that environment, but many variations are possible. When the caller is executing its program within that outer environment, it can usually make such a call directly to the code for the nested procedure without recourse to any additional procedure descriptors. However, when a procedure value for the nested procedure must be passed outside of that environment to a call site that has no knowledge of the target procedure, a bound procedure descriptor is created so that the nested procedure can be called just like a simple procedure.
Bound procedure values, as defined by this standard, are designed for
multilanguage use and utilize the properties of procedure descriptors
to allow callers of procedures to use common code to call both bound
and simple procedures.
Bound procedure descriptors provide a mechanism to interpose special processing between a call and the called routine without modifying either. The descriptor may contain (or reference) data used as part of that processing. Between native and translated images, the OpenVMS Alpha operating system uses linker and image-activator created bound procedure descriptors to mediate the handling of parameter and result passing (see Section 5.2). Language processors on OpenVMS Alpha systems use bound procedure descriptors to implement bound procedure values (see Section 3.6.4.2). Other uses are possible. The minimum size of the descriptor is 24 bytes (defined by PDSC$K_MIN_BOUND_SIZE). An optional PDSC extension in 8-byte increments provides the specific environment values as defined by the implementation. The fields defined in the bound procedure descriptor are illustrated in Figure 3-12 and described in Table 3-9. Figure 3-12 Bound Procedure Descriptor (PDSC)
|