JavaScript程序的动态行为分析外文翻译节选.docx

上传人:b****2 文档编号:2466426 上传时间:2023-05-03 格式:DOCX 页数:10 大小:24.70KB
下载 相关 举报
JavaScript程序的动态行为分析外文翻译节选.docx_第1页
第1页 / 共10页
JavaScript程序的动态行为分析外文翻译节选.docx_第2页
第2页 / 共10页
JavaScript程序的动态行为分析外文翻译节选.docx_第3页
第3页 / 共10页
JavaScript程序的动态行为分析外文翻译节选.docx_第4页
第4页 / 共10页
JavaScript程序的动态行为分析外文翻译节选.docx_第5页
第5页 / 共10页
JavaScript程序的动态行为分析外文翻译节选.docx_第6页
第6页 / 共10页
JavaScript程序的动态行为分析外文翻译节选.docx_第7页
第7页 / 共10页
JavaScript程序的动态行为分析外文翻译节选.docx_第8页
第8页 / 共10页
JavaScript程序的动态行为分析外文翻译节选.docx_第9页
第9页 / 共10页
JavaScript程序的动态行为分析外文翻译节选.docx_第10页
第10页 / 共10页
亲,该文档总共10页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

JavaScript程序的动态行为分析外文翻译节选.docx

《JavaScript程序的动态行为分析外文翻译节选.docx》由会员分享,可在线阅读,更多相关《JavaScript程序的动态行为分析外文翻译节选.docx(10页珍藏版)》请在冰点文库上搜索。

JavaScript程序的动态行为分析外文翻译节选.docx

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

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 医药卫生 > 中医中药

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2