Discussion Series (2) - Global Analysis

zhaozj2021-02-11  200

The following article translated from Ian Joyner "C ?? a critique of C and program" 3 / e [Ian Joyner 1996] The original copyright belongs to Ian Joyner, and I am from the consent of Ian Joyner himself. This article is translated into Chinese. Therefore, the Chinese version of this article should belong to me ;-) The English and Chinese versions of this article are used for non-commercial purposes, you can copy and post it at will. However, it is best to add the previous declaration in front of the repost. If someone or agency wants to publish this article, please contact the original copyright owner and me.

In addition, this article has been included in the book "Objects Unencapsulated" written in Ian Joyner (there is already a translation version of Japanese), which is described in: http://www.prenhall.com/allbooks /PTR_0130142697.htmlhttp://efsa.sourceforge.net/cgi-bin/view/main/ObjectsuNCapsulatedHttp://www.accu.org/Bookreviews/public/reviews/O/O002284.htm

Ian Joyner Contact: I.Joyner@acm.org My Contact: cber@email.com.cn

Translator's preface: If you want to completely master a language, you need to know what it is, but also know what it is in the shortcomings. This way we can use this language to avoid some traps in the language to better use this language to serve our work. This article of Ian Joyner and the book herself "Objects Unencapsulated", fully demonstrates some of the deficiencies of C , we should fully learn from the great work he has completed, better understand C , thus Write more secure C code.

Discussion Series (2)

Global analysis

[P & S 94] mentioned that there are two assumptions for type safety detection. One is a hypothesis in a closed environment. At this time, the individuals in the program can be determined during the compilation period, and then we can detect the entire program. The other is assumption in an open environment, at which point detection of types is performed in a separate module. For actual development and establishment of prototype, the second hypothesis is very effective. However, in [P & S 94], it is mentioned that "When a completed software product reaches maturity, the hypothesis can be considered, because this can make some more advanced compilation technology With the use of martial arts. Only when the entire program is understood, we can implement action on the top of the global register allocation, program process analysis, and invalid code detection. "(With: [P & S 94] Jens Palsberg and One of Michael I. Schwartzbach, Object-Oriented Type Systems, Wiley 1994) is: For program analysis, the compiler (hypothesis work in an open environment) and linker (depending on very limited closed Analysis in the environment) is opened. There are two aspects of the enclosed environment or global analytics: First, it guarantees the consistency of the assembly system; secondly, it reducs the burden of programmers by providing automatic optimization. The main burden of programmers can be reduced is: Designing the programmer of the parent class no longer needs (have to be) by using the virtual function's modification ingredients (Virtual) to assist the compiler set up VTABLE. As we mentioned in the Virtual Function, this will affect the elasticity of the software. VTABLE should not be built when a separate class is compiled, it is best to be established when it is assembled throughout the system. When the system is assembled (link) period, the compiler and the linker can synergist, you can fully determine if a function needs to have a place in VTABLE. In addition to the above, programmers can also freely use some local invisible information defined in other modules; and programmers no longer need to maintain the exist of the header file. In Eiffel and Object Pascal, global analysis is applied to the entire system, which determines the true polymorphism function call, and constructs the desired VTABLE. In Eiffel, these are done by the compiler. In Object Pascal, Apple extends the functionality of the linker so that it has the ability to global analysis. Such global analysis is difficult to be implemented in the C / UNX environment, so in C , it has not been included in the C , making the burden to the programmer. In order to remove this burden from the programmer, we should built the global analysis to be built into the linker. However, since the version of C is implemented as a CFRONT preprocessor, any necessary changes made to the linker cannot be guaranteed. The original implementation version of C looks like a patchwork thing, full of vulnerabilities. [Translator believes that it is too much. :)] C design is strictly limited to its implementation technology, not other (for example, no good programming language design principle), because it requires a new compiler And the linker. That is, the current C develops are strictly limited by their original test-based products. I am now confident that this technical dependency (ie, C depends on earlier C) severely damages C , making it not a full-meaning-oriented high-level language.

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

New Post(0)