JavaScript程序的动态行为分析外文翻译节选.docx
- 文档编号:2466426
- 上传时间:2023-05-03
- 格式:DOCX
- 页数:10
- 大小:24.70KB
JavaScript程序的动态行为分析外文翻译节选.docx
《JavaScript程序的动态行为分析外文翻译节选.docx》由会员分享,可在线阅读,更多相关《JavaScript程序的动态行为分析外文翻译节选.docx(10页珍藏版)》请在冰点文库上搜索。
JavaScript程序的动态行为分析外文翻译节选
1800单词,1万英文字符,3600汉字
出处:
RichardsG,LebresneS,BurgB,etal.AnanalysisofthedynamicbehaviorofJavaScriptprograms[C]//AcmSigplanConferenceonProgrammingLanguageDesign&Implementation.ACM,2010:
1-12.
AnAnalysisoftheDynamicBehaviorofJavaScriptPrograms
GregorRichardsSylvainLebresneBrianBurgJanVitek
Abstract
TheJavaScriptprogramminglanguageiswidelyusedforwebprogrammingand,increasingly,forgeneralpurposecomputing.Assuch,improvingthecorrectness,securityandperformanceofJavaScriptapplicationshasbeenthedrivingforceforresearchintypesystems,staticanalysisandcompilertechniquesforthislanguage.Manyofthesetechniquesaimtoreigninsomeofthemostdynamicfeaturesofthelanguage,yetlittleseemstobeknownabouthowprogrammersactuallyutilizethelanguageorthesefeatures.Inthispaperweperformanempiricalstudyofthedynamicbehaviorofacorpusofwidely-usedJavaScriptprograms,andanalyzehowandwhythedynamicfeaturesareused.WereportonthedegreeofdynamismthatisexhibitedbytheseJavaScriptprogramsandcomparethatwithassumptionscommonlymadeintheliteratureandacceptedindustrybenchmarksuites.
Keywords:
DynamicBehavior,ExecutionTracing,DynamicMetrics,ProgramAnalysis,JavaScript
1.Introduction
JavaScriptisanobject-orientedlanguagedesignedin1995byBrendanEichatNetscapetoallownon-programmerstoextendwebsiteswithclient-sideexecutablecode.UnlikemoretraditionallanguagessuchasJava,C#orevenSmalltalk,itdoesnothaveclasses,anddoesnotencourageencapsulationorevenstructuredprogramming.InsteadJavaScriptstrivestomaximizeflexibility.JavaScript’ssuccessisundeniable.Asadatapoint,itisusedby97outoftheweb’s100mostpopularsites.2Thelanguageisalsobecomingageneralpurposecomputingplatformwithofficeapplications,browsersanddevelopmentenvironmentsbeingdevelopedinJavaScript.Ithasbeendubbedthe“assemblylanguage”oftheInternetandistargetedbycodegeneratorsfromthelikesofJavaandScheme.Inresponsetothissuccess,JavaScripthasstartedtogarneracademicattentionandrespect.Researchershavefocusedonthreemainproblems:
security,correctnessandperformance.SecurityisarguablyJavaScript’smostpressingproblem:
anumberofattackshavebeendiscoveredthatexploitthelanguage’sdynamism(mostlytheabilitytoaccessandmodifysharedobjectsandtoinjectcodeviaeval).Researchershaveproposedapproachesthatmarrystaticanalysisandruntimemonitoringtopreventasubsetofknownattacks.Anotherstrandofresearchhastriedtoinvestigatehowtoprovidebettertoolsfordevelopersforcatchingerrorsearly.Beingaweaklytypedlanguagewithnotypedeclarationsandonlyrun-timecheckingofcallsandfieldaccesses,itisnaturaltotrytoprovideastatictypesystemforJavaScript.Finally,aftermanyyearsofneglect,modernimplementationsofJavaScripthavestartedtoappearwhichusestateoftheartjust-in-timecompilationtechniques.
2.MotivationandRelatedWork
TheoriginalimpetusforourinterestinJavaScriptwastoassessthefeasibilityofastatictypesystemabletosuccessfullyandmeaningfullytypecheckexistingJavaScriptprograms.OtherdynamiclanguagessuchasSchemehavehadrecentsuccessintroducinggradualtypingsystems,buttheyhavestoppedshortoftypecheckingobject-orientedextensions(implementedbymacrosinScheme).ForJavaScript,Andersonetal.proposedatypesystemwithdefiniteandpotentialtypes,whileHeideggerandThiemannfollowinguponsomeoftheirearlierworkproposerecencytypesin,andFurretal.proposedarelatedsystemforDRuby.Whileallofthesetypesystemsacknowledgesomeminorsimplificationstothetargetlanguage,theyrelyonfairlysimilarassumptions.Forinstance,Thiemannwrites:
“Usually,nofurtherpropertiesaredefinedaftertheinitializationandthetypeofthepropertiesrarelychanges.”
CommonAssumptionsaboutthedynamicbehaviorofJavaScript.
Weproceedtoenumeratetheexplicitandimplicitassumptionsthatarecommonlyfoundintheliteratureandinimplementations.
1.Theprototypehierarchyisinvariant.Theassumptionthattheprototypehierarchydoesnotchangeafteranobjectiscreatedissocentraltothetypesystemworkthatchosetonotevenmodelprototypes.Researchonstaticanalysistypicallydoesnotmentionprototypeupdates.Yet,anymodificationtotheprototypehierarchycanpotentiallyimpactthecontrolflowgraphoftheapplicationjustaswellasthetypesofaffectedobjects.
2.Propertiesareaddedatobjectinitialization.Folkloreholdsthatthereissomethingakintoan“initializationphase”indynamiclanguageswheremostofthedynamicactivityoccursandafterwhichtheapplicationismostlystatic.ForJavaScriptthisisembodiedbytheassumptionthatmostchangestothefieldsandmethodsofobjectsoccuratinitialization,andthusthatitisreasonabletoassignanalmostcompletetypetoobjectsatcreation,leavingasmallnumberofpropertiesaspotential.
3.Propertiesarerarelydeleted.Removalofmethodsorfieldsisdifficulttoccommodateinatypesystemasitpermitsnonmonotonicevolutionoftypesthatbreakssubtypingguaranteesusuallyenforcedinmoderntypedlanguages.Ifdeletionisanexceptionaloccurrence(andonethatcanbepredicted),onecouldusepotentialtypesforpropertiesthatmaybedeletedinthefuture.But,thiswouldreducethebenefitsofhavingatype.
systeminthefirstplace,whichisprobablywhyrelatedworkchoosestoforbidit.Staticanalysisapproachesareusuallyabitmoretoleranttoimprecisionandcanhandledeletes,butwehavenotfoundanyexplanationofitshandlinginexistingdataflowanalysistechniques.
4.Theuseofevalisinfrequentanddoesnotaffectsemantics.Theuseofevalonarbitrarystringshasthepotentialofinvalidatinganyresultsobtainedbystaticanalysisorstatictypechecking.Thusmanyworkssimplyignoreit,whileotherassumethatusesareeithertrivialorrelatedtodeserializationusingtheJSONprotocol.
5.Declaredfunctionsignaturesareindicativeoftypes.TypesystemsforJavaScripttypicallyassumethatthedeclaredarityofafunctionisrepresentativeofthewayitwillbeinvoked.ThisisnotnecessarilythecasebecauseJavaScriptallows
callswithdifferentarities.
6.Programsizeismodest.SomepapersjustifyveryexpensiveanalyseswiththeexplicitassumptionthathandwrittenJavaScriptprogramsaresmall,andothersimplicitlyrelyonthisastheypresentanalyseswhichwouldnotscaletolargesystems.
7.Call-sitedynamismislow.SomeJavaScriptimplementationssuchasGoogleV8relyonwell-knownimplementationtechniquestooptimizeJavaScriptprogramssuchascreatingclasses(intheJavasense)forobjectsandinlinecaches.ThesetechniqueswillleadtogoodperformanceonlyifthebehaviorofJavaScriptisbroadlysimilartothatofotherobject-orientedlanguages
8.Executiontimeisdominatedbyhotloops.Trace-basedJustin-timecompilerssuchasTraceMonkeyrelyonthetraditionalassumptionthatexecutiontimeisdominatedbysmallloops.
9.IndustrybenchmarksarerepresentativeofJavaScriptworkloads.StandardenchmarksuitessuchasSunSpider,DromaeoandV8,areusedtotuneandcompareJavaScriptimplementationsandtoevaluatetheaccuracyofstaticanalysistechniques.ButconclusionsobtainedfromuseofthosebenchmarksareonlymeaningfuliftheyaccuratelyrepresenttherangeofJavaScriptworkloadsinthewild.
Thegoalofthispaperistoprovidesupportingevidencetoeitherconfirmorinvalidatetheseassumptions.Wearenotdisputingthevalidityofpreviousresearch,asevenifacoupleoftheaboveassumptionsprovedtobeunfounded,previousworkcanstillserveasausefulstartingpointforhandlingfullJavaScript.Butwedowanttohighlightlimitationstowidespreadadoptionofexistingtechniquesandpointtochallengesthatshouldbeaddressedinfutureresearch.
RelatedWork.Untilnow,tothebestofourknowledge,therehasbeennostudyofthedynamicbehaviorofJavaScriptprogramsofcomparabledepthorbreadth.Ratanaworabhanetal.haveperformedasimilarstudyconcurrentlytoourown,anditsresultsaresimilartoours.TherehavebeenstudiesofJavaScript’sdynamicbehaviorasitappliestosecurity,butthebehaviorsstudiedwererestrictedtothoseparticularlyrelevanttosecurity.WeconductedasmallscalestudyofJavaScriptandreportedpreliminaryresultsin,andthoseresultsareconsistentwiththenewresultspresentedhere.HolknerandHarlandhaveconductedastudyoftheuseofdynamicfeatures(additionanddeletionoffieldsandmethods)inthePythonprogramminglanguage.Theirstudyfocusedonasmallersetofprogramsandconcludedthatthereisaclearphasedistinction.Intheircorpusdynamicfeaturesoccurmostlyintheinitializationphaseofprogramsandlesssoduringthemaincomputation.OurresultssuggestthatJavaScriptismoredynamicthanPythoninpractice.Therearemanystudiesoftheruntimeuseofselectedfeaturesofobject-orientedlanguages.Forexample,Garretetal.reportedonthedynamismofmessagesendsinSelf,Calderetal.characterizedthedifferenceofbetweenCandC++programsin,andTemporoetal.studiedtheusageofinheritanceinJavain.Thesepreviouspapersstudyingreatdetailoneparticularaspectofeachlanguage.Inthisparticularwork,westriveforanoverviewofJavaScript,andleavedetailedanalysisforfuturework.Finally,wewereinspiredbytheworkofDufouretal.andtheirrigorousframeworkfordiscussingruntimemetricsforJava.
3.TracingandAnalysisInfrastructure
Thetracing
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JavaScript 程序 动态 行为 分析 外文 翻译 节选