Java Virtual Machine Guide - Oracle

Transcription

Java Platform, Standard EditionJava Virtual Machine GuideRelease 9E68512-05October 2017

Java Platform, Standard Edition Java Virtual Machine Guide, Release 9E68512-05Copyright 1993, 2017, Oracle and/or its affiliates. All rights reserved.This software and related documentation are provided under a license agreement containing restrictions onuse and disclosure and are protected by intellectual property laws. Except as expressly permitted in yourlicense agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify,license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means.Reverse engineering, disassembly, or decompilation of this software, unless required by law forinteroperability, is prohibited.The information contained herein is subject to change without notice and is not warranted to be error-free. Ifyou find any errors, please report them to us in writing.If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it onbehalf of the U.S. Government, then the following notice is applicable:U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software,any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are"commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agencyspecific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of theprograms, including any operating system, integrated software, any programs installed on the hardware,and/or documentation, shall be subject to license terms and license restrictions applicable to the programs.No other rights are granted to the U.S. Government.This software or hardware is developed for general use in a variety of information management applications.It is not developed or intended for use in any inherently dangerous applications, including applications thatmay create a risk of personal injury. If you use this software or hardware in dangerous applications, then youshall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure itssafe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of thissoftware or hardware in dangerous applications.Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks oftheir respective owners.Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks areused under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron,the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced MicroDevices. UNIX is a registered trademark of The Open Group.This software or hardware and documentation may provide access to or information about content, products,and services from third parties. Oracle Corporation and its affiliates are not responsible for and expresslydisclaim all warranties of any kind with respect to third-party content, products, and services unless otherwiseset forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not beresponsible for any loss, costs, or damages incurred due to your access to or use of third-party content,products, or services, except as set forth in an applicable agreement between you and Oracle.

ContentsPrefaceAudienceviDocumentation AccessibilityviRelated DocumentsviConventionsvi1Java Virtual Machine Technology Overview2Compiler ControlWriting Directives2-1List of Compiler Control Options2-2Writing a Directives File2-5Writing a Compiler Directive2-6Writing a Method Pattern in a Compiler Directive2-8Writing an Inline Directive Option2-9Preventing Duplication with the Enable Option2-9Understanding Directives Better2-11What Is the Default Directive?2-11How Are Directives Applied to Code?2-13Compiler Control and Backward Compatibility2-14Commands to Work with Directive Files2-15Compiler Directives and the Command Line2-15Compiler Directives and Diagnostic Commands2-16Getting Your Java Process Identification Number2-16Adding Directives Through Diagnostic Commands2-16Removing Directives Through Diagnostic Commands2-16Printing Directives Through Diagnostic Commands2-17How Are Directives Ordered in the Directives Stack?2-17iii

3Garbage Collection4Class Data Sharing56Overview of Class Data Sharing4-1Regenerating the Shared Archive4-2Manually Controlling Class Data Sharing4-2Java HotSpot Virtual Machine Performance EnhancementsCompact Strings5-1Tiered Compilation5-2Compressed Ordinary Object Pointer5-2Zero-Based Compressed Ordinary Object Pointers5-3Escape Analysis5-3Support for Non-Java LanguagesIntroduction to Non-Java Language Features6-1Static and Dynamic Typing6-2Statically-Typed Languages Are Not Necessarily Strongly-Typed Languages6-3The Challenge of Compiling Dynamically-Typed Languages6-3The invokedynamic Instruction6-5Defining the Bootstrap Method6-6Specifying Constant Pool Entries6-6Example Constant Pool6-7Using the invokedynamic Instruction7Signal Chaining8Native Memory Tracking6-8Key Features8-1Using Native Memory Tracking8-1Enabling NMT8-1Accessing NMT Data using jcmd8-2Obtaining NMT Data at VM Exit8-2iv

9DTrace Probes in HotSpot VMUsing the hotspot Provider10VM Lifecycle Probes9-1Thread Lifecycle Probes9-2Classloading Probes9-2Garbage Collection Probes9-3Method Compilation Probes9-4Monitor Probes9-5Application Tracking Probes9-6Using the hotspot jni Provider9-7Sample DTrace Probes9-7Fatal Error ReportingError Report Example119-110-1Java Virtual Machine Related ResourcesTools11-1v

PrefacePrefaceThis document provides information about the features supported by Java VirtualMachine technology.AudienceThis document is intended for experienced developers who build applications usingthe Java HotSpot technology.Documentation AccessibilityFor information about Oracle's commitment to accessibility, visit the OracleAccessibility Program website at http://www.oracle.com/pls/topic/lookup?ctx acc&id docacc.Access to Oracle SupportOracle customers that have purchased support have access to electronic supportthrough My Oracle Support. For information, visit http://www.oracle.com/pls/topic/lookup?ctx acc&id info or visit http://www.oracle.com/pls/topic/lookup?ctx acc&id trsif you are hearing impaired.Related DocumentsSee Oracle JDK 9 Documentation for other Oracle Java Development Kit (JDK) 9guides.ConventionsThe following text conventions are used in this document:ConventionMeaningboldfaceBoldface type indicates graphical user interface elements associatedwith an action, or terms defined in text.italicItalic type indicates book titles, emphasis, or placeholder variables forwhich you supply particular values.monospaceMonospace type indicates commands within a paragraph, URLs, codein examples, text that appears on the screen, or text that you enter.vi

1Java Virtual Machine Technology OverviewThis chapter describes the implementation of the Java Virtual Machine (JVM) and themain features of the Java HotSpot technology: Adaptive compiler: A standard interpreter is used to launch the applications. Whenthe application runs, the code is analyzed to detect performance bottlenecks, orhot spots. The Java HotSpot VM compiles the performance-critical portions of thecode for a boost in performance, but does not compile the seldom-used code(most of the application). The Java HotSpot VM uses the adaptive compiler todecide how to optimize compiled code with techniques such as inlining. Rapid memory allocation and garbage collection: Java HotSpot technologyprovides rapid memory allocation for objects and fast, efficient, state-of-the-artgarbage collectors. Thread synchronization: Java HotSpot technology provides a thread-handlingcapability that is designed to scale for use in large, shared-memory multiprocessorservers.In Oracle Java Runtime Environment (JRE) 8 and earlier, different implementations ofthe JVM, (the client VM, server VM, and minimal VM), were supported forconfigurations commonly used as clients, servers, and for embedded systems. Asmost systems can now take advantage of the server VM, the Oracle Java RuntimeEnvironment (JRE) 9 provides only that VM implementation.1-1

2Compiler ControlCompiler Control provides a way to control Java Virtual Machine (JVM) compilationthrough compiler directive options. The level of control is runtime-manageable andmethod specific.A compiler directive is an instruction that tells the JVM how compilation should occur.A directive provides method-context precision in controlling the compilation process.Directives are a powerful tool for writing small, contained, JVM compiler tests becausetests can be run without restarting the entire JVM. Compiler Control is also very usefulfor creating workarounds for bugs in the JVM compilers.You can specify a file that contains compiler directives while starting a programthrough the command line. You can also add or remove directives from an alreadyrunning program through diagnostic commands.Compiler Control supersedes and is backward compatible with CompileCommand.Topics: Writing Directives–Writing a Directives File–Writing a Compiler Directive–Writing a Method Pattern in a Compiler Directive–Writing an Inline Directive Option–Preventing Duplication with the Enable OptionUnderstanding Directives Better–What Is the Default Directive?–How Are Directives Applied to Code?–Compiler Control and Backward CompatibilityCommands to Work with Directive Files–Compiler Directives and the Command Line–Compiler Directives and Diagnostic Commands–How Are Directives Ordered in the Directives Stack?Writing DirectivesThis topic examines Compiler Control options and steps for writing directives fromthose options.Topics: List of Compiler Control Options2-1

Chapter 2Writing Directives Writing a Directives File Writing a Compiler Directive Writing a Method Pattern in a Compiler Directive Writing an Inline Directive Option Preventing Duplication with the Enable OptionList of Compiler Control OptionsOptions are instructions for compilation. Options provide method-context precision.Available options vary by compiler and require specific types of values.Table 2-1Common OptionsOptionDescriptionValue TypeEnableHides a directive and boolrenders it unmatchableif it is set to false.This is useful forpreventing optionduplication. SeePreventing Duplicationwith the EnableOption.trueExcludeExcludes methodsfrom compilation.boolfalseBreakAtExecuteSets a breakpoint tostop execution at thebeginning of thespecified methodswhen debugging theJVM.boolfalseBreakAtCompileSets a breakpoint toboolstop compilation at thebeginning of thespecified methodswhen debugging theJVM.falseLogPlaces only theboolspecified methods in alog. You must first setthe command-lineoption -XX: LogCompilation. Thedefault value falseplaces all compiledmethods in a log.falsePrintAssemblyPrints assembly codefor bytecoded andnative methods byusing the externaldisassembler.solibrary.falseboolDefault Value2-2

Chapter 2Writing DirectivesTable 2-1(Cont.) Common OptionsOptionDescriptionPrintInliningPrints which methods boolare inlined, and where.falsePrintNMethodsPrints nmethods asthey are generated.boolfalsebooltrueBackgroundCompilati Compiles methods asa background task.onMethods run ininterpreter mode untilthe backgroundcompilation finishes.The value falsecompiles methods asa foreground task.Value TypeDefault ValueReplayInlineEnables the sameboolCIReplay functionalityas the correspondingglobal option, but on aper-method basis.falseDumpReplayEnables the sameboolCIReplay functionalityas the correspondingglobal option, but on aper-method basis.falseDumpInlineEnables the sameboolCIReplay functionalityas the correspondingglobal option, but on aper-method basis.falseCompilerDirectivesI Disregards allgnoreCompileCommand CompileCommands.sboolfalseDisableIntrinsicDisables the use ofintrinsics based onmethod-matchingcriteria.ccstrNo default value.inlineForces or preventsinlining of a methodbased on methodmatching criteria. SeeWriting an InlineDirective Option.ccstr[]No default value.Value TypeDefault ValuebooltrueTable 2-2OptionC2 Exclusive OptionsDescriptionBlockLayoutByFreque Moves infrequentexecution branchesncyfrom the hot path.2-3

Chapter 2Writing DirectivesTable 2-2(Cont.) C2 Exclusive OptionsOptionDescriptionValue TypePrintOptoAssemblyPrints generatedboolassembly code aftercompilation by usingthe externaldisassembler.solibrary. This requires adebugging build of theJVM.falsePrintIntrinsicsPrints which intrinsicmethods are used,and where.boolfalseTraceOptoPipelining Traces pipeliningboolinformation, similar tothe correspondingglobal option, but on aper-method basis.This is intended forslow and fastdebugging builds.falseTraceOptoOutputTraces pipeliningboolinformation, similar tothe correspondingglobal option, but on aper-method basis.This is intended forslow and fastdebugging builds.falseTraceSpillingTraces variablespilling.boolfalseVectorizePerforms calculationsin parallel, acrossvector registers.boolfalseVectorizeDebugPerforms calculationsin parallel, acrossvector registers. Thisrequires a debuggingbuild of the JVM.intx0CloneMapDebugEnables you toboolexamine the CloneMapgenerated fromvectorization. Thisrequires a debuggingbuild of the JVM.falseIGVPrintLevelSpecifies the pointswhere the compilergraph is printed inHotspot’s IdealGraphic Visualizer(IGV). A higher valuemeans highergranularity.0intxDefault Value2-4

Chapter 2Writing DirectivesTable 2-2(Cont.) C2 Exclusive OptionsOptionDescriptionValue TypeMaxNodeLimitSets the maximumintxnumber of nodes to beused during a singlemethod’s compilation.Default Value80000A ccstr value type is a method pattern. See Writing a Method Pattern in a CompilerDirective.The default directive supplies default values for compiler options. See What Is theDefault Directive?Writing a Directives FileIndividual compiler directives are written in a directives file. Only directive files, notindividual directives, can be added to the stack of active directives.1.Create a file with a .json extension. Directive files are written using a subset ofJSON syntax with minor additions and deviations.2.Insert the following syntax as a template you can work from:[ //Array of Directives{ //Directive Block//Directive 1},{ //Directive Block//Directive 2},]The components of this template are:Array of Directives: A directives file stores an array of directive blocks, denoted with a pair ofbrackets ([]). The brackets are optional if the file contains only a single directive block.Directive Block: A block is denoted with a pair of braces ({}). A block contains one individual directive. A file can contain any number of directive blocks. Blocks are separated with a comma (,). A comma is optional following the final block in the array.Individual Directive: Each individual directive must exist within a directive block. Files can contain multiple directives when they contain multiple directiveblocks.Comments:2-5

Chapter 2Writing Directives Single-line comments are inserted with two slashes (//). Multiline comments are not allowed.3.Add or remove directive blocks from the template to match the number ofdirectives you want in the file.4.Fill in each directive block with one compiler directive. See Writing a CompilerDirective.5.Reorder the directive blocks if necessary. The ordering of directives within a file issignificant. Directives written closer to the beginning of the array receive higherpriority. For more information, see How Are Directives Ordered in the DirectivesStack? and How Are Directives Applied to Code?[ //Array of directives{ //Directive Block//Directive 1match: ["java*.*", "oracle*.*"],c1: {Enable: true,Exclude: true,BreakAtExecute: true,},c2: {Enable: false,MaxNodeLimit: 1000,},BreakAtCompile: true,DumpReplay: true,},{ //Directive Block//Directive 2match: ["*Concurrent.*"],c2: {Exclude:true,},},]Writing a Compiler DirectiveCompiler directives must be written within a directives file. Repeat these steps for eachindividual compiler directive you want to write in a directives file.An individual compiler directive is written within a directive block in a directives file.See Writing a Directives File.1.Insert the following block of code, as a template you can work from, to write anindividual compiler directive. This block of code is a directive block.{match: [],c1: {//c1 directive options},c2: {//c2 directive options},//Directive options applicable to all compilers},2-6

Chapter 2Writing Directives2.Provide the match attribute with an array of method patterns. See Writing a MethodPattern in a Compiler Directive.For example:match: ["java*.*", "oracle*.*"],3.Provide the c1 attribute with a block of comma-separated directive options. Ensurethat these options are valid for the c1 compiler.For example:c1: {Enable: true,Exclude: true,BreakAtExecute: true,},4.Provide the c2 attribute with a block of comma-separated directive options. Thisblock can contain a mix of common and c2 exclusive compiler options.For example:c2: {Enable: false,MaxNodeLimit: 1000,},5.Provide, at the end of the directive, options you want applicable to all compilers.These options are considered written within the scope of the common block.Options are comma-separated.For example:BreakAtCompile: true,DumpReplay: true,6.Clean up the file:a.Check the ordering and potential duplication of directive options. If there is aconflict, then the last occurrence of an option takes priority. Conflicts mostlikely occur between the common block and the c1 or c2 blocks, not betweenc1 and c2 blocks.b.Avoid writing c2–exclusive directive options in the common block. Although thecommon block can accept a mix of common and c2–exclusive options, it’smisleading to structure a directive this way because c2–exclusive options inthe common block have no effect on the c1 compiler. Write c2–exclusiveoptions within the c2 block instead.c.If either the c1 or c2 attribute has no corresponding directive options, then omitthe attribute-value syntax for that compiler.The resulting directive, based on earlier examples, is:{match: ["java*.*", "oracle*.*"],c1: {Enable: true,Exclude: true,BreakAtExecute: true,},c2: {Enable: false,MaxNodeLimit: 1000,},2-7

Chapter 2Writing DirectivesBreakAtCompile: true,DumpReplay: true,},The JSON format of directive files allows certain deviations in syntax: Extra trailing commas are optional in arrays and objects. Attributes are strings and are optionally placed within quotation marks. If an array contains only one element, then brackets are optional.Therefore, a valid example of a compiler directive is:{"match": "*Concurrent.*",c2: {"Exclude": true,}},Writing a Method Pattern in a Compiler DirectiveA ccstr is a method pattern. It can be written precisely or generalized with wildcardcharacters. It specifies what best-matching Java code should have accompanyingdirective options applied, or what Java code should be inlined.To write a method pattern:1.Fill in the following syntax to format your method pattern: package/class.method(parameter list). If you’re unable to be precise, see Step 2 for waysto generalize a method pattern with wildcard characters.An example method pattern that uses this style of formatting is:java/lang/String.indexOf()Other formatting styles are available. This ensures backward compatibility withearlier ways of method matching such as CompileCommand. Valid formattingalternatives for the previous example include: java/lang/String.indexOf() java/lang/String,indexOf() java/lang/String indexOf() java.lang.String::indexOf()You may find the last formatting style preferable because it matches the Hotspotoutput.2.Insert a wildcard character (*) where you need to generalize part of the methodpattern.The following are valid generalizations of the method pattern example from Step 1: java/lang/String.indexOf* *lang/String.indexOf* *va/lang*.*dex* java/lang/String.* *.*2-8

Chapter 2Writing DirectivesIncreased generalization leads to decreased precision in these examples. This isrisky because more Java code becomes a potential match with the methodpattern. Therefore, it’s important to use the wildcard character (*) judiciously.3.Modify the signature portion of the method pattern. Signatures are writtenaccording to the Java Specifications. Signature matches must be exact, otherwisea signature defaults to a wildcard character (*). Omitted signatures also default toa wildcard character. Signatures themselves cannot contain the wildcardcharacter.4.Optional: If you’re writing a method pattern to accompany the inline directiveoption, then there are additional characters you must prefix the method patternwith. See Writing an Inline Directive Option.Writing an Inline Directive OptionThe attribute for an inline directive option requires an array of method patterns withspecial commands prefixed. This indicates which method patterns should or shouldn’tinline.1.Write inline: in the common block, c1, or c2 block of a directive.2.Accompany this with an array of carefully ordered method patterns. The prefixedcommand on the first matching method pattern is executed. The remaining methodpatterns in the array are ignored.3.Prefix a to force inlining of any matching Java code.4.Prefix a - to prevent inlining of any matching Java code.5.Optional: If you need inlining behavior applied to multiple method patterns, thenrepeat these steps to write multiple inline statements. Don’t write a single arraythat contains all patterns.Examples of inline directive options are: inline: [" java/lang*.*", "-sun*.*"] inline: " java/lang*.*"Preventing Duplication with the Enable OptionThe Enable option hides aspects of directives. This option prevents duplicationbetween directives.Here is an example directives file:[{match: ["java*.*"],c1: {BreakAtExecute: true,BreakAtCompile: true,DumpReplay: true,DumpInline: true,},c2: {MaxNodeLimit: 1000,},},{2-9

Chapter 2Writing Directivesmatch: ["oracle*.*"],c1: {BreakAtExecute: true,BreakAtCompile: true,DumpReplay: true,DumpInline: true,},c2: {MaxNodeLimit: 2000,},},]The c1 attribute of both directives are identical. This undesirable code duplication isresolved with the Enable option. Enable hides a block directives and renders themunmatchable. This produces the example solution:[{match: ["java*.*"],c1: {Enable: false,},c2: {MaxNodeLimit: 1000,},},{match: ["oracle*.*"],c1: {Enable: false,},c2: {MaxNodeLimit: 2000,},},{match: ["java*.*", "oracle*.*"],c1: {BreakAtExecute: true,BreakAtCompile: true,DumpReplay: true,DumpInline: true,},c2: {//Unreachable code},},]The Enable option provides an exception to this rule; the first matching directive isapplied to a method’s compilation. Any method that would be compiled by c1 in the firstor second directive is now compiled with the c1 block of the third directive. The c2block of the third directive is unreachable because the c2 blocks in the first and seconddirective take priority.2-10

Chapter 2Understanding Directives BetterUnderstanding Directives BetterThe following topic examines how directives behave and interact.Topics What Is the Default Directive? How Are Directives Applied to Code? Compiler Control and Backward CompatibilityWhat Is the Default Directive?The default directive is a compiler directive that contains default values for all possibledirective options. It is at the bottom of the directives stack and matches every methodsubmitted for compilation.When you design a new directive, you specify how the new directive differs from thedefault directive. The default directive becomes a template to guide your designdecisions.Directive Option Values in the Default DirectivePrinting an empty directive stack reveals the default directive’s matching criteria andvalues for all directive options:Directive: (default)matching: *.*c1 directives:inline: Enable:true Exclude:false BreakAtExecute:false BreakAtCompile:false Log:falsePrintAssembly:false PrintInlining:false PrintNMethods:falseBackgroundCompilation:true ReplayInline:false DumpReplay:false mands:false DisableIntrinsic:BlockLayoutByFrequency:true PrintOptoAssembly:false PrintIntrinsics:falseTraceOptoPipelining:false TraceOptoOutput:false TraceSpilling:false Vectorize:falseVectorizeDebug:0 CloneMapDebug:false IGVPrintLevel:0 MaxNodeLimit:80000c2 directives:inline: Enable:true Exclude:false BreakAtExecute:false BreakAtCompile:false Log:falsePrintAssembly:false PrintInlining:false PrintNMethods:falseBackgroundCompilation:true ReplayInline:false DumpReplay:false mands:false DisableIntrinsic:BlockLayoutByFrequency:true PrintOptoAssembly:false PrintIntrinsics:falseTraceOptoPipelining:false TraceOptoOutput:false TraceSpilling:false Vectorize:falseVectorizeDebug:0 CloneMapDebug:false IGVPrintLevel:0 MaxNodeLimit:80000Note:Although these printouts provide a thorough account of all directive optionsand their values, certain options are applicable exclusively to the c2 compiler.For a complete list, see Table 2-2.2-11

Chapter 2Understanding Directives BetterDirective Option Values in New DirectivesNew directives must specify how they differ from the default directive. If a directiveoption is not mentioned, then that option retains the value from the default directive.For example:[{match: ["*Concurrent.*"],c2: {MaxNodeLimit: 1000,},Exclude:true,},]When you add this directive to the directives stack, the default directive becomes thebottom-most directive of the stack. See How Are Directives Ordered in the DirectivesStack? for a description of this process. The printout from the resulting directives stackshows how only the directive options specified in the example differ from the valuesfound in the default directive:Directive:matching: *Concurrent.*c1 directives:inline: Enable:true Exclude:true BreakAtExecute:false BreakAtCompile:false Log:falsePrintAssembly:false PrintInlining:false PrintNMethods:falseBackgroundCompilation:true ReplayInline:false DumpReplay:false mands:false DisableIntrinsic:BlockLayoutByFrequency:true PrintOptoAssembly:false PrintIntrinsics:falseTraceOptoPipelining:false TraceOptoOutput:false TraceSpilling:false Vectorize:falseVectorizeDebug:0 CloneMapDebug:false IGVPrintLevel:0 MaxNodeLimit:80000c2 directives:inline: Enable:true Exclude:true BreakAtExecute:false BreakAtCompile:false Log:falsePrintAssembly:false PrintInlining:false PrintNMethods:falseBackgroundCompilation:true ReplayInline:false DumpReplay:false mands:false DisableIntrinsic:BlockLayoutByFrequency:true PrintOptoAssembly:false PrintIntrinsics:falseTraceOptoPipelining:false TraceOptoOutput:false TraceSpilling:false Vectorize:falseVectorizeDebug:0 CloneMapDebug:false IGVPrintLevel:0 MaxNodeLimit:1000Directive: (default)matching: *.*c1 directives:inline: Enable:true Exclude:false BreakAtExecute:false BreakAtCompile:false Log:falsePrintAssembly:false PrintInlining:false PrintNMethods:falseBackgroundCompilation:true ReplayInline:false DumpReplay:false mands:false DisableIntrinsic:BlockLayoutByFrequency:true PrintOptoAssembly:false PrintIntrinsics:falseTraceOptoPipelining:false TraceOptoOutput:false TraceSpilling:false Vectorize:falseVectorizeDebug:0 CloneMapDebug:false IGVPrintLevel:0 MaxNodeLimit:80000c2 directives:inline: -2-12

Chapter 2Understanding Directives BetterEnable:true Exclude:false BreakAtExecute:false BreakAtCompile:false Log:falsePrintAssembly:false PrintInlining:false PrintNMethods:falseBackgroundCompilation:true ReplayInline:false DumpReplay:false mands:false DisableIntrinsic:BlockLayoutByFrequency:true PrintOptoAssembly:false PrintIntrinsics:falseTraceOptoPipelining:false TraceOptoOutput:false TraceSpilling:false Vectorize:falseVectorizeDebug:0 CloneMapDebug:false IGVPrintLevel:0 MaxNodeLimit:80000How Are Directives Applied to Code?A directive is applied to code based on a method matching process. Every methodsubmitted for compilation is matched with a directive in the directives stack.The process of brokering a match between a method and the directives stack isperformed by the CompilerBroker.The Method Matching ProcessWhen a method is submitted for compilation, its fully qualified name is compared to thematching criteria in the directives stack. The first matching directive in the stack isapplied to the method. The remaining directives in the stack are ignored. If no othermatch is found, then the default directive is applied.This process is repeated for all methods in a compilation. Therefore, more than onedirective could be applied in a compilation, while only one directive is applied permethod. All directives in the stack are considered active because they are potentiallyapplicable. The key differences between active and applied directives are: A directive is active if it’s present in the directives stack. A directive is applied if it’s affecting code.Example 2-1When a Match Is FoundExample of a method submitted for compilation:public int exampleMethod(int x){return x;}Based on method-matching criteria, Directive 2 is applied from the following exampledirective stack:Directive 2:matching: *.*example*Directive 1:matching: *.*exampleMethod*Directive 0: (default)matching: *.*Example 2-2When No Match Is FoundThe following example method is submitted for compilation:public int otherMethod(int y){return y;}Based on method-matching criteria in the following example directive stack, Directive0 (the default directive) is applied:2-13

Chapter 2Understanding Directives BetterDirective 2:matching: *.*example*Directive 1:matching: *.*exampleMeth

Java Virtual Machine Technology Overview This chapter describes the implementation of the Java Virtual Machine (JVM) and the main features of the Java HotSpot technology: Adaptive compiler: A standard interpreter is used to launch the applications. When the application runs, the code is