欢迎来到天天文库
浏览记录
ID:51326893
大小:281.00 KB
页数:54页
时间:2020-03-22
《东南大学 编译原理 教学教案 Cp7.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Chapter7RuntimeEnvironmentsZhaiYuqingZhouXiaoyuProgramvsProgramExecutionAnexecutionofaprogramiscalledasaprocess.Aprogramconsistsofseveralprocedures(functions).Anexecutionofaprogramwouldcausetheactivationoftherelatedprocedures.AllocationandDe-allocationofDataObjectsAname(e.g
2、,avariablename)inaprocedurewouldberelatedtodifferentdataobjects.Anactivationmaymanipulatedataobjectsallocatedforitsuse.BindingsofNamesWhenanenvironmentassociatesstoragelocationswithanamex,wesaythatxisboundtos;theassociationitselfisreferredtoasabindingofx.Abindingisthedynamic
3、counterpartofadeclaration.DataObjectEveneachnameisdeclaredonceinaprogram,thesamenamemaydenotedifferentobjectsatruntime.The“dataobject”correspondstoastoragelocationthatcanholdvalues.EnvironmentandStateInprogramminglanguagesemantics,theterm“environment”referstoafunctionthatmap
4、sanametoastoragelocation,andterm“state”referstoafunctionthatmapsastoragelocationtothevalueheldthere.EnvironmentandStateenvironmentstatenamestoragevalueEnvironmentandStateAnassignmentchangesthestate,butnottheenvironment.AllocationandDe-allocationofDataObjectsManagedbytherun-t
5、imesupportpackage.Therepresentationofadataobjectatruntimeisdeterminedbyitstype.Ifxisnotofabasictype,thestoragesforxmaybeacollectionofmemorywords.FactorsthatDeterminestheRunTimeEnvironmentofaProgramRecursivecallofprocedures.Localnamestoragespaceallocationstrategy.globalnamest
6、oragespaceallocationstrategy.Parameterpassingmechanism.FactorsthatDeterminestheRunTimeEnvironmentofaProgramwhetherafunctionisallowedtobeaparameteroforreturnvalueofafunction.SubdivisionofRuntimeMemoryTypicalsubdivisionofruntimememoryintocodeanddataareascodeStaticdatastackheap
7、Thegeneratedtargetcode;Dataobjects;Acounterpartofthecontrolstacktokeeptrackofprocedureactivations;StorageAllocationStrategiesStorageAllocationStrategiesStaticallocation.Laysoutstorageforalldataobjectsatcompiletime.Stackallocation.Managestherun-timestorageasastack.Heapallocat
8、ion.Allocatesandde-allocatesstorageasneededatruntimefromaheap.RestrictionsG
此文档下载收益归作者所有