Che cosa significa quando il codice "viene eseguito" su .NET CLR?

1

.NET CLR non è un interprete, poiché il codice viene compilato in codice nativo dal compilatore JIT. Quindi trovo la solita descrizione del codice "in esecuzione" sul CLR che confonde.

In che modo il codice nativo interagisce con il CLR? Il compilatore inserisce le chiamate nei metodi CLR all'inizio e alla fine dei tuoi metodi, ad esempio?

Non ne ho idea.

    
posta willem 24.06.2014 - 18:20
fonte

1 risposta

2

C'è una decente panoramica del Runtime Common Language di .NET su MSDN . Ci sono alcuni paragrafi chiave che potrebbero farti iniziare a capire il processo:

The common language runtime provides the infrastructure that enables managed execution to take place and services that can be used during execution. Before a method can be run, it must be compiled to processor-specific code. Each method for which MSIL has been generated is JIT-compiled when it is called for the first time, and then run. The next time the method is run, the existing JIT-compiled native code is run. The process of JIT-compiling and then running the code is repeated until execution is complete.

During execution, managed code receives services such as garbage collection, security, interoperability with unmanaged code, cross-language debugging support, and enhanced deployment and versioning support.

In Microsoft Windows XP and Windows Vista, the operating system loader checks for managed modules by examining a bit in the COFF header. The bit being set denotes a managed module. If the loader detects managed modules, it loads mscoree.dll, and _CorValidateImage and _CorImageUnloading notify the loader when the managed module images are loaded and unloaded. _CorValidateImage performs the following actions:

  1. Ensures that the code is valid managed code.

  2. Changes the entry point in the image to an entry point in the runtime.

    
risposta data 25.06.2014 - 01:43
fonte

Leggi altre domande sui tag