Live-structure analysis for logic programming lang

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

Live-structureAnalysisforLogicProgrammingLanguageswithDeclarationsMauriceBruynoogheGerdaJanssensAndreasKagedalReportCW231,May1996DepartmentofComputingScience,K.U.LeuvenAbstractLive-structureanalysisaddressestheproblemofmemoryreuseforlogicprogramsthroughprogramanalysisratherthanbyrun-timegarbagecollection.Thepresentpaperfocusesonpurelogicprogramswithdeclarationsofmodes,types,anddeterminism.TheanalysisisbasedonpreviousworkforpurePrologbutintroducesimportantinnovations.First,thelivenessanalysisisextendedtoconsidernotonlyforwardlivenessbutalsobackwardliveness(i.e.,duringbacktrackingbytheprogram).Thisallowsustoidentifythecallswithexclusiveaccesstosomepartsofthedata-structures.Second,theeciencyoftheanalysisisreachednotonlybyexploitingtheinformationprovidedbythedeclarations,butalsobysplittingtheanalysisinagoal-independentandagoal-dependentphase(asproposedbyCodishetal.).Keywords:Programanalysis,AbstractInterpretation,LogicProgramswithDeclarations,Liveness.Live-structureAnalysisforLogicProgrammingLanguageswithDeclarationsMauriceBruynoogheyGerdaJanssenszAndreasKagedalxMay6,1996AbstractLive-structureanalysisaddressestheproblemofmemoryreuseforlogicprogramsthroughprogramanalysisratherthanbyrun-timegarbagecollection.Thepresentpaperfocusesonpurelogicprogramswithdeclarationsofmodes,types,andde-terminism.TheanalysisisbasedonpreviousworkforpurePrologbutintroducesimportantinnovations.First,thelivenessanalysisisextendedtoconsidernotonlyforwardlivenessbutalsobackwardliveness(i.e.,duringbacktrackingbythepro-gram).Thisallowsustoidentifythecallswithexclusiveaccesstosomepartsofthedata-structures.Second,theeciencyoftheanalysisisreachednotonlybyexploit-ingtheinformationprovidedbythedeclarations,butalsobysplittingtheanalysisinagoal-independentandagoal-dependentphase(asproposedbyCodishetal.).Keywords:Programanalysis,AbstractInterpretation,LogicProgramswithDecla-rations,Liveness.1IntroductionInimperativelanguagessuchasCorPascal,theprogrammerexplicitlyrecyclesobsoletememorythroughdestructiveassignments.Declarative(functionalandlogic)languagesintheirpureformdonothavedestructiveassignment.Standardimplementationsusecomponentsofexistingdatastructurestocreatenewones,andkeeptheoldstructurealwaysintact,althoughtheremaybenosubsequentreferencestotheoldstructure.Creatinganewdatastructureinsteadofreusingtheobsoleteoneisnotonlymoreexpensiveinmemoryusagebutalsooftenintime(alleldsneedtobeinitialised,whileonlyafewneedanupdate).Run-timegarbagecollection,activatedtorecoverthedeaddatastructures,furtherincreasesthetimeoverhead.Thepurposeoflive-structureanal-ysisistoderiveateachprogrampointwhichstructurescanhaveasubsequentreferenceafterperformingthenextinstruction.Ifastructurehasnosuchreferences,thenthenextinstructioncanfreelyusethememoryoccupiedbythestructureandcanrecognisethatsomeofitspartsbecomedead.Contactperson:GerdaJanssens,KatholiekeUniversiteitLeuven,Dept.ComputerScience,Celestij-nenlaan200A,B-3001Heverlee,Belgium.Phone+32(0)16327634,Fax+32(0)16327996.ySupportedbytheNationalFundforScienticResearch.e-mail:maurice@cs.kuleuven.ac.be.zSupportedbytheNationalFundforScienticResearch.e-mail:gerda@cs.kuleuven.ac.be.xSupportedbyEC,projectHCMABILE(CHRX-CT94-0624).e-mail:aka@ida.liu.se.1In[15],suchananalysishasbeendevelopedforpureProlog.Theanalysisisratherexpensive.Inarstphase,integratedtypes,typeinformationintegratedwithmodeinformation[11],havetobederived.Alsotheactuallivenessanalysisisrathercomplex,partlybecausetheintegratedtypesdierfromprogrampointtoprogrampoint,andconsequently,theinformationaboutpossiblesharingofmemorycellshastobeadaptedfromprogrampointtoprogrampoint.Recently,thepointofviewthatlogicprogramminglanguagesshouldoermorere-dundancy[2]tobeacceptablefromasoftwareengineeringpointofviewhasbeenmorewidelyaccepted.Godel[10]isatypedlanguage,modesanddirectionaltypes[1,16]havealsoreceivedmoreattention.Mercury[5,17]isalanguagewheredeclarations|oftypes,modes,determinism|playaprominentrole.Thesedeclarationsallowthelan-guagetobemoredeclarativethanfullProlog,thecompilertocatchmoreerrors,andtheimplementationtohaveabetterperformance.Mercurypositionsitselfasanalternativetoimperativelanguages,whilestillallowingtoprogramatahigherlevel.Tocompetewithlanguageshavingdestructiveassignment,Mercuryneedstobeabletorecogniseandreusedeadstructures.AlsohereMercuryreliesondeclarations:uniquenesspropertiescanbedeclared.Typescertainlyprovidedeclarativeproperties;thepropertiesdescribedbymodesanddeterminismdeclarationsareratherprocedural,butstillatahighlevelofabstraction.Themodesspecifyforwhichcallsthedenitionisprocedurallywellbehav-ing,andthedeterminismisspecifyingsomethingabouttheclauseselectionandaboutthepossibilityoffailure.Thisismuchlesstruefortheuniquenesspropertieswhicharerelatedtotheuseofmemory,alevelofdetailwhichistypicallyhiddenfromtheprogrammerinlogicandfunctionallanguages.Inthecurrentpaperwedevelopananalysiswhichderiveslivenesspropertiesofpurelogicprogramsaugmentedwithtypes,modesanddeterminismdeclarations.Theanalysiscanbeusedtogenerateorcheck(inthelattercas

1 / 21
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功