1.9 - [Intro.execution] - [General. Execution]

xiaoxiao2021-03-06  130

Please don't reprint this article; please don't re-publish this article in any form; please delete it within 24 hours of downloading this article; it is forbidden to use this article for commercial purposes.

1 General [intro] 1.9 Program execution [intro.execution] 1 General [1.9] General [General program execution.] Execute The semantic descriptions in this International Standard define a parameterized nondeterministic abstract machine. This International Standard places no requirement on the structure of conforming implementations. in particular, they need not copy or emulate the structure of the abstract machine. Rather, conforming implementations are required to emulate (only) the observable behavior of the abstract machine as explained below.5) semantics described in this international standard In, a parameterized, unknown abstract machine is defined. This international standard does not set any constraints for internal structures that meet the standard. The implementation does not need to copy or simulate the structure of this abstract machine, which requires analog (only) (only) observable behavior of abstract machines. 5) Certain aspects and operations of the abstract machine are described in this International Standard as implementation-defined (for example, sizeof (int)). These constitute the parameters of the abstract machine. Each implementation shall include documentation describing its characteristics and behavior in these respects. such documentation shall define the instance of the abstract machine that corresponds to that implementation (referred to as the "corresponding instance" below). this international standard virtual machine and the performance of certain operations are described as implementation-defined (e.g., sizeof INT). These have formed the implementation parameters of the virtual machine. Each implementation should provide document description to their specific features and behavior. The implementation of the documentation should be defined as an instance of the virtual machine corresponding to the implementation ("Correspondence Instance" as follows).

Certain other aspects and operations of the abstract machine are described in this International Standard as unspecified (for example, order of evaluation of arguments to a function). Where possible, this International Standard defines a set of allowable behaviors. These define the nondeterministic aspects of The Abstract Machine. ABSTRACT MACHINE. An Instance of the Abstract Machine Can Thus Have More Than One Possible Execution Sequence for A Given Program and a Given Input. This international standard describes other performance and operations of the virtual machine as unmetuted (such as function parameters). Aspiration order). This international standard defines a group of adopted behaviors in a possible situation. This defines the performance of the non-deterministic of the abstract machine. For a known procedure and known data, an instance of a virtual machine will generate less than one possible execution sequence due to its non-determination performance. Certain other operations are described in this International Standard as undefined (for example, the effect of dereferencing the null pointer) [Note:. This International Standard imposes no requirements on the behavior of programs that contain undefined behavior]. Other operations are present International Standard Undefined (such as the consequences of the empty pointer solution). [Note: This international standard does not make any specification for the behavior of programs that contain undefined behavior. ] A conforming implementation executing a well-formed program shall produce the same observable behavior as one of the possible execution sequences of the corresponding instance of the abstract machine with the same program and the same input. However, if any such execution sequence contains an undefined operation, this International standard places no requirement on the implementation executing that program with that input (not even with regard to operations preceding the first undefined operation). when a standard procedure implemented execute a good form in line, which produces observable The behavior should correspond to the abstract machine corresponding example of the implementation of the same program and one of the possible execution sequences generated by the same output. Despite this, if there is an undefined behavior in this execution sequence, the international standard still does not make any specification for the implementation of this program of this input data (excluding the operation before the first undefined operation).

The Observable Behavior of the Abstract Machine Is Its Sequence of Reads and Writes To Volatile Data and Calls To Library I / O Functions.6) Observer Abstract Machine is its read and write and the library I / O function on Volatile data Calling sequence. 6) Accessing an object designated by a volatile lvalue (3.10), modifying an object, calling a library I / O function, or calling a function that does any of those operations are all side effects, which are changes in the state of the execution environment. Evaluation of an expression might produce side effects. At certain specified points in the execution sequence called sequence points, all side effects of previous evaluations shall be complete and no side effects of subsequent evaluations shall have taken place.7) to access a standard For the object of the Volatile Left value (3.10), change an object, call the I / O library function, or call a function containing any functions containing any such operations, has side effects, and side effects change the status of the execution environment. The evaluation of the expression may bring side effects. In certain points of certain sequences known as the sequence point, all the side effects brought by all the previous evaluations must have been completed, and the side effects of the subsequent execution sequence have not occurred yet. 7) Once The Execution Of A Function BEGINS, NO Expressions from the calling function is the called function HAS completed.8) Once one is started to be executed, the expression in any caller function must wait until After the modulation is completed. 8) When the processing of the abstract machine is interrupted by receipt of a signal, the value of objects with type other than volatile sig_atomic_t are unspecified, and the value of any object not of volatile sig_atomic_t that is modified by the handler becomes undefined. When Execution of the abstract machine When interrupted by the signal, any type of object other than the Volatile Sig_atomic_T is not specified. The value of any type of object except Volatile Sig_atomic_T is not specified by the signal processor change.

An instance of each object with automatic storage duration (3.7.2) is associated with each entry into its block. Such an object exists and retains its last-stored value during the execution of the block and while the block is suspended (by a call Each object instance having an automatic storage period (3.7.2) is associated with the corresponding entry of its statement block. This object will always exist during the execution of the block and when the block is suspended, and always maintain its nearest saved value. The least requirements on a conforming implementation are:. At sequence points, volatile objects are stable in the sense that previous evaluations are complete and subsequent evaluations have not yet occurred At program termination, all data written into files shall be identical to one of the possible results that execution of the program according to the abstract semantics would have produced. The input and output dynamics of interactive devices shall take place in such a fashion that prompting messages actually appear prior to a program waiting for input. What constitutes an interactive device is implementation -defined. [NOTE: More Stringent Correspondences Between Abstract and actual semantics may be defined by Each Implementation.] for the minimum requirements of the standard implementation:

In the sequence point, the value before the Volatile object should have been completed, and the evaluation after it should have not happened, that is, this Volatile object should be stable. When the program terminates, all the data written to the file should be combined with the abstract semantic to perform one of all possible results that can be made by this program. The dynamic behavior of the interactive device performs input and output should be characterized by outputting the prompt information before the program is waiting for input. The actual composition of the interactive device is defined by implementation. [Note: Abstract and actual semantics more stringent correspondence may be defined by each implementation. ] A full-expression is an expression that is not a subexpression of another expression. If a language construct is defined to produce an implicit call of a function, a use of the language construct is considered to be an expression for the purposes of this definition The expression of sub-expression in other expressions is a complete expression. If the definition of a language implicitly creates a call to a function, the use case constituted by this language is considered to meet the definition of this standard. [Note:. Certain contexts in C cause the evaluation of a full-expression that results from a syntactic construct other than expression (5.18) For example, in 8.5 one syntax for initializer is (expression-list) but the resulting construct is a function call upon a constructor function with expression-list as an argument list;. such a function call is a full-expression for example, in 8.5, another syntax for initializer is = initializer-clausebut again the resulting construct might be a function call upon a Constructor Function With Assignment; Again, The Function Call IS A ful-expression.] [Note: The specific context of C will result in a full expression of the execution of the syntax constitutes a syntax that is not an expression (5.18). . For example, the syntax of one of the initializers in Section 8.5 is (Expression - list) but the composition it produces may be a function called to a constructor, a function called expression - list as a parameter list; this function call is one Complete expression. For example, the syntax of another initializer in Section 8.5 is = initializer-clause, but it is still possible to be a call to a constructor, with an assignment-expression as a parameter; this function call is still It is a complete expression.

] [Note:. The evaluation of a full-expression can include the evaluation of subexpressions that are not lexically part of the full-expression For example, subexpressions involved in evaluating default argument expressions (8.3.6) are considered to be created in the Expression That Calls The Function, NOT The Expression That Defines The Default Argument.] [Note: The evaluation of the full expression may contain the value of the sub-expression that is not a part of the intact expression of the lexical. For example, a sub-expression involved in the default parameter expression is created in the expression of the call function, not the expression of the default parameter.

] [Note: operators can be regrouped according to the usual mathematical rules only where the operators really are associative or commutative.9) For example, in the following fragment int a, b; /*...*/ a = a 32760 B 5; The Expression Statement Behaves EXACTLY THE SAME AS A = (((A 32760) B) 5); Due To The Associative and Precedency of these Operators. Thus, The Result of the Sum (A 32760 ) is next added to b, and that result is then added to 5 which results in the value assigned to a. On a machine in which overflows produce an exception and in which the range of values ​​representable by an int is [-32768, 32767], The importation cannot REWRITE This Expression As A = ((A B) 32765; Since if The VALUES for A and B WERE, RESPECTIELY, -32754 and -15, The Sum A B Would Produce An Exception While The Original Expression Would Not; NOR CAN The Expression Be Rewritten Either AS A = ((A 32765) B); OR A = (A (B 32765)); Since The VALUES for A and B might have been, respectively, 4 and -8 or -17 and 12. However on a machine in which overflows do not produce an exception and in which the results of overflows are reversible, the above expression statement can be rewritten by the implementation in any Of The Above Ways Because The Same Result Will Occur.] [Note: Reissant in accordance with mathematical management rules only when the operator really has a combination or exchange. 9) For example, int a, b; /*...*/ a = a 32760 b 5 is in the following segment; the expression statement actually appears as a = according to the combination and priority of the operator. (A 32760) B) 5); thereby, and (A 32760) results are then added to B, and then the result value is assigned to A.

If a machine is abnormal on the overflow, and its INT value range is [-32768, 32767], the implementation on which the expression cannot be pressed by A = ((A B) 23765); rewriting, Since the values ​​of A and B are -32754 and -15, the sum of A B will cause an exception, and the original expression is not; the expression cannot be pressed by A = ((A 32765) b); or A = (A (B 32765)); rewriting, because the values ​​of A and B are 4 and -8, or -17 and 12, respectively. However, in an overflow does not produce an abnormality, and the resulting result reversible machine, the above-described expression statement can be rewritten in any way in the above, as they produce the same result. ] There is a sequence point at the completion of evression of evression10). Each complete expression is completed by a sequence point 10). When calling a function (whether or not the function is inline), there is a sequence point after the evaluation of all function arguments (if any) which takes place before execution of any expressions or statements in the function body. There is also a sequence . point after the copying of a returned value and before the execution of any expressions outside the function11) Several contexts in C cause evaluation of a function call, even though no corresponding function call syntax appears in the translation unit [Example:. evaluation of a new expression invokes one or more allocation and constructor functions;. see 5.3.4 For another example, invocation of a conversion function (12.3.2) can arise in contexts in which no function call syntax appears] The sequence points at function-entry. And Function-Exit (As Described Above) Are Features of the Function Calls As Evaluated, WHATEVER THE SYNTAX OF The Expression That Calls The Function Might BE. When a function is called (regardless of the function inline), all function parameters (if there is The evaluation is a preface List points and appear before any expressions or statements in the function body. There is also a sequence point 11 after the replication return value is executed and the function other than the function is executed. In some C context, even if there is no items corresponding to it in the translation unit, the execution of the function call is also caused.

[Example: The evaluation of the NEW expression will perform at least one storage allocation and constructor; see 5.3.4. For example, the context that does not include a function call syntax may result in the execution of type conversion functions (12.3.2). 】 Regardless of the expression syntax of the calling function, the sequence points of the function portions and function outlets (as described above) are characteristics when the function call is evaluated. In The Evaluation of Each of The Expressions A & I || B A? B: C A, Busing The Built-in Meaning of The Operators in There Expresss (5.14, 5.15, 5.16, 5.18), There is a sequence point THE EVALAN OF THE FIREST Expression12). For expression A && B A | B A? B: C A, B uses the built-in significance of the operator (5.14, 5.15, 5.16, 5.18), where the first After the expression is evaluated, it is a sequence point. 12) 5) This provision is sometimes called the "as-if" rule, because an implementation is free to disregard any requirement of this International Standard as long as the result is as if the requirement had been obeyed, as far as can be determined from the observable behavior of the program. For instance, an actual implementation need not evaluate part of an expression if it can deduce that its value is not used and that no side effects affecting the observable behavior of the program are produced. 5) of this clause It is often referred to as the principle of "seemingly" because as long as the results of the achievement can be considered to comply with the specifications of the international standard by investigation, it can be free to ignore any specifications. For example, if a particular implementation can derive a certain value of a part of the expression is not used, and this part of the expression is not affected by the observable behavior generated by the program, this implementation does not need to Part of the expression is evaluated. 6) An Implementation CAN Offer Additional Library. Implementation That Do So SHOULD TREAT CALLS THOSE FUNSE SHOULD TREAT CALLS THOSE FUNSE SOSE "OBSERVABLE BEHAVIOR" AS Well. 6) Implementation can provide additional I / O library function as an extension, implementation The call to these functions should also be regarded as "observable behavior".

7) Note that some aspects of sequencing in the abstract machine are unspecified; the preceding restriction upon side effects applies to that particular execution sequence in which the actual code is generated Also note that when a call to a library I / O function returns,. THE SIDE EFFECT IS CONSIDETE, EVEN THOUGH SOTERNAL ACTIONS IMPLIED BY THE CALL (SUCH AS I / O Itself) May Not Have completed yet. 7) Note that in some cases the order of abstract machine execution is not specified; Restrictions on side effects apply to the execution sequences that generate actual code. Also, when returning from the I / O library function, even if some external actions executed by this function (such as hardware I / O action itself) have not completed, the side effects of this function call is still considered to be completed. 8) In Other Words, Function Executions Do Not Interleave with each other. 8) That is, the execution of the function will not cross each other. 9) Overloaded Operators Are Never Assumed to Be Associative or Commutative. 9) The overloaded operator does not have a combination or exchange. 10) As specified in 12.2, after the "end-of-full-expression" sequence point, a sequence of zero or more invocations of destructor functions for temporary objects takes place, usually in reverse order of the construction of each temporary object. 10 ) The sequence of zero or more temporary object calls is performed in the order of the "Complete Expression end" in 12.2. 11) The sequence point at the function return is not explicitly specified in ISO C, and can be considered redundant with sequence points at full-expressions, but the extra clarity is important in C . In C , there are more ways in which a called Function Can Terminate ITS Expection, Such As The Throw of an Expression. 11) The function returned to the sequence point is not explicitly specified by ISO C, and is redundant in the sequence point of the full expression, but in C is clarified Very important. In C , there is more ways to terminate execution, such as throw an expression.

转载请注明原文地址:https://www.9cbs.com/read-98962.html

New Post(0)