受控代碼
维库,知识与思想的自由文库
|
受控代碼(managed code)是來自微軟公司的術語,在中國大陸較多譯為托管代碼。受控代碼以CLI虛擬機執行,如微軟的.NET Framework共通語言執行平台,其它的CLI實作有Mono和DotGNU。
[编辑] 受控代碼的執行一般以較易為人所理解的程式語言來為受控代碼環境撰寫程式,具代表性的程式語言為C#、J#、C++或Visual Basic .NET。 執行代碼時,運行庫編譯器(runtime-aware compiler)在受控執行環境下,將中間語言(Intermediate Language)編譯成本機的機器碼。受控執行環境可為代碼插入垃圾回收、異常處理、類型安全、陣列邊界和索引檢查等,以保證代碼安全的執行。 這正是即時編譯(Just-in-time compilation)的手法。不同的是,檔案中除了保存假機器碼,同時也可包含提供給不同機器(如x86和PowerPC)的已編譯執行碼。類似於蘋果的通用執行碼格式的概念。 [编辑] 受控代碼和非受控代碼在微軟Windows環境下,所有不屬於受控代碼的,就被認為是非受控代碼。在非微軟Windows和混合環境下,受控代碼有時汎化為用來指任何解譯式程式語言。 Managed refers to a method of exchanging information between the program and the runtime environment. It is specified that at any point of execution, the runtime may stop an executing CPU and retrieve information specific to the current CPU instruction address. Information that must be accessible generally pertains to runtime state, such as processor register or stack memory contents. The necessary information is then encoded in Common Intermediate Language (formerly known as Microsoft Intermediate Language) and associated metadata. [编辑] 參閱[编辑] 外部連結 |


