Artificial Intelligence Programming Lab(AIPLab) 討論區

Please login or register.

請輸入帳號, 密碼以及預計登入時間



作者 主題: [期末報告]-Escape analysis->95441050  (閱讀 27558 次)


  • Newbie
  • *
  • 文章: 1
    • 檢視個人資料
[期末報告]-Escape analysis->95441050
« 於: 一月 07, 2009, 12:27:37 am »
資工3C 95441050 魏振原

第三類Compiler issues
Escape analysis

In programming language compiler optimization theory, escape analysis is a method for determining the dynamic scope of pointers. It is related to pointer analysis and shape analysis.

When a variable (or an object) is allocated in a subroutine, a pointer to the variable can escape to other threads of execution, or to calling subroutines. If a subroutine allocates an object and returns a pointer to it, the object can be accessed from undetermined places in the program — the pointer has "escaped". Pointers can also escape if they are stored in global variables or other data structures that, in turn, escape the current procedure.

Escape analysis determines all the places where a pointer can be stored and whether the lifetime of the pointer can be proven to be restricted only to the current procedure and/or thread.

A compiler can use the results of escape analysis as basis for optimizations:
Converting heap allocations to stack allocations. If an object is allocated in a subroutine, and a pointer to the object never escapes, the object may be a candidate for stack allocation instead of heap allocation.
Synchronization elision. If an object is found to be accessible from one thread only, operations on the object can be performed without synchronization.
Breaking up objects or scalar replacement. An object may be found to be accessed in ways that do not require the object to exist as a sequential memory structure. This may allow parts (or all) of the object to be stored in CPU registers instead of in memory.

Practical considerations
In object-oriented programming languages dynamic compilers are particularly good candidates for performing escape analysis. In traditional static compilation method overriding can make escape analysis impossible, as any called method might be overridden by a version that allows a pointer to escape. Dynamic compilers can perform escape analysis using the available information on overloading, and re-do the analysis when relevant methods are overridden by dynamic code loading.

Escape analysis has been a target of interest in particular due to the Java programming language. Java's combination of heap-only object allocation, built-in threading, and the Sun HotSpot dynamic compiler creates a candidate platform for escape analysis related optimizations (see Escape analysis in Java). Escape analysis is implemented in Java Standard Edition 6.


Pascal是種高階的程式語言,由瑞士蘇黎士理工學院的尼古拉斯·沃斯(Niklaus Wirth)教授於1960年末期所設計,ISO對Pascal進行修改以後,形成了標準Pascal語言。

Pascal語言還是一種自編譯的語言,這就使它的可靠性大大提高了。在Pascal的各個版本中,經典編譯器中尤以Turbo Pascal的功能最為強大,在當今普遍認為Free Pascal的功能更加強大。


它最初是為系統地教授程序設計而設計的,特點是簡明化和結構化,適合教學科學計算與系統軟體的研製。如今,在許多學校的計算機語言課上,學的都是Pascal語言,用的都是Turbo Pascal。至今,Pascal還是國際信息學奧林匹克競賽中最受歡迎的程式語言之一。


美國Borland公司于1983年推出了Turbo Pascal編譯器。其後發展了Object Pascal,作為其Delphi開發工具的開發語言。 Kylix是Borland公司Pascal產品的新成員,支持Delphi和C/C++,運行於Linux。

Free Pascal [1] 原名 FPK Pascal,是一個 32 bit 的 Pascal 編譯器(現在亦可執行於64-bit的系統),採用GNU通用公共許可證,可運行於多個平臺,支持 Delphi 的語法。它是用 Pascal 寫成的。包含Turbo Pascal、Delphi等的兼容模式。是中國現在信息學奧林匹克競賽中的Windows下推薦編譯器之一。
GNU Pascal Compiler (GPC)是GNU Compiler Collection (GCC)的一員,用C寫成。
P4 compiler

很多人認為Pascal不適合開發大程式。在八十年代,Pascal非常流行,許多重要的程式如Apple Lisa和Macintosh,都使用Pascal開發。Brian Kernighan,C編程語言的發明者之一,在他的文章「Why Pascal Is Not My Favorite Programming Language」(「為什麼Pascal不是我最喜愛的程式語言」)批評了當時Pascal的種種缺點。 事實上,隨著Pascal的不斷發展,他的論點已經不能符合現在的Pascal編譯器。
« 最後編輯時間: 一月 09, 2009, 03:46:04 am 由 wei81 »


  • 管理員
  • Hero Member
  • *****
  • 文章: 1897
    • 檢視個人資料
回覆: [期末報告]-Escape analysis->95441050
« 回覆文章 #1 於: 一月 15, 2009, 02:28:58 pm »

SimplePortal Classic 2.0.5