Орташа тіл (CIL): CLI спецификациясындағы бірыңғай код жинағы. .NET қолданбаларын жасау үшін CIL-ге компиляцияланатын тілдер, JIT арқылы жергілікті кодқа аударылады.
Ағылшыншамен салыстырыңыз: абзацты басыңыз — түпнұсқа терезеде ашылады. Абзац астындағы EN түймесі оны мәтін ішінде көрсетеді.
Мазмұны
Кіріспе
CLI ерекшеліктерінде анықталған аралық өрнек Common Intermediate Language (CIL), бұрын Microsoft Intermediate Language (MSIL) немесе Intermediate Language (IL) деп аталған, Common Language Infrastructure (CLI) ерекшеліктерінде анықталған аралық тілдің екілік нұсқаулар жиынтығы болып табылады. CIL нұсқаулары CIL-ге үйлесімді орындалу ортасында, мысалы Common Language Runtime-та орындалады. CLI-ге бағытталған тілдер CIL-ге компиляцияланады. CIL – объектіге бағытталған, стекке негізделген байт-код. Орындалу уақыты CIL нұсқауларын әдетте жергілікті кодқа компиляциялайды. CIL бастапқыда .NET тілдерінің бета нұсқалары кезінде Microsoft Intermediate Language (MSIL) деп белгілі болды. C# және CLI стандартталуының нәтижесінде байт-код енді ресми түрде CIL деп аталады. Windows Defender вирустық анықтамалары одан құрастырылған бинарлық файлдарды әлі де MSIL деп атайды.
Intermediate representation defined within the CLI specification
Common Intermediate Language (CIL), formerly called Microsoft Intermediate Language (MSIL) or Intermediate Language (IL), is the intermediate language binary instruction set defined within the Common Language Infrastructure (CLI) specification. CIL instructions are executed by a CIL compatible runtime environment such as the Common Language Runtime. Languages which target the CLI compile to CIL. CIL is object oriented, stack based bytecode. Runtimes typically just in time compile CIL instructions into native code. CIL was originally known as Microsoft Intermediate Language (MSIL) during the beta releases of the NET languages. Due to standardization of C# and the CLI, the bytecode is now officially known as CIL. Windows Defender virus definitions continue to refer to binaries compiled with it as MSIL.
Метадеректер
Жалпы тілдік инфрақұрылым (CLI) компиляцияланған кластар туралы ақпаратты метадеректер түрінде сақтайды. Компоненттік объект моделіндегі типтік кітапхана сияқты, бұл қосымшаларға құрастырудағы интерфейстерді, сыныптарды, типтерді, әдістерді және өрістерді қолдауға және анықтауға мүмкіндік береді. Мұндай метадеректерді оқу процесі "рефлексия" деп аталады. Метадеректер "атрибуттар" түріндегі деректер болып табылады. Атрибуттарды Attribute класын кеңейту арқылы өзгертуге болады. Бұл қуатты мүмкіндік. Ол сыныпты жасаушыға оны қосымша ақпаратпен толықтыруға мүмкіндік береді, оны сыныпты пайдаланушылар қолдану саласына байланысты әртүрлі мағыналы тәсілдермен пайдалана алады.
The Common Language Infrastructure (CLI) records information about compiled classes as metadata. Like the type library in the Component Object Model, this enables applications to support and discover the interfaces, classes, types, methods, and fields in the assembly. The process of reading such metadata is called "reflection". Metadata can be data in the form of "attributes". Attributes can be customized by extending the Attribute class. This is a powerful feature. It allows the creator of the class the ability to adorn it with extra information that consumers of the class can use in various meaningful ways, depending on the application domain.
Ұрпақ
CIL құрастыруы мен нұсқауларын компилятор немесе орындау ортасымен бірге келетін IL Assembler (ILAsm) деп аталатын қосымша құрал жасайды. Құрастырылған CIL кодын IL-дизассемблер (ILDASM) арқылы қайтадан кодқа айналдыруға болады. CIL кодын жоғары деңгейлі тілге (мысалы, C# немесе Visual Basic) түрлендіре алатын NET Reflector сияқты басқа да құралдар бар. Бұл CIL-ді кері инженерия үшін өте қолайлы нысанаға айналдырады. Бұл қасиет Java байт-кодымен ортақ. Дегенмен, кодты жасыра алатын, оны оқуды қиындататын, бірақ орындауға мүмкіндік беретін құралдар да бар.
A CIL assembly and instructions are generated by either a compiler or a utility called the IL Assembler (ILAsm) that is shipped with the execution environment. Assembled CIL can also be disassembled into code again using the IL Disassembler (ILDASM). There are other tools such as NET Reflector that can decompile CIL into a high level language (e. g. C# or Visual Basic). This makes CIL a very easy target for reverse engineering. This trait is shared with Java bytecode. However, there are tools that can obfuscate the code, and do it so that the code cannot be easily readable but still be runnable.
Уақытша жинақтау
Тек уақытында компиляция (JIT) байт-кодты CPU тікелей орындай алатын кодқа түрлендіруді қамтиды. Түрлендіру бағдарлама жұмыс істеп тұрғанда кезең-кезеңімен жүзеге асырылады. JIT компиляциясы ортаға қатысты оптимизацияны, орындалу кезіндегі типтік қауіпсіздікті және құрастырудың дұрыстығын тексеруді қамтамасыз етеді. Осы мақсатта JIT компиляторы құрастыру метадеректерін заңсыз қолжетімділіктерге тексеріп, олардың бұзылуын тиісті түрде өңдейді.
Just in time compilation (JIT) involves turning the byte code into code immediately executable by the CPU. The conversion is performed gradually during the program's execution. JIT compilation provides environment specific optimization, runtime type safety, and assembly verification. To accomplish this, the JIT compiler examines the assembly metadata for any illegal accesses and handles violations appropriately.
Уақытша жинақтау
CLI-мен үйлесімді орындау орталары құрастырудың алдын ала компиляциясын (AOT) жасау мүмкіндігімен де келеді, бұл JIT процесін орындау кезінде жою арқылы орындалу жылдамдығын арттырады. .NET Framework-те AOT-ны жүзеге асыратын Native Image Generator (NGEN) деп аталатын арнайы құрал бар. CoreRT – AOT-қа қатысты тағы бір тәсіл, ол Net Core кодын орындау уақытына тәуелділіксіз, жалғыз орындалатын файлға компиляциялауға мүмкіндік береді. Mono-да AOT жасау опциясы бар.
CLI compatible execution environments also come with the option to do an Ahead of time compilation (AOT) of an assembly to make it execute faster by removing the JIT process at runtime. In the NET Framework there is a special tool called the Native Image Generator (NGEN) that performs the AOT. A different approach for AOT is CoreRT that allows the compilation of Net Core code to a single executable with no dependency on a runtime. In Mono there is also an option to do an AOT.