Ahead-of-time compilation - Wikipedia

文章推薦指數: 80 %
投票人數:10人

In computer science, ahead-of-time compilation (AOT compilation) is the act of compiling an (often) higher-level programming language into an (often) ... Ahead-of-timecompilation FromWikipedia,thefreeencyclopedia Jumptonavigation Jumptosearch Thisarticleincludesalistofgeneralreferences,butitremainslargelyunverifiedbecauseitlackssufficientcorrespondinginlinecitations.Pleasehelptoimprovethisarticlebyintroducingmoreprecisecitations.(February2014)(Learnhowandwhentoremovethistemplatemessage) Programexecution Generalconcepts Code Translation Compiler Compile-time Optimizingcompiler Intermediaterepresentation(IR) Execution Runtimesystem Runtime Executable Interpreter Virtualmachine Typesofcode Sourcecode Objectcode Bytecode Machinecode Microcode Compilationstrategies Just-in-time(JIT) Tracingjust-in-time Ahead-of-time(AOT) Transcompilation Recompilation Notableruntimes AndroidRuntime(ART) CommonLanguageRuntime(CLR)and Mono crt0 Javavirtualmachine(JVM) Objective-Cand Swift V8and Node.js CPythonand PyPy ZendEngine(PHP) Notablecompilers&toolchains GNUCompilerCollection(GCC) LLVMand Clang vte Incomputerscience,ahead-of-timecompilation(AOTcompilation)istheactofcompilingan(often)higher-levelprogramminglanguageintoan(often)lower-levellanguagebeforeexecutionofaprogram,usuallyatbuild-time,toreducetheamountofworkneededtobeperformedatruntime. Mostoften,Itisassociatedwiththeactofcompilingahigher-levelprogramminglanguagesuchasCorC++,oranintermediaterepresentationsuchasJavabytecodeor.NETFrameworkCommonIntermediateLanguage(CIL)code,intoanative(system-dependent)machinecodesothattheresultingbinaryfilecanexecutenatively,justlikeastandardnativecompiler.Whenbeingusedinthisspecificcontext,it'softenseenasanoppositeofjust-in-time(JIT)compiling. Speakingmoregenerally,thetargetlanguagesofanAOTcompilationarenotnecessarilyspecifictonativemachinecodebutaredefinedratherarbitrarily.SomeacademicpapersusethiswordtomeantheactofcompilingtheJavabytecodetoC[1]orthetimingwhenoptimizationpipelineareperformed.[2]Anacademicproject[3]usesthiswordtomeantheactofpre-compilingJavaScripttoamachine-dependentoptimizedIRforV8(JavaScriptengine)[4]andtoamachineindependentbytecodeforJavaScriptCore.[5]Someindustriallanguageimplementations(e.g.Closure[6]andHermesJavaScriptengine[7])usethiswordtomeantheactofpre-compilingthesourcelanguagetoVMspecificbytecode.Angular(webframework)usesthiswordtomeanconvertingitsHTMLtemplateandTypeScripttoJavaScript.[8] Infact,sinceallstaticcompilationaretechnicallyperformedaheadoftime,thisparticularwordingareoftenusedtoemphasizesomekindofperformanceadvantagesfromtheactofsuchpre-compiling.TheactofcompilingJavatoJavabytecodeishencerarelyreferredtoasAOTsinceit'susuallyarequirement,notanoptimization. Contents 1Reducedruntimeoverhead 2Performancetrade-offs 3Storagetrade-offs 4Seealso 5References 6Externallinks Reducedruntimeoverhead[edit] Someprogramminglanguageswithamanagedcoderuntimethatcanbecompiledtoanintermediaterepresentation,usejust-in-time(JIT)compiling.This,briefly,compilesintermediatecodeintomachinecodeforanativerunwhiletheintermediatecodeisexecuting,whichmayslowanapplication'sperformance.Ahead-of-timecompilingeliminatestheneedforthisstepbyoccurringbeforeexecutionratherthanduringexecution. Ahead-of-timecompilingfordynamicallytypedlanguagestonativemachinecodeorotherstaticVMbytecodeispossibleinalimitednumberofcasesonly.[citationneeded]Forexample,theHighPerformanceErlangProject(HiPE)AOTcompilerforthelanguageErlangcandothisbecauseofadvancedstatictypereconstructiontechniquesandtypespeculations. InmostsituationswithfullyAOTcompiledprogramsandlibraries,itispossibletodropausefulfractionofaruntimeenvironment,thussavingdiskspace,memory,batterylife,andstartuptimes(noJITwarmupphase),etc.Becauseofthis,itcanbeusefulinembeddedormobiledevices. Performancetrade-offs[edit] AOTcompilerscanperformcomplexandadvancedcodeoptimizations,whichinmostcasesofJITingwillbeconsideredmuchtoocostly.Incontrast,AOTusuallycannotperformsomeoptimizationspossibleinJIT,likeruntimeprofile-guidedoptimization(PGO),pseudo-constantpropagation,orindirect-virtualfunctioninlining.AOTmustcompiletoatargetarchitecture,whileaJITcancompilethecodetomakethebestuseoftheactualCPUitisrunningon,evenyearsafterthesoftwarehasbeenreleased. Further,JITcompilerscanspeculativelyoptimizehotcodebymakingassumptionsonthecode.Thegeneratedcodecanbedeoptimizedifaspeculativeassumptionlaterproveswrong.Suchoperationslowstheperformanceoftherunningsoftwareuntilcodeisoptimizedagainbyadaptiveoptimization.AnAOTcompilercannotmakesuchassumptionsandneedstoinferasmuchinformationaspossibleatcompiletime.Itneedstoresorttolessspecializedcodebecauseitcannotknowwhattypeswillgothroughamethod.Suchproblemscanbealleviatedbyprofile-guidedoptimizations.Buteveninthiscase,thegeneratedcodecannotbeadapteddynamicallytothechangingruntimeprofileasaJITcompilerwoulddo. Storagetrade-offs[edit] Thissectionneedsexpansion.Youcanhelpbyaddingtoit.(May2021) Seealso[edit] Computerprogrammingportal asm.jscompiler(JavaScript) Bartok(CIL) ExcelsiorJET(Java) GNUCompilerforJava IL2CPU(CIL) NativeImageGenerator(CIL) RubyMotion(Ruby) SharpOSAOT(CIL) References[edit] ^Jung,Dong-Heon;Park,JongKuk;Bae,Sung-Hwan;Lee,Jaemok;Moon,Soo-Mook(2006-10-22)."EfficientexceptionhandlinginJavabytecode-to-cahead-of-timecompilerforsmbeddedsystems".Proceedingsofthe6thACM&IEEEInternationalconferenceonEmbeddedsoftware.EMSOFT'06.Seoul,Korea:AssociationforComputingMachinery:188–194.doi:10.1145/1176887.1176915.ISBN 978-1-59593-542-7. ^Chambers,Craig(2002-01-14)."Stagedcompilation".Proceedingsofthe2002ACMSIGPLANworkshoponPartialevaluationandsemantics-basedprogrammanipulation.PEPM'02.Portland,Oregon:AssociationforComputingMachinery:1–8.doi:10.1145/503032.503045.ISBN 978-1-58113-455-1. ^Zhuykov,R.;Sharygin,E.(2017-01-01)."Ahead-of-timecompilationofJavaScriptprograms".ProgrammingandComputerSoftware.43(1):51–59.doi:10.1134/S036176881701008X.ISSN 1608-3261. ^ispras/v8-aotc,IvannikovInstituteforSystemProgrammingoftheRussianAcademyofSciences,2021-01-30,retrieved2021-03-17 ^ispras/webkit-aotc,IvannikovInstituteforSystemProgrammingoftheRussianAcademyofSciences,2021-01-30,retrieved2021-03-17 ^"Clojure-Ahead-of-timeCompilationandClassGeneration".clojure.org.Retrieved2021-03-17. ^"Hermes:AnewopensourceJavaScriptengineoptimizedformobileapps".FacebookEngineering.2019-07-12.Retrieved2021-03-17. ^"Angular".angular.io.Retrieved2021-03-17. Externallinks[edit] Speed:NGenRevsUpYourPerformancewithPowerfulNewFeatures–MSDNMagazine,April2005 MonoAOT ExcelsiorJET–CertifiedJavaSEImplementationwithAOTcompiler GNUCompilerforJava AOTcompilationofasm.js Real-timeJava,Part2:Comparingcompilationtechniques–IBMdeveloperWorks,April2007 ImprovingSwingPerformance:JITvsAOTCompilation–LinuxWorldMagazine,November2004 Manta Retrievedfrom"https://en.wikipedia.org/w/index.php?title=Ahead-of-time_compilation&oldid=1025605008" Categories:CompilersHiddencategories:Articleslackingin-textcitationsfromFebruary2014Allarticleslackingin-textcitationsAllarticleswithunsourcedstatementsArticleswithunsourcedstatementsfromFebruary2011ArticlestobeexpandedfromMay2021AllarticlestobeexpandedArticlesusingsmallmessageboxes Navigationmenu Personaltools NotloggedinTalkContributionsCreateaccountLogin Namespaces ArticleTalk Variants expanded collapsed Views ReadEditViewhistory More expanded collapsed Search Navigation MainpageContentsCurrenteventsRandomarticleAboutWikipediaContactusDonate Contribute HelpLearntoeditCommunityportalRecentchangesUploadfile Tools WhatlinkshereRelatedchangesUploadfileSpecialpagesPermanentlinkPageinformationCitethispageWikidataitem Print/export DownloadasPDFPrintableversion Languages ČeštinaEspañolفارسیFrançais한국어ՀայերենPortuguêsРусскийSlovenščinaTürkçeУкраїнська粵語 Editlinks



請為這篇文章評分?