Java Virtual Machine Guide - Docs.oracle

3y ago
31 Views
2 Downloads
631.81 KB
75 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Mya Leung
Transcription

Java Platform, Standard EditionJava Virtual Machine GuideRelease 16F38289-01March 2021

Java Platform, Standard Edition Java Virtual Machine Guide, Release 16F38289-01Copyright 1993, 2021, Oracle and/or its affiliates.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. Reverseengineering, disassembly, or decompilation of this software, unless required by law for interoperability, isprohibited.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 embedded, installed or activated on delivered hardware, and modifications of such programs)and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Governmentend users are "commercial computer software" or "commercial computer software documentation" pursuantto the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such,the use, reproduction, duplication, release, display, disclosure, modification, preparation of derivative works,and/or adaptation of i) Oracle programs (including any operating system, integrated software, any programsembedded, installed or activated on delivered hardware, and modifications of such programs), ii) Oraclecomputer documentation and/or iii) other Oracle data, is subject to the rights and limitations specified in thelicense contained in the applicable contract. The terms governing the U.S. Government’s use of Oracle cloudservices are defined by the applicable contract for such services. 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 Inside 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, Epyc,and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registeredtrademark 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 notbe responsible 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-1Compiler Control Options2-2Writing a Directive File2-5Writing a Compiler Directive2-7Writing a Method Pattern in a Compiler Directive2-9Writing an Inline Directive Option2-10Preventing Duplication with the Enable Option2-10Understanding Directives2-11What Is the Default Directive?2-12How Directives are Applied to Code?2-14Compiler Control and Backward Compatibility2-15Commands for Working with Directive Files2-16Compiler Directives and the Command Line2-16Compiler Directives and Diagnostic Commands2-17Getting Your Java Process Identification Number2-17Adding Directives Through Diagnostic Commands2-17Removing Directives Through Diagnostic Commands2-18Printing Directives Through Diagnostic Commands2-18How Directives Are Ordered in the Directives Stack?2-18iii

3Garbage Collection4Class Data SharingClass Data Sharing5Application Class-Data Sharing4-2Dynamic CDS Archive4-2Regenerating the Shared Archive4-2Manually Controlling Class Data Sharing4-3Java HotSpot Virtual Machine Performance EnhancementsCompact Strings5-1Tiered Compilation5-2Segmented Code Cache5-2Graal : a Java-Based JIT Compiler5-3Ahead-of-Time Compilation5-3Compressed Ordinary Object Pointer5-4Zero-Based Compressed Ordinary Object Pointers5-5Escape Analysis5-56JVM Constants API7Support for Non-Java LanguagesIntroduction to Non-Java Language Features7-1Static and Dynamic Typing7-2Statically-Typed Languages Are Not Necessarily Strongly-Typed Languages7-3The Challenge of Compiling Dynamically-Typed Languages7-3The invokedynamic Instruction7-5Defining the Bootstrap Method7-6Specifying Constant Pool Entries7-7Example Constant Pool7-7Using the invokedynamic Instruction84-17-8Signal Chainingiv

9Native Memory TrackingKey Features9-1Using Native Memory Tracking9-1Enabling NMT9-1Accessing NMT Data using jcmd9-2Obtaining NMT Data at VM Exit10DTrace Probes in HotSpot VMUsing the hotspot Provider1110-1VM Lifecycle Probes10-1Thread Lifecycle Probes10-2Classloading Probes10-2Garbage Collection Probes10-3Method Compilation Probes10-4Monitor Probes10-5Application Tracking Probes10-6Using the hotspot jni Provider10-7Sample DTrace Probes10-7Fatal Error ReportingError Report Example129-211-1Java Virtual Machine Related ResourcesTools12-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 theOracle Accessibility 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 JDK 16 Documentation for other JDK 16 guides.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.When the application runs, the code is analyzed to detect performancebottlenecks, or hot spots. The Java HotSpot VM compiles the performance-criticalportions of the code for a boost in performance, but does not compile the seldomused code (most of the application). The Java HotSpot VM uses the adaptivecompiler to decide how to optimize compiled code with techniques such asinlining. 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 implementationsof the JVM, (the client VM, server VM, and minimal VM) were supported forconfigurations commonly used as clients, as servers, and for embedded systems.Because most systems can now take advantage of the server VM, only that VMimplementation is provided in later versions.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.You can use directives to write small, contained, JVM compiler tests that can runwithout restarting the entire JVM. You can also use directives to create workaroundsfor bugs, in the JVM compilers.You can specify a file that contains compiler directives when you start a programthrough the command line. You can also add or remove directives from an alreadyrunning program by using diagnostic commands.Compiler Control supersedes and is backward compatible with CompileCommand.Topics: Writing Directives–Writing a Directive 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–What Is the Default Directive?–How Directives are Applied to Code?–Compiler Control and Backward CompatibilityCommands for Working with Directive Files–Compiler Directives and the Command Line–Compiler Directives and Diagnostic Commands–How Directives Are Ordered in the Directives Stack?Writing DirectivesThis topic examines Compiler Control options and steps for writing directives fromthose options.Topics: Compiler Control Options2-1

Chapter 2Writing Directives Writing a Directive File Writing a Compiler Directive Writing a Method Pattern in a Compiler Directive Writing an Inline Directive Option Preventing Duplication with the Enable OptionCompiler 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 TypeDefault ValueEnableHides a directive and boolrenders it unmatchableif it is set tofalse. This option isuseful for preventingoption duplication. SeePreventing Duplicationwith the EnableOption.trueExcludeExcludes methodsfrom compilation.boolfalseBreakAtExecuteSets a breakpointto stop executionat the beginning ofthe specified methodswhen debugging theJVM.boolfalseBreakAtCompileSets a breakpointto stop compilationat the beginning ofthe specified methodswhen debugging theJVM.boolfalseLogPlaces only theboolspecified methods in alog. You must first setthe command-lineoption -falseXX: LogCompilation. The default valuefalse places allcompiled methods in alog.PrintAssemblyPrints assembly codefor bytecoded andnative methods byusing the externalboolfalsedisassembler.solibrary.2-2

Chapter 2Writing DirectivesTable 2-1(Cont.) Common OptionsOptionDescriptionPrintInliningPrints which methods boolare inlined, and where.falsePrintNMethodsPrints nmethods asthey are generated.boolfalsebooltrueBackgroundCompila Compiles methodsas a backgroundtionValue TypeDefault Valuetask. Methods runin interpreter modeuntil the backgroundcompilation finishes.The value falsecompiles methods asa foreground task.ReplayInlineDumpReplayEnables the sameboolCIReplay functionalityas the correspondingglobal option, but on aper-method basis.falseEnables the sameboolfalseboolfalseboolfalseCIReplay functionalityas the correspondingglobal option, but on aper-method basis.DumpInlineEnables the sameCIReplay functionalityas the correspondingglobal option, but on aper-method basis.CompilerDirective Disregards allsIgnoreCompileCom CompileCommands.mandsDisableIntrinsicDisables the useof intrinsics basedon method-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 OptionsDescriptionBlockLayoutByFreq Moves infrequentexecution branchesuencyfrom the hot path.2-3

Chapter 2Writing DirectivesTable 2-2(Cont.) C2 Exclusive OptionsOptionDescriptionValue TypeDefault ces pipeliningboolinformation, similarto the correspondingglobal option, buton a per-methodbasis. This is intendedfor slow and fastdebugging builds.falseTraceSpillingTraces variablespilling.boolfalseVectorizePerforms calculationsin parallel, acrossvector registers.boolfalseVectorizeDebugPerforms calculationsin parallel, acrossvector registers. Thisrequires a debuggingbuild of the JVM.intx0CloneMapDebugEnables youboolto examine theCloneMap generatedfrom vectorization.This requires adebugging build of theJVM.PrintOptoAssembly Prints generatedassembly codeafter compilation byusing the externaldisassembler.solibrary. This requires adebugging build of theJVM.PrintIntrinsicsPrints which intrinsicmethods are used,and where.TraceOptoPipelini Traces pipelininginformation, similarngto the correspondingglobal option, buton a per-methodbasis. This is intendedfor slow and fastdebugging builds.false2-4

Chapter 2Writing DirectivesTable 2-2(Cont.) C2 Exclusive OptionsOptionDescriptionValue TypeDefault ValueIGVPrintLevelSpecifies the pointsintxwhere the compilergraph is printed inOracle’s Hotspot IdealGraphic Visualizer(IGV). A highervalue means highergranularity.0MaxNodeLimitSets the maximumintxnumber of nodes touse during a singlemethod’s compilation.80000A 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 Directive 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.Add 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 directives file can contain any number of directive blocks.2-5

Chapter 2Writing Directives Blocks are separated with a comma (,). A comma is optional following the final block in the array.Directive Each directive must be within a directive block. A directives file can contain multiple directives when it contains multipledirective blocks.Comments Single-line comments are preceded 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 directives file.4.In each directive block, write one compiler directive. See Writing a CompilerDirective.5.Reorder the directive blocks if necessary. The ordering of directives in a file issignificant. Directives written closer to the beginning of the array receive higherpriority. For more information, see How Directives Are Ordered in the DirectivesStack? and How Directives are 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,},},]2-6

Chapter 2Writing DirectivesWriting a Compiler DirectiveYou must write a compiler directive within a directives file. You can repeat the followingsteps for each individual compiler directive that 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 Directive 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.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.2-7

Chapter 2Writing DirectivesFor example:BreakAtCompile: true,DumpReplay: true,6.Clean up the file by completing the following steps.a.Check for the duplication of directive options. If a conflict occurs, then the lastoccurrence of an option takes priority. Conflicts typically occur between thecommon block and the c1 or c2 blocks, not between the c1 and c2 blocks.b.Avoid writing c2-exclusive directive options in the common block. Althoughthe common block can accept a mix of common and c2-exclusive options, it’spointless to structure a directive this way because c2-exclusive options in thecommon block have no effect on the c1 compiler. Write c2-exclusive optionswithin the c2 block instead.c.If the c1 or c2 attribute has no corresponding directive options, then omit theattribute-value syntax for that compiler.The following example shows the resulting directive, based on earlier examples, is:{match: ["java*.*", "oracle*.*"],c1: {Enable: true,Exclude: true,BreakAtExecute: true,},c2: {Enable: false,MaxNodeLimit: 1000,},BreakAtCompile: true,DumpReplay: true,},The JSON format of directive files allows the following 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, the following example shows a valid compiler directive:{"match": "*Concurrent.*",c2: {"Exclude": true,}},2-8

Chapter 2Writing DirectivesWriting a Method Pattern in a Compiler DirectiveA ccstr is a method pattern that you can write precisely or you can generalize withwildcard characters. You can specify what best-matching Java code should haveaccompanying directive options applied, or what Java code should be inlined.To write a method pattern:1.Use the following syntax to write your method pattern: package/class.method(parameter list). To generalize a method pattern with wildcardcharacters, see Step 2.The following example shows a method patte

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 analyzed to detect performance bottlenecks, or hot spots.

Related Documents:

java.io Input and output java.lang Language support java.math Arbitrary-precision numbers java.net Networking java.nio "New" (memory-mapped) I/O java.rmi Remote method invocations java.security Security support java.sql Database support java.text Internationalized formatting of text and numbers java.time Dates, time, duration, time zones, etc.

Java Version Java FAQs 2. Java Version 2.1 Used Java Version This is how you find your Java version: Start the Control Panel Java General About. 2.2 Checking Java Version Check Java version on https://www.java.com/de/download/installed.jsp. 2.3 Switching on Java Console Start Control Panel Java Advanced. The following window appears:

The Java Virtual Machine Specification 5.6 Binding Native Method Implementations 401 5.7 Java Virtual Machine Exit 401 6 The Java Virtual Machine Instruction Set 403 6.1 Assumptions: The Meaning of "Must" 403 6.2 Reserved Opcodes 404 6.3 Virtual Machine Errors 404 6.4 Format of Instruction Descriptions 405 mnemonic 406 6.5 Instructions 408 .

3. _ is a software that interprets Java bytecode. a. Java virtual machine b. Java compiler c. Java debugger d. Java API 4. Which of the following is true? a. Java uses only interpreter b. Java uses only compiler. c. Java uses both interpreter and compiler. d. None of the above. 5. A Java file with

programmer only deals with the Java filesystem API. The virtual machine then handles translating between this “virtual” API to the true operating system API (see diagram B-2). What is Java? Part 3: Java Applets and Java Web Start Beyond the language, compiler, virtual machine and API, Java has a number of ancillary technolo-gies that .

The Java Virtual Machine: Java Virtual Machine (JVM) is the heart of entire Java program execution process. First of all, the .java program is converted into a .class file consisting of byte code instructions by the java compiler at the time of compilation. Remember, this java compiler is outside the JVM. This .class file is given to the JVM.

besteht aus der Java-API (Java Application Programming Interface) und der Java-VM (Java Virtual Machine). Abbildung 1: Java-Plattform Die Java-API ist eine große Sammlung von Java-Programmen, die in sog. Pakete (packages) aufgeteilt sind. Pakete sind vergleichbar mit Bibliotheken in anderen Programmiersprachen und umfassen u.a.

Alfredo Chavero (1981) concluye que los anteojos no son otra cosa que ex-presiones de las nubes y en cuanto a los colmillos, . lo señala Alfredo López Austin (1990): .como creador, Tláloc lo fue de la luna, del agua y de la lluvia y fue también uno de los cuatro soles cosmogónicos que precedieron al actual. Además de esto, reinaba en su propio paraí-so, el Tlalocan, que se .