完整版毕业设计外文文献翻译3943817.docx
- 文档编号:27224964
- 上传时间:2023-06-28
- 格式:DOCX
- 页数:17
- 大小:30.21KB
完整版毕业设计外文文献翻译3943817.docx
《完整版毕业设计外文文献翻译3943817.docx》由会员分享,可在线阅读,更多相关《完整版毕业设计外文文献翻译3943817.docx(17页珍藏版)》请在冰豆网上搜索。
完整版毕业设计外文文献翻译3943817
EncodingtheJavaVirtualMachine’sInstructionSet
1Introduction
ThedevelopmentofprogramsthatparseandanalyzeJavaBytecode[9]developingsuchtools,language(OPALSPL)forencodingtheinstructionsofstack-basedintermediatelanguages.Theideaisthat—oncetheinstructionsetiscompletelyspecifiedusingOPALSPL—generatingbothbytecodeparsersandstandardanalysesismucheasierthantheirmanualdevelopment.Tosupportthisgoal,OPALSPLsupportsthespecificationofboththeformatofbytecodeinstructionsandtheeffectonthestackandregisterstheseinstructionsexecuted.AnalternativeuseofanOPALSPLspecificationisasinputtoagenericparserortogenericanalysesasillustratedbyFig.1
ThoughthelanguagewasdesignedwithJavaBytecodespecificallyinmindandisusedtoencodethecompleteinstructionsetoftheJavaVirtualMachine(JVM),weforaJava-independentspecificationlanguage.Inparticular,OPALSPLfocusesonspecifyingtheinstructionsetratherthanthecompleteclassfileformat,notonlybecausetheformer’sstructureismuchmoreregularthanthelatter’s,butalsobecauseaspecificationoftheinstructionsetpromisestobemostbeneficial.GiventheprimaryfocusofOPALSPL—generatingparsersandfacilitatingbasicanalyses—weexplicitlydesignedthelanguagesuchthatitispossibletogrouprelatedinstructions.Thismakesspecificationsmoreconciseandallowsanalysestotreatsimilarinstructionsinnearlythesameway.Forexample,theJVM’siload5instruction,whichloadstheintegervaluestoredinregister#5,isaspecialcaseofthegenericiloadinstructionwheretheinstruction’soperandis5.WealsodesignedOPALSPLinsuchawaythatspecificationsdonotprescribe;i.e.,OPALSPLisrepresentationagnostic.
Thenextsectiondescribesthespecificationlanguage.InSection3wereasonaboutthelanguage’sdesignbydiscussingthespecificationofselectedJVMinstructions.InSection4thevalidationofspecificationsisdiscussed.TheevaluationoftheapproachispresentedinSection5.Thepaperendswithadiscussionofrelatedworkandaconclusion.
2SpecifyingBytecodeInstructions
Thelanguageforspecifyingbytecodeinstructions(OPALSPL)wasprimarilydesignedtoenableaconcisespecificationoftheJVM’sinstructionset.OPALSPLsupportsthespecificationofbothaninstruction’sformatanditseffectonthestackandlocalvariables(registers)whentheinstructionisexecuted.Itisthuspossibletospecifywhichkindofvaluesarepoppedfromandpushedontothestackaswellaswhichlocalvariablesarereadorwritten.Givenaspecificationofthecompleteinstructionsettheinformationrequiredbystandardcontrol-anddata-flowanalysesisthenavailable.
However,OPALSPLisnotparticularlytiedtoJavaasitabstractsfromtheparticularitiesoftheJVMSpecification.Forexample,theJVM’stypesystemispartofanOPALSPLspecificationratherthananintegralpartoftheOPALSPLlanguageitself.
Next,wefirstgiveanoverviewofthelanguagebeforewediscussitssemantics.
2.1Syntax
TheOPALSpecificationLanguage(OPALSPL)isanXML-basedlanguage.ItsgrammarisdepictedinFig.2usinganEBNF-likeformat.Non-terminalsarewrittenincapitalletters(INSTRUCTIONS,TYPES,etc.),thenamesofXML-elementsarewritteninsmallletters(types,stack,etc.)andthenamesofXML-attributesstartwith“@”(@type,@var,etc.).WerefertothecontentofanXML-elementusingsymbolsthatstartwith“”(VALUEEXPRESSION,EXPECTEDVALUE,etc.).“<>”isusedtospecifynestingofelements.“(),?
+,*,{},|”@type)+>specifiesthattheXML-elementexceptionshasoneormoreexceptionchildelementsthatalways
EachspecificationwritteninOPALSPLconsistsoffourmajorparts(line1inFig.2).Thefirstpart(types,lines2–3)specifiesthetypesystemthatisusedbytheunderlyingvirtualmachine.Thesecondpart(exceptions,line4)declarestheexceptionsthatmaybethrownwheninstructionsareexecuted.Thethirdpart(functions,line5)declaresthefunctionsthatareusedininstructionspecifications.Thefourthpartisthespecificationoftheinstructionsthemselves(lines6–12),eachofwhichmayresorttothedeclaredfunctionstoaccessinformationnotsimplystoredalongwiththeinstruction.Forexample,invokeinstructionsdonotstorethesignatureanddeclaringclassofthecalledmethods.Instead,areferencetoanentryintheso-calledconstantpoolisstored.Onlythisconstantpoolentryaboutthemethod.Toobtain,e.g.,thereturntypeofthecalledmethod,anabstractfunctionTYPEmethodrefreturntype(methodref)isdeclaredthattakesareferencetotheentryasinputandreturnsthemethod’sreturntype.Usingabstractfunctiondeclarations,weabstract—inthespecificationoftheinstructions—fromtheconcreterepresentationofsuchinformationbytheenclosingbytecodetoolkit.
Thespecificationofaninstructionconsistsofuptofourparts:
theinstruction’sformat(lines7–8),adescriptionoftheeffecttheinstructionthestackwhenexecuted(lines9–10),adescriptionsoftheregistersitaffectsuponexecution(lines11–12),andinformationabouttheexceptionsthatmaybethrownduringexecution(endofline6).Aninstruction’sformatisspecifiedbysequenceswhichdescribeinstructionisstored.Theu1,u2andu4elements(line8)ofeachformatsequencespecifythatthecurrentvalueisanunsignedintegervaluewith1,2and4bytes,respectively.Similarly,thei1,i2andi4elements(line8)areusedtospecifythatthecurrentvalueisa(1,2or4byte)signedintegervalue.Thevaluescanbeboundtovariablesusingthevarattributeandcanbegivenasecondsemanticsusingthetypeattribute.Forexample,
UniquePrefixRule
OneconstraintplaceduponspecificationswritteninOPALSPListhataformatsequencecanbeidentifiedunambiguouslybyonlyparsingaprefixoftheinstruction;nolookaheadisnecessary.Inotherwords,ifeachformatsequenceisconsideredaproductionandeachu1,u2,etc.isconsideredaterminal,thenOPALSPLrequirestheformatsequencestoconstituteanLR(0)grammarThisuniqueprefixruleischeckedautomatically(cf.Sec.4);furthermore,thisrulefacilitatesgeneratingfastparsersfromthespecification,e.g.,usingnestedswitchstatements.
TypeSystem
OPALSPLdoesnotwritteninSPLcontainsadescriptionofthetypesystemusedbythebytecodelanguagebeingdescribed.Theonlyrestrictionisthatalltypesasingle,strict[9]’stypeinFig.3
(1).ItcapturesallruntimetypesknowntotheJavavirtualmachine,aswellasthosetypesthatareusedonlyatlink-orcompile-time,e.g.,branchoffset,fieldrefandmethodref.Theset.Thebyteorbooleantype,e.g.,isrequiredtomodelthebaloadandbastoreinstructions,whichoperateonarraysofbyteorbooleanalike.
OPALSPL’stypesystemimplicitlydefinesasecondtypeFig.3).Thedeclared(upper-case)kind.Thisconventionensurestheirconsistencyandkeepsthespecificationitselfbrief.ThevaluesofkindINTLIKEareint,short,etc.,justasthevaluesoftypeintlikeare1,2,etc.Kindsenableparameterizinglogicalinstructionslikeareturnwithtypes,thusmakingaconcisespecificationofrelatedinstructions(e.g.,freturn,ireturn,andareturn)possible(cf.Sec.3.12).
InformationFlow
InOPALSPL,theflowofinformation(values,types,registerIDs)ismodeledbymeansofnamedvariablesandexpressionsusingthevariables.Ingeneral,theflowofinformationissubjecttotheconstraintsillustratedbyFig.4.Forexample,variablesdefinedwithinaspecificformatsequencecanonlybereferredtobylaterelementswithinthesameformatsequence;avariablecannotbereferredtoacrossformatsequences.Ifthesamevariableisboundbyallformatsequences,i.e.,itiscommontoallformatsequences,thenthevariablecanbeusedtoidentifyregisterIDs,thevaluespushedontothestack,etc.Similarly,ifaninstructiondefinesmultiplestacklayouts,thenavaluecanonlyflowfromthei-thstacklayoutbeforeexecutiontothei-thstacklayoutafterexecutionandonlyinformationthatiscommontoallstacklayoutsbeforeexecutionmaybestoredinaregister.
3DesignDiscussion
ThedesignoftheOPALspecificationlanguage(OPALSPL)isinfluencedbythepeculiaritiesoftheJVM’sinstructionset[9,Chapter6].Inthefollowing,wediscussthoseinstructionsthatthedesign.
3.1ModelingtheStackBottom(athro
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 完整版 毕业设计 外文 文献 翻译 3943817