--- old/./.hgignore 2016-05-04 09:42:43.000000000 -1000 +++ new/./.hgignore 2016-05-04 09:42:43.000000000 -1000 @@ -16,10 +16,10 @@ ^\.mx.jvmci/hotspot/eclipse/.* ^\.idea/ ^workingsets.xml -^src/jdk.vm.ci/share/classes/\w[\w\.]*/.*\.xml -^src/jdk.vm.ci/share/classes/\w[\w\.]*/.*\.iml -^src/jdk.vm.ci/share/classes/\w[\w\.]*/nbproject -^src/jdk.vm.ci/share/classes/\w[\w\.]*/\..* +^src/\w[\w\.]*/share/classes/\w[\w\.]*/.*\.xml +^src/\w[\w\.]*/share/classes/\w[\w\.]*/.*\.iml +^src/\w[\w\.]*/share/classes/\w[\w\.]*/nbproject +^src/\w[\w\.]*/share/classes/\w[\w\.]*/\..* ^test/compiler/jvmci/\w[\w\.]*/.*\.xml ^test/compiler/jvmci/\w[\w\.]*/.*\.iml ^test/compiler/jvmci/\w[\w\.]*/nbproject --- old/.mx.jvmci/suite.py 2016-05-04 09:42:44.000000000 -1000 +++ new/.mx.jvmci/suite.py 2016-05-04 09:42:43.000000000 -1000 @@ -130,7 +130,7 @@ "workingSets" : "JVMCI", }, - # ------------- JVMCI:HotSpot ------------- + # ------------- JVMCI:Generic ------------- "jdk.vm.ci.aarch64" : { "subDir" : "src/jdk.vm.ci/share/classes", @@ -159,8 +159,10 @@ "workingSets" : "JVMCI,SPARC", }, + # ------------- JVMCI:HotSpot ------------- + "jdk.vm.ci.hotspot" : { - "subDir" : "src/jdk.vm.ci/share/classes", + "subDir" : "src/jdk.vm.ci.hotspot/share/classes", "sourceDirs" : ["src"], "dependencies" : [ "jdk.vm.ci.hotspotvmconfig", @@ -188,7 +190,7 @@ }, "jdk.vm.ci.hotspotvmconfig" : { - "subDir" : "src/jdk.vm.ci/share/classes", + "subDir" : "src/jdk.vm.ci.hotspot/share/classes", "sourceDirs" : ["src"], "checkstyle" : "jdk.vm.ci.services", "javaCompliance" : "1.8", @@ -196,7 +198,7 @@ }, "jdk.vm.ci.hotspot.aarch64" : { - "subDir" : "src/jdk.vm.ci/share/classes", + "subDir" : "src/jdk.vm.ci.hotspot/share/classes", "sourceDirs" : ["src"], "dependencies" : [ "jdk.vm.ci.aarch64", @@ -208,7 +210,7 @@ }, "jdk.vm.ci.hotspot.amd64" : { - "subDir" : "src/jdk.vm.ci/share/classes", + "subDir" : "src/jdk.vm.ci.hotspot/share/classes", "sourceDirs" : ["src"], "dependencies" : [ "jdk.vm.ci.amd64", @@ -220,7 +222,7 @@ }, "jdk.vm.ci.hotspot.sparc" : { - "subDir" : "src/jdk.vm.ci/share/classes", + "subDir" : "src/jdk.vm.ci.hotspot/share/classes", "sourceDirs" : ["src"], "dependencies" : [ "jdk.vm.ci.sparc", @@ -262,14 +264,14 @@ }, "JVMCI_HOTSPOTVMCONFIG" : { - "subDir" : "src/jdk.vm.ci/share/classes", + "subDir" : "src/jdk.vm.ci.hotspot/share/classes", "dependencies" : [ "jdk.vm.ci.hotspotvmconfig", ], }, "JVMCI_HOTSPOT" : { - "subDir" : "src/jdk.vm.ci/share/classes", + "subDir" : "src/jdk.vm.ci.hotspot/share/classes", "dependencies" : [ "jdk.vm.ci.hotspot.aarch64", "jdk.vm.ci.hotspot.amd64", --- old/src/jdk.vm.ci/share/classes/module-info.java 2016-05-04 09:42:44.000000000 -1000 +++ new/src/jdk.vm.ci/share/classes/module-info.java 2016-05-04 09:42:44.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,14 +24,18 @@ */ module jdk.vm.ci { - uses jdk.vm.ci.hotspot.HotSpotVMEventListener; - uses jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; - uses jdk.vm.ci.runtime.JVMCICompilerFactory; + exports jdk.vm.ci.code to jdk.vm.ci.hotspot; + exports jdk.vm.ci.code.site to jdk.vm.ci.hotspot; + exports jdk.vm.ci.code.stack to jdk.vm.ci.hotspot; + exports jdk.vm.ci.common to jdk.vm.ci.hotspot; + exports jdk.vm.ci.inittimer to jdk.vm.ci.hotspot; + exports jdk.vm.ci.meta to jdk.vm.ci.hotspot; + exports jdk.vm.ci.runtime to jdk.vm.ci.hotspot; + exports jdk.vm.ci.services to jdk.vm.ci.hotspot; + + exports jdk.vm.ci.aarch64 to jdk.vm.ci.hotspot; + exports jdk.vm.ci.amd64 to jdk.vm.ci.hotspot; + exports jdk.vm.ci.sparc to jdk.vm.ci.hotspot; - provides jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory with - jdk.vm.ci.hotspot.aarch64.AArch64HotSpotJVMCIBackendFactory; - provides jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory with - jdk.vm.ci.hotspot.amd64.AMD64HotSpotJVMCIBackendFactory; - provides jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory with - jdk.vm.ci.hotspot.sparc.SPARCHotSpotJVMCIBackendFactory; + uses jdk.vm.ci.runtime.JVMCICompilerFactory; } --- old/test/compiler/jvmci/SecurityRestrictionsTest.java 2016-05-04 09:42:45.000000000 -1000 +++ new/test/compiler/jvmci/SecurityRestrictionsTest.java 2016-05-04 09:42:45.000000000 -1000 @@ -28,8 +28,8 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @modules jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @run main/othervm -XX:+UnlockExperimentalVMOptions * -XX:+EnableJVMCI * compiler.jvmci.SecurityRestrictionsTest --- old/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java 2016-05-04 09:42:46.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java 2016-05-04 09:42:46.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,9 +29,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.AllocateCompileIdTest * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java 2016-05-04 09:42:46.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java 2016-05-04 09:42:46.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.CanInlineMethodTest * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/CollectCountersTest.java 2016-05-04 09:42:47.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/CollectCountersTest.java 2016-05-04 09:42:47.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,14 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @modules jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.CollectCountersTest * @run main/othervm -XX:+UnlockExperimentalVMOptions * -XX:+EnableJVMCI --- old/test/compiler/jvmci/compilerToVM/DebugOutputTest.java 2016-05-04 09:42:48.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/DebugOutputTest.java 2016-05-04 09:42:48.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,14 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @modules jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.DebugOutputTest * @run main/othervm compiler.jvmci.compilerToVM.DebugOutputTest */ --- old/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java 2016-05-04 09:42:49.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java 2016-05-04 09:42:48.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.DoNotInlineOrCompileTest * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java 2016-05-04 09:42:49.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java 2016-05-04 09:42:49.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,7 +21,7 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -29,9 +29,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.FindUniqueConcreteMethodTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.FindUniqueConcreteMethodTest --- old/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java 2016-05-04 09:42:50.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java 2016-05-04 09:42:49.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetBytecodeTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.GetBytecodeTest --- old/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java 2016-05-04 09:42:50.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java 2016-05-04 09:42:50.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,14 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @modules jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetClassInitializerTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.GetClassInitializerTest --- old/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java 2016-05-04 09:42:51.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java 2016-05-04 09:42:51.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -19,19 +19,18 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @build jdk.vm.ci/jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject + * @modules jdk.vm.ci/jdk.vm.ci.meta + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject * @build compiler.jvmci.compilerToVM.GetConstantPoolTest * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java 2016-05-04 09:42:51.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java 2016-05-04 09:42:51.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetExceptionTableTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.GetExceptionTableTest --- old/test/compiler/jvmci/compilerToVM/GetImplementorTest.java 2016-05-04 09:42:52.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetImplementorTest.java 2016-05-04 09:42:52.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,14 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @modules jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetImplementorTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.GetImplementorTest --- old/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java 2016-05-04 09:42:53.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java 2016-05-04 09:42:52.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,9 +31,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetLineNumberTableTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.GetLineNumberTableTest --- old/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java 2016-05-04 09:42:53.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java 2016-05-04 09:42:53.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,13 +30,13 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @clean compiler.jvmci.compilerToVM.* * @compile -g DummyInterface.java * @compile -g DummyAbstractClass.java * @compile -g DummyClass.java - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetLocalVariableTableTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.GetLocalVariableTableTest --- old/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java 2016-05-04 09:42:54.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java 2016-05-04 09:42:54.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,14 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @modules jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetMaxCallTargetOffsetTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.GetMaxCallTargetOffsetTest --- old/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java 2016-05-04 09:42:54.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java 2016-05-04 09:42:54.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,7 +21,7 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -29,10 +29,10 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetNextStackFrameTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.GetNextStackFrameTest --- old/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java 2016-05-04 09:42:55.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java 2016-05-04 09:42:55.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,10 +30,10 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetNextStackFrameTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.GetResolvedJavaMethodAtSlotTest --- old/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java 2016-05-04 09:42:56.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java 2016-05-04 09:42:55.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,15 +21,15 @@ * questions. */ - /* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * jdk.vm.ci/jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject + * @modules jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject * @build compiler.jvmci.compilerToVM.GetResolvedJavaMethodTest * @run main ClassFileInstaller * sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java 2016-05-04 09:42:56.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java 2016-05-04 09:42:56.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,16 +21,16 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * jdk.vm.ci/jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject + * @modules jdk.vm.ci/jdk.vm.ci.meta + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject * @build compiler.jvmci.compilerToVM.GetResolvedJavaTypeTest * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller --- old/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java 2016-05-04 09:42:57.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java 2016-05-04 09:42:57.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetStackTraceElementTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.GetStackTraceElementTest --- old/test/compiler/jvmci/compilerToVM/GetSymbolTest.java 2016-05-04 09:42:58.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetSymbolTest.java 2016-05-04 09:42:57.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,7 +21,7 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -29,10 +29,10 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetSymbolTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.GetSymbolTest --- old/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java 2016-05-04 09:42:58.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java 2016-05-04 09:42:58.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,7 +21,7 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -29,9 +29,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetVtableIndexForInterfaceTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.GetVtableIndexForInterfaceTest --- old/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java 2016-05-04 09:42:59.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java 2016-05-04 09:42:59.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.HasCompiledCodeForOSRTest * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java 2016-05-04 09:42:59.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java 2016-05-04 09:42:59.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,14 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @modules jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.HasFinalizableSubclassTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.HasFinalizableSubclassTest --- old/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java 2016-05-04 09:43:00.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java 2016-05-04 09:43:00.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,14 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @modules jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.InitializeConfigurationTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.InitializeConfigurationTest --- old/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java 2016-05-04 09:43:01.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java 2016-05-04 09:43:00.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ * */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -30,11 +30,11 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.runtime + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @ignore 8139700 - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.InvalidateInstalledCodeTest * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/IsMatureTest.java 2016-05-04 09:43:01.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/IsMatureTest.java 2016-05-04 09:43:01.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,14 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @modules jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.IsMatureTest * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java 2016-05-04 09:43:02.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java 2016-05-04 09:43:02.000000000 -1000 @@ -22,13 +22,13 @@ * */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary / - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * jdk.vm.ci/jdk.vm.ci.runtime + * @modules jdk.vm.ci/jdk.vm.ci.runtime + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @run main/othervm -XX:+UnlockExperimentalVMOptions * -Dcompiler.jvmci.compilerToVM.JVM_RegisterJVMCINatives.positive=true * -XX:+EnableJVMCI --- old/test/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java 2016-05-04 09:43:02.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java 2016-05-04 09:43:02.000000000 -1000 @@ -22,7 +22,7 @@ * */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -32,9 +32,9 @@ * @modules java.base/jdk.internal.misc * java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build sun.hotspot.WhiteBox * compiler.jvmci.compilerToVM.LookupKlassInPoolTest * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java 2016-05-04 09:43:03.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java 2016-05-04 09:43:03.000000000 -1000 @@ -22,7 +22,7 @@ * */ -/* +/** * @test * @bug 8138708 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -31,9 +31,9 @@ * @modules java.base/jdk.internal.misc * java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build sun.hotspot.WhiteBox * compiler.jvmci.compilerToVM.LookupKlassRefIndexInPoolTest * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java 2016-05-04 09:43:03.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java 2016-05-04 09:43:03.000000000 -1000 @@ -22,7 +22,7 @@ * */ -/* +/** * @test * @bug 8138708 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -31,9 +31,9 @@ * @modules java.base/jdk.internal.misc * java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build sun.hotspot.WhiteBox * compiler.jvmci.compilerToVM.LookupMethodInPoolTest * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java 2016-05-04 09:43:04.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java 2016-05-04 09:43:04.000000000 -1000 @@ -22,7 +22,7 @@ * */ -/* +/** * @test * @bug 8138708 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -31,9 +31,9 @@ * @modules java.base/jdk.internal.misc * java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build sun.hotspot.WhiteBox * compiler.jvmci.compilerToVM.LookupNameAndTypeRefIndexInPoolTest * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java 2016-05-04 09:43:04.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java 2016-05-04 09:43:04.000000000 -1000 @@ -22,7 +22,7 @@ * */ -/* +/** * @test * @bug 8138708 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -31,9 +31,9 @@ * @modules java.base/jdk.internal.misc * java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build sun.hotspot.WhiteBox * compiler.jvmci.compilerToVM.LookupNameInPoolTest * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java 2016-05-04 09:43:05.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java 2016-05-04 09:43:05.000000000 -1000 @@ -22,7 +22,7 @@ * */ -/* +/** * @test * @bug 8138708 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -31,9 +31,9 @@ * @modules java.base/jdk.internal.misc * java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build sun.hotspot.WhiteBox * compiler.jvmci.compilerToVM.LookupSignatureInPoolTest * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/LookupTypeTest.java 2016-05-04 09:43:05.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/LookupTypeTest.java 2016-05-04 09:43:05.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,14 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @modules jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.LookupTypeTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.LookupTypeTest --- old/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java 2016-05-04 09:43:06.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java 2016-05-04 09:43:06.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,7 +21,7 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -29,11 +29,11 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.meta + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @ignore 8139703 - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java 2016-05-04 09:43:07.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java 2016-05-04 09:43:06.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.MethodIsIgnoredBySecurityStackWalkTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.MethodIsIgnoredBySecurityStackWalkTest --- old/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java 2016-05-04 09:43:07.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java 2016-05-04 09:43:07.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,14 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @modules jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.ReadUncompressedOopTest * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller --- old/test/compiler/jvmci/compilerToVM/ReprofileTest.java 2016-05-04 09:43:08.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/ReprofileTest.java 2016-05-04 09:43:08.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,10 +30,10 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build sun.hotspot.WhiteBox * @build compiler.jvmci.compilerToVM.ReprofileTest * @run main ClassFileInstaller --- old/test/compiler/jvmci/compilerToVM/ResolveConstantInPoolTest.java 2016-05-04 09:43:08.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/ResolveConstantInPoolTest.java 2016-05-04 09:43:08.000000000 -1000 @@ -22,7 +22,7 @@ * */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -30,9 +30,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.misc * java.base/jdk.internal.org.objectweb.asm - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build sun.hotspot.WhiteBox * compiler.jvmci.compilerToVM.ResolveConstantInPoolTest * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java 2016-05-04 09:43:09.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java 2016-05-04 09:43:09.000000000 -1000 @@ -19,10 +19,9 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ -/* +/** * @test * @bug 8138708 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -31,9 +30,9 @@ * @modules java.base/jdk.internal.misc * java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build sun.hotspot.WhiteBox * compiler.jvmci.compilerToVM.ResolveFieldInPoolTest * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java 2016-05-04 09:43:09.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java 2016-05-04 09:43:09.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,7 +21,7 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -29,9 +29,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.ResolveMethodTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * compiler.jvmci.compilerToVM.ResolveMethodTest --- old/test/compiler/jvmci/compilerToVM/ResolvePossiblyCachedConstantInPoolTest.java 2016-05-04 09:43:10.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/ResolvePossiblyCachedConstantInPoolTest.java 2016-05-04 09:43:10.000000000 -1000 @@ -19,10 +19,9 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ -/* +/** * @test * @bug 8138708 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -31,9 +30,9 @@ * @modules java.base/jdk.internal.misc * java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build sun.hotspot.WhiteBox * compiler.jvmci.compilerToVM.ResolvePossiblyCachedConstantInPoolTest * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java 2016-05-04 09:43:10.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java 2016-05-04 09:43:10.000000000 -1000 @@ -19,10 +19,9 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -31,9 +30,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.misc * java.base/jdk.internal.org.objectweb.asm - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build sun.hotspot.WhiteBox * compiler.jvmci.compilerToVM.ResolveTypeInPoolTest * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java 2016-05-04 09:43:11.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java 2016-05-04 09:43:11.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,14 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @modules jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.ShouldDebugNonSafepointsTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * -XX:+UnlockDiagnosticVMOptions --- old/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java 2016-05-04 09:43:12.000000000 -1000 +++ new/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java 2016-05-04 09:43:12.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -19,7 +19,6 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ /** @@ -30,9 +29,9 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.ShouldInlineMethodTest * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox --- old/test/compiler/jvmci/errors/TestInvalidCompilationResult.java 2016-05-04 09:43:12.000000000 -1000 +++ new/test/compiler/jvmci/errors/TestInvalidCompilationResult.java 2016-05-04 09:43:12.000000000 -1000 @@ -24,12 +24,12 @@ /** * @test * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * jdk.vm.ci/jdk.vm.ci.code + * @modules jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.code.site * jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.common + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @compile CodeInstallerTest.java * @build compiler.jvmci.errors.TestInvalidCompilationResult * @run junit/othervm -da:jdk.vm.ci... -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.errors.TestInvalidCompilationResult --- old/test/compiler/jvmci/errors/TestInvalidDebugInfo.java 2016-05-04 09:43:13.000000000 -1000 +++ new/test/compiler/jvmci/errors/TestInvalidDebugInfo.java 2016-05-04 09:43:13.000000000 -1000 @@ -24,12 +24,12 @@ /** * @test * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * jdk.vm.ci/jdk.vm.ci.code + * @modules jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.code.site * jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.common + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @compile CodeInstallerTest.java * @run junit/othervm -da:jdk.vm.ci... -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.errors.TestInvalidDebugInfo */ --- old/test/compiler/jvmci/errors/TestInvalidOopMap.java 2016-05-04 09:43:14.000000000 -1000 +++ new/test/compiler/jvmci/errors/TestInvalidOopMap.java 2016-05-04 09:43:13.000000000 -1000 @@ -24,12 +24,12 @@ /** * @test * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * jdk.vm.ci/jdk.vm.ci.code + * @modules jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.code.site * jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.common + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @compile CodeInstallerTest.java * @run junit/othervm -da:jdk.vm.ci... -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.errors.TestInvalidOopMap */ --- old/test/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.java 2016-05-04 09:43:14.000000000 -1000 +++ new/test/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.java 2016-05-04 09:43:14.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,17 +21,17 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary * @library ../common/patches - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * jdk.vm.ci/jdk.vm.ci.code + * @modules jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime - * @build jdk.vm.ci/jdk.vm.ci.hotspot.MetaAccessWrapper + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.MetaAccessWrapper * @build compiler.jvmci.common.JVMCIHelpers * compiler.jvmci.events.JvmciCreateMetaAccessContextTest * @run main jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/ --- old/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java 2016-05-04 09:43:15.000000000 -1000 +++ new/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java 2016-05-04 09:43:15.000000000 -1000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,7 +21,7 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") @@ -29,12 +29,12 @@ * @library ../common/patches * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @ignore 8144964 - * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper + * @build jdk.vm.ci.hotspot/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.common.JVMCIHelpers * compiler.jvmci.events.JvmciNotifyInstallEventTest * @run main jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/ --- old/test/compiler/jvmci/events/JvmciShutdownEventTest.java 2016-05-04 09:43:15.000000000 -1000 +++ new/test/compiler/jvmci/events/JvmciShutdownEventTest.java 2016-05-04 09:43:15.000000000 -1000 @@ -21,15 +21,15 @@ * questions. */ -/* +/** * @test * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary / - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * jdk.vm.ci/jdk.vm.ci.code + * @modules jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @build compiler.jvmci.common.JVMCIHelpers * compiler.jvmci.events.JvmciShutdownEventListener * compiler.jvmci.events.JvmciShutdownEventTest --- old/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java 2016-05-04 09:43:16.000000000 -1000 +++ new/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java 2016-05-04 09:43:16.000000000 -1000 @@ -25,13 +25,13 @@ * @test * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" * @library / - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * jdk.vm.ci/jdk.vm.ci.meta + * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.code.site * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.DataPatchTest */ --- old/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java 2016-05-04 09:43:16.000000000 -1000 +++ new/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java 2016-05-04 09:43:16.000000000 -1000 @@ -24,14 +24,14 @@ /** * @test * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * jdk.vm.ci/jdk.vm.ci.code + * @modules jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.code.site * jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.common * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.InterpreterFrameSizeTest */ --- old/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java 2016-05-04 09:43:17.000000000 -1000 +++ new/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java 2016-05-04 09:43:17.000000000 -1000 @@ -25,13 +25,13 @@ * @test * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" * @library / - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * jdk.vm.ci/jdk.vm.ci.meta + * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.code.site * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.SimpleCodeInstallationTest */ --- old/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java 2016-05-04 09:43:18.000000000 -1000 +++ new/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java 2016-05-04 09:43:17.000000000 -1000 @@ -25,13 +25,13 @@ * @test * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" * @library / - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * jdk.vm.ci/jdk.vm.ci.meta + * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.code.site * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.SimpleDebugInfoTest */ --- old/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java 2016-05-04 09:43:18.000000000 -1000 +++ new/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java 2016-05-04 09:43:18.000000000 -1000 @@ -25,13 +25,13 @@ * @test * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" * @library / - * @modules jdk.vm.ci/jdk.vm.ci.hotspot - * jdk.vm.ci/jdk.vm.ci.meta + * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.code.site * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.VirtualObjectDebugInfoTest */ --- old/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java 2016-05-04 09:43:19.000000000 -1000 +++ new/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java 2016-05-04 09:43:19.000000000 -1000 @@ -21,12 +21,12 @@ * questions. */ -/* +/** * @test jdk.vm.ci.hotspot.test.HotSpotConstantReflectionProviderTest * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @modules jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.meta - * jdk.vm.ci/jdk.vm.ci.hotspot + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * java.base/jdk.internal.vm.annotation * java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/jvmci/jdk.vm.ci.hotspot.test/src @@ -58,7 +58,7 @@ public void testForObject(Object obj, String expected) { JavaConstant jConst = TestHelper.CONSTANT_REFLECTION_PROVIDER.forObject(obj); Assert.assertNotNull(jConst, - "An instance of JavaConstant returned by" + " \"forObject\" method should not be null"); + "An instance of JavaConstant returned by" + " \"forObject\" method should not be null"); Assert.assertEquals(jConst.toString(), expected, "Unexpected result:"); } @@ -66,67 +66,63 @@ public void testForString(String string, String expected) { JavaConstant jConst = CONSTANT_REFLECTION_PROVIDER.forString(string); Assert.assertNotNull(jConst, - "An instance of JavaConstant returned by" + " \"forString\" method should not be null"); + "An instance of JavaConstant returned by" + " \"forString\" method should not be null"); Assert.assertEquals(jConst.toString(), expected, "Unexpected result:"); } @Test(dataProvider = "constantEqualsDataProvider", dataProviderClass = ConstantEqualsDataProvider.class) public void testConstantEquals(Constant const1, Constant const2, Boolean expected) { Assert.assertEquals(CONSTANT_REFLECTION_PROVIDER.constantEquals(const1, const2), expected, - "Unexpected result:"); + "Unexpected result:"); } @Test(dataProvider = "readArrayLengthDataProvider", dataProviderClass = ReadArrayLengthDataProvider.class) public void testReadArrayLength(JavaConstant array, Integer expected) { Assert.assertEquals(CONSTANT_REFLECTION_PROVIDER.readArrayLength(array), expected, - "Unexpected result:"); + "Unexpected result:"); } @Test(dataProvider = "readArrayElementDataProvider", dataProviderClass = ReadArrayElementDataProvider.class) public void testReadArrayElement(JavaConstant array, int index, Object expected) { Assert.assertEquals(CONSTANT_REFLECTION_PROVIDER.readArrayElement(array, index), expected, - "Unexpected result:"); + "Unexpected result:"); } @Test(dataProvider = "readFieldValueDataProvider", dataProviderClass = ReadFieldValueDataProvider.class) public void testReadFieldValue(ResolvedJavaField field, JavaConstant receiver, JavaConstant expected) { JavaConstant actual = CONSTANT_REFLECTION_PROVIDER.readFieldValue(field, receiver); Assert.assertEquals(actual == null ? "null" : actual.toString(), - expected == null ? "null" : expected.toString(), "Unexpected result:"); + expected == null ? "null" : expected.toString(), "Unexpected result:"); } - @Test(dataProvider = "readFieldValueNegativeDataProvider", - dataProviderClass = ReadFieldValueDataProvider.class, - expectedExceptions = {NullPointerException.class}) + @Test(dataProvider = "readFieldValueNegativeDataProvider", dataProviderClass = ReadFieldValueDataProvider.class, expectedExceptions = {NullPointerException.class}) public void testNegativeReadFieldValue(ResolvedJavaField field, JavaConstant receiver) { CONSTANT_REFLECTION_PROVIDER.readFieldValue(field, receiver); } - @Test(dataProvider = "readStableFieldValueDataProvider", - dataProviderClass = ReadStableFieldValueDataProvider.class) + @Test(dataProvider = "readStableFieldValueDataProvider", dataProviderClass = ReadStableFieldValueDataProvider.class) public void testReadStableFieldValue(ResolvedJavaField field, JavaConstant receiver, boolean isDefStab, - JavaConstant expected) { + JavaConstant expected) { Assert.assertEquals( - CONSTANT_REFLECTION_PROVIDER.readStableFieldValue(field, receiver, isDefStab), - expected, - "Unexpected result:"); + CONSTANT_REFLECTION_PROVIDER.readStableFieldValue(field, receiver, isDefStab), + expected, + "Unexpected result:"); } - @Test(dataProvider = "readStableFieldValueArrayDataProvider", - dataProviderClass = ReadStableFieldValueDataProvider.class) + @Test(dataProvider = "readStableFieldValueArrayDataProvider", dataProviderClass = ReadStableFieldValueDataProvider.class) public void testReadStableFieldValueForArray(ResolvedJavaField field, JavaConstant receiver, boolean isDefStab, - int arrayDim, JavaConstant expected) { + int arrayDim, JavaConstant expected) { JavaConstant result = CONSTANT_REFLECTION_PROVIDER.readStableFieldValue(field, receiver, - isDefStab); + isDefStab); boolean resultDefStab = false; int resultStableDim = -1; try { Class hotSpotObjectConstantImplClass = Class.forName( - "jdk.vm.ci.hotspot.HotSpotObjectConstantImpl"); + "jdk.vm.ci.hotspot.HotSpotObjectConstantImpl"); Method getStableDimensionMethod = hotSpotObjectConstantImplClass.getDeclaredMethod( - "getStableDimension"); + "getStableDimension"); Method isDefaultStableMethod = hotSpotObjectConstantImplClass.getDeclaredMethod( - "isDefaultStable"); + "isDefaultStable"); getStableDimensionMethod.setAccessible(true); isDefaultStableMethod.setAccessible(true); resultDefStab = (boolean) isDefaultStableMethod.invoke(result); @@ -135,62 +131,55 @@ throw new Error("Unexpected error: " + e, e); } Assert.assertEquals(resultDefStab, isDefStab, - "Wrong default stable value for " + result.toString()); + "Wrong default stable value for " + result.toString()); Assert.assertEquals(resultStableDim, arrayDim, - "Wrong array dimension for " + result.toString()); + "Wrong array dimension for " + result.toString()); Assert.assertEquals(result.toString(), expected.toString(), "Unexpected result:"); } - @Test(dataProvider = "readStableFieldValueNegativeDataProvider", - dataProviderClass = ReadStableFieldValueDataProvider.class, - expectedExceptions = {NullPointerException.class}) + @Test(dataProvider = "readStableFieldValueNegativeDataProvider", dataProviderClass = ReadStableFieldValueDataProvider.class, expectedExceptions = {NullPointerException.class}) public void testNegativeReadStableFieldValue(ResolvedJavaField field, JavaConstant receiver, boolean isDefStab) { CONSTANT_REFLECTION_PROVIDER.readStableFieldValue(field, receiver, isDefStab); } - @Test(dataProvider = "readConstantFieldValueDataProvider", - dataProviderClass = ReadConstantFieldValueDataProvider.class) + @Test(dataProvider = "readConstantFieldValueDataProvider", dataProviderClass = ReadConstantFieldValueDataProvider.class) public void testReadConstantFieldValue(ResolvedJavaField field, JavaConstant receiver, JavaConstant expected, - String testInfo) { + String testInfo) { String msg = String.format("Unexpected result for %s. Field is stable = %s.", testInfo, - ((HotSpotResolvedJavaField) field).isStable()); + ((HotSpotResolvedJavaField) field).isStable()); Assert.assertEquals(CONSTANT_REFLECTION_PROVIDER.readConstantFieldValue(field, receiver), - expected, msg); + expected, msg); } - @Test(dataProvider = "readConstantFieldValueNegativeDataProvider", - dataProviderClass = ReadConstantFieldValueDataProvider.class, - expectedExceptions = {NullPointerException.class}) + @Test(dataProvider = "readConstantFieldValueNegativeDataProvider", dataProviderClass = ReadConstantFieldValueDataProvider.class, expectedExceptions = {NullPointerException.class}) public void testNegativeReadConstantFieldValue(ResolvedJavaField field, JavaConstant receiver) { CONSTANT_REFLECTION_PROVIDER.readConstantFieldValue(field, receiver); } - @Test(dataProvider = "readConstantArrayElementDataProvider", - dataProviderClass = ReadConstantArrayElementDataProvider.class) + @Test(dataProvider = "readConstantArrayElementDataProvider", dataProviderClass = ReadConstantArrayElementDataProvider.class) public void testReadConstantArrayElement(JavaConstant array, int index, JavaConstant expected, String testInfo) { JavaConstant actual = CONSTANT_REFLECTION_PROVIDER.readConstantArrayElement(array, index); Assert.assertEquals(actual == null ? "null" : actual.toString(), - expected == null ? "null" : expected.toString(), - String.format("Unexpected result while testing %s:", testInfo)); + expected == null ? "null" : expected.toString(), + String.format("Unexpected result while testing %s:", testInfo)); } - @Test(dataProvider = "readConstantArrayElementForOffsetDataProvider", - dataProviderClass = ReadConstantArrayElementDataProvider.class) + @Test(dataProvider = "readConstantArrayElementForOffsetDataProvider", dataProviderClass = ReadConstantArrayElementDataProvider.class) public void testReadConstantArrayElementForOffset(JavaConstant array, long offset, JavaConstant expected, - String testInfo) { + String testInfo) { JavaConstant actual = CONSTANT_REFLECTION_PROVIDER.readConstantArrayElementForOffset(array, - offset); + offset); Assert.assertEquals(actual == null ? "null" : actual.toString(), - expected == null ? "null" : expected.toString(), - String.format("Unexpected result while testing %s:", testInfo)); + expected == null ? "null" : expected.toString(), + String.format("Unexpected result while testing %s:", testInfo)); } @Test(dataProvider = "asJavaTypeDataProvider", dataProviderClass = AsJavaTypeDataProvider.class) public void testAsJavaType(JavaConstant constant, String expected) { ResolvedJavaType actual = CONSTANT_REFLECTION_PROVIDER.asJavaType(constant); Assert.assertEquals(actual == null ? "null" : actual.toJavaName(), - expected == null ? "null" : expected, - "Unexpected result, wrong type returned:"); + expected == null ? "null" : expected, + "Unexpected result, wrong type returned:"); } @Test(dataProvider = "boxPrimitiveDataProvider", dataProviderClass = BoxPrimitiveDataProvider.class) @@ -221,6 +210,6 @@ public void testGetMethodHandleAccess() { MethodHandleAccessProvider actual = CONSTANT_REFLECTION_PROVIDER.getMethodHandleAccess(); Assert.assertNotNull(actual, - "Returned MethodHandleAccessProvider instance should not be null"); + "Returned MethodHandleAccessProvider instance should not be null"); } } --- old/test/compiler/jvmci/meta/StableFieldTest.java 2016-05-04 09:43:20.000000000 -1000 +++ new/test/compiler/jvmci/meta/StableFieldTest.java 2016-05-04 09:43:20.000000000 -1000 @@ -27,9 +27,9 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @modules java.base/jdk.internal.vm.annotation - * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime + * jdk.vm.ci.hotspot/jdk.vm.ci.hotspot * @compile StableFieldTest.java * @run main ClassFileInstaller compiler.jvmci.meta.StableFieldTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xbootclasspath/a:. compiler.jvmci.meta.StableFieldTest --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java 2016-05-04 09:43:21.000000000 -1000 +++ /dev/null 2016-05-04 09:43:21.000000000 -1000 @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.aarch64; - -import static jdk.vm.ci.inittimer.InitTimer.timer; - -import java.util.EnumSet; - -import jdk.vm.ci.aarch64.AArch64; -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.stack.StackIntrospection; -import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; -import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; -import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; -import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; -import jdk.vm.ci.hotspot.HotSpotStackIntrospection; -import jdk.vm.ci.hotspot.HotSpotVMConfig; -import jdk.vm.ci.inittimer.InitTimer; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.runtime.JVMCIBackend; - -public class AArch64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { - - protected EnumSet computeFeatures(@SuppressWarnings("unused") HotSpotVMConfig config) { - // Configure the feature set using the HotSpot flag settings. - EnumSet features = EnumSet.noneOf(AArch64.CPUFeature.class); - return features; - } - - protected EnumSet computeFlags(@SuppressWarnings("unused") HotSpotVMConfig config) { - EnumSet flags = EnumSet.noneOf(AArch64.Flag.class); - return flags; - } - - protected TargetDescription createTarget(HotSpotVMConfig config) { - final int stackFrameAlignment = 16; - final int implicitNullCheckLimit = 4096; - final boolean inlineObjects = true; - Architecture arch = new AArch64(computeFeatures(config), computeFlags(config)); - return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); - } - - protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntimeProvider runtime) { - return new HotSpotConstantReflectionProvider(runtime); - } - - protected RegisterConfig createRegisterConfig(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target) { - return new AArch64HotSpotRegisterConfig(target.arch, runtime.getConfig()); - } - - protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { - return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); - } - - protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntimeProvider runtime) { - return new HotSpotMetaAccessProvider(runtime); - } - - @Override - public String getArchitecture() { - return "aarch64"; - } - - @Override - public String toString() { - return "JVMCIBackend:" + getArchitecture(); - } - - @SuppressWarnings("try") - public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { - - assert host == null; - TargetDescription target = createTarget(runtime.getConfig()); - - RegisterConfig regConfig; - HotSpotCodeCacheProvider codeCache; - ConstantReflectionProvider constantReflection; - HotSpotMetaAccessProvider metaAccess; - StackIntrospection stackIntrospection; - try (InitTimer t = timer("create providers")) { - try (InitTimer rt = timer("create MetaAccess provider")) { - metaAccess = createMetaAccess(runtime); - } - try (InitTimer rt = timer("create RegisterConfig")) { - regConfig = createRegisterConfig(runtime, target); - } - try (InitTimer rt = timer("create CodeCache provider")) { - codeCache = createCodeCache(runtime, target, regConfig); - } - try (InitTimer rt = timer("create ConstantReflection provider")) { - constantReflection = createConstantReflection(runtime); - } - try (InitTimer rt = timer("create StackIntrospection provider")) { - stackIntrospection = new HotSpotStackIntrospection(runtime); - } - } - try (InitTimer rt = timer("instantiate backend")) { - return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } - } - - protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, StackIntrospection stackIntrospection) { - return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } -} --- /dev/null 2016-05-04 09:43:21.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java 2016-05-04 09:43:20.000000000 -1000 @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot.aarch64; + +import static jdk.vm.ci.inittimer.InitTimer.timer; + +import java.util.EnumSet; + +import jdk.vm.ci.aarch64.AArch64; +import jdk.vm.ci.code.Architecture; +import jdk.vm.ci.code.RegisterConfig; +import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.code.stack.StackIntrospection; +import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; +import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; +import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; +import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; +import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; +import jdk.vm.ci.hotspot.HotSpotStackIntrospection; +import jdk.vm.ci.hotspot.HotSpotVMConfig; +import jdk.vm.ci.inittimer.InitTimer; +import jdk.vm.ci.meta.ConstantReflectionProvider; +import jdk.vm.ci.runtime.JVMCIBackend; + +public class AArch64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { + + protected EnumSet computeFeatures(@SuppressWarnings("unused") HotSpotVMConfig config) { + // Configure the feature set using the HotSpot flag settings. + EnumSet features = EnumSet.noneOf(AArch64.CPUFeature.class); + return features; + } + + protected EnumSet computeFlags(@SuppressWarnings("unused") HotSpotVMConfig config) { + EnumSet flags = EnumSet.noneOf(AArch64.Flag.class); + return flags; + } + + protected TargetDescription createTarget(HotSpotVMConfig config) { + final int stackFrameAlignment = 16; + final int implicitNullCheckLimit = 4096; + final boolean inlineObjects = true; + Architecture arch = new AArch64(computeFeatures(config), computeFlags(config)); + return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); + } + + protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntimeProvider runtime) { + return new HotSpotConstantReflectionProvider(runtime); + } + + protected RegisterConfig createRegisterConfig(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target) { + return new AArch64HotSpotRegisterConfig(target.arch, runtime.getConfig()); + } + + protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { + return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); + } + + protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntimeProvider runtime) { + return new HotSpotMetaAccessProvider(runtime); + } + + @Override + public String getArchitecture() { + return "aarch64"; + } + + @Override + public String toString() { + return "JVMCIBackend:" + getArchitecture(); + } + + @SuppressWarnings("try") + public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { + + assert host == null; + TargetDescription target = createTarget(runtime.getConfig()); + + RegisterConfig regConfig; + HotSpotCodeCacheProvider codeCache; + ConstantReflectionProvider constantReflection; + HotSpotMetaAccessProvider metaAccess; + StackIntrospection stackIntrospection; + try (InitTimer t = timer("create providers")) { + try (InitTimer rt = timer("create MetaAccess provider")) { + metaAccess = createMetaAccess(runtime); + } + try (InitTimer rt = timer("create RegisterConfig")) { + regConfig = createRegisterConfig(runtime, target); + } + try (InitTimer rt = timer("create CodeCache provider")) { + codeCache = createCodeCache(runtime, target, regConfig); + } + try (InitTimer rt = timer("create ConstantReflection provider")) { + constantReflection = createConstantReflection(runtime); + } + try (InitTimer rt = timer("create StackIntrospection provider")) { + stackIntrospection = new HotSpotStackIntrospection(runtime); + } + } + try (InitTimer rt = timer("instantiate backend")) { + return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); + } + } + + protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, StackIntrospection stackIntrospection) { + return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java 2016-05-04 09:43:21.000000000 -1000 +++ /dev/null 2016-05-04 09:43:21.000000000 -1000 @@ -1,310 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.aarch64; - -import static jdk.vm.ci.aarch64.AArch64.lr; -import static jdk.vm.ci.aarch64.AArch64.r0; -import static jdk.vm.ci.aarch64.AArch64.r1; -import static jdk.vm.ci.aarch64.AArch64.r12; -import static jdk.vm.ci.aarch64.AArch64.r2; -import static jdk.vm.ci.aarch64.AArch64.r27; -import static jdk.vm.ci.aarch64.AArch64.r28; -import static jdk.vm.ci.aarch64.AArch64.r29; -import static jdk.vm.ci.aarch64.AArch64.r3; -import static jdk.vm.ci.aarch64.AArch64.r31; -import static jdk.vm.ci.aarch64.AArch64.r4; -import static jdk.vm.ci.aarch64.AArch64.r5; -import static jdk.vm.ci.aarch64.AArch64.r6; -import static jdk.vm.ci.aarch64.AArch64.r7; -import static jdk.vm.ci.aarch64.AArch64.r9; -import static jdk.vm.ci.aarch64.AArch64.sp; -import static jdk.vm.ci.aarch64.AArch64.v0; -import static jdk.vm.ci.aarch64.AArch64.v1; -import static jdk.vm.ci.aarch64.AArch64.v2; -import static jdk.vm.ci.aarch64.AArch64.v3; -import static jdk.vm.ci.aarch64.AArch64.v4; -import static jdk.vm.ci.aarch64.AArch64.v5; -import static jdk.vm.ci.aarch64.AArch64.v6; -import static jdk.vm.ci.aarch64.AArch64.v7; -import static jdk.vm.ci.aarch64.AArch64.zr; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import jdk.vm.ci.aarch64.AArch64; -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.CallingConvention.Type; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterAttributes; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotCallingConventionType; -import jdk.vm.ci.hotspot.HotSpotVMConfig; -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.LIRKind; -import jdk.vm.ci.meta.PlatformKind; -import jdk.vm.ci.meta.Value; - -public class AArch64HotSpotRegisterConfig implements RegisterConfig { - - private final Architecture architecture; - - private final Register[] allocatable; - - private final int maxFrameSize; - - /** - * The caller saved registers always include all parameter registers. - */ - private final Register[] callerSaved; - - private final boolean allAllocatableAreCallerSaved; - - private final RegisterAttributes[] attributesMap; - - public int getMaximumFrameSize() { - return maxFrameSize; - } - - @Override - public Register[] getAllocatableRegisters() { - return allocatable.clone(); - } - - @Override - public Register[] filterAllocatableRegisters(PlatformKind kind, Register[] registers) { - ArrayList list = new ArrayList<>(); - for (Register reg : registers) { - if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) { - list.add(reg); - } - } - - Register[] ret = list.toArray(new Register[list.size()]); - return ret; - } - - @Override - public RegisterAttributes[] getAttributesMap() { - return attributesMap.clone(); - } - - private final Register[] javaGeneralParameterRegisters = {r1, r2, r3, r4, r5, r6, r7, r0}; - private final Register[] nativeGeneralParameterRegisters = {r0, r1, r2, r3, r4, r5, r6, r7}; - private final Register[] simdParameterRegisters = {v0, v1, v2, v3, v4, v5, v6, v7}; - - public static final Register inlineCacheRegister = r9; - - /** - * Vtable stubs expect the metaspace Method in r12. - */ - public static final Register metaspaceMethodRegister = r12; - - public static final Register heapBaseRegister = r27; - public static final Register threadRegister = r28; - public static final Register fp = r29; - - private static final Register[] reservedRegisters = {threadRegister, fp, lr, r31, zr, sp}; - - private static Register[] initAllocatable(Architecture arch, boolean reserveForHeapBase) { - Register[] allRegisters = arch.getAvailableValueRegisters(); - Register[] registers = new Register[allRegisters.length - reservedRegisters.length - (reserveForHeapBase ? 1 : 0)]; - List reservedRegistersList = Arrays.asList(reservedRegisters); - - int idx = 0; - for (Register reg : allRegisters) { - if (reservedRegistersList.contains(reg)) { - // skip reserved registers - continue; - } - assert !(reg.equals(threadRegister) || reg.equals(fp) || reg.equals(lr) || reg.equals(r31) || reg.equals(zr) || reg.equals(sp)); - if (reserveForHeapBase && reg.equals(heapBaseRegister)) { - // skip heap base register - continue; - } - - registers[idx++] = reg; - } - - assert idx == registers.length; - return registers; - } - - public AArch64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config) { - this(architecture, config, initAllocatable(architecture, config.useCompressedOops)); - assert callerSaved.length >= allocatable.length; - } - - public AArch64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config, Register[] allocatable) { - this.architecture = architecture; - this.maxFrameSize = config.maxFrameSize; - - this.allocatable = allocatable.clone(); - Set callerSaveSet = new HashSet<>(); - Collections.addAll(callerSaveSet, allocatable); - Collections.addAll(callerSaveSet, simdParameterRegisters); - Collections.addAll(callerSaveSet, javaGeneralParameterRegisters); - Collections.addAll(callerSaveSet, nativeGeneralParameterRegisters); - callerSaved = callerSaveSet.toArray(new Register[callerSaveSet.size()]); - - allAllocatableAreCallerSaved = true; - attributesMap = RegisterAttributes.createMap(this, AArch64.allRegisters); - } - - @Override - public Register[] getCallerSaveRegisters() { - return callerSaved; - } - - public Register[] getCalleeSaveRegisters() { - return null; - } - - @Override - public boolean areAllAllocatableRegistersCallerSaved() { - return allAllocatableAreCallerSaved; - } - - @Override - public Register getRegisterForRole(int index) { - throw new UnsupportedOperationException(); - } - - @Override - public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - if (type == HotSpotCallingConventionType.NativeCall) { - return callingConvention(nativeGeneralParameterRegisters, returnType, parameterTypes, hotspotType, target); - } - // On x64, parameter locations are the same whether viewed - // from the caller or callee perspective - return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, hotspotType, target); - } - - @Override - public Register[] getCallingConventionRegisters(Type type, JavaKind kind) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - switch (kind) { - case Boolean: - case Byte: - case Short: - case Char: - case Int: - case Long: - case Object: - return hotspotType == HotSpotCallingConventionType.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters; - case Float: - case Double: - return simdParameterRegisters; - default: - throw JVMCIError.shouldNotReachHere(); - } - } - - private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, TargetDescription target) { - AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; - - int currentGeneral = 0; - int currentSIMD = 0; - int currentStackOffset = 0; - - for (int i = 0; i < parameterTypes.length; i++) { - final JavaKind kind = parameterTypes[i].getJavaKind().getStackKind(); - - switch (kind) { - case Byte: - case Boolean: - case Short: - case Char: - case Int: - case Long: - case Object: - if (currentGeneral < generalParameterRegisters.length) { - Register register = generalParameterRegisters[currentGeneral++]; - locations[i] = register.asValue(target.getLIRKind(kind)); - } - break; - case Float: - case Double: - if (currentSIMD < simdParameterRegisters.length) { - Register register = simdParameterRegisters[currentSIMD++]; - locations[i] = register.asValue(target.getLIRKind(kind)); - } - break; - default: - throw JVMCIError.shouldNotReachHere(); - } - - if (locations[i] == null) { - LIRKind lirKind = target.getLIRKind(kind); - locations[i] = StackSlot.get(lirKind, currentStackOffset, !type.out); - currentStackOffset += Math.max(lirKind.getPlatformKind().getSizeInBytes(), target.wordSize); - } - } - - JavaKind returnKind = returnType == null ? JavaKind.Void : returnType.getJavaKind(); - AllocatableValue returnLocation = returnKind == JavaKind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(target.getLIRKind(returnKind.getStackKind())); - return new CallingConvention(currentStackOffset, returnLocation, locations); - } - - @Override - public Register getReturnRegister(JavaKind kind) { - switch (kind) { - case Boolean: - case Byte: - case Char: - case Short: - case Int: - case Long: - case Object: - return r0; - case Float: - case Double: - return v0; - case Void: - case Illegal: - return null; - default: - throw new UnsupportedOperationException("no return register for type " + kind); - } - } - - @Override - public Register getFrameRegister() { - return sp; - } - - @Override - public String toString() { - return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n"); - } -} --- /dev/null 2016-05-04 09:43:21.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java 2016-05-04 09:43:21.000000000 -1000 @@ -0,0 +1,310 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot.aarch64; + +import static jdk.vm.ci.aarch64.AArch64.lr; +import static jdk.vm.ci.aarch64.AArch64.r0; +import static jdk.vm.ci.aarch64.AArch64.r1; +import static jdk.vm.ci.aarch64.AArch64.r12; +import static jdk.vm.ci.aarch64.AArch64.r2; +import static jdk.vm.ci.aarch64.AArch64.r27; +import static jdk.vm.ci.aarch64.AArch64.r28; +import static jdk.vm.ci.aarch64.AArch64.r29; +import static jdk.vm.ci.aarch64.AArch64.r3; +import static jdk.vm.ci.aarch64.AArch64.r31; +import static jdk.vm.ci.aarch64.AArch64.r4; +import static jdk.vm.ci.aarch64.AArch64.r5; +import static jdk.vm.ci.aarch64.AArch64.r6; +import static jdk.vm.ci.aarch64.AArch64.r7; +import static jdk.vm.ci.aarch64.AArch64.r9; +import static jdk.vm.ci.aarch64.AArch64.sp; +import static jdk.vm.ci.aarch64.AArch64.v0; +import static jdk.vm.ci.aarch64.AArch64.v1; +import static jdk.vm.ci.aarch64.AArch64.v2; +import static jdk.vm.ci.aarch64.AArch64.v3; +import static jdk.vm.ci.aarch64.AArch64.v4; +import static jdk.vm.ci.aarch64.AArch64.v5; +import static jdk.vm.ci.aarch64.AArch64.v6; +import static jdk.vm.ci.aarch64.AArch64.v7; +import static jdk.vm.ci.aarch64.AArch64.zr; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import jdk.vm.ci.aarch64.AArch64; +import jdk.vm.ci.code.Architecture; +import jdk.vm.ci.code.CallingConvention; +import jdk.vm.ci.code.CallingConvention.Type; +import jdk.vm.ci.code.Register; +import jdk.vm.ci.code.RegisterAttributes; +import jdk.vm.ci.code.RegisterConfig; +import jdk.vm.ci.code.StackSlot; +import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.hotspot.HotSpotCallingConventionType; +import jdk.vm.ci.hotspot.HotSpotVMConfig; +import jdk.vm.ci.meta.AllocatableValue; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.LIRKind; +import jdk.vm.ci.meta.PlatformKind; +import jdk.vm.ci.meta.Value; + +public class AArch64HotSpotRegisterConfig implements RegisterConfig { + + private final Architecture architecture; + + private final Register[] allocatable; + + private final int maxFrameSize; + + /** + * The caller saved registers always include all parameter registers. + */ + private final Register[] callerSaved; + + private final boolean allAllocatableAreCallerSaved; + + private final RegisterAttributes[] attributesMap; + + public int getMaximumFrameSize() { + return maxFrameSize; + } + + @Override + public Register[] getAllocatableRegisters() { + return allocatable.clone(); + } + + @Override + public Register[] filterAllocatableRegisters(PlatformKind kind, Register[] registers) { + ArrayList list = new ArrayList<>(); + for (Register reg : registers) { + if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) { + list.add(reg); + } + } + + Register[] ret = list.toArray(new Register[list.size()]); + return ret; + } + + @Override + public RegisterAttributes[] getAttributesMap() { + return attributesMap.clone(); + } + + private final Register[] javaGeneralParameterRegisters = {r1, r2, r3, r4, r5, r6, r7, r0}; + private final Register[] nativeGeneralParameterRegisters = {r0, r1, r2, r3, r4, r5, r6, r7}; + private final Register[] simdParameterRegisters = {v0, v1, v2, v3, v4, v5, v6, v7}; + + public static final Register inlineCacheRegister = r9; + + /** + * Vtable stubs expect the metaspace Method in r12. + */ + public static final Register metaspaceMethodRegister = r12; + + public static final Register heapBaseRegister = r27; + public static final Register threadRegister = r28; + public static final Register fp = r29; + + private static final Register[] reservedRegisters = {threadRegister, fp, lr, r31, zr, sp}; + + private static Register[] initAllocatable(Architecture arch, boolean reserveForHeapBase) { + Register[] allRegisters = arch.getAvailableValueRegisters(); + Register[] registers = new Register[allRegisters.length - reservedRegisters.length - (reserveForHeapBase ? 1 : 0)]; + List reservedRegistersList = Arrays.asList(reservedRegisters); + + int idx = 0; + for (Register reg : allRegisters) { + if (reservedRegistersList.contains(reg)) { + // skip reserved registers + continue; + } + assert !(reg.equals(threadRegister) || reg.equals(fp) || reg.equals(lr) || reg.equals(r31) || reg.equals(zr) || reg.equals(sp)); + if (reserveForHeapBase && reg.equals(heapBaseRegister)) { + // skip heap base register + continue; + } + + registers[idx++] = reg; + } + + assert idx == registers.length; + return registers; + } + + public AArch64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config) { + this(architecture, config, initAllocatable(architecture, config.useCompressedOops)); + assert callerSaved.length >= allocatable.length; + } + + public AArch64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config, Register[] allocatable) { + this.architecture = architecture; + this.maxFrameSize = config.maxFrameSize; + + this.allocatable = allocatable.clone(); + Set callerSaveSet = new HashSet<>(); + Collections.addAll(callerSaveSet, allocatable); + Collections.addAll(callerSaveSet, simdParameterRegisters); + Collections.addAll(callerSaveSet, javaGeneralParameterRegisters); + Collections.addAll(callerSaveSet, nativeGeneralParameterRegisters); + callerSaved = callerSaveSet.toArray(new Register[callerSaveSet.size()]); + + allAllocatableAreCallerSaved = true; + attributesMap = RegisterAttributes.createMap(this, AArch64.allRegisters); + } + + @Override + public Register[] getCallerSaveRegisters() { + return callerSaved; + } + + public Register[] getCalleeSaveRegisters() { + return null; + } + + @Override + public boolean areAllAllocatableRegistersCallerSaved() { + return allAllocatableAreCallerSaved; + } + + @Override + public Register getRegisterForRole(int index) { + throw new UnsupportedOperationException(); + } + + @Override + public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target) { + HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; + if (type == HotSpotCallingConventionType.NativeCall) { + return callingConvention(nativeGeneralParameterRegisters, returnType, parameterTypes, hotspotType, target); + } + // On x64, parameter locations are the same whether viewed + // from the caller or callee perspective + return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, hotspotType, target); + } + + @Override + public Register[] getCallingConventionRegisters(Type type, JavaKind kind) { + HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; + switch (kind) { + case Boolean: + case Byte: + case Short: + case Char: + case Int: + case Long: + case Object: + return hotspotType == HotSpotCallingConventionType.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters; + case Float: + case Double: + return simdParameterRegisters; + default: + throw JVMCIError.shouldNotReachHere(); + } + } + + private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, TargetDescription target) { + AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; + + int currentGeneral = 0; + int currentSIMD = 0; + int currentStackOffset = 0; + + for (int i = 0; i < parameterTypes.length; i++) { + final JavaKind kind = parameterTypes[i].getJavaKind().getStackKind(); + + switch (kind) { + case Byte: + case Boolean: + case Short: + case Char: + case Int: + case Long: + case Object: + if (currentGeneral < generalParameterRegisters.length) { + Register register = generalParameterRegisters[currentGeneral++]; + locations[i] = register.asValue(target.getLIRKind(kind)); + } + break; + case Float: + case Double: + if (currentSIMD < simdParameterRegisters.length) { + Register register = simdParameterRegisters[currentSIMD++]; + locations[i] = register.asValue(target.getLIRKind(kind)); + } + break; + default: + throw JVMCIError.shouldNotReachHere(); + } + + if (locations[i] == null) { + LIRKind lirKind = target.getLIRKind(kind); + locations[i] = StackSlot.get(lirKind, currentStackOffset, !type.out); + currentStackOffset += Math.max(lirKind.getPlatformKind().getSizeInBytes(), target.wordSize); + } + } + + JavaKind returnKind = returnType == null ? JavaKind.Void : returnType.getJavaKind(); + AllocatableValue returnLocation = returnKind == JavaKind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(target.getLIRKind(returnKind.getStackKind())); + return new CallingConvention(currentStackOffset, returnLocation, locations); + } + + @Override + public Register getReturnRegister(JavaKind kind) { + switch (kind) { + case Boolean: + case Byte: + case Char: + case Short: + case Int: + case Long: + case Object: + return r0; + case Float: + case Double: + return v0; + case Void: + case Illegal: + return null; + default: + throw new UnsupportedOperationException("no return register for type " + kind); + } + } + + @Override + public Register getFrameRegister() { + return sp; + } + + @Override + public String toString() { + return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n"); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java 2016-05-04 09:43:22.000000000 -1000 +++ /dev/null 2016-05-04 09:43:22.000000000 -1000 @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.amd64; - -import static jdk.vm.ci.inittimer.InitTimer.timer; - -import java.util.EnumSet; - -import jdk.vm.ci.amd64.AMD64; -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.stack.StackIntrospection; -import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; -import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; -import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; -import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; -import jdk.vm.ci.hotspot.HotSpotStackIntrospection; -import jdk.vm.ci.hotspot.HotSpotVMConfig; -import jdk.vm.ci.inittimer.InitTimer; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.runtime.JVMCIBackend; - -public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { - - protected EnumSet computeFeatures(HotSpotVMConfig config) { - // Configure the feature set using the HotSpot flag settings. - EnumSet features = EnumSet.noneOf(AMD64.CPUFeature.class); - if ((config.vmVersionFeatures & config.amd643DNOWPREFETCH) != 0) { - features.add(AMD64.CPUFeature.AMD_3DNOW_PREFETCH); - } - assert config.useSSE >= 2 : "minimum config for x64"; - features.add(AMD64.CPUFeature.SSE); - features.add(AMD64.CPUFeature.SSE2); - if ((config.vmVersionFeatures & config.amd64SSE3) != 0) { - features.add(AMD64.CPUFeature.SSE3); - } - if ((config.vmVersionFeatures & config.amd64SSSE3) != 0) { - features.add(AMD64.CPUFeature.SSSE3); - } - if ((config.vmVersionFeatures & config.amd64SSE4A) != 0) { - features.add(AMD64.CPUFeature.SSE4A); - } - if ((config.vmVersionFeatures & config.amd64SSE41) != 0) { - features.add(AMD64.CPUFeature.SSE4_1); - } - if ((config.vmVersionFeatures & config.amd64SSE42) != 0) { - features.add(AMD64.CPUFeature.SSE4_2); - } - if ((config.vmVersionFeatures & config.amd64POPCNT) != 0) { - features.add(AMD64.CPUFeature.POPCNT); - } - if ((config.vmVersionFeatures & config.amd64LZCNT) != 0) { - features.add(AMD64.CPUFeature.LZCNT); - } - if ((config.vmVersionFeatures & config.amd64ERMS) != 0) { - features.add(AMD64.CPUFeature.ERMS); - } - if ((config.vmVersionFeatures & config.amd64AVX) != 0) { - features.add(AMD64.CPUFeature.AVX); - } - if ((config.vmVersionFeatures & config.amd64AVX2) != 0) { - features.add(AMD64.CPUFeature.AVX2); - } - if ((config.vmVersionFeatures & config.amd64AES) != 0) { - features.add(AMD64.CPUFeature.AES); - } - if ((config.vmVersionFeatures & config.amd643DNOWPREFETCH) != 0) { - features.add(AMD64.CPUFeature.AMD_3DNOW_PREFETCH); - } - if ((config.vmVersionFeatures & config.amd64BMI1) != 0) { - features.add(AMD64.CPUFeature.BMI1); - } - if ((config.vmVersionFeatures & config.amd64BMI2) != 0) { - features.add(AMD64.CPUFeature.BMI2); - } - if ((config.vmVersionFeatures & config.amd64RTM) != 0) { - features.add(AMD64.CPUFeature.RTM); - } - if ((config.vmVersionFeatures & config.amd64ADX) != 0) { - features.add(AMD64.CPUFeature.ADX); - } - if ((config.vmVersionFeatures & config.amd64AVX512F) != 0) { - features.add(AMD64.CPUFeature.AVX512F); - } - if ((config.vmVersionFeatures & config.amd64AVX512DQ) != 0) { - features.add(AMD64.CPUFeature.AVX512DQ); - } - if ((config.vmVersionFeatures & config.amd64AVX512PF) != 0) { - features.add(AMD64.CPUFeature.AVX512PF); - } - if ((config.vmVersionFeatures & config.amd64AVX512ER) != 0) { - features.add(AMD64.CPUFeature.AVX512ER); - } - if ((config.vmVersionFeatures & config.amd64AVX512CD) != 0) { - features.add(AMD64.CPUFeature.AVX512CD); - } - if ((config.vmVersionFeatures & config.amd64AVX512BW) != 0) { - features.add(AMD64.CPUFeature.AVX512BW); - } - if ((config.vmVersionFeatures & config.amd64AVX512VL) != 0) { - features.add(AMD64.CPUFeature.AVX512VL); - } - if ((config.vmVersionFeatures & config.amd64SHA) != 0) { - features.add(AMD64.CPUFeature.SHA); - } - return features; - } - - protected EnumSet computeFlags(HotSpotVMConfig config) { - EnumSet flags = EnumSet.noneOf(AMD64.Flag.class); - if (config.useCountLeadingZerosInstruction) { - flags.add(AMD64.Flag.UseCountLeadingZerosInstruction); - } - if (config.useCountTrailingZerosInstruction) { - flags.add(AMD64.Flag.UseCountTrailingZerosInstruction); - } - return flags; - } - - protected TargetDescription createTarget(HotSpotVMConfig config) { - final int stackFrameAlignment = 16; - final int implicitNullCheckLimit = 4096; - final boolean inlineObjects = true; - Architecture arch = new AMD64(computeFeatures(config), computeFlags(config)); - return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); - } - - protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntimeProvider runtime) { - return new HotSpotConstantReflectionProvider(runtime); - } - - protected RegisterConfig createRegisterConfig(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target) { - return new AMD64HotSpotRegisterConfig(target.arch, runtime.getConfig()); - } - - protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { - return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); - } - - protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntimeProvider runtime) { - return new HotSpotMetaAccessProvider(runtime); - } - - @Override - public String getArchitecture() { - return "AMD64"; - } - - @Override - public String toString() { - return "JVMCIBackend:" + getArchitecture(); - } - - @SuppressWarnings("try") - public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { - - assert host == null; - TargetDescription target = createTarget(runtime.getConfig()); - - RegisterConfig regConfig; - HotSpotCodeCacheProvider codeCache; - ConstantReflectionProvider constantReflection; - HotSpotMetaAccessProvider metaAccess; - StackIntrospection stackIntrospection; - try (InitTimer t = timer("create providers")) { - try (InitTimer rt = timer("create MetaAccess provider")) { - metaAccess = createMetaAccess(runtime); - } - try (InitTimer rt = timer("create RegisterConfig")) { - regConfig = createRegisterConfig(runtime, target); - } - try (InitTimer rt = timer("create CodeCache provider")) { - codeCache = createCodeCache(runtime, target, regConfig); - } - try (InitTimer rt = timer("create ConstantReflection provider")) { - constantReflection = createConstantReflection(runtime); - } - try (InitTimer rt = timer("create StackIntrospection provider")) { - stackIntrospection = new HotSpotStackIntrospection(runtime); - } - } - try (InitTimer rt = timer("instantiate backend")) { - return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } - } - - protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, StackIntrospection stackIntrospection) { - return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } -} --- /dev/null 2016-05-04 09:43:22.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java 2016-05-04 09:43:21.000000000 -1000 @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot.amd64; + +import static jdk.vm.ci.inittimer.InitTimer.timer; + +import java.util.EnumSet; + +import jdk.vm.ci.amd64.AMD64; +import jdk.vm.ci.code.Architecture; +import jdk.vm.ci.code.RegisterConfig; +import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.code.stack.StackIntrospection; +import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; +import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; +import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; +import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; +import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; +import jdk.vm.ci.hotspot.HotSpotStackIntrospection; +import jdk.vm.ci.hotspot.HotSpotVMConfig; +import jdk.vm.ci.inittimer.InitTimer; +import jdk.vm.ci.meta.ConstantReflectionProvider; +import jdk.vm.ci.runtime.JVMCIBackend; + +public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { + + protected EnumSet computeFeatures(HotSpotVMConfig config) { + // Configure the feature set using the HotSpot flag settings. + EnumSet features = EnumSet.noneOf(AMD64.CPUFeature.class); + if ((config.vmVersionFeatures & config.amd643DNOWPREFETCH) != 0) { + features.add(AMD64.CPUFeature.AMD_3DNOW_PREFETCH); + } + assert config.useSSE >= 2 : "minimum config for x64"; + features.add(AMD64.CPUFeature.SSE); + features.add(AMD64.CPUFeature.SSE2); + if ((config.vmVersionFeatures & config.amd64SSE3) != 0) { + features.add(AMD64.CPUFeature.SSE3); + } + if ((config.vmVersionFeatures & config.amd64SSSE3) != 0) { + features.add(AMD64.CPUFeature.SSSE3); + } + if ((config.vmVersionFeatures & config.amd64SSE4A) != 0) { + features.add(AMD64.CPUFeature.SSE4A); + } + if ((config.vmVersionFeatures & config.amd64SSE41) != 0) { + features.add(AMD64.CPUFeature.SSE4_1); + } + if ((config.vmVersionFeatures & config.amd64SSE42) != 0) { + features.add(AMD64.CPUFeature.SSE4_2); + } + if ((config.vmVersionFeatures & config.amd64POPCNT) != 0) { + features.add(AMD64.CPUFeature.POPCNT); + } + if ((config.vmVersionFeatures & config.amd64LZCNT) != 0) { + features.add(AMD64.CPUFeature.LZCNT); + } + if ((config.vmVersionFeatures & config.amd64ERMS) != 0) { + features.add(AMD64.CPUFeature.ERMS); + } + if ((config.vmVersionFeatures & config.amd64AVX) != 0) { + features.add(AMD64.CPUFeature.AVX); + } + if ((config.vmVersionFeatures & config.amd64AVX2) != 0) { + features.add(AMD64.CPUFeature.AVX2); + } + if ((config.vmVersionFeatures & config.amd64AES) != 0) { + features.add(AMD64.CPUFeature.AES); + } + if ((config.vmVersionFeatures & config.amd643DNOWPREFETCH) != 0) { + features.add(AMD64.CPUFeature.AMD_3DNOW_PREFETCH); + } + if ((config.vmVersionFeatures & config.amd64BMI1) != 0) { + features.add(AMD64.CPUFeature.BMI1); + } + if ((config.vmVersionFeatures & config.amd64BMI2) != 0) { + features.add(AMD64.CPUFeature.BMI2); + } + if ((config.vmVersionFeatures & config.amd64RTM) != 0) { + features.add(AMD64.CPUFeature.RTM); + } + if ((config.vmVersionFeatures & config.amd64ADX) != 0) { + features.add(AMD64.CPUFeature.ADX); + } + if ((config.vmVersionFeatures & config.amd64AVX512F) != 0) { + features.add(AMD64.CPUFeature.AVX512F); + } + if ((config.vmVersionFeatures & config.amd64AVX512DQ) != 0) { + features.add(AMD64.CPUFeature.AVX512DQ); + } + if ((config.vmVersionFeatures & config.amd64AVX512PF) != 0) { + features.add(AMD64.CPUFeature.AVX512PF); + } + if ((config.vmVersionFeatures & config.amd64AVX512ER) != 0) { + features.add(AMD64.CPUFeature.AVX512ER); + } + if ((config.vmVersionFeatures & config.amd64AVX512CD) != 0) { + features.add(AMD64.CPUFeature.AVX512CD); + } + if ((config.vmVersionFeatures & config.amd64AVX512BW) != 0) { + features.add(AMD64.CPUFeature.AVX512BW); + } + if ((config.vmVersionFeatures & config.amd64AVX512VL) != 0) { + features.add(AMD64.CPUFeature.AVX512VL); + } + if ((config.vmVersionFeatures & config.amd64SHA) != 0) { + features.add(AMD64.CPUFeature.SHA); + } + return features; + } + + protected EnumSet computeFlags(HotSpotVMConfig config) { + EnumSet flags = EnumSet.noneOf(AMD64.Flag.class); + if (config.useCountLeadingZerosInstruction) { + flags.add(AMD64.Flag.UseCountLeadingZerosInstruction); + } + if (config.useCountTrailingZerosInstruction) { + flags.add(AMD64.Flag.UseCountTrailingZerosInstruction); + } + return flags; + } + + protected TargetDescription createTarget(HotSpotVMConfig config) { + final int stackFrameAlignment = 16; + final int implicitNullCheckLimit = 4096; + final boolean inlineObjects = true; + Architecture arch = new AMD64(computeFeatures(config), computeFlags(config)); + return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); + } + + protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntimeProvider runtime) { + return new HotSpotConstantReflectionProvider(runtime); + } + + protected RegisterConfig createRegisterConfig(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target) { + return new AMD64HotSpotRegisterConfig(target.arch, runtime.getConfig()); + } + + protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { + return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); + } + + protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntimeProvider runtime) { + return new HotSpotMetaAccessProvider(runtime); + } + + @Override + public String getArchitecture() { + return "AMD64"; + } + + @Override + public String toString() { + return "JVMCIBackend:" + getArchitecture(); + } + + @SuppressWarnings("try") + public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { + + assert host == null; + TargetDescription target = createTarget(runtime.getConfig()); + + RegisterConfig regConfig; + HotSpotCodeCacheProvider codeCache; + ConstantReflectionProvider constantReflection; + HotSpotMetaAccessProvider metaAccess; + StackIntrospection stackIntrospection; + try (InitTimer t = timer("create providers")) { + try (InitTimer rt = timer("create MetaAccess provider")) { + metaAccess = createMetaAccess(runtime); + } + try (InitTimer rt = timer("create RegisterConfig")) { + regConfig = createRegisterConfig(runtime, target); + } + try (InitTimer rt = timer("create CodeCache provider")) { + codeCache = createCodeCache(runtime, target, regConfig); + } + try (InitTimer rt = timer("create ConstantReflection provider")) { + constantReflection = createConstantReflection(runtime); + } + try (InitTimer rt = timer("create StackIntrospection provider")) { + stackIntrospection = new HotSpotStackIntrospection(runtime); + } + } + try (InitTimer rt = timer("instantiate backend")) { + return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); + } + } + + protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, StackIntrospection stackIntrospection) { + return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java 2016-05-04 09:43:22.000000000 -1000 +++ /dev/null 2016-05-04 09:43:22.000000000 -1000 @@ -1,307 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.amd64; - -import static jdk.vm.ci.amd64.AMD64.r12; -import static jdk.vm.ci.amd64.AMD64.r15; -import static jdk.vm.ci.amd64.AMD64.r8; -import static jdk.vm.ci.amd64.AMD64.r9; -import static jdk.vm.ci.amd64.AMD64.rax; -import static jdk.vm.ci.amd64.AMD64.rcx; -import static jdk.vm.ci.amd64.AMD64.rdi; -import static jdk.vm.ci.amd64.AMD64.rdx; -import static jdk.vm.ci.amd64.AMD64.rsi; -import static jdk.vm.ci.amd64.AMD64.rsp; -import static jdk.vm.ci.amd64.AMD64.xmm0; -import static jdk.vm.ci.amd64.AMD64.xmm1; -import static jdk.vm.ci.amd64.AMD64.xmm2; -import static jdk.vm.ci.amd64.AMD64.xmm3; -import static jdk.vm.ci.amd64.AMD64.xmm4; -import static jdk.vm.ci.amd64.AMD64.xmm5; -import static jdk.vm.ci.amd64.AMD64.xmm6; -import static jdk.vm.ci.amd64.AMD64.xmm7; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.CallingConvention.Type; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterAttributes; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotCallingConventionType; -import jdk.vm.ci.hotspot.HotSpotVMConfig; -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.LIRKind; -import jdk.vm.ci.meta.PlatformKind; -import jdk.vm.ci.meta.Value; - -public class AMD64HotSpotRegisterConfig implements RegisterConfig { - - private final Architecture architecture; - - private final Register[] allocatable; - - private final int maxFrameSize; - - /** - * The caller saved registers always include all parameter registers. - */ - private final Register[] callerSaved; - - private final boolean allAllocatableAreCallerSaved; - - private final RegisterAttributes[] attributesMap; - - public int getMaximumFrameSize() { - return maxFrameSize; - } - - @Override - public Register[] getAllocatableRegisters() { - return allocatable.clone(); - } - - @Override - public Register[] filterAllocatableRegisters(PlatformKind kind, Register[] registers) { - ArrayList list = new ArrayList<>(); - for (Register reg : registers) { - if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) { - list.add(reg); - } - } - - Register[] ret = list.toArray(new Register[list.size()]); - return ret; - } - - @Override - public RegisterAttributes[] getAttributesMap() { - return attributesMap.clone(); - } - - private final Register[] javaGeneralParameterRegisters; - private final Register[] nativeGeneralParameterRegisters; - private final Register[] xmmParameterRegisters = {xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7}; - - /* - * Some ABIs (e.g. Windows) require a so-called "home space", that is a save area on the stack - * to store the argument registers - */ - private final boolean needsNativeStackHomeSpace; - - private static final Register[] reservedRegisters = {rsp, r15}; - - private static Register[] initAllocatable(Architecture arch, boolean reserveForHeapBase) { - Register[] allRegisters = arch.getAvailableValueRegisters(); - Register[] registers = new Register[allRegisters.length - reservedRegisters.length - (reserveForHeapBase ? 1 : 0)]; - List reservedRegistersList = Arrays.asList(reservedRegisters); - - int idx = 0; - for (Register reg : allRegisters) { - if (reservedRegistersList.contains(reg)) { - // skip reserved registers - continue; - } - if (reserveForHeapBase && reg.equals(r12)) { - // skip heap base register - continue; - } - - registers[idx++] = reg; - } - - assert idx == registers.length; - return registers; - } - - public AMD64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config) { - this(architecture, config, initAllocatable(architecture, config.useCompressedOops)); - assert callerSaved.length >= allocatable.length; - } - - public AMD64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config, Register[] allocatable) { - this.architecture = architecture; - this.maxFrameSize = config.maxFrameSize; - - if (config.windowsOs) { - javaGeneralParameterRegisters = new Register[]{rdx, r8, r9, rdi, rsi, rcx}; - nativeGeneralParameterRegisters = new Register[]{rcx, rdx, r8, r9}; - this.needsNativeStackHomeSpace = true; - } else { - javaGeneralParameterRegisters = new Register[]{rsi, rdx, rcx, r8, r9, rdi}; - nativeGeneralParameterRegisters = new Register[]{rdi, rsi, rdx, rcx, r8, r9}; - this.needsNativeStackHomeSpace = false; - } - - this.allocatable = allocatable; - Set callerSaveSet = new HashSet<>(); - Collections.addAll(callerSaveSet, allocatable); - Collections.addAll(callerSaveSet, xmmParameterRegisters); - Collections.addAll(callerSaveSet, javaGeneralParameterRegisters); - Collections.addAll(callerSaveSet, nativeGeneralParameterRegisters); - callerSaved = callerSaveSet.toArray(new Register[callerSaveSet.size()]); - - allAllocatableAreCallerSaved = true; - attributesMap = RegisterAttributes.createMap(this, architecture.getRegisters()); - } - - @Override - public Register[] getCallerSaveRegisters() { - return callerSaved; - } - - @Override - public Register[] getCalleeSaveRegisters() { - return null; - } - - @Override - public boolean areAllAllocatableRegistersCallerSaved() { - return allAllocatableAreCallerSaved; - } - - @Override - public Register getRegisterForRole(int index) { - throw new UnsupportedOperationException(); - } - - @Override - public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - if (type == HotSpotCallingConventionType.NativeCall) { - return callingConvention(nativeGeneralParameterRegisters, returnType, parameterTypes, hotspotType, target); - } - // On x64, parameter locations are the same whether viewed - // from the caller or callee perspective - return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, hotspotType, target); - } - - @Override - public Register[] getCallingConventionRegisters(Type type, JavaKind kind) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - switch (kind) { - case Boolean: - case Byte: - case Short: - case Char: - case Int: - case Long: - case Object: - return hotspotType == HotSpotCallingConventionType.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters; - case Float: - case Double: - return xmmParameterRegisters; - default: - throw JVMCIError.shouldNotReachHere(); - } - } - - private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, TargetDescription target) { - AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; - - int currentGeneral = 0; - int currentXMM = 0; - int currentStackOffset = type == HotSpotCallingConventionType.NativeCall && needsNativeStackHomeSpace ? generalParameterRegisters.length * target.wordSize : 0; - - for (int i = 0; i < parameterTypes.length; i++) { - final JavaKind kind = parameterTypes[i].getJavaKind().getStackKind(); - - switch (kind) { - case Byte: - case Boolean: - case Short: - case Char: - case Int: - case Long: - case Object: - if (currentGeneral < generalParameterRegisters.length) { - Register register = generalParameterRegisters[currentGeneral++]; - locations[i] = register.asValue(target.getLIRKind(kind)); - } - break; - case Float: - case Double: - if (currentXMM < xmmParameterRegisters.length) { - Register register = xmmParameterRegisters[currentXMM++]; - locations[i] = register.asValue(target.getLIRKind(kind)); - } - break; - default: - throw JVMCIError.shouldNotReachHere(); - } - - if (locations[i] == null) { - LIRKind lirKind = target.getLIRKind(kind); - locations[i] = StackSlot.get(lirKind, currentStackOffset, !type.out); - currentStackOffset += Math.max(lirKind.getPlatformKind().getSizeInBytes(), target.wordSize); - } - } - - JavaKind returnKind = returnType == null ? JavaKind.Void : returnType.getJavaKind(); - AllocatableValue returnLocation = returnKind == JavaKind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(target.getLIRKind(returnKind.getStackKind())); - return new CallingConvention(currentStackOffset, returnLocation, locations); - } - - @Override - public Register getReturnRegister(JavaKind kind) { - switch (kind) { - case Boolean: - case Byte: - case Char: - case Short: - case Int: - case Long: - case Object: - return rax; - case Float: - case Double: - return xmm0; - case Void: - case Illegal: - return null; - default: - throw new UnsupportedOperationException("no return register for type " + kind); - } - } - - @Override - public Register getFrameRegister() { - return rsp; - } - - @Override - public String toString() { - return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n"); - } -} --- /dev/null 2016-05-04 09:43:22.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java 2016-05-04 09:43:22.000000000 -1000 @@ -0,0 +1,307 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot.amd64; + +import static jdk.vm.ci.amd64.AMD64.r12; +import static jdk.vm.ci.amd64.AMD64.r15; +import static jdk.vm.ci.amd64.AMD64.r8; +import static jdk.vm.ci.amd64.AMD64.r9; +import static jdk.vm.ci.amd64.AMD64.rax; +import static jdk.vm.ci.amd64.AMD64.rcx; +import static jdk.vm.ci.amd64.AMD64.rdi; +import static jdk.vm.ci.amd64.AMD64.rdx; +import static jdk.vm.ci.amd64.AMD64.rsi; +import static jdk.vm.ci.amd64.AMD64.rsp; +import static jdk.vm.ci.amd64.AMD64.xmm0; +import static jdk.vm.ci.amd64.AMD64.xmm1; +import static jdk.vm.ci.amd64.AMD64.xmm2; +import static jdk.vm.ci.amd64.AMD64.xmm3; +import static jdk.vm.ci.amd64.AMD64.xmm4; +import static jdk.vm.ci.amd64.AMD64.xmm5; +import static jdk.vm.ci.amd64.AMD64.xmm6; +import static jdk.vm.ci.amd64.AMD64.xmm7; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import jdk.vm.ci.code.Architecture; +import jdk.vm.ci.code.CallingConvention; +import jdk.vm.ci.code.CallingConvention.Type; +import jdk.vm.ci.code.Register; +import jdk.vm.ci.code.RegisterAttributes; +import jdk.vm.ci.code.RegisterConfig; +import jdk.vm.ci.code.StackSlot; +import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.hotspot.HotSpotCallingConventionType; +import jdk.vm.ci.hotspot.HotSpotVMConfig; +import jdk.vm.ci.meta.AllocatableValue; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.LIRKind; +import jdk.vm.ci.meta.PlatformKind; +import jdk.vm.ci.meta.Value; + +public class AMD64HotSpotRegisterConfig implements RegisterConfig { + + private final Architecture architecture; + + private final Register[] allocatable; + + private final int maxFrameSize; + + /** + * The caller saved registers always include all parameter registers. + */ + private final Register[] callerSaved; + + private final boolean allAllocatableAreCallerSaved; + + private final RegisterAttributes[] attributesMap; + + public int getMaximumFrameSize() { + return maxFrameSize; + } + + @Override + public Register[] getAllocatableRegisters() { + return allocatable.clone(); + } + + @Override + public Register[] filterAllocatableRegisters(PlatformKind kind, Register[] registers) { + ArrayList list = new ArrayList<>(); + for (Register reg : registers) { + if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) { + list.add(reg); + } + } + + Register[] ret = list.toArray(new Register[list.size()]); + return ret; + } + + @Override + public RegisterAttributes[] getAttributesMap() { + return attributesMap.clone(); + } + + private final Register[] javaGeneralParameterRegisters; + private final Register[] nativeGeneralParameterRegisters; + private final Register[] xmmParameterRegisters = {xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7}; + + /* + * Some ABIs (e.g. Windows) require a so-called "home space", that is a save area on the stack + * to store the argument registers + */ + private final boolean needsNativeStackHomeSpace; + + private static final Register[] reservedRegisters = {rsp, r15}; + + private static Register[] initAllocatable(Architecture arch, boolean reserveForHeapBase) { + Register[] allRegisters = arch.getAvailableValueRegisters(); + Register[] registers = new Register[allRegisters.length - reservedRegisters.length - (reserveForHeapBase ? 1 : 0)]; + List reservedRegistersList = Arrays.asList(reservedRegisters); + + int idx = 0; + for (Register reg : allRegisters) { + if (reservedRegistersList.contains(reg)) { + // skip reserved registers + continue; + } + if (reserveForHeapBase && reg.equals(r12)) { + // skip heap base register + continue; + } + + registers[idx++] = reg; + } + + assert idx == registers.length; + return registers; + } + + public AMD64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config) { + this(architecture, config, initAllocatable(architecture, config.useCompressedOops)); + assert callerSaved.length >= allocatable.length; + } + + public AMD64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config, Register[] allocatable) { + this.architecture = architecture; + this.maxFrameSize = config.maxFrameSize; + + if (config.windowsOs) { + javaGeneralParameterRegisters = new Register[]{rdx, r8, r9, rdi, rsi, rcx}; + nativeGeneralParameterRegisters = new Register[]{rcx, rdx, r8, r9}; + this.needsNativeStackHomeSpace = true; + } else { + javaGeneralParameterRegisters = new Register[]{rsi, rdx, rcx, r8, r9, rdi}; + nativeGeneralParameterRegisters = new Register[]{rdi, rsi, rdx, rcx, r8, r9}; + this.needsNativeStackHomeSpace = false; + } + + this.allocatable = allocatable; + Set callerSaveSet = new HashSet<>(); + Collections.addAll(callerSaveSet, allocatable); + Collections.addAll(callerSaveSet, xmmParameterRegisters); + Collections.addAll(callerSaveSet, javaGeneralParameterRegisters); + Collections.addAll(callerSaveSet, nativeGeneralParameterRegisters); + callerSaved = callerSaveSet.toArray(new Register[callerSaveSet.size()]); + + allAllocatableAreCallerSaved = true; + attributesMap = RegisterAttributes.createMap(this, architecture.getRegisters()); + } + + @Override + public Register[] getCallerSaveRegisters() { + return callerSaved; + } + + @Override + public Register[] getCalleeSaveRegisters() { + return null; + } + + @Override + public boolean areAllAllocatableRegistersCallerSaved() { + return allAllocatableAreCallerSaved; + } + + @Override + public Register getRegisterForRole(int index) { + throw new UnsupportedOperationException(); + } + + @Override + public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target) { + HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; + if (type == HotSpotCallingConventionType.NativeCall) { + return callingConvention(nativeGeneralParameterRegisters, returnType, parameterTypes, hotspotType, target); + } + // On x64, parameter locations are the same whether viewed + // from the caller or callee perspective + return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, hotspotType, target); + } + + @Override + public Register[] getCallingConventionRegisters(Type type, JavaKind kind) { + HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; + switch (kind) { + case Boolean: + case Byte: + case Short: + case Char: + case Int: + case Long: + case Object: + return hotspotType == HotSpotCallingConventionType.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters; + case Float: + case Double: + return xmmParameterRegisters; + default: + throw JVMCIError.shouldNotReachHere(); + } + } + + private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, TargetDescription target) { + AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; + + int currentGeneral = 0; + int currentXMM = 0; + int currentStackOffset = type == HotSpotCallingConventionType.NativeCall && needsNativeStackHomeSpace ? generalParameterRegisters.length * target.wordSize : 0; + + for (int i = 0; i < parameterTypes.length; i++) { + final JavaKind kind = parameterTypes[i].getJavaKind().getStackKind(); + + switch (kind) { + case Byte: + case Boolean: + case Short: + case Char: + case Int: + case Long: + case Object: + if (currentGeneral < generalParameterRegisters.length) { + Register register = generalParameterRegisters[currentGeneral++]; + locations[i] = register.asValue(target.getLIRKind(kind)); + } + break; + case Float: + case Double: + if (currentXMM < xmmParameterRegisters.length) { + Register register = xmmParameterRegisters[currentXMM++]; + locations[i] = register.asValue(target.getLIRKind(kind)); + } + break; + default: + throw JVMCIError.shouldNotReachHere(); + } + + if (locations[i] == null) { + LIRKind lirKind = target.getLIRKind(kind); + locations[i] = StackSlot.get(lirKind, currentStackOffset, !type.out); + currentStackOffset += Math.max(lirKind.getPlatformKind().getSizeInBytes(), target.wordSize); + } + } + + JavaKind returnKind = returnType == null ? JavaKind.Void : returnType.getJavaKind(); + AllocatableValue returnLocation = returnKind == JavaKind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(target.getLIRKind(returnKind.getStackKind())); + return new CallingConvention(currentStackOffset, returnLocation, locations); + } + + @Override + public Register getReturnRegister(JavaKind kind) { + switch (kind) { + case Boolean: + case Byte: + case Char: + case Short: + case Int: + case Long: + case Object: + return rax; + case Float: + case Double: + return xmm0; + case Void: + case Illegal: + return null; + default: + throw new UnsupportedOperationException("no return register for type " + kind); + } + } + + @Override + public Register getFrameRegister() { + return rsp; + } + + @Override + public String toString() { + return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n"); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java 2016-05-04 09:43:23.000000000 -1000 +++ /dev/null 2016-05-04 09:43:23.000000000 -1000 @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.sparc; - -import static jdk.vm.ci.inittimer.InitTimer.timer; - -import java.util.EnumSet; - -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.stack.StackIntrospection; -import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; -import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; -import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; -import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; -import jdk.vm.ci.hotspot.HotSpotStackIntrospection; -import jdk.vm.ci.hotspot.HotSpotVMConfig; -import jdk.vm.ci.inittimer.InitTimer; -import jdk.vm.ci.runtime.JVMCIBackend; -import jdk.vm.ci.sparc.SPARC; -import jdk.vm.ci.sparc.SPARC.CPUFeature; - -public class SPARCHotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { - - protected TargetDescription createTarget(HotSpotVMConfig config) { - final int stackFrameAlignment = 16; - final int implicitNullCheckLimit = 4096; - final boolean inlineObjects = false; - Architecture arch = new SPARC(computeFeatures(config)); - return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); - } - - protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { - return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); - } - - protected EnumSet computeFeatures(HotSpotVMConfig config) { - EnumSet features = EnumSet.noneOf(CPUFeature.class); - if ((config.vmVersionFeatures & config.sparcVis1Instructions) != 0) { - features.add(CPUFeature.VIS1); - } - if ((config.vmVersionFeatures & config.sparcVis2Instructions) != 0) { - features.add(CPUFeature.VIS2); - } - if ((config.vmVersionFeatures & config.sparcVis3Instructions) != 0) { - features.add(CPUFeature.VIS3); - } - if ((config.vmVersionFeatures & config.sparcCbcondInstructions) != 0) { - features.add(CPUFeature.CBCOND); - } - if ((config.vmVersionFeatures & config.sparcV8Instructions) != 0) { - features.add(CPUFeature.V8); - } - if ((config.vmVersionFeatures & config.sparcHardwareMul32) != 0) { - features.add(CPUFeature.HARDWARE_MUL32); - } - if ((config.vmVersionFeatures & config.sparcHardwareDiv32) != 0) { - features.add(CPUFeature.HARDWARE_DIV32); - } - if ((config.vmVersionFeatures & config.sparcHardwareFsmuld) != 0) { - features.add(CPUFeature.HARDWARE_FSMULD); - } - if ((config.vmVersionFeatures & config.sparcHardwarePopc) != 0) { - features.add(CPUFeature.HARDWARE_POPC); - } - if ((config.vmVersionFeatures & config.sparcV9Instructions) != 0) { - features.add(CPUFeature.V9); - } - if ((config.vmVersionFeatures & config.sparcSun4v) != 0) { - features.add(CPUFeature.SUN4V); - } - if ((config.vmVersionFeatures & config.sparcBlkInitInstructions) != 0) { - features.add(CPUFeature.BLK_INIT_INSTRUCTIONS); - } - if ((config.vmVersionFeatures & config.sparcFmafInstructions) != 0) { - features.add(CPUFeature.FMAF); - } - if ((config.vmVersionFeatures & config.sparcFmauInstructions) != 0) { - features.add(CPUFeature.FMAU); - } - if ((config.vmVersionFeatures & config.sparcSparc64Family) != 0) { - features.add(CPUFeature.SPARC64_FAMILY); - } - if ((config.vmVersionFeatures & config.sparcMFamily) != 0) { - features.add(CPUFeature.M_FAMILY); - } - if ((config.vmVersionFeatures & config.sparcTFamily) != 0) { - features.add(CPUFeature.T_FAMILY); - } - if ((config.vmVersionFeatures & config.sparcT1Model) != 0) { - features.add(CPUFeature.T1_MODEL); - } - if ((config.vmVersionFeatures & config.sparcSparc5Instructions) != 0) { - features.add(CPUFeature.SPARC5); - } - if ((config.vmVersionFeatures & config.sparcAesInstructions) != 0) { - features.add(CPUFeature.SPARC64_FAMILY); - } - if ((config.vmVersionFeatures & config.sparcSha1Instruction) != 0) { - features.add(CPUFeature.SHA1); - } - if ((config.vmVersionFeatures & config.sparcSha256Instruction) != 0) { - features.add(CPUFeature.SHA256); - } - if ((config.vmVersionFeatures & config.sparcSha512Instruction) != 0) { - features.add(CPUFeature.SHA512); - } - return features; - } - - @Override - public String getArchitecture() { - return "SPARC"; - } - - @Override - public String toString() { - return "JVMCIBackend:" + getArchitecture(); - } - - @SuppressWarnings("try") - public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { - assert host == null; - TargetDescription target = createTarget(runtime.getConfig()); - - HotSpotMetaAccessProvider metaAccess = new HotSpotMetaAccessProvider(runtime); - RegisterConfig regConfig = new SPARCHotSpotRegisterConfig(target.arch, runtime.getConfig()); - HotSpotCodeCacheProvider codeCache = createCodeCache(runtime, target, regConfig); - HotSpotConstantReflectionProvider constantReflection = new HotSpotConstantReflectionProvider(runtime); - StackIntrospection stackIntrospection = new HotSpotStackIntrospection(runtime); - try (InitTimer rt = timer("instantiate backend")) { - return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } - } - - protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, HotSpotConstantReflectionProvider constantReflection, - StackIntrospection stackIntrospection) { - return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } -} --- /dev/null 2016-05-04 09:43:23.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java 2016-05-04 09:43:22.000000000 -1000 @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot.sparc; + +import static jdk.vm.ci.inittimer.InitTimer.timer; + +import java.util.EnumSet; + +import jdk.vm.ci.code.Architecture; +import jdk.vm.ci.code.RegisterConfig; +import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.code.stack.StackIntrospection; +import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; +import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; +import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; +import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; +import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; +import jdk.vm.ci.hotspot.HotSpotStackIntrospection; +import jdk.vm.ci.hotspot.HotSpotVMConfig; +import jdk.vm.ci.inittimer.InitTimer; +import jdk.vm.ci.runtime.JVMCIBackend; +import jdk.vm.ci.sparc.SPARC; +import jdk.vm.ci.sparc.SPARC.CPUFeature; + +public class SPARCHotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { + + protected TargetDescription createTarget(HotSpotVMConfig config) { + final int stackFrameAlignment = 16; + final int implicitNullCheckLimit = 4096; + final boolean inlineObjects = false; + Architecture arch = new SPARC(computeFeatures(config)); + return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); + } + + protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { + return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); + } + + protected EnumSet computeFeatures(HotSpotVMConfig config) { + EnumSet features = EnumSet.noneOf(CPUFeature.class); + if ((config.vmVersionFeatures & config.sparcVis1Instructions) != 0) { + features.add(CPUFeature.VIS1); + } + if ((config.vmVersionFeatures & config.sparcVis2Instructions) != 0) { + features.add(CPUFeature.VIS2); + } + if ((config.vmVersionFeatures & config.sparcVis3Instructions) != 0) { + features.add(CPUFeature.VIS3); + } + if ((config.vmVersionFeatures & config.sparcCbcondInstructions) != 0) { + features.add(CPUFeature.CBCOND); + } + if ((config.vmVersionFeatures & config.sparcV8Instructions) != 0) { + features.add(CPUFeature.V8); + } + if ((config.vmVersionFeatures & config.sparcHardwareMul32) != 0) { + features.add(CPUFeature.HARDWARE_MUL32); + } + if ((config.vmVersionFeatures & config.sparcHardwareDiv32) != 0) { + features.add(CPUFeature.HARDWARE_DIV32); + } + if ((config.vmVersionFeatures & config.sparcHardwareFsmuld) != 0) { + features.add(CPUFeature.HARDWARE_FSMULD); + } + if ((config.vmVersionFeatures & config.sparcHardwarePopc) != 0) { + features.add(CPUFeature.HARDWARE_POPC); + } + if ((config.vmVersionFeatures & config.sparcV9Instructions) != 0) { + features.add(CPUFeature.V9); + } + if ((config.vmVersionFeatures & config.sparcSun4v) != 0) { + features.add(CPUFeature.SUN4V); + } + if ((config.vmVersionFeatures & config.sparcBlkInitInstructions) != 0) { + features.add(CPUFeature.BLK_INIT_INSTRUCTIONS); + } + if ((config.vmVersionFeatures & config.sparcFmafInstructions) != 0) { + features.add(CPUFeature.FMAF); + } + if ((config.vmVersionFeatures & config.sparcFmauInstructions) != 0) { + features.add(CPUFeature.FMAU); + } + if ((config.vmVersionFeatures & config.sparcSparc64Family) != 0) { + features.add(CPUFeature.SPARC64_FAMILY); + } + if ((config.vmVersionFeatures & config.sparcMFamily) != 0) { + features.add(CPUFeature.M_FAMILY); + } + if ((config.vmVersionFeatures & config.sparcTFamily) != 0) { + features.add(CPUFeature.T_FAMILY); + } + if ((config.vmVersionFeatures & config.sparcT1Model) != 0) { + features.add(CPUFeature.T1_MODEL); + } + if ((config.vmVersionFeatures & config.sparcSparc5Instructions) != 0) { + features.add(CPUFeature.SPARC5); + } + if ((config.vmVersionFeatures & config.sparcAesInstructions) != 0) { + features.add(CPUFeature.SPARC64_FAMILY); + } + if ((config.vmVersionFeatures & config.sparcSha1Instruction) != 0) { + features.add(CPUFeature.SHA1); + } + if ((config.vmVersionFeatures & config.sparcSha256Instruction) != 0) { + features.add(CPUFeature.SHA256); + } + if ((config.vmVersionFeatures & config.sparcSha512Instruction) != 0) { + features.add(CPUFeature.SHA512); + } + return features; + } + + @Override + public String getArchitecture() { + return "SPARC"; + } + + @Override + public String toString() { + return "JVMCIBackend:" + getArchitecture(); + } + + @SuppressWarnings("try") + public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { + assert host == null; + TargetDescription target = createTarget(runtime.getConfig()); + + HotSpotMetaAccessProvider metaAccess = new HotSpotMetaAccessProvider(runtime); + RegisterConfig regConfig = new SPARCHotSpotRegisterConfig(target.arch, runtime.getConfig()); + HotSpotCodeCacheProvider codeCache = createCodeCache(runtime, target, regConfig); + HotSpotConstantReflectionProvider constantReflection = new HotSpotConstantReflectionProvider(runtime); + StackIntrospection stackIntrospection = new HotSpotStackIntrospection(runtime); + try (InitTimer rt = timer("instantiate backend")) { + return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); + } + } + + protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, HotSpotConstantReflectionProvider constantReflection, + StackIntrospection stackIntrospection) { + return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java 2016-05-04 09:43:23.000000000 -1000 +++ /dev/null 2016-05-04 09:43:23.000000000 -1000 @@ -1,345 +0,0 @@ -/* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.sparc; - -import static jdk.vm.ci.meta.JavaKind.Void; -import static jdk.vm.ci.meta.Value.ILLEGAL; -import static jdk.vm.ci.sparc.SPARC.REGISTER_SAFE_AREA_SIZE; -import static jdk.vm.ci.sparc.SPARC.d0; -import static jdk.vm.ci.sparc.SPARC.d2; -import static jdk.vm.ci.sparc.SPARC.d4; -import static jdk.vm.ci.sparc.SPARC.d6; -import static jdk.vm.ci.sparc.SPARC.f0; -import static jdk.vm.ci.sparc.SPARC.f1; -import static jdk.vm.ci.sparc.SPARC.f2; -import static jdk.vm.ci.sparc.SPARC.f3; -import static jdk.vm.ci.sparc.SPARC.f4; -import static jdk.vm.ci.sparc.SPARC.f5; -import static jdk.vm.ci.sparc.SPARC.f6; -import static jdk.vm.ci.sparc.SPARC.f7; -import static jdk.vm.ci.sparc.SPARC.g0; -import static jdk.vm.ci.sparc.SPARC.g2; -import static jdk.vm.ci.sparc.SPARC.g6; -import static jdk.vm.ci.sparc.SPARC.i0; -import static jdk.vm.ci.sparc.SPARC.i1; -import static jdk.vm.ci.sparc.SPARC.i2; -import static jdk.vm.ci.sparc.SPARC.i3; -import static jdk.vm.ci.sparc.SPARC.i4; -import static jdk.vm.ci.sparc.SPARC.i5; -import static jdk.vm.ci.sparc.SPARC.i6; -import static jdk.vm.ci.sparc.SPARC.i7; -import static jdk.vm.ci.sparc.SPARC.l0; -import static jdk.vm.ci.sparc.SPARC.l1; -import static jdk.vm.ci.sparc.SPARC.l2; -import static jdk.vm.ci.sparc.SPARC.l3; -import static jdk.vm.ci.sparc.SPARC.l4; -import static jdk.vm.ci.sparc.SPARC.l5; -import static jdk.vm.ci.sparc.SPARC.l6; -import static jdk.vm.ci.sparc.SPARC.l7; -import static jdk.vm.ci.sparc.SPARC.o0; -import static jdk.vm.ci.sparc.SPARC.o1; -import static jdk.vm.ci.sparc.SPARC.o2; -import static jdk.vm.ci.sparc.SPARC.o3; -import static jdk.vm.ci.sparc.SPARC.o4; -import static jdk.vm.ci.sparc.SPARC.o5; -import static jdk.vm.ci.sparc.SPARC.sp; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; - -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.CallingConvention.Type; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterAttributes; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotCallingConventionType; -import jdk.vm.ci.hotspot.HotSpotVMConfig; -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.LIRKind; -import jdk.vm.ci.meta.PlatformKind; -import jdk.vm.ci.sparc.SPARC; - -public class SPARCHotSpotRegisterConfig implements RegisterConfig { - - private final Architecture architecture; - - private final Register[] allocatable; - - private final RegisterAttributes[] attributesMap; - - /** - * Does native code (C++ code) spill arguments in registers to the parent frame? - */ - private final boolean addNativeRegisterArgumentSlots; - - @Override - public Register[] getAllocatableRegisters() { - return allocatable.clone(); - } - - @Override - public Register[] filterAllocatableRegisters(PlatformKind kind, Register[] registers) { - ArrayList list = new ArrayList<>(); - for (Register reg : registers) { - if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) { - list.add(reg); - } - } - Register[] ret = list.toArray(new Register[list.size()]); - return ret; - } - - @Override - public RegisterAttributes[] getAttributesMap() { - return attributesMap.clone(); - } - - private final Register[] cpuCallerParameterRegisters = {o0, o1, o2, o3, o4, o5}; - private final Register[] cpuCalleeParameterRegisters = {i0, i1, i2, i3, i4, i5}; - - private final Register[] fpuFloatParameterRegisters = {f0, f1, f2, f3, f4, f5, f6, f7}; - private final Register[] fpuDoubleParameterRegisters = {d0, null, d2, null, d4, null, d6, null}; - - // @formatter:off - private final Register[] callerSaveRegisters; - - /** - * Registers saved by the callee. This lists all L and I registers which are saved in the - * register window. - */ - private final Register[] calleeSaveRegisters = { - l0, l1, l2, l3, l4, l5, l6, l7, - i0, i1, i2, i3, i4, i5, i6, i7}; - // @formatter:on - - private static final Register[] reservedRegisters = {sp, g0, g2}; - - private static Register[] initAllocatable(Architecture arch, boolean reserveForHeapBase) { - Register[] allRegisters = arch.getAvailableValueRegisters(); - Register[] registers = new Register[allRegisters.length - reservedRegisters.length - (reserveForHeapBase ? 1 : 0)]; - List reservedRegistersList = Arrays.asList(reservedRegisters); - - int idx = 0; - for (Register reg : allRegisters) { - if (reservedRegistersList.contains(reg)) { - // skip reserved registers - continue; - } - if (reserveForHeapBase && reg.equals(g6)) { - // skip heap base register - continue; - } - - registers[idx++] = reg; - } - - assert idx == registers.length; - return registers; - } - - public SPARCHotSpotRegisterConfig(Architecture arch, HotSpotVMConfig config) { - this(arch, initAllocatable(arch, config.useCompressedOops), config); - } - - public SPARCHotSpotRegisterConfig(Architecture arch, Register[] allocatable, HotSpotVMConfig config) { - this.architecture = arch; - this.allocatable = allocatable.clone(); - this.addNativeRegisterArgumentSlots = config.linuxOs; - HashSet callerSaveSet = new HashSet<>(); - Collections.addAll(callerSaveSet, arch.getAvailableValueRegisters()); - for (Register cs : calleeSaveRegisters) { - callerSaveSet.remove(cs); - } - this.callerSaveRegisters = callerSaveSet.toArray(new Register[callerSaveSet.size()]); - attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters); - } - - @Override - public Register[] getCallerSaveRegisters() { - return callerSaveRegisters; - } - - public Register[] getCalleeSaveRegisters() { - return calleeSaveRegisters; - } - - @Override - public boolean areAllAllocatableRegistersCallerSaved() { - return false; - } - - @Override - public Register getRegisterForRole(int index) { - throw new UnsupportedOperationException(); - } - - @Override - public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - if (type == HotSpotCallingConventionType.JavaCall || type == HotSpotCallingConventionType.NativeCall) { - return callingConvention(cpuCallerParameterRegisters, returnType, parameterTypes, hotspotType, target); - } - if (type == HotSpotCallingConventionType.JavaCallee) { - return callingConvention(cpuCalleeParameterRegisters, returnType, parameterTypes, hotspotType, target); - } - throw JVMCIError.shouldNotReachHere(); - } - - @Override - public Register[] getCallingConventionRegisters(Type type, JavaKind kind) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - switch (kind) { - case Boolean: - case Byte: - case Short: - case Char: - case Int: - case Long: - case Object: - return hotspotType == HotSpotCallingConventionType.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters; - case Double: - case Float: - return fpuFloatParameterRegisters; - default: - throw JVMCIError.shouldNotReachHere("Unknown JavaKind " + kind); - } - } - - private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, TargetDescription target) { - AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; - - int currentGeneral = 0; - int currentFloating = 0; - int currentStackOffset = 0; - - for (int i = 0; i < parameterTypes.length; i++) { - final JavaKind kind = parameterTypes[i].getJavaKind().getStackKind(); - - switch (kind) { - case Byte: - case Boolean: - case Short: - case Char: - case Int: - case Long: - case Object: - if (currentGeneral < generalParameterRegisters.length) { - Register register = generalParameterRegisters[currentGeneral++]; - locations[i] = register.asValue(target.getLIRKind(kind)); - } - break; - case Double: - if (currentFloating < fpuFloatParameterRegisters.length) { - if (currentFloating % 2 != 0) { - // Make register number even to be a double reg - currentFloating++; - } - Register register = fpuDoubleParameterRegisters[currentFloating]; - currentFloating += 2; // Only every second is a double register - locations[i] = register.asValue(target.getLIRKind(kind)); - } - break; - case Float: - if (currentFloating < fpuFloatParameterRegisters.length) { - Register register = fpuFloatParameterRegisters[currentFloating++]; - locations[i] = register.asValue(target.getLIRKind(kind)); - } - break; - default: - throw JVMCIError.shouldNotReachHere(); - } - - if (locations[i] == null) { - LIRKind lirKind = target.getLIRKind(kind); - // Stack slot is always aligned to its size in bytes but minimum wordsize - int typeSize = lirKind.getPlatformKind().getSizeInBytes(); - currentStackOffset = roundUp(currentStackOffset, typeSize); - int slotOffset = currentStackOffset + REGISTER_SAFE_AREA_SIZE; - locations[i] = StackSlot.get(lirKind, slotOffset, !type.out); - currentStackOffset += typeSize; - } - } - - JavaKind returnKind = returnType == null ? Void : returnType.getJavaKind(); - AllocatableValue returnLocation = returnKind == Void ? ILLEGAL : getReturnRegister(returnKind, type).asValue(target.getLIRKind(returnKind.getStackKind())); - - int outArgSpillArea; - if (type == HotSpotCallingConventionType.NativeCall && addNativeRegisterArgumentSlots) { - // Space for native callee which may spill our outgoing arguments - outArgSpillArea = Math.min(locations.length, generalParameterRegisters.length) * target.wordSize; - } else { - outArgSpillArea = 0; - } - return new CallingConvention(currentStackOffset + outArgSpillArea, returnLocation, locations); - } - - private static int roundUp(int number, int mod) { - return ((number + mod - 1) / mod) * mod; - } - - @Override - public Register getReturnRegister(JavaKind kind) { - return getReturnRegister(kind, HotSpotCallingConventionType.JavaCallee); - } - - private static Register getReturnRegister(JavaKind kind, HotSpotCallingConventionType type) { - switch (kind) { - case Boolean: - case Byte: - case Char: - case Short: - case Int: - case Long: - case Object: - return type == HotSpotCallingConventionType.JavaCallee ? i0 : o0; - case Float: - return f0; - case Double: - return d0; - case Void: - case Illegal: - return null; - default: - throw new UnsupportedOperationException("no return register for type " + kind); - } - } - - @Override - public Register getFrameRegister() { - return sp; - } - - @Override - public String toString() { - return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n"); - } -} --- /dev/null 2016-05-04 09:43:23.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java 2016-05-04 09:43:23.000000000 -1000 @@ -0,0 +1,345 @@ +/* + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot.sparc; + +import static jdk.vm.ci.meta.JavaKind.Void; +import static jdk.vm.ci.meta.Value.ILLEGAL; +import static jdk.vm.ci.sparc.SPARC.REGISTER_SAFE_AREA_SIZE; +import static jdk.vm.ci.sparc.SPARC.d0; +import static jdk.vm.ci.sparc.SPARC.d2; +import static jdk.vm.ci.sparc.SPARC.d4; +import static jdk.vm.ci.sparc.SPARC.d6; +import static jdk.vm.ci.sparc.SPARC.f0; +import static jdk.vm.ci.sparc.SPARC.f1; +import static jdk.vm.ci.sparc.SPARC.f2; +import static jdk.vm.ci.sparc.SPARC.f3; +import static jdk.vm.ci.sparc.SPARC.f4; +import static jdk.vm.ci.sparc.SPARC.f5; +import static jdk.vm.ci.sparc.SPARC.f6; +import static jdk.vm.ci.sparc.SPARC.f7; +import static jdk.vm.ci.sparc.SPARC.g0; +import static jdk.vm.ci.sparc.SPARC.g2; +import static jdk.vm.ci.sparc.SPARC.g6; +import static jdk.vm.ci.sparc.SPARC.i0; +import static jdk.vm.ci.sparc.SPARC.i1; +import static jdk.vm.ci.sparc.SPARC.i2; +import static jdk.vm.ci.sparc.SPARC.i3; +import static jdk.vm.ci.sparc.SPARC.i4; +import static jdk.vm.ci.sparc.SPARC.i5; +import static jdk.vm.ci.sparc.SPARC.i6; +import static jdk.vm.ci.sparc.SPARC.i7; +import static jdk.vm.ci.sparc.SPARC.l0; +import static jdk.vm.ci.sparc.SPARC.l1; +import static jdk.vm.ci.sparc.SPARC.l2; +import static jdk.vm.ci.sparc.SPARC.l3; +import static jdk.vm.ci.sparc.SPARC.l4; +import static jdk.vm.ci.sparc.SPARC.l5; +import static jdk.vm.ci.sparc.SPARC.l6; +import static jdk.vm.ci.sparc.SPARC.l7; +import static jdk.vm.ci.sparc.SPARC.o0; +import static jdk.vm.ci.sparc.SPARC.o1; +import static jdk.vm.ci.sparc.SPARC.o2; +import static jdk.vm.ci.sparc.SPARC.o3; +import static jdk.vm.ci.sparc.SPARC.o4; +import static jdk.vm.ci.sparc.SPARC.o5; +import static jdk.vm.ci.sparc.SPARC.sp; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; + +import jdk.vm.ci.code.Architecture; +import jdk.vm.ci.code.CallingConvention; +import jdk.vm.ci.code.CallingConvention.Type; +import jdk.vm.ci.code.Register; +import jdk.vm.ci.code.RegisterAttributes; +import jdk.vm.ci.code.RegisterConfig; +import jdk.vm.ci.code.StackSlot; +import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.hotspot.HotSpotCallingConventionType; +import jdk.vm.ci.hotspot.HotSpotVMConfig; +import jdk.vm.ci.meta.AllocatableValue; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.LIRKind; +import jdk.vm.ci.meta.PlatformKind; +import jdk.vm.ci.sparc.SPARC; + +public class SPARCHotSpotRegisterConfig implements RegisterConfig { + + private final Architecture architecture; + + private final Register[] allocatable; + + private final RegisterAttributes[] attributesMap; + + /** + * Does native code (C++ code) spill arguments in registers to the parent frame? + */ + private final boolean addNativeRegisterArgumentSlots; + + @Override + public Register[] getAllocatableRegisters() { + return allocatable.clone(); + } + + @Override + public Register[] filterAllocatableRegisters(PlatformKind kind, Register[] registers) { + ArrayList list = new ArrayList<>(); + for (Register reg : registers) { + if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) { + list.add(reg); + } + } + Register[] ret = list.toArray(new Register[list.size()]); + return ret; + } + + @Override + public RegisterAttributes[] getAttributesMap() { + return attributesMap.clone(); + } + + private final Register[] cpuCallerParameterRegisters = {o0, o1, o2, o3, o4, o5}; + private final Register[] cpuCalleeParameterRegisters = {i0, i1, i2, i3, i4, i5}; + + private final Register[] fpuFloatParameterRegisters = {f0, f1, f2, f3, f4, f5, f6, f7}; + private final Register[] fpuDoubleParameterRegisters = {d0, null, d2, null, d4, null, d6, null}; + + // @formatter:off + private final Register[] callerSaveRegisters; + + /** + * Registers saved by the callee. This lists all L and I registers which are saved in the + * register window. + */ + private final Register[] calleeSaveRegisters = { + l0, l1, l2, l3, l4, l5, l6, l7, + i0, i1, i2, i3, i4, i5, i6, i7}; + // @formatter:on + + private static final Register[] reservedRegisters = {sp, g0, g2}; + + private static Register[] initAllocatable(Architecture arch, boolean reserveForHeapBase) { + Register[] allRegisters = arch.getAvailableValueRegisters(); + Register[] registers = new Register[allRegisters.length - reservedRegisters.length - (reserveForHeapBase ? 1 : 0)]; + List reservedRegistersList = Arrays.asList(reservedRegisters); + + int idx = 0; + for (Register reg : allRegisters) { + if (reservedRegistersList.contains(reg)) { + // skip reserved registers + continue; + } + if (reserveForHeapBase && reg.equals(g6)) { + // skip heap base register + continue; + } + + registers[idx++] = reg; + } + + assert idx == registers.length; + return registers; + } + + public SPARCHotSpotRegisterConfig(Architecture arch, HotSpotVMConfig config) { + this(arch, initAllocatable(arch, config.useCompressedOops), config); + } + + public SPARCHotSpotRegisterConfig(Architecture arch, Register[] allocatable, HotSpotVMConfig config) { + this.architecture = arch; + this.allocatable = allocatable.clone(); + this.addNativeRegisterArgumentSlots = config.linuxOs; + HashSet callerSaveSet = new HashSet<>(); + Collections.addAll(callerSaveSet, arch.getAvailableValueRegisters()); + for (Register cs : calleeSaveRegisters) { + callerSaveSet.remove(cs); + } + this.callerSaveRegisters = callerSaveSet.toArray(new Register[callerSaveSet.size()]); + attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters); + } + + @Override + public Register[] getCallerSaveRegisters() { + return callerSaveRegisters; + } + + public Register[] getCalleeSaveRegisters() { + return calleeSaveRegisters; + } + + @Override + public boolean areAllAllocatableRegistersCallerSaved() { + return false; + } + + @Override + public Register getRegisterForRole(int index) { + throw new UnsupportedOperationException(); + } + + @Override + public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target) { + HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; + if (type == HotSpotCallingConventionType.JavaCall || type == HotSpotCallingConventionType.NativeCall) { + return callingConvention(cpuCallerParameterRegisters, returnType, parameterTypes, hotspotType, target); + } + if (type == HotSpotCallingConventionType.JavaCallee) { + return callingConvention(cpuCalleeParameterRegisters, returnType, parameterTypes, hotspotType, target); + } + throw JVMCIError.shouldNotReachHere(); + } + + @Override + public Register[] getCallingConventionRegisters(Type type, JavaKind kind) { + HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; + switch (kind) { + case Boolean: + case Byte: + case Short: + case Char: + case Int: + case Long: + case Object: + return hotspotType == HotSpotCallingConventionType.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters; + case Double: + case Float: + return fpuFloatParameterRegisters; + default: + throw JVMCIError.shouldNotReachHere("Unknown JavaKind " + kind); + } + } + + private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, TargetDescription target) { + AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; + + int currentGeneral = 0; + int currentFloating = 0; + int currentStackOffset = 0; + + for (int i = 0; i < parameterTypes.length; i++) { + final JavaKind kind = parameterTypes[i].getJavaKind().getStackKind(); + + switch (kind) { + case Byte: + case Boolean: + case Short: + case Char: + case Int: + case Long: + case Object: + if (currentGeneral < generalParameterRegisters.length) { + Register register = generalParameterRegisters[currentGeneral++]; + locations[i] = register.asValue(target.getLIRKind(kind)); + } + break; + case Double: + if (currentFloating < fpuFloatParameterRegisters.length) { + if (currentFloating % 2 != 0) { + // Make register number even to be a double reg + currentFloating++; + } + Register register = fpuDoubleParameterRegisters[currentFloating]; + currentFloating += 2; // Only every second is a double register + locations[i] = register.asValue(target.getLIRKind(kind)); + } + break; + case Float: + if (currentFloating < fpuFloatParameterRegisters.length) { + Register register = fpuFloatParameterRegisters[currentFloating++]; + locations[i] = register.asValue(target.getLIRKind(kind)); + } + break; + default: + throw JVMCIError.shouldNotReachHere(); + } + + if (locations[i] == null) { + LIRKind lirKind = target.getLIRKind(kind); + // Stack slot is always aligned to its size in bytes but minimum wordsize + int typeSize = lirKind.getPlatformKind().getSizeInBytes(); + currentStackOffset = roundUp(currentStackOffset, typeSize); + int slotOffset = currentStackOffset + REGISTER_SAFE_AREA_SIZE; + locations[i] = StackSlot.get(lirKind, slotOffset, !type.out); + currentStackOffset += typeSize; + } + } + + JavaKind returnKind = returnType == null ? Void : returnType.getJavaKind(); + AllocatableValue returnLocation = returnKind == Void ? ILLEGAL : getReturnRegister(returnKind, type).asValue(target.getLIRKind(returnKind.getStackKind())); + + int outArgSpillArea; + if (type == HotSpotCallingConventionType.NativeCall && addNativeRegisterArgumentSlots) { + // Space for native callee which may spill our outgoing arguments + outArgSpillArea = Math.min(locations.length, generalParameterRegisters.length) * target.wordSize; + } else { + outArgSpillArea = 0; + } + return new CallingConvention(currentStackOffset + outArgSpillArea, returnLocation, locations); + } + + private static int roundUp(int number, int mod) { + return ((number + mod - 1) / mod) * mod; + } + + @Override + public Register getReturnRegister(JavaKind kind) { + return getReturnRegister(kind, HotSpotCallingConventionType.JavaCallee); + } + + private static Register getReturnRegister(JavaKind kind, HotSpotCallingConventionType type) { + switch (kind) { + case Boolean: + case Byte: + case Char: + case Short: + case Int: + case Long: + case Object: + return type == HotSpotCallingConventionType.JavaCallee ? i0 : o0; + case Float: + return f0; + case Double: + return d0; + case Void: + case Illegal: + return null; + default: + throw new UnsupportedOperationException("no return register for type " + kind); + } + } + + @Override + public Register getFrameRegister() { + return sp; + } + + @Override + public String toString() { + return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n"); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java 2016-05-04 09:43:24.000000000 -1000 +++ /dev/null 2016-05-04 09:43:24.000000000 -1000 @@ -1,608 +0,0 @@ -/* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.inittimer.InitTimer.timer; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -import jdk.vm.ci.code.BytecodeFrame; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.code.InvalidInstalledCodeException; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; -import jdk.vm.ci.inittimer.InitTimer; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.internal.misc.Unsafe; - -/** - * Calls from Java into HotSpot. The behavior of all the methods in this class that take a native - * pointer as an argument (e.g., {@link #getSymbol(long)}) is undefined if the argument does not - * denote a valid native object. - */ -final class CompilerToVM { - /** - * Initializes the native part of the JVMCI runtime. - */ - private static native void registerNatives(); - - static { - initialize(); - } - - @SuppressWarnings("try") - private static void initialize() { - try (InitTimer t = timer("CompilerToVM.registerNatives")) { - registerNatives(); - } - } - - /** - * Gets the {@link CompilerToVM} instance associated with the singleton - * {@link HotSpotJVMCIRuntime} instance. - */ - public static CompilerToVM compilerToVM() { - return runtime().getCompilerToVM(); - } - - /** - * Copies the original bytecode of {@code method} into a new byte array and returns it. - * - * @return a new byte array containing the original bytecode of {@code method} - */ - native byte[] getBytecode(HotSpotResolvedJavaMethodImpl method); - - /** - * Gets the number of entries in {@code method}'s exception handler table or 0 if it has not - * exception handler table. - */ - native int getExceptionTableLength(HotSpotResolvedJavaMethodImpl method); - - /** - * Gets the address of the first entry in {@code method}'s exception handler table. - * - * Each entry is a native object described by these fields: - * - *
    - *
  • {@link HotSpotVMConfig#exceptionTableElementSize}
  • - *
  • {@link HotSpotVMConfig#exceptionTableElementStartPcOffset}
  • - *
  • {@link HotSpotVMConfig#exceptionTableElementEndPcOffset}
  • - *
  • {@link HotSpotVMConfig#exceptionTableElementHandlerPcOffset}
  • - *
  • {@link HotSpotVMConfig#exceptionTableElementCatchTypeIndexOffset} - *
- * - * @return 0 if {@code method} has no exception handlers (i.e. - * {@code getExceptionTableLength(method) == 0}) - */ - native long getExceptionTableStart(HotSpotResolvedJavaMethodImpl method); - - /** - * Determines if {@code method} can be inlined. A method may not be inlinable for a number of - * reasons such as: - *
    - *
  • a CompileOracle directive may prevent inlining or compilation of methods
  • - *
  • the method may have a bytecode breakpoint set
  • - *
  • the method may have other bytecode features that require special handling by the VM
  • - *
- */ - native boolean canInlineMethod(HotSpotResolvedJavaMethodImpl method); - - /** - * Determines if {@code method} should be inlined at any cost. This could be because: - *
    - *
  • a CompileOracle directive may forces inlining of this methods
  • - *
  • an annotation forces inlining of this method
  • - *
- */ - native boolean shouldInlineMethod(HotSpotResolvedJavaMethodImpl method); - - /** - * Used to implement {@link ResolvedJavaType#findUniqueConcreteMethod(ResolvedJavaMethod)}. - * - * @param method the method on which to base the search - * @param actualHolderType the best known type of receiver - * @return the method result or 0 is there is no unique concrete method for {@code method} - */ - native HotSpotResolvedJavaMethodImpl findUniqueConcreteMethod(HotSpotResolvedObjectTypeImpl actualHolderType, HotSpotResolvedJavaMethodImpl method); - - /** - * Gets the implementor for the interface class {@code type}. - * - * @return the implementor if there is a single implementor, 0 if there is no implementor, or - * {@code type} itself if there is more than one implementor - */ - native HotSpotResolvedObjectTypeImpl getImplementor(HotSpotResolvedObjectTypeImpl type); - - /** - * Determines if {@code method} is ignored by security stack walks. - */ - native boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethodImpl method); - - /** - * Converts a name to a type. - * - * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format - * @param accessingClass the context of resolution (must not be null) - * @param resolve force resolution to a {@link ResolvedJavaType}. If true, this method will - * either return a {@link ResolvedJavaType} or throw an exception - * @return the type for {@code name} or 0 if resolution failed and {@code resolve == false} - * @throws LinkageError if {@code resolve == true} and the resolution failed - */ - native HotSpotResolvedObjectTypeImpl lookupType(String name, Class accessingClass, boolean resolve); - - /** - * Resolves the entry at index {@code cpi} in {@code constantPool} to an object. - * - * The behavior of this method is undefined if {@code cpi} does not denote one of the following - * entry types: {@code JVM_CONSTANT_MethodHandle}, {@code JVM_CONSTANT_MethodHandleInError}, - * {@code JVM_CONSTANT_MethodType} and {@code JVM_CONSTANT_MethodTypeInError}. - */ - native Object resolveConstantInPool(HotSpotConstantPool constantPool, int cpi); - - /** - * Resolves the entry at index {@code cpi} in {@code constantPool} to an object, looking in the - * constant pool cache first. - * - * The behavior of this method is undefined if {@code cpi} does not denote a - * {@code JVM_CONSTANT_String} entry. - */ - native Object resolvePossiblyCachedConstantInPool(HotSpotConstantPool constantPool, int cpi); - - /** - * Gets the {@code JVM_CONSTANT_NameAndType} index from the entry at index {@code cpi} in - * {@code constantPool}. - * - * The behavior of this method is undefined if {@code cpi} does not denote an entry containing a - * {@code JVM_CONSTANT_NameAndType} index. - */ - native int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, int cpi); - - /** - * Gets the name of the {@code JVM_CONSTANT_NameAndType} entry referenced by another entry - * denoted by {@code which} in {@code constantPool}. - * - * The behavior of this method is undefined if {@code which} does not denote a entry that - * references a {@code JVM_CONSTANT_NameAndType} entry. - */ - native String lookupNameInPool(HotSpotConstantPool constantPool, int which); - - /** - * Gets the signature of the {@code JVM_CONSTANT_NameAndType} entry referenced by another entry - * denoted by {@code which} in {@code constantPool}. - * - * The behavior of this method is undefined if {@code which} does not denote a entry that - * references a {@code JVM_CONSTANT_NameAndType} entry. - */ - native String lookupSignatureInPool(HotSpotConstantPool constantPool, int which); - - /** - * Gets the {@code JVM_CONSTANT_Class} index from the entry at index {@code cpi} in - * {@code constantPool}. - * - * The behavior of this method is undefined if {@code cpi} does not denote an entry containing a - * {@code JVM_CONSTANT_Class} index. - */ - native int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, int cpi); - - /** - * Looks up a class denoted by the {@code JVM_CONSTANT_Class} entry at index {@code cpi} in - * {@code constantPool}. This method does not perform any resolution. - * - * The behavior of this method is undefined if {@code cpi} does not denote a - * {@code JVM_CONSTANT_Class} entry. - * - * @return the resolved class entry or a String otherwise - */ - native Object lookupKlassInPool(HotSpotConstantPool constantPool, int cpi); - - /** - * Looks up a method denoted by the entry at index {@code cpi} in {@code constantPool}. This - * method does not perform any resolution. - * - * The behavior of this method is undefined if {@code cpi} does not denote an entry representing - * a method. - * - * @param opcode the opcode of the instruction for which the lookup is being performed or - * {@code -1}. If non-negative, then resolution checks specific to the bytecode it - * denotes are performed if the method is already resolved. Should any of these - * checks fail, 0 is returned. - * @return the resolved method entry, 0 otherwise - */ - native HotSpotResolvedJavaMethodImpl lookupMethodInPool(HotSpotConstantPool constantPool, int cpi, byte opcode); - - /** - * Ensures that the type referenced by the specified {@code JVM_CONSTANT_InvokeDynamic} entry at - * index {@code cpi} in {@code constantPool} is loaded and initialized. - * - * The behavior of this method is undefined if {@code cpi} does not denote a - * {@code JVM_CONSTANT_InvokeDynamic} entry. - */ - native void resolveInvokeDynamicInPool(HotSpotConstantPool constantPool, int cpi); - - /** - * Ensures that the type referenced by the entry for a signature - * polymorphic method at index {@code cpi} in {@code constantPool} is loaded and - * initialized. - * - * The behavior of this method is undefined if {@code cpi} does not denote an entry representing - * a signature polymorphic method. - */ - native void resolveInvokeHandleInPool(HotSpotConstantPool constantPool, int cpi); - - /** - * Gets the resolved type denoted by the entry at index {@code cpi} in {@code constantPool}. - * - * The behavior of this method is undefined if {@code cpi} does not denote an entry representing - * a class. - * - * @throws LinkageError if resolution failed - */ - native HotSpotResolvedObjectTypeImpl resolveTypeInPool(HotSpotConstantPool constantPool, int cpi) throws LinkageError; - - /** - * Looks up and attempts to resolve the {@code JVM_CONSTANT_Field} entry at index {@code cpi} in - * {@code constantPool}. The values returned in {@code info} are: - * - *
-     *     [(int) flags,   // only valid if field is resolved
-     *      (int) offset]  // only valid if field is resolved
-     * 
- * - * The behavior of this method is undefined if {@code cpi} does not denote a - * {@code JVM_CONSTANT_Field} entry. - * - * @param info an array in which the details of the field are returned - * @return the type defining the field if resolution is successful, 0 otherwise - */ - native HotSpotResolvedObjectTypeImpl resolveFieldInPool(HotSpotConstantPool constantPool, int cpi, byte opcode, long[] info); - - /** - * Converts {@code cpci} from an index into the cache for {@code constantPool} to an index - * directly into {@code constantPool}. - * - * The behavior of this method is undefined if {@code ccpi} is an invalid constant pool cache - * index. - */ - native int constantPoolRemapInstructionOperandFromCache(HotSpotConstantPool constantPool, int cpci); - - /** - * Gets the appendix object (if any) associated with the entry at index {@code cpi} in - * {@code constantPool}. - */ - native Object lookupAppendixInPool(HotSpotConstantPool constantPool, int cpi); - - /** - * Installs the result of a compilation into the code cache. - * - * @param target the target where this code should be installed - * @param compiledCode the result of a compilation - * @param code the details of the installed CodeBlob are written to this object - * @return the outcome of the installation which will be one of - * {@link HotSpotVMConfig#codeInstallResultOk}, - * {@link HotSpotVMConfig#codeInstallResultCacheFull}, - * {@link HotSpotVMConfig#codeInstallResultCodeTooLarge}, - * {@link HotSpotVMConfig#codeInstallResultDependenciesFailed} or - * {@link HotSpotVMConfig#codeInstallResultDependenciesInvalid}. - * @throws JVMCIError if there is something wrong with the compiled code or the associated - * metadata. - */ - native int installCode(TargetDescription target, HotSpotCompiledCode compiledCode, InstalledCode code, HotSpotSpeculationLog speculationLog); - - public native int getMetadata(TargetDescription target, HotSpotCompiledCode compiledCode, HotSpotMetaData metaData); - - /** - * Resets all compilation statistics. - */ - native void resetCompilationStatistics(); - - /** - * Initializes the fields of {@code config}. - */ - native long initializeConfiguration(HotSpotVMConfig config); - - /** - * Resolves the implementation of {@code method} for virtual dispatches on objects of dynamic - * type {@code exactReceiver}. This resolution process only searches "up" the class hierarchy of - * {@code exactReceiver}. - * - * @param caller the caller or context type used to perform access checks - * @return the link-time resolved method (might be abstract) or {@code 0} if it can not be - * linked - */ - native HotSpotResolvedJavaMethodImpl resolveMethod(HotSpotResolvedObjectTypeImpl exactReceiver, HotSpotResolvedJavaMethodImpl method, HotSpotResolvedObjectTypeImpl caller); - - /** - * Gets the static initializer of {@code type}. - * - * @return 0 if {@code type} has no static initializer - */ - native HotSpotResolvedJavaMethodImpl getClassInitializer(HotSpotResolvedObjectTypeImpl type); - - /** - * Determines if {@code type} or any of its currently loaded subclasses overrides - * {@code Object.finalize()}. - */ - native boolean hasFinalizableSubclass(HotSpotResolvedObjectTypeImpl type); - - /** - * Gets the method corresponding to {@code holder} and slot number {@code slot} (i.e. - * {@link Method#slot} or {@link Constructor#slot}). - */ - native HotSpotResolvedJavaMethodImpl getResolvedJavaMethodAtSlot(Class holder, int slot); - - /** - * Gets the maximum absolute offset of a PC relative call to {@code address} from any position - * in the code cache. - * - * @param address an address that may be called from any code in the code cache - * @return -1 if {@code address == 0} - */ - native long getMaxCallTargetOffset(long address); - - /** - * Gets a textual disassembly of {@code codeBlob}. - * - * @return a non-zero length string containing a disassembly of {@code codeBlob} or null if - * {@code codeBlob} could not be disassembled for some reason - */ - // The HotSpot disassembler seems not to be thread safe so it's better to synchronize its usage - synchronized native String disassembleCodeBlob(InstalledCode installedCode); - - /** - * Gets a stack trace element for {@code method} at bytecode index {@code bci}. - */ - native StackTraceElement getStackTraceElement(HotSpotResolvedJavaMethodImpl method, int bci); - - /** - * Executes some {@code installedCode} with arguments {@code args}. - * - * @return the result of executing {@code installedCode} - * @throws InvalidInstalledCodeException if {@code installedCode} has been invalidated - */ - native Object executeInstalledCode(Object[] args, InstalledCode installedCode) throws InvalidInstalledCodeException; - - /** - * Gets the line number table for {@code method}. The line number table is encoded as (bci, - * source line number) pairs. - * - * @return the line number table for {@code method} or null if it doesn't have one - */ - native long[] getLineNumberTable(HotSpotResolvedJavaMethodImpl method); - - /** - * Gets the number of entries in the local variable table for {@code method}. - * - * @return the number of entries in the local variable table for {@code method} - */ - native int getLocalVariableTableLength(HotSpotResolvedJavaMethodImpl method); - - /** - * Gets the address of the first entry in the local variable table for {@code method}. - * - * Each entry is a native object described by these fields: - * - *
    - *
  • {@link HotSpotVMConfig#localVariableTableElementSize}
  • - *
  • {@link HotSpotVMConfig#localVariableTableElementLengthOffset}
  • - *
  • {@link HotSpotVMConfig#localVariableTableElementNameCpIndexOffset}
  • - *
  • {@link HotSpotVMConfig#localVariableTableElementDescriptorCpIndexOffset}
  • - *
  • {@link HotSpotVMConfig#localVariableTableElementSignatureCpIndexOffset} - *
  • {@link HotSpotVMConfig#localVariableTableElementSlotOffset} - *
  • {@link HotSpotVMConfig#localVariableTableElementStartBciOffset} - *
- * - * @return 0 if {@code method} does not have a local variable table - */ - native long getLocalVariableTableStart(HotSpotResolvedJavaMethodImpl method); - - /** - * Reads an object pointer within a VM data structure. That is, any {@link HotSpotVMField} whose - * {@link HotSpotVMField#type() type} is {@code "oop"} (e.g., - * {@code ArrayKlass::_component_mirror}, {@code Klass::_java_mirror}, - * {@code JavaThread::_threadObj}). - * - * Note that {@link Unsafe#getObject(Object, long)} cannot be used for this since it does a - * {@code narrowOop} read if the VM is using compressed oops whereas oops within VM data - * structures are (currently) always uncompressed. - * - * @param address address of an oop field within a VM data structure - */ - native Object readUncompressedOop(long address); - - /** - * Determines if {@code method} should not be inlined or compiled. - */ - native void doNotInlineOrCompile(HotSpotResolvedJavaMethodImpl method); - - /** - * Invalidates the profiling information for {@code method} and (re)initializes it such that - * profiling restarts upon its next invocation. - */ - native void reprofile(HotSpotResolvedJavaMethodImpl method); - - /** - * Invalidates {@code installedCode} such that {@link InvalidInstalledCodeException} will be - * raised the next time {@code installedCode} is executed. - */ - native void invalidateInstalledCode(InstalledCode installedCode); - - /** - * Collects the current values of all JVMCI benchmark counters, summed up over all threads. - */ - native long[] collectCounters(); - - /** - * Determines if {@code metaspaceMethodData} is mature. - */ - native boolean isMature(long metaspaceMethodData); - - /** - * Generate a unique id to identify the result of the compile. - */ - native int allocateCompileId(HotSpotResolvedJavaMethodImpl method, int entryBCI); - - /** - * Determines if {@code method} has OSR compiled code identified by {@code entryBCI} for - * compilation level {@code level}. - */ - native boolean hasCompiledCodeForOSR(HotSpotResolvedJavaMethodImpl method, int entryBCI, int level); - - /** - * Gets the value of {@code metaspaceSymbol} as a String. - */ - native String getSymbol(long metaspaceSymbol); - - /** - * Lookup a VMSymbol from a String. - */ - native long lookupSymbol(String symbol); - - /** - * Looks for the next Java stack frame matching an entry in {@code methods}. - * - * @param frame the starting point of the search, where {@code null} refers to the topmost frame - * @param methods the methods to look for, where {@code null} means that any frame is returned - * @return the frame, or {@code null} if the end of the stack was reached during the search - */ - native HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, ResolvedJavaMethod[] methods, int initialSkip); - - /** - * Materializes all virtual objects within {@code stackFrame} updates its locals. - * - * @param invalidate if {@code true}, the compiled method for the stack frame will be - * invalidated. - */ - native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); - - /** - * Gets the v-table index for interface method {@code method} in the receiver {@code type} or - * {@link HotSpotVMConfig#invalidVtableIndex} if {@code method} is not in {@code type}'s - * v-table. - * - * @throws InternalError if {@code type} is an interface or {@code method} is not held by an - * interface or class represented by {@code type} is not initialized - */ - native int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectTypeImpl type, HotSpotResolvedJavaMethodImpl method); - - /** - * Determines if debug info should also be emitted at non-safepoint locations. - */ - - native boolean shouldDebugNonSafepoints(); - - /** - * Writes {@code length} bytes from {@code bytes} starting at offset {@code offset} to the - * HotSpot's log stream. - * - * @exception NullPointerException if {@code bytes == null} - * @exception IndexOutOfBoundsException if copying would cause access of data outside array - * bounds - */ - native void writeDebugOutput(byte[] bytes, int offset, int length); - - /** - * Flush HotSpot's log stream. - */ - native void flushDebugOutput(); - - /** - * Read a HotSpot Method* value from the memory location described by {@code base} plus - * {@code displacement} and return the {@link HotSpotResolvedJavaMethodImpl} wrapping it. This - * method does no checking that the memory location actually contains a valid pointer and may - * crash the VM if an invalid location is provided. If the {@code base} is null then - * {@code displacement} is used by itself. If {@code base} is a - * {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or - * {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object - * and added to {@code displacement}. Any other non-null object type causes an - * {@link IllegalArgumentException} to be thrown. - * - * @param base an object to read from or null - * @param displacement - * @return null or the resolved method for this location - */ - native HotSpotResolvedJavaMethodImpl getResolvedJavaMethod(Object base, long displacement); - - /** - * Read a HotSpot ConstantPool* value from the memory location described by {@code base} plus - * {@code displacement} and return the {@link HotSpotConstantPool} wrapping it. This method does - * no checking that the memory location actually contains a valid pointer and may crash the VM - * if an invalid location is provided. If the {@code base} is null then {@code displacement} is - * used by itself. If {@code base} is a {@link HotSpotResolvedJavaMethodImpl}, - * {@link HotSpotConstantPool} or {@link HotSpotResolvedObjectTypeImpl} then the metaspace - * pointer is fetched from that object and added to {@code displacement}. Any other non-null - * object type causes an {@link IllegalArgumentException} to be thrown. - * - * @param base an object to read from or null - * @param displacement - * @return null or the resolved method for this location - */ - native HotSpotConstantPool getConstantPool(Object base, long displacement); - - /** - * Read a HotSpot Klass* value from the memory location described by {@code base} plus - * {@code displacement} and return the {@link HotSpotResolvedObjectTypeImpl} wrapping it. This - * method does no checking that the memory location actually contains a valid pointer and may - * crash the VM if an invalid location is provided. If the {@code base} is null then - * {@code displacement} is used by itself. If {@code base} is a - * {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or - * {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object - * and added to {@code displacement}. Any other non-null object type causes an - * {@link IllegalArgumentException} to be thrown. - * - * @param base an object to read from or null - * @param displacement - * @param compressed true if the location contains a compressed Klass* - * @return null or the resolved method for this location - */ - native HotSpotResolvedObjectTypeImpl getResolvedJavaType(Object base, long displacement, boolean compressed); - - /** - * Return the size of the HotSpot ProfileData* pointed at by {@code position}. If - * {@code position} is outside the space of the MethodData then an - * {@link IllegalArgumentException} is thrown. A {@code position} inside the MethodData but that - * isn't pointing at a valid ProfileData will crash the VM. - * - * @param metaspaceMethodData - * @param position - * @return the size of the ProfileData item pointed at by {@code position} - * @throws IllegalArgumentException if an out of range position is given - */ - native int methodDataProfileDataSize(long metaspaceMethodData, int position); - - /** - * Return the amount of native stack required for the interpreter frames represented by - * {@code frame}. This is used when emitting the stack banging code to ensure that there is - * enough space for the frames during deoptimization. - * - * @param frame - * @return the number of bytes required for deoptimization of this frame state - */ - native int interpreterFrameSize(BytecodeFrame frame); -} --- /dev/null 2016-05-04 09:43:24.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java 2016-05-04 09:43:23.000000000 -1000 @@ -0,0 +1,608 @@ +/* + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; +import static jdk.vm.ci.inittimer.InitTimer.timer; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +import jdk.vm.ci.code.BytecodeFrame; +import jdk.vm.ci.code.InstalledCode; +import jdk.vm.ci.code.InvalidInstalledCodeException; +import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; +import jdk.vm.ci.inittimer.InitTimer; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; +import jdk.internal.misc.Unsafe; + +/** + * Calls from Java into HotSpot. The behavior of all the methods in this class that take a native + * pointer as an argument (e.g., {@link #getSymbol(long)}) is undefined if the argument does not + * denote a valid native object. + */ +final class CompilerToVM { + /** + * Initializes the native part of the JVMCI runtime. + */ + private static native void registerNatives(); + + static { + initialize(); + } + + @SuppressWarnings("try") + private static void initialize() { + try (InitTimer t = timer("CompilerToVM.registerNatives")) { + registerNatives(); + } + } + + /** + * Gets the {@link CompilerToVM} instance associated with the singleton + * {@link HotSpotJVMCIRuntime} instance. + */ + public static CompilerToVM compilerToVM() { + return runtime().getCompilerToVM(); + } + + /** + * Copies the original bytecode of {@code method} into a new byte array and returns it. + * + * @return a new byte array containing the original bytecode of {@code method} + */ + native byte[] getBytecode(HotSpotResolvedJavaMethodImpl method); + + /** + * Gets the number of entries in {@code method}'s exception handler table or 0 if it has not + * exception handler table. + */ + native int getExceptionTableLength(HotSpotResolvedJavaMethodImpl method); + + /** + * Gets the address of the first entry in {@code method}'s exception handler table. + * + * Each entry is a native object described by these fields: + * + *
    + *
  • {@link HotSpotVMConfig#exceptionTableElementSize}
  • + *
  • {@link HotSpotVMConfig#exceptionTableElementStartPcOffset}
  • + *
  • {@link HotSpotVMConfig#exceptionTableElementEndPcOffset}
  • + *
  • {@link HotSpotVMConfig#exceptionTableElementHandlerPcOffset}
  • + *
  • {@link HotSpotVMConfig#exceptionTableElementCatchTypeIndexOffset} + *
+ * + * @return 0 if {@code method} has no exception handlers (i.e. + * {@code getExceptionTableLength(method) == 0}) + */ + native long getExceptionTableStart(HotSpotResolvedJavaMethodImpl method); + + /** + * Determines if {@code method} can be inlined. A method may not be inlinable for a number of + * reasons such as: + *
    + *
  • a CompileOracle directive may prevent inlining or compilation of methods
  • + *
  • the method may have a bytecode breakpoint set
  • + *
  • the method may have other bytecode features that require special handling by the VM
  • + *
+ */ + native boolean canInlineMethod(HotSpotResolvedJavaMethodImpl method); + + /** + * Determines if {@code method} should be inlined at any cost. This could be because: + *
    + *
  • a CompileOracle directive may forces inlining of this methods
  • + *
  • an annotation forces inlining of this method
  • + *
+ */ + native boolean shouldInlineMethod(HotSpotResolvedJavaMethodImpl method); + + /** + * Used to implement {@link ResolvedJavaType#findUniqueConcreteMethod(ResolvedJavaMethod)}. + * + * @param method the method on which to base the search + * @param actualHolderType the best known type of receiver + * @return the method result or 0 is there is no unique concrete method for {@code method} + */ + native HotSpotResolvedJavaMethodImpl findUniqueConcreteMethod(HotSpotResolvedObjectTypeImpl actualHolderType, HotSpotResolvedJavaMethodImpl method); + + /** + * Gets the implementor for the interface class {@code type}. + * + * @return the implementor if there is a single implementor, 0 if there is no implementor, or + * {@code type} itself if there is more than one implementor + */ + native HotSpotResolvedObjectTypeImpl getImplementor(HotSpotResolvedObjectTypeImpl type); + + /** + * Determines if {@code method} is ignored by security stack walks. + */ + native boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethodImpl method); + + /** + * Converts a name to a type. + * + * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format + * @param accessingClass the context of resolution (must not be null) + * @param resolve force resolution to a {@link ResolvedJavaType}. If true, this method will + * either return a {@link ResolvedJavaType} or throw an exception + * @return the type for {@code name} or 0 if resolution failed and {@code resolve == false} + * @throws LinkageError if {@code resolve == true} and the resolution failed + */ + native HotSpotResolvedObjectTypeImpl lookupType(String name, Class accessingClass, boolean resolve); + + /** + * Resolves the entry at index {@code cpi} in {@code constantPool} to an object. + * + * The behavior of this method is undefined if {@code cpi} does not denote one of the following + * entry types: {@code JVM_CONSTANT_MethodHandle}, {@code JVM_CONSTANT_MethodHandleInError}, + * {@code JVM_CONSTANT_MethodType} and {@code JVM_CONSTANT_MethodTypeInError}. + */ + native Object resolveConstantInPool(HotSpotConstantPool constantPool, int cpi); + + /** + * Resolves the entry at index {@code cpi} in {@code constantPool} to an object, looking in the + * constant pool cache first. + * + * The behavior of this method is undefined if {@code cpi} does not denote a + * {@code JVM_CONSTANT_String} entry. + */ + native Object resolvePossiblyCachedConstantInPool(HotSpotConstantPool constantPool, int cpi); + + /** + * Gets the {@code JVM_CONSTANT_NameAndType} index from the entry at index {@code cpi} in + * {@code constantPool}. + * + * The behavior of this method is undefined if {@code cpi} does not denote an entry containing a + * {@code JVM_CONSTANT_NameAndType} index. + */ + native int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, int cpi); + + /** + * Gets the name of the {@code JVM_CONSTANT_NameAndType} entry referenced by another entry + * denoted by {@code which} in {@code constantPool}. + * + * The behavior of this method is undefined if {@code which} does not denote a entry that + * references a {@code JVM_CONSTANT_NameAndType} entry. + */ + native String lookupNameInPool(HotSpotConstantPool constantPool, int which); + + /** + * Gets the signature of the {@code JVM_CONSTANT_NameAndType} entry referenced by another entry + * denoted by {@code which} in {@code constantPool}. + * + * The behavior of this method is undefined if {@code which} does not denote a entry that + * references a {@code JVM_CONSTANT_NameAndType} entry. + */ + native String lookupSignatureInPool(HotSpotConstantPool constantPool, int which); + + /** + * Gets the {@code JVM_CONSTANT_Class} index from the entry at index {@code cpi} in + * {@code constantPool}. + * + * The behavior of this method is undefined if {@code cpi} does not denote an entry containing a + * {@code JVM_CONSTANT_Class} index. + */ + native int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, int cpi); + + /** + * Looks up a class denoted by the {@code JVM_CONSTANT_Class} entry at index {@code cpi} in + * {@code constantPool}. This method does not perform any resolution. + * + * The behavior of this method is undefined if {@code cpi} does not denote a + * {@code JVM_CONSTANT_Class} entry. + * + * @return the resolved class entry or a String otherwise + */ + native Object lookupKlassInPool(HotSpotConstantPool constantPool, int cpi); + + /** + * Looks up a method denoted by the entry at index {@code cpi} in {@code constantPool}. This + * method does not perform any resolution. + * + * The behavior of this method is undefined if {@code cpi} does not denote an entry representing + * a method. + * + * @param opcode the opcode of the instruction for which the lookup is being performed or + * {@code -1}. If non-negative, then resolution checks specific to the bytecode it + * denotes are performed if the method is already resolved. Should any of these + * checks fail, 0 is returned. + * @return the resolved method entry, 0 otherwise + */ + native HotSpotResolvedJavaMethodImpl lookupMethodInPool(HotSpotConstantPool constantPool, int cpi, byte opcode); + + /** + * Ensures that the type referenced by the specified {@code JVM_CONSTANT_InvokeDynamic} entry at + * index {@code cpi} in {@code constantPool} is loaded and initialized. + * + * The behavior of this method is undefined if {@code cpi} does not denote a + * {@code JVM_CONSTANT_InvokeDynamic} entry. + */ + native void resolveInvokeDynamicInPool(HotSpotConstantPool constantPool, int cpi); + + /** + * Ensures that the type referenced by the entry for a signature + * polymorphic method at index {@code cpi} in {@code constantPool} is loaded and + * initialized. + * + * The behavior of this method is undefined if {@code cpi} does not denote an entry representing + * a signature polymorphic method. + */ + native void resolveInvokeHandleInPool(HotSpotConstantPool constantPool, int cpi); + + /** + * Gets the resolved type denoted by the entry at index {@code cpi} in {@code constantPool}. + * + * The behavior of this method is undefined if {@code cpi} does not denote an entry representing + * a class. + * + * @throws LinkageError if resolution failed + */ + native HotSpotResolvedObjectTypeImpl resolveTypeInPool(HotSpotConstantPool constantPool, int cpi) throws LinkageError; + + /** + * Looks up and attempts to resolve the {@code JVM_CONSTANT_Field} entry at index {@code cpi} in + * {@code constantPool}. The values returned in {@code info} are: + * + *
+     *     [(int) flags,   // only valid if field is resolved
+     *      (int) offset]  // only valid if field is resolved
+     * 
+ * + * The behavior of this method is undefined if {@code cpi} does not denote a + * {@code JVM_CONSTANT_Field} entry. + * + * @param info an array in which the details of the field are returned + * @return the type defining the field if resolution is successful, 0 otherwise + */ + native HotSpotResolvedObjectTypeImpl resolveFieldInPool(HotSpotConstantPool constantPool, int cpi, byte opcode, long[] info); + + /** + * Converts {@code cpci} from an index into the cache for {@code constantPool} to an index + * directly into {@code constantPool}. + * + * The behavior of this method is undefined if {@code ccpi} is an invalid constant pool cache + * index. + */ + native int constantPoolRemapInstructionOperandFromCache(HotSpotConstantPool constantPool, int cpci); + + /** + * Gets the appendix object (if any) associated with the entry at index {@code cpi} in + * {@code constantPool}. + */ + native Object lookupAppendixInPool(HotSpotConstantPool constantPool, int cpi); + + /** + * Installs the result of a compilation into the code cache. + * + * @param target the target where this code should be installed + * @param compiledCode the result of a compilation + * @param code the details of the installed CodeBlob are written to this object + * @return the outcome of the installation which will be one of + * {@link HotSpotVMConfig#codeInstallResultOk}, + * {@link HotSpotVMConfig#codeInstallResultCacheFull}, + * {@link HotSpotVMConfig#codeInstallResultCodeTooLarge}, + * {@link HotSpotVMConfig#codeInstallResultDependenciesFailed} or + * {@link HotSpotVMConfig#codeInstallResultDependenciesInvalid}. + * @throws JVMCIError if there is something wrong with the compiled code or the associated + * metadata. + */ + native int installCode(TargetDescription target, HotSpotCompiledCode compiledCode, InstalledCode code, HotSpotSpeculationLog speculationLog); + + public native int getMetadata(TargetDescription target, HotSpotCompiledCode compiledCode, HotSpotMetaData metaData); + + /** + * Resets all compilation statistics. + */ + native void resetCompilationStatistics(); + + /** + * Initializes the fields of {@code config}. + */ + native long initializeConfiguration(HotSpotVMConfig config); + + /** + * Resolves the implementation of {@code method} for virtual dispatches on objects of dynamic + * type {@code exactReceiver}. This resolution process only searches "up" the class hierarchy of + * {@code exactReceiver}. + * + * @param caller the caller or context type used to perform access checks + * @return the link-time resolved method (might be abstract) or {@code 0} if it can not be + * linked + */ + native HotSpotResolvedJavaMethodImpl resolveMethod(HotSpotResolvedObjectTypeImpl exactReceiver, HotSpotResolvedJavaMethodImpl method, HotSpotResolvedObjectTypeImpl caller); + + /** + * Gets the static initializer of {@code type}. + * + * @return 0 if {@code type} has no static initializer + */ + native HotSpotResolvedJavaMethodImpl getClassInitializer(HotSpotResolvedObjectTypeImpl type); + + /** + * Determines if {@code type} or any of its currently loaded subclasses overrides + * {@code Object.finalize()}. + */ + native boolean hasFinalizableSubclass(HotSpotResolvedObjectTypeImpl type); + + /** + * Gets the method corresponding to {@code holder} and slot number {@code slot} (i.e. + * {@link Method#slot} or {@link Constructor#slot}). + */ + native HotSpotResolvedJavaMethodImpl getResolvedJavaMethodAtSlot(Class holder, int slot); + + /** + * Gets the maximum absolute offset of a PC relative call to {@code address} from any position + * in the code cache. + * + * @param address an address that may be called from any code in the code cache + * @return -1 if {@code address == 0} + */ + native long getMaxCallTargetOffset(long address); + + /** + * Gets a textual disassembly of {@code codeBlob}. + * + * @return a non-zero length string containing a disassembly of {@code codeBlob} or null if + * {@code codeBlob} could not be disassembled for some reason + */ + // The HotSpot disassembler seems not to be thread safe so it's better to synchronize its usage + synchronized native String disassembleCodeBlob(InstalledCode installedCode); + + /** + * Gets a stack trace element for {@code method} at bytecode index {@code bci}. + */ + native StackTraceElement getStackTraceElement(HotSpotResolvedJavaMethodImpl method, int bci); + + /** + * Executes some {@code installedCode} with arguments {@code args}. + * + * @return the result of executing {@code installedCode} + * @throws InvalidInstalledCodeException if {@code installedCode} has been invalidated + */ + native Object executeInstalledCode(Object[] args, InstalledCode installedCode) throws InvalidInstalledCodeException; + + /** + * Gets the line number table for {@code method}. The line number table is encoded as (bci, + * source line number) pairs. + * + * @return the line number table for {@code method} or null if it doesn't have one + */ + native long[] getLineNumberTable(HotSpotResolvedJavaMethodImpl method); + + /** + * Gets the number of entries in the local variable table for {@code method}. + * + * @return the number of entries in the local variable table for {@code method} + */ + native int getLocalVariableTableLength(HotSpotResolvedJavaMethodImpl method); + + /** + * Gets the address of the first entry in the local variable table for {@code method}. + * + * Each entry is a native object described by these fields: + * + *
    + *
  • {@link HotSpotVMConfig#localVariableTableElementSize}
  • + *
  • {@link HotSpotVMConfig#localVariableTableElementLengthOffset}
  • + *
  • {@link HotSpotVMConfig#localVariableTableElementNameCpIndexOffset}
  • + *
  • {@link HotSpotVMConfig#localVariableTableElementDescriptorCpIndexOffset}
  • + *
  • {@link HotSpotVMConfig#localVariableTableElementSignatureCpIndexOffset} + *
  • {@link HotSpotVMConfig#localVariableTableElementSlotOffset} + *
  • {@link HotSpotVMConfig#localVariableTableElementStartBciOffset} + *
+ * + * @return 0 if {@code method} does not have a local variable table + */ + native long getLocalVariableTableStart(HotSpotResolvedJavaMethodImpl method); + + /** + * Reads an object pointer within a VM data structure. That is, any {@link HotSpotVMField} whose + * {@link HotSpotVMField#type() type} is {@code "oop"} (e.g., + * {@code ArrayKlass::_component_mirror}, {@code Klass::_java_mirror}, + * {@code JavaThread::_threadObj}). + * + * Note that {@link Unsafe#getObject(Object, long)} cannot be used for this since it does a + * {@code narrowOop} read if the VM is using compressed oops whereas oops within VM data + * structures are (currently) always uncompressed. + * + * @param address address of an oop field within a VM data structure + */ + native Object readUncompressedOop(long address); + + /** + * Determines if {@code method} should not be inlined or compiled. + */ + native void doNotInlineOrCompile(HotSpotResolvedJavaMethodImpl method); + + /** + * Invalidates the profiling information for {@code method} and (re)initializes it such that + * profiling restarts upon its next invocation. + */ + native void reprofile(HotSpotResolvedJavaMethodImpl method); + + /** + * Invalidates {@code installedCode} such that {@link InvalidInstalledCodeException} will be + * raised the next time {@code installedCode} is executed. + */ + native void invalidateInstalledCode(InstalledCode installedCode); + + /** + * Collects the current values of all JVMCI benchmark counters, summed up over all threads. + */ + native long[] collectCounters(); + + /** + * Determines if {@code metaspaceMethodData} is mature. + */ + native boolean isMature(long metaspaceMethodData); + + /** + * Generate a unique id to identify the result of the compile. + */ + native int allocateCompileId(HotSpotResolvedJavaMethodImpl method, int entryBCI); + + /** + * Determines if {@code method} has OSR compiled code identified by {@code entryBCI} for + * compilation level {@code level}. + */ + native boolean hasCompiledCodeForOSR(HotSpotResolvedJavaMethodImpl method, int entryBCI, int level); + + /** + * Gets the value of {@code metaspaceSymbol} as a String. + */ + native String getSymbol(long metaspaceSymbol); + + /** + * Lookup a VMSymbol from a String. + */ + native long lookupSymbol(String symbol); + + /** + * Looks for the next Java stack frame matching an entry in {@code methods}. + * + * @param frame the starting point of the search, where {@code null} refers to the topmost frame + * @param methods the methods to look for, where {@code null} means that any frame is returned + * @return the frame, or {@code null} if the end of the stack was reached during the search + */ + native HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, ResolvedJavaMethod[] methods, int initialSkip); + + /** + * Materializes all virtual objects within {@code stackFrame} updates its locals. + * + * @param invalidate if {@code true}, the compiled method for the stack frame will be + * invalidated. + */ + native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); + + /** + * Gets the v-table index for interface method {@code method} in the receiver {@code type} or + * {@link HotSpotVMConfig#invalidVtableIndex} if {@code method} is not in {@code type}'s + * v-table. + * + * @throws InternalError if {@code type} is an interface or {@code method} is not held by an + * interface or class represented by {@code type} is not initialized + */ + native int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectTypeImpl type, HotSpotResolvedJavaMethodImpl method); + + /** + * Determines if debug info should also be emitted at non-safepoint locations. + */ + + native boolean shouldDebugNonSafepoints(); + + /** + * Writes {@code length} bytes from {@code bytes} starting at offset {@code offset} to the + * HotSpot's log stream. + * + * @exception NullPointerException if {@code bytes == null} + * @exception IndexOutOfBoundsException if copying would cause access of data outside array + * bounds + */ + native void writeDebugOutput(byte[] bytes, int offset, int length); + + /** + * Flush HotSpot's log stream. + */ + native void flushDebugOutput(); + + /** + * Read a HotSpot Method* value from the memory location described by {@code base} plus + * {@code displacement} and return the {@link HotSpotResolvedJavaMethodImpl} wrapping it. This + * method does no checking that the memory location actually contains a valid pointer and may + * crash the VM if an invalid location is provided. If the {@code base} is null then + * {@code displacement} is used by itself. If {@code base} is a + * {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or + * {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object + * and added to {@code displacement}. Any other non-null object type causes an + * {@link IllegalArgumentException} to be thrown. + * + * @param base an object to read from or null + * @param displacement + * @return null or the resolved method for this location + */ + native HotSpotResolvedJavaMethodImpl getResolvedJavaMethod(Object base, long displacement); + + /** + * Read a HotSpot ConstantPool* value from the memory location described by {@code base} plus + * {@code displacement} and return the {@link HotSpotConstantPool} wrapping it. This method does + * no checking that the memory location actually contains a valid pointer and may crash the VM + * if an invalid location is provided. If the {@code base} is null then {@code displacement} is + * used by itself. If {@code base} is a {@link HotSpotResolvedJavaMethodImpl}, + * {@link HotSpotConstantPool} or {@link HotSpotResolvedObjectTypeImpl} then the metaspace + * pointer is fetched from that object and added to {@code displacement}. Any other non-null + * object type causes an {@link IllegalArgumentException} to be thrown. + * + * @param base an object to read from or null + * @param displacement + * @return null or the resolved method for this location + */ + native HotSpotConstantPool getConstantPool(Object base, long displacement); + + /** + * Read a HotSpot Klass* value from the memory location described by {@code base} plus + * {@code displacement} and return the {@link HotSpotResolvedObjectTypeImpl} wrapping it. This + * method does no checking that the memory location actually contains a valid pointer and may + * crash the VM if an invalid location is provided. If the {@code base} is null then + * {@code displacement} is used by itself. If {@code base} is a + * {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or + * {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object + * and added to {@code displacement}. Any other non-null object type causes an + * {@link IllegalArgumentException} to be thrown. + * + * @param base an object to read from or null + * @param displacement + * @param compressed true if the location contains a compressed Klass* + * @return null or the resolved method for this location + */ + native HotSpotResolvedObjectTypeImpl getResolvedJavaType(Object base, long displacement, boolean compressed); + + /** + * Return the size of the HotSpot ProfileData* pointed at by {@code position}. If + * {@code position} is outside the space of the MethodData then an + * {@link IllegalArgumentException} is thrown. A {@code position} inside the MethodData but that + * isn't pointing at a valid ProfileData will crash the VM. + * + * @param metaspaceMethodData + * @param position + * @return the size of the ProfileData item pointed at by {@code position} + * @throws IllegalArgumentException if an out of range position is given + */ + native int methodDataProfileDataSize(long metaspaceMethodData, int position); + + /** + * Return the amount of native stack required for the interpreter frames represented by + * {@code frame}. This is used when emitting the stack banging code to ensure that there is + * enough space for the frames during deoptimization. + * + * @param frame + * @return the number of bytes required for deoptimization of this frame state + */ + native int interpreterFrameSize(BytecodeFrame frame); +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCallingConventionType.java 2016-05-04 09:43:24.000000000 -1000 +++ /dev/null 2016-05-04 09:43:24.000000000 -1000 @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.CallingConvention.Type; - -public enum HotSpotCallingConventionType implements CallingConvention.Type { - /** - * A request for the outgoing argument locations at a call site to Java code. - */ - JavaCall(true), - - /** - * A request for the incoming argument locations. - */ - JavaCallee(false), - - /** - * A request for the outgoing argument locations at a call site to external native code that - * complies with the platform ABI. - */ - NativeCall(true); - - /** - * Determines if this is a request for the outgoing argument locations at a call site. - */ - public final boolean out; - - public static final Type[] VALUES = values(); - - HotSpotCallingConventionType(boolean out) { - this.out = out; - } -} --- /dev/null 2016-05-04 09:43:24.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCallingConventionType.java 2016-05-04 09:43:24.000000000 -1000 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.code.CallingConvention; +import jdk.vm.ci.code.CallingConvention.Type; + +public enum HotSpotCallingConventionType implements CallingConvention.Type { + /** + * A request for the outgoing argument locations at a call site to Java code. + */ + JavaCall(true), + + /** + * A request for the incoming argument locations. + */ + JavaCallee(false), + + /** + * A request for the outgoing argument locations at a call site to external native code that + * complies with the platform ABI. + */ + NativeCall(true); + + /** + * Determines if this is a request for the outgoing argument locations at a call site. + */ + public final boolean out; + + public static final Type[] VALUES = values(); + + HotSpotCallingConventionType(boolean out) { + this.out = out; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java 2016-05-04 09:43:25.000000000 -1000 +++ /dev/null 2016-05-04 09:43:25.000000000 -1000 @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.lang.reflect.Field; - -import jdk.vm.ci.code.BailoutException; -import jdk.vm.ci.code.BytecodeFrame; -import jdk.vm.ci.code.CodeCacheProvider; -import jdk.vm.ci.code.CompiledCode; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.site.Call; -import jdk.vm.ci.code.site.Mark; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.SpeculationLog; - -/** - * HotSpot implementation of {@link CodeCacheProvider}. - */ -public class HotSpotCodeCacheProvider implements CodeCacheProvider { - - protected final HotSpotJVMCIRuntimeProvider runtime; - public final HotSpotVMConfig config; - protected final TargetDescription target; - protected final RegisterConfig regConfig; - - public HotSpotCodeCacheProvider(HotSpotJVMCIRuntimeProvider runtime, HotSpotVMConfig config, TargetDescription target, RegisterConfig regConfig) { - this.runtime = runtime; - this.config = config; - this.target = target; - this.regConfig = regConfig; - } - - @Override - public String getMarkName(Mark mark) { - int markId = (int) mark.id; - Field[] fields = runtime.getConfig().getClass().getDeclaredFields(); - for (Field f : fields) { - if (f.getName().startsWith("MARKID_")) { - f.setAccessible(true); - try { - if (f.getInt(runtime.getConfig()) == markId) { - return f.getName(); - } - } catch (Exception e) { - } - } - } - return CodeCacheProvider.super.getMarkName(mark); - } - - /** - * Decodes a call target to a mnemonic if possible. - */ - @Override - public String getTargetName(Call call) { - Field[] fields = runtime.getConfig().getClass().getDeclaredFields(); - for (Field f : fields) { - if (f.getName().endsWith("Stub")) { - f.setAccessible(true); - try { - Object address = f.get(runtime.getConfig()); - if (address.equals(call.target)) { - return f.getName() + ":0x" + Long.toHexString((Long) address); - } - } catch (Exception e) { - } - } - } - return CodeCacheProvider.super.getTargetName(call); - } - - @Override - public RegisterConfig getRegisterConfig() { - return regConfig; - } - - @Override - public int getMinimumOutgoingSize() { - return runtime.getConfig().runtimeCallStackSize; - } - - private InstalledCode logOrDump(InstalledCode installedCode, CompiledCode compiledCode) { - ((HotSpotJVMCIRuntime) runtime).notifyInstall(this, installedCode, compiledCode); - return installedCode; - } - - public InstalledCode installCode(ResolvedJavaMethod method, CompiledCode compiledCode, InstalledCode installedCode, SpeculationLog log, boolean isDefault) { - InstalledCode resultInstalledCode; - if (installedCode == null) { - if (method == null) { - // Must be a stub - resultInstalledCode = new HotSpotRuntimeStub(((HotSpotCompiledCode) compiledCode).getName()); - } else { - resultInstalledCode = new HotSpotNmethod((HotSpotResolvedJavaMethod) method, ((HotSpotCompiledCode) compiledCode).getName(), isDefault); - } - } else { - resultInstalledCode = installedCode; - } - - HotSpotSpeculationLog speculationLog = (log != null && log.hasSpeculations()) ? (HotSpotSpeculationLog) log : null; - - int result = runtime.getCompilerToVM().installCode(target, (HotSpotCompiledCode) compiledCode, resultInstalledCode, speculationLog); - if (result != config.codeInstallResultOk) { - String resultDesc = config.getCodeInstallResultDescription(result); - if (compiledCode instanceof HotSpotCompiledNmethod) { - HotSpotCompiledNmethod compiledNmethod = (HotSpotCompiledNmethod) compiledCode; - String msg = compiledNmethod.getInstallationFailureMessage(); - if (msg != null) { - msg = String.format("Code installation failed: %s%n%s", resultDesc, msg); - } else { - msg = String.format("Code installation failed: %s", resultDesc); - } - if (result == config.codeInstallResultDependenciesInvalid) { - throw new AssertionError(resultDesc + " " + msg); - } - throw new BailoutException(result != config.codeInstallResultDependenciesFailed, msg); - } else { - throw new BailoutException("Error installing %s: %s", ((HotSpotCompiledCode) compiledCode).getName(), resultDesc); - } - } - return logOrDump(resultInstalledCode, compiledCode); - } - - public void invalidateInstalledCode(InstalledCode installedCode) { - runtime.getCompilerToVM().invalidateInstalledCode(installedCode); - } - - @Override - public TargetDescription getTarget() { - return target; - } - - public String disassemble(InstalledCode code) { - if (code.isValid()) { - return runtime.getCompilerToVM().disassembleCodeBlob(code); - } - return null; - } - - public SpeculationLog createSpeculationLog() { - return new HotSpotSpeculationLog(); - } - - public long getMaxCallTargetOffset(long address) { - return runtime.getCompilerToVM().getMaxCallTargetOffset(address); - } - - public boolean shouldDebugNonSafepoints() { - return runtime.getCompilerToVM().shouldDebugNonSafepoints(); - } - - public int interpreterFrameSize(BytecodeFrame pos) { - return runtime.getCompilerToVM().interpreterFrameSize(pos); - } - - /** - * Resets all compilation statistics. - */ - public void resetCompilationStatistics() { - runtime.getCompilerToVM().resetCompilationStatistics(); - } -} --- /dev/null 2016-05-04 09:43:25.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java 2016-05-04 09:43:25.000000000 -1000 @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import java.lang.reflect.Field; + +import jdk.vm.ci.code.BailoutException; +import jdk.vm.ci.code.BytecodeFrame; +import jdk.vm.ci.code.CodeCacheProvider; +import jdk.vm.ci.code.CompiledCode; +import jdk.vm.ci.code.InstalledCode; +import jdk.vm.ci.code.RegisterConfig; +import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.code.site.Call; +import jdk.vm.ci.code.site.Mark; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.SpeculationLog; + +/** + * HotSpot implementation of {@link CodeCacheProvider}. + */ +public class HotSpotCodeCacheProvider implements CodeCacheProvider { + + protected final HotSpotJVMCIRuntimeProvider runtime; + public final HotSpotVMConfig config; + protected final TargetDescription target; + protected final RegisterConfig regConfig; + + public HotSpotCodeCacheProvider(HotSpotJVMCIRuntimeProvider runtime, HotSpotVMConfig config, TargetDescription target, RegisterConfig regConfig) { + this.runtime = runtime; + this.config = config; + this.target = target; + this.regConfig = regConfig; + } + + @Override + public String getMarkName(Mark mark) { + int markId = (int) mark.id; + Field[] fields = runtime.getConfig().getClass().getDeclaredFields(); + for (Field f : fields) { + if (f.getName().startsWith("MARKID_")) { + f.setAccessible(true); + try { + if (f.getInt(runtime.getConfig()) == markId) { + return f.getName(); + } + } catch (Exception e) { + } + } + } + return CodeCacheProvider.super.getMarkName(mark); + } + + /** + * Decodes a call target to a mnemonic if possible. + */ + @Override + public String getTargetName(Call call) { + Field[] fields = runtime.getConfig().getClass().getDeclaredFields(); + for (Field f : fields) { + if (f.getName().endsWith("Stub")) { + f.setAccessible(true); + try { + Object address = f.get(runtime.getConfig()); + if (address.equals(call.target)) { + return f.getName() + ":0x" + Long.toHexString((Long) address); + } + } catch (Exception e) { + } + } + } + return CodeCacheProvider.super.getTargetName(call); + } + + @Override + public RegisterConfig getRegisterConfig() { + return regConfig; + } + + @Override + public int getMinimumOutgoingSize() { + return runtime.getConfig().runtimeCallStackSize; + } + + private InstalledCode logOrDump(InstalledCode installedCode, CompiledCode compiledCode) { + ((HotSpotJVMCIRuntime) runtime).notifyInstall(this, installedCode, compiledCode); + return installedCode; + } + + public InstalledCode installCode(ResolvedJavaMethod method, CompiledCode compiledCode, InstalledCode installedCode, SpeculationLog log, boolean isDefault) { + InstalledCode resultInstalledCode; + if (installedCode == null) { + if (method == null) { + // Must be a stub + resultInstalledCode = new HotSpotRuntimeStub(((HotSpotCompiledCode) compiledCode).getName()); + } else { + resultInstalledCode = new HotSpotNmethod((HotSpotResolvedJavaMethod) method, ((HotSpotCompiledCode) compiledCode).getName(), isDefault); + } + } else { + resultInstalledCode = installedCode; + } + + HotSpotSpeculationLog speculationLog = (log != null && log.hasSpeculations()) ? (HotSpotSpeculationLog) log : null; + + int result = runtime.getCompilerToVM().installCode(target, (HotSpotCompiledCode) compiledCode, resultInstalledCode, speculationLog); + if (result != config.codeInstallResultOk) { + String resultDesc = config.getCodeInstallResultDescription(result); + if (compiledCode instanceof HotSpotCompiledNmethod) { + HotSpotCompiledNmethod compiledNmethod = (HotSpotCompiledNmethod) compiledCode; + String msg = compiledNmethod.getInstallationFailureMessage(); + if (msg != null) { + msg = String.format("Code installation failed: %s%n%s", resultDesc, msg); + } else { + msg = String.format("Code installation failed: %s", resultDesc); + } + if (result == config.codeInstallResultDependenciesInvalid) { + throw new AssertionError(resultDesc + " " + msg); + } + throw new BailoutException(result != config.codeInstallResultDependenciesFailed, msg); + } else { + throw new BailoutException("Error installing %s: %s", ((HotSpotCompiledCode) compiledCode).getName(), resultDesc); + } + } + return logOrDump(resultInstalledCode, compiledCode); + } + + public void invalidateInstalledCode(InstalledCode installedCode) { + runtime.getCompilerToVM().invalidateInstalledCode(installedCode); + } + + @Override + public TargetDescription getTarget() { + return target; + } + + public String disassemble(InstalledCode code) { + if (code.isValid()) { + return runtime.getCompilerToVM().disassembleCodeBlob(code); + } + return null; + } + + public SpeculationLog createSpeculationLog() { + return new HotSpotSpeculationLog(); + } + + public long getMaxCallTargetOffset(long address) { + return runtime.getCompilerToVM().getMaxCallTargetOffset(address); + } + + public boolean shouldDebugNonSafepoints() { + return runtime.getCompilerToVM().shouldDebugNonSafepoints(); + } + + public int interpreterFrameSize(BytecodeFrame pos) { + return runtime.getCompilerToVM().interpreterFrameSize(pos); + } + + /** + * Resets all compilation statistics. + */ + public void resetCompilationStatistics() { + runtime.getCompilerToVM().resetCompilationStatistics(); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompilationRequest.java 2016-05-04 09:43:25.000000000 -1000 +++ /dev/null 2016-05-04 09:43:25.000000000 -1000 @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.CompilationRequest; - -/** - * A compilation request with extra HotSpot specific context such as a compilation identifier and - * the address of a {@code JVMCIEnv} object that provides native context for a compilation. - */ -public class HotSpotCompilationRequest extends CompilationRequest { - private final long jvmciEnv; - private final int id; - - /** - * Creates a request to compile a method starting at a given BCI and allocates an identifier to - * the request. - * - * @param method the method to be compiled - * @param entryBCI the bytecode index (BCI) at which to start compiling where -1 denotes the - * method's entry point - * @param jvmciEnv address of a native {@code JVMCIEnv} object or 0L - */ - public HotSpotCompilationRequest(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv) { - this(method, entryBCI, jvmciEnv, method.allocateCompileId(entryBCI)); - } - - /** - * Creates a request to compile a method starting at a given BCI. - * - * @param method the method to be compiled - * @param entryBCI the bytecode index (BCI) at which to start compiling where -1 denotes the - * method's entry point - * @param jvmciEnv address of a native {@code JVMCIEnv} object or 0L - * @param id an identifier for the request - */ - public HotSpotCompilationRequest(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) { - super(method, entryBCI); - this.jvmciEnv = jvmciEnv; - this.id = id; - } - - @Override - public HotSpotResolvedJavaMethod getMethod() { - return (HotSpotResolvedJavaMethod) super.getMethod(); - } - - /** - * Gets the address of the native {@code JVMCIEnv} object or 0L if no such object exists. - */ - public long getJvmciEnv() { - return jvmciEnv; - } - - /** - * Gets the VM allocated identifier for this compilation. - */ - public int getId() { - return id; - } - -} --- /dev/null 2016-05-04 09:43:25.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompilationRequest.java 2016-05-04 09:43:25.000000000 -1000 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.code.CompilationRequest; + +/** + * A compilation request with extra HotSpot specific context such as a compilation identifier and + * the address of a {@code JVMCIEnv} object that provides native context for a compilation. + */ +public class HotSpotCompilationRequest extends CompilationRequest { + private final long jvmciEnv; + private final int id; + + /** + * Creates a request to compile a method starting at a given BCI and allocates an identifier to + * the request. + * + * @param method the method to be compiled + * @param entryBCI the bytecode index (BCI) at which to start compiling where -1 denotes the + * method's entry point + * @param jvmciEnv address of a native {@code JVMCIEnv} object or 0L + */ + public HotSpotCompilationRequest(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv) { + this(method, entryBCI, jvmciEnv, method.allocateCompileId(entryBCI)); + } + + /** + * Creates a request to compile a method starting at a given BCI. + * + * @param method the method to be compiled + * @param entryBCI the bytecode index (BCI) at which to start compiling where -1 denotes the + * method's entry point + * @param jvmciEnv address of a native {@code JVMCIEnv} object or 0L + * @param id an identifier for the request + */ + public HotSpotCompilationRequest(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) { + super(method, entryBCI); + this.jvmciEnv = jvmciEnv; + this.id = id; + } + + @Override + public HotSpotResolvedJavaMethod getMethod() { + return (HotSpotResolvedJavaMethod) super.getMethod(); + } + + /** + * Gets the address of the native {@code JVMCIEnv} object or 0L if no such object exists. + */ + public long getJvmciEnv() { + return jvmciEnv; + } + + /** + * Gets the VM allocated identifier for this compilation. + */ + public int getId() { + return id; + } + +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java 2016-05-04 09:43:27.000000000 -1000 +++ /dev/null 2016-05-04 09:43:27.000000000 -1000 @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.BytecodeFrame; -import jdk.vm.ci.code.CompiledCode; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.site.DataPatch; -import jdk.vm.ci.code.site.Infopoint; -import jdk.vm.ci.code.site.Site; -import jdk.vm.ci.meta.Assumptions.Assumption; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -/** - * A {@link CompiledCode} with additional HotSpot-specific information required for installing the - * code in HotSpot's code cache. - */ -public class HotSpotCompiledCode implements CompiledCode { - - /** - * The name of this compilation unit. - */ - protected final String name; - - /** - * The buffer containing the emitted machine code. - */ - protected final byte[] targetCode; - - /** - * The leading number of bytes in {@link #targetCode} containing the emitted machine code. - */ - protected final int targetCodeSize; - - /** - * A list of code annotations describing special sites in {@link #targetCode}. - */ - protected final Site[] sites; - - /** - * A list of {@link Assumption} this code relies on. - */ - protected final Assumption[] assumptions; - - /** - * The list of the methods whose bytecodes were used as input to the compilation. If - * {@code null}, then the compilation did not record method dependencies. Otherwise, the first - * element of this array is the root method of the compilation. - */ - protected final ResolvedJavaMethod[] methods; - - /** - * A list of comments that will be included in code dumps. - */ - protected final Comment[] comments; - - /** - * The data section containing serialized constants for the emitted machine code. - */ - protected final byte[] dataSection; - - /** - * The minimum alignment of the data section. - */ - protected final int dataSectionAlignment; - - /** - * A list of relocations in the {@link #dataSection}. - */ - protected final DataPatch[] dataSectionPatches; - - /** - * A flag determining whether this code is immutable and position independent. - */ - protected final boolean isImmutablePIC; - - /** - * The total size of the stack frame of this compiled method. - */ - protected final int totalFrameSize; - - /** - * The deopt rescue slot. Must be non-null if there is a safepoint in the method. - */ - protected final StackSlot deoptRescueSlot; - - public static class Comment { - - public final String text; - public final int pcOffset; - - public Comment(int pcOffset, String text) { - this.text = text; - this.pcOffset = pcOffset; - } - } - - public HotSpotCompiledCode(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection, - int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, StackSlot deoptRescueSlot) { - this.name = name; - this.targetCode = targetCode; - this.targetCodeSize = targetCodeSize; - this.sites = sites; - this.assumptions = assumptions; - this.methods = methods; - - this.comments = comments; - this.dataSection = dataSection; - this.dataSectionAlignment = dataSectionAlignment; - this.dataSectionPatches = dataSectionPatches; - this.isImmutablePIC = isImmutablePIC; - this.totalFrameSize = totalFrameSize; - this.deoptRescueSlot = deoptRescueSlot; - - assert validateFrames(); - } - - public String getName() { - return name; - } - - @Override - public String toString() { - return name; - } - - /** - * Ensure that all the frames passed into the VM are properly formatted with an empty or illegal - * slot following double word slots. - */ - private boolean validateFrames() { - for (Site site : sites) { - if (site instanceof Infopoint) { - Infopoint info = (Infopoint) site; - if (info.debugInfo != null) { - BytecodeFrame frame = info.debugInfo.frame(); - assert frame == null || frame.validateFormat(); - } - } - } - return true; - } -} --- /dev/null 2016-05-04 09:43:27.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java 2016-05-04 09:43:26.000000000 -1000 @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.code.BytecodeFrame; +import jdk.vm.ci.code.CompiledCode; +import jdk.vm.ci.code.StackSlot; +import jdk.vm.ci.code.site.DataPatch; +import jdk.vm.ci.code.site.Infopoint; +import jdk.vm.ci.code.site.Site; +import jdk.vm.ci.meta.Assumptions.Assumption; +import jdk.vm.ci.meta.ResolvedJavaMethod; + +/** + * A {@link CompiledCode} with additional HotSpot-specific information required for installing the + * code in HotSpot's code cache. + */ +public class HotSpotCompiledCode implements CompiledCode { + + /** + * The name of this compilation unit. + */ + protected final String name; + + /** + * The buffer containing the emitted machine code. + */ + protected final byte[] targetCode; + + /** + * The leading number of bytes in {@link #targetCode} containing the emitted machine code. + */ + protected final int targetCodeSize; + + /** + * A list of code annotations describing special sites in {@link #targetCode}. + */ + protected final Site[] sites; + + /** + * A list of {@link Assumption} this code relies on. + */ + protected final Assumption[] assumptions; + + /** + * The list of the methods whose bytecodes were used as input to the compilation. If + * {@code null}, then the compilation did not record method dependencies. Otherwise, the first + * element of this array is the root method of the compilation. + */ + protected final ResolvedJavaMethod[] methods; + + /** + * A list of comments that will be included in code dumps. + */ + protected final Comment[] comments; + + /** + * The data section containing serialized constants for the emitted machine code. + */ + protected final byte[] dataSection; + + /** + * The minimum alignment of the data section. + */ + protected final int dataSectionAlignment; + + /** + * A list of relocations in the {@link #dataSection}. + */ + protected final DataPatch[] dataSectionPatches; + + /** + * A flag determining whether this code is immutable and position independent. + */ + protected final boolean isImmutablePIC; + + /** + * The total size of the stack frame of this compiled method. + */ + protected final int totalFrameSize; + + /** + * The deopt rescue slot. Must be non-null if there is a safepoint in the method. + */ + protected final StackSlot deoptRescueSlot; + + public static class Comment { + + public final String text; + public final int pcOffset; + + public Comment(int pcOffset, String text) { + this.text = text; + this.pcOffset = pcOffset; + } + } + + public HotSpotCompiledCode(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection, + int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, StackSlot deoptRescueSlot) { + this.name = name; + this.targetCode = targetCode; + this.targetCodeSize = targetCodeSize; + this.sites = sites; + this.assumptions = assumptions; + this.methods = methods; + + this.comments = comments; + this.dataSection = dataSection; + this.dataSectionAlignment = dataSectionAlignment; + this.dataSectionPatches = dataSectionPatches; + this.isImmutablePIC = isImmutablePIC; + this.totalFrameSize = totalFrameSize; + this.deoptRescueSlot = deoptRescueSlot; + + assert validateFrames(); + } + + public String getName() { + return name; + } + + @Override + public String toString() { + return name; + } + + /** + * Ensure that all the frames passed into the VM are properly formatted with an empty or illegal + * slot following double word slots. + */ + private boolean validateFrames() { + for (Site site : sites) { + if (site instanceof Infopoint) { + Infopoint info = (Infopoint) site; + if (info.debugInfo != null) { + BytecodeFrame frame = info.debugInfo.frame(); + assert frame == null || frame.validateFormat(); + } + } + } + return true; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java 2016-05-04 09:43:28.000000000 -1000 +++ /dev/null 2016-05-04 09:43:28.000000000 -1000 @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.site.DataPatch; -import jdk.vm.ci.code.site.Site; -import jdk.vm.ci.inittimer.SuppressFBWarnings; -import jdk.vm.ci.meta.Assumptions.Assumption; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -/** - * {@link HotSpotCompiledCode} destined for installation as an nmethod. - */ -public final class HotSpotCompiledNmethod extends HotSpotCompiledCode { - - protected final HotSpotResolvedJavaMethod method; - protected final int entryBCI; - - /** - * Compilation identifier. - */ - protected final int id; - - /** - * Address of a native {@code JVMCIEnv} object or 0L if no such object exists. - */ - protected final long jvmciEnv; - - protected final boolean hasUnsafeAccess; - - /** - * May be set by VM if code installation fails. It will describe in more detail why installation - * failed (e.g., exactly which dependency failed). - */ - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "set by the VM") private String installationFailureMessage; - - public HotSpotCompiledNmethod(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection, - int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, StackSlot deoptRescueSlot, HotSpotResolvedJavaMethod method, int entryBCI, - int id, long jvmciEnv, boolean hasUnsafeAccess) { - super(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC, totalFrameSize, deoptRescueSlot); - this.method = method; - this.entryBCI = entryBCI; - this.id = id; - this.jvmciEnv = jvmciEnv; - this.hasUnsafeAccess = hasUnsafeAccess; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[" + id + ":" + method.format("%H.%n(%p)%r@") + entryBCI + "]"; - } - - public String getInstallationFailureMessage() { - return installationFailureMessage; - } -} --- /dev/null 2016-05-04 09:43:28.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java 2016-05-04 09:43:27.000000000 -1000 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.code.StackSlot; +import jdk.vm.ci.code.site.DataPatch; +import jdk.vm.ci.code.site.Site; +import jdk.vm.ci.inittimer.SuppressFBWarnings; +import jdk.vm.ci.meta.Assumptions.Assumption; +import jdk.vm.ci.meta.ResolvedJavaMethod; + +/** + * {@link HotSpotCompiledCode} destined for installation as an nmethod. + */ +public final class HotSpotCompiledNmethod extends HotSpotCompiledCode { + + protected final HotSpotResolvedJavaMethod method; + protected final int entryBCI; + + /** + * Compilation identifier. + */ + protected final int id; + + /** + * Address of a native {@code JVMCIEnv} object or 0L if no such object exists. + */ + protected final long jvmciEnv; + + protected final boolean hasUnsafeAccess; + + /** + * May be set by VM if code installation fails. It will describe in more detail why installation + * failed (e.g., exactly which dependency failed). + */ + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "set by the VM") private String installationFailureMessage; + + public HotSpotCompiledNmethod(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection, + int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, StackSlot deoptRescueSlot, HotSpotResolvedJavaMethod method, int entryBCI, + int id, long jvmciEnv, boolean hasUnsafeAccess) { + super(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC, totalFrameSize, deoptRescueSlot); + this.method = method; + this.entryBCI = entryBCI; + this.id = id; + this.jvmciEnv = jvmciEnv; + this.hasUnsafeAccess = hasUnsafeAccess; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "[" + id + ":" + method.format("%H.%n(%p)%r@") + entryBCI + "]"; + } + + public String getInstallationFailureMessage() { + return installationFailureMessage; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompressedNullConstant.java 2016-05-04 09:43:28.000000000 -1000 +++ /dev/null 2016-05-04 09:43:28.000000000 -1000 @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; - -/** - * The compressed representation of the {@link JavaConstant#NULL_POINTER null constant}. - */ -public final class HotSpotCompressedNullConstant implements JavaConstant, HotSpotConstant { - - public static final JavaConstant COMPRESSED_NULL = new HotSpotCompressedNullConstant(); - - private HotSpotCompressedNullConstant() { - } - - public JavaKind getJavaKind() { - return JavaKind.Object; - } - - @Override - public boolean isNull() { - return true; - } - - @Override - public boolean isCompressed() { - return true; - } - - public Constant compress() { - throw new IllegalArgumentException(); - } - - public Constant uncompress() { - return NULL_POINTER; - } - - @Override - public boolean isDefaultForKind() { - return true; - } - - @Override - public Object asBoxedPrimitive() { - throw new IllegalArgumentException(); - } - - @Override - public int asInt() { - throw new IllegalArgumentException(); - } - - @Override - public boolean asBoolean() { - throw new IllegalArgumentException(); - } - - @Override - public long asLong() { - throw new IllegalArgumentException(); - } - - @Override - public float asFloat() { - throw new IllegalArgumentException(); - } - - @Override - public double asDouble() { - throw new IllegalArgumentException(); - } - - @Override - public String toString() { - return JavaConstant.toString(this); - } - - @Override - public String toValueString() { - return "null"; - } - - @Override - public int hashCode() { - return System.identityHashCode(this); - } - - @Override - public boolean equals(Object o) { - return o instanceof HotSpotCompressedNullConstant; - } -} --- /dev/null 2016-05-04 09:43:28.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompressedNullConstant.java 2016-05-04 09:43:28.000000000 -1000 @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.Constant; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.JavaKind; + +/** + * The compressed representation of the {@link JavaConstant#NULL_POINTER null constant}. + */ +public final class HotSpotCompressedNullConstant implements JavaConstant, HotSpotConstant { + + public static final JavaConstant COMPRESSED_NULL = new HotSpotCompressedNullConstant(); + + private HotSpotCompressedNullConstant() { + } + + public JavaKind getJavaKind() { + return JavaKind.Object; + } + + @Override + public boolean isNull() { + return true; + } + + @Override + public boolean isCompressed() { + return true; + } + + public Constant compress() { + throw new IllegalArgumentException(); + } + + public Constant uncompress() { + return NULL_POINTER; + } + + @Override + public boolean isDefaultForKind() { + return true; + } + + @Override + public Object asBoxedPrimitive() { + throw new IllegalArgumentException(); + } + + @Override + public int asInt() { + throw new IllegalArgumentException(); + } + + @Override + public boolean asBoolean() { + throw new IllegalArgumentException(); + } + + @Override + public long asLong() { + throw new IllegalArgumentException(); + } + + @Override + public float asFloat() { + throw new IllegalArgumentException(); + } + + @Override + public double asDouble() { + throw new IllegalArgumentException(); + } + + @Override + public String toString() { + return JavaConstant.toString(this); + } + + @Override + public String toValueString() { + return "null"; + } + + @Override + public int hashCode() { + return System.identityHashCode(this); + } + + @Override + public boolean equals(Object o) { + return o instanceof HotSpotCompressedNullConstant; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstant.java 2016-05-04 09:43:29.000000000 -1000 +++ /dev/null 2016-05-04 09:43:29.000000000 -1000 @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.Constant; - -/** - * Marker interface for hotspot specific constants. - */ -public interface HotSpotConstant extends Constant { - - boolean isCompressed(); - - Constant compress(); - - Constant uncompress(); -} --- /dev/null 2016-05-04 09:43:29.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstant.java 2016-05-04 09:43:29.000000000 -1000 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.Constant; + +/** + * Marker interface for hotspot specific constants. + */ +public interface HotSpotConstant extends Constant { + + boolean isCompressed(); + + Constant compress(); + + Constant uncompress(); +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java 2016-05-04 09:43:29.000000000 -1000 +++ /dev/null 2016-05-04 09:43:29.000000000 -1000 @@ -1,714 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import java.lang.invoke.MethodHandle; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.ConstantPool; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaField; -import jdk.vm.ci.meta.JavaMethod; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.Signature; - -/** - * Implementation of {@link ConstantPool} for HotSpot. - */ -final class HotSpotConstantPool implements ConstantPool, HotSpotProxified, MetaspaceWrapperObject { - - /** - * Subset of JVM bytecode opcodes used by {@link HotSpotConstantPool}. - */ - public static class Bytecodes { - public static final int LDC = 18; // 0x12 - public static final int LDC_W = 19; // 0x13 - public static final int LDC2_W = 20; // 0x14 - public static final int GETSTATIC = 178; // 0xB2 - public static final int PUTSTATIC = 179; // 0xB3 - public static final int GETFIELD = 180; // 0xB4 - public static final int PUTFIELD = 181; // 0xB5 - public static final int INVOKEVIRTUAL = 182; // 0xB6 - public static final int INVOKESPECIAL = 183; // 0xB7 - public static final int INVOKESTATIC = 184; // 0xB8 - public static final int INVOKEINTERFACE = 185; // 0xB9 - public static final int INVOKEDYNAMIC = 186; // 0xBA - public static final int NEW = 187; // 0xBB - public static final int NEWARRAY = 188; // 0xBC - public static final int ANEWARRAY = 189; // 0xBD - public static final int CHECKCAST = 192; // 0xC0 - public static final int INSTANCEOF = 193; // 0xC1 - public static final int MULTIANEWARRAY = 197; // 0xC5 - - static boolean isInvoke(int opcode) { - switch (opcode) { - case INVOKEVIRTUAL: - case INVOKESPECIAL: - case INVOKESTATIC: - case INVOKEINTERFACE: - case INVOKEDYNAMIC: - return true; - default: - return false; - } - } - - /** - * See: {@code Rewriter::maybe_rewrite_invokehandle}. - */ - static boolean isInvokeHandleAlias(int opcode) { - switch (opcode) { - case INVOKEVIRTUAL: - case INVOKESPECIAL: - return true; - default: - return false; - } - } - } - - /** - * Enum of all {@code JVM_CONSTANT} constants used in the VM. This includes the public and - * internal ones. - */ - private enum JVM_CONSTANT { - // @formatter:off - Utf8(config().jvmConstantUtf8), - Integer(config().jvmConstantInteger), - Long(config().jvmConstantLong), - Float(config().jvmConstantFloat), - Double(config().jvmConstantDouble), - Class(config().jvmConstantClass), - UnresolvedClass(config().jvmConstantUnresolvedClass), - UnresolvedClassInError(config().jvmConstantUnresolvedClassInError), - String(config().jvmConstantString), - Fieldref(config().jvmConstantFieldref), - MethodRef(config().jvmConstantMethodref), - InterfaceMethodref(config().jvmConstantInterfaceMethodref), - NameAndType(config().jvmConstantNameAndType), - MethodHandle(config().jvmConstantMethodHandle), - MethodHandleInError(config().jvmConstantMethodHandleInError), - MethodType(config().jvmConstantMethodType), - MethodTypeInError(config().jvmConstantMethodTypeInError), - InvokeDynamic(config().jvmConstantInvokeDynamic); - // @formatter:on - - private final int tag; - - private static final int ExternalMax = config().jvmConstantExternalMax; - private static final int InternalMin = config().jvmConstantInternalMin; - private static final int InternalMax = config().jvmConstantInternalMax; - - JVM_CONSTANT(int tag) { - this.tag = tag; - } - - /** - * Maps JVM_CONSTANT tags to {@link JVM_CONSTANT} values. Using a separate class for lazy - * initialization. - */ - static class TagValueMap { - private static final JVM_CONSTANT[] table = new JVM_CONSTANT[ExternalMax + 1 + (InternalMax - InternalMin) + 1]; - - static { - assert InternalMin > ExternalMax; - for (JVM_CONSTANT e : values()) { - table[indexOf(e.tag)] = e; - } - } - - private static int indexOf(int tag) { - if (tag >= InternalMin) { - return tag - InternalMin + ExternalMax + 1; - } else { - assert tag <= ExternalMax; - } - return tag; - } - - static JVM_CONSTANT get(int tag) { - JVM_CONSTANT res = table[indexOf(tag)]; - if (res != null) { - return res; - } - throw new JVMCIError("Unknown JVM_CONSTANT tag %s", tag); - } - } - - public static JVM_CONSTANT getEnum(int tag) { - return TagValueMap.get(tag); - } - } - - private static class LookupTypeCacheElement { - int lastCpi = Integer.MIN_VALUE; - JavaType javaType; - - LookupTypeCacheElement(int lastCpi, JavaType javaType) { - super(); - this.lastCpi = lastCpi; - this.javaType = javaType; - } - } - - /** - * Reference to the C++ ConstantPool object. - */ - private final long metaspaceConstantPool; - private volatile LookupTypeCacheElement lastLookupType; - - /** - * Gets the JVMCI mirror from a HotSpot constant pool.The VM is responsible for ensuring that - * the ConstantPool is kept alive for the duration of this call and the - * {@link HotSpotJVMCIMetaAccessContext} keeps it alive after that. - * - * Called from the VM. - * - * @param metaspaceConstantPool a metaspace ConstantPool object - * @return the {@link HotSpotConstantPool} corresponding to {@code metaspaceConstantPool} - */ - @SuppressWarnings("unused") - private static HotSpotConstantPool fromMetaspace(long metaspaceConstantPool) { - return new HotSpotConstantPool(metaspaceConstantPool); - } - - private HotSpotConstantPool(long metaspaceConstantPool) { - this.metaspaceConstantPool = metaspaceConstantPool; - } - - /** - * Gets the holder for this constant pool as {@link HotSpotResolvedObjectTypeImpl}. - * - * @return holder for this constant pool - */ - private HotSpotResolvedObjectType getHolder() { - return compilerToVM().getResolvedJavaType(this, config().constantPoolHolderOffset, false); - } - - /** - * Converts a raw index from the bytecodes to a constant pool index by adding a - * {@link HotSpotVMConfig#constantPoolCpCacheIndexTag constant}. - * - * @param rawIndex index from the bytecode - * @param opcode bytecode to convert the index for - * @return constant pool index - */ - private static int rawIndexToConstantPoolIndex(int rawIndex, int opcode) { - int index; - if (opcode == Bytecodes.INVOKEDYNAMIC) { - index = rawIndex; - // See: ConstantPool::is_invokedynamic_index - assert index < 0 : "not an invokedynamic constant pool index " + index; - } else { - assert opcode == Bytecodes.GETFIELD || opcode == Bytecodes.PUTFIELD || opcode == Bytecodes.GETSTATIC || opcode == Bytecodes.PUTSTATIC || opcode == Bytecodes.INVOKEINTERFACE || - opcode == Bytecodes.INVOKEVIRTUAL || opcode == Bytecodes.INVOKESPECIAL || opcode == Bytecodes.INVOKESTATIC : "unexpected invoke opcode " + opcode; - index = rawIndex + config().constantPoolCpCacheIndexTag; - } - return index; - } - - /** - * Decode a constant pool cache index to a constant pool index. - * - * See {@code ConstantPool::decode_cpcache_index}. - * - * @param index constant pool cache index - * @return decoded index - */ - private static int decodeConstantPoolCacheIndex(int index) { - if (isInvokedynamicIndex(index)) { - return decodeInvokedynamicIndex(index); - } else { - return index - config().constantPoolCpCacheIndexTag; - } - } - - /** - * See {@code ConstantPool::is_invokedynamic_index}. - */ - private static boolean isInvokedynamicIndex(int index) { - return index < 0; - } - - /** - * See {@code ConstantPool::decode_invokedynamic_index}. - */ - private static int decodeInvokedynamicIndex(int i) { - assert isInvokedynamicIndex(i) : i; - return ~i; - } - - long getMetaspaceConstantPool() { - return metaspaceConstantPool; - } - - public long getMetaspacePointer() { - return getMetaspaceConstantPool(); - } - - /** - * Gets the constant pool tag at index {@code index}. - * - * @param index constant pool index - * @return constant pool tag - */ - private JVM_CONSTANT getTagAt(int index) { - assertBounds(index); - HotSpotVMConfig config = config(); - final long metaspaceConstantPoolTags = UNSAFE.getAddress(getMetaspaceConstantPool() + config.constantPoolTagsOffset); - final int tag = UNSAFE.getByteVolatile(null, metaspaceConstantPoolTags + config.arrayU1DataOffset + index); - if (tag == 0) { - return null; - } - return JVM_CONSTANT.getEnum(tag); - } - - /** - * Gets the constant pool entry at index {@code index}. - * - * @param index constant pool index - * @return constant pool entry - */ - private long getEntryAt(int index) { - assertBounds(index); - return UNSAFE.getAddress(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); - } - - /** - * Gets the integer constant pool entry at index {@code index}. - * - * @param index constant pool index - * @return integer constant pool entry at index - */ - private int getIntAt(int index) { - assertTag(index, JVM_CONSTANT.Integer); - return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); - } - - /** - * Gets the long constant pool entry at index {@code index}. - * - * @param index constant pool index - * @return long constant pool entry - */ - private long getLongAt(int index) { - assertTag(index, JVM_CONSTANT.Long); - return UNSAFE.getLong(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); - } - - /** - * Gets the float constant pool entry at index {@code index}. - * - * @param index constant pool index - * @return float constant pool entry - */ - private float getFloatAt(int index) { - assertTag(index, JVM_CONSTANT.Float); - return UNSAFE.getFloat(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); - } - - /** - * Gets the double constant pool entry at index {@code index}. - * - * @param index constant pool index - * @return float constant pool entry - */ - private double getDoubleAt(int index) { - assertTag(index, JVM_CONSTANT.Double); - return UNSAFE.getDouble(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); - } - - /** - * Gets the {@code JVM_CONSTANT_NameAndType} constant pool entry at index {@code index}. - * - * @param index constant pool index - * @return {@code JVM_CONSTANT_NameAndType} constant pool entry - */ - private int getNameAndTypeAt(int index) { - assertTag(index, JVM_CONSTANT.NameAndType); - return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); - } - - /** - * Gets the {@code JVM_CONSTANT_NameAndType} reference index constant pool entry at index - * {@code index}. - * - * @param index constant pool index - * @return {@code JVM_CONSTANT_NameAndType} reference constant pool entry - */ - private int getNameAndTypeRefIndexAt(int index) { - return compilerToVM().lookupNameAndTypeRefIndexInPool(this, index); - } - - /** - * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry referenced by another - * entry denoted by {@code which}. - * - * @param which constant pool index or constant pool cache index - * @return name as {@link String} - */ - private String getNameOf(int which) { - return compilerToVM().lookupNameInPool(this, which); - } - - /** - * Gets the name reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry at - * index {@code index}. - * - * @param index constant pool index - * @return name reference index - */ - private int getNameRefIndexAt(int index) { - final int refIndex = getNameAndTypeAt(index); - // name ref index is in the low 16-bits. - return refIndex & 0xFFFF; - } - - /** - * Gets the signature of a {@code JVM_CONSTANT_NameAndType} constant pool entry referenced by - * another entry denoted by {@code which}. - * - * @param which constant pool index or constant pool cache index - * @return signature as {@link String} - */ - private String getSignatureOf(int which) { - return compilerToVM().lookupSignatureInPool(this, which); - } - - /** - * Gets the signature reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry - * at index {@code index}. - * - * @param index constant pool index - * @return signature reference index - */ - private int getSignatureRefIndexAt(int index) { - final int refIndex = getNameAndTypeAt(index); - // signature ref index is in the high 16-bits. - return refIndex >>> 16; - } - - /** - * Gets the klass reference index constant pool entry at index {@code index}. - * - * @param index constant pool index - * @return klass reference index - */ - private int getKlassRefIndexAt(int index) { - return compilerToVM().lookupKlassRefIndexInPool(this, index); - } - - /** - * Gets the uncached klass reference index constant pool entry at index {@code index}. See: - * {@code ConstantPool::uncached_klass_ref_index_at}. - * - * @param index constant pool index - * @return klass reference index - */ - private int getUncachedKlassRefIndexAt(int index) { - assertTagIsFieldOrMethod(index); - final int refIndex = UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); - // klass ref index is in the low 16-bits. - return refIndex & 0xFFFF; - } - - /** - * Asserts that the constant pool index {@code index} is in the bounds of the constant pool. - * - * @param index constant pool index - */ - private void assertBounds(int index) { - assert 0 <= index && index < length() : "index " + index + " not between 0 and " + length(); - } - - /** - * Asserts that the constant pool tag at index {@code index} is equal to {@code tag}. - * - * @param index constant pool index - * @param tag expected tag - */ - private void assertTag(int index, JVM_CONSTANT tag) { - final JVM_CONSTANT tagAt = getTagAt(index); - assert tagAt == tag : "constant pool tag at index " + index + " is " + tagAt + " but expected " + tag; - } - - /** - * Asserts that the constant pool tag at index {@code index} is a {@link JVM_CONSTANT#Fieldref}, - * or a {@link JVM_CONSTANT#MethodRef}, or a {@link JVM_CONSTANT#InterfaceMethodref}. - * - * @param index constant pool index - */ - private void assertTagIsFieldOrMethod(int index) { - final JVM_CONSTANT tagAt = getTagAt(index); - assert tagAt == JVM_CONSTANT.Fieldref || tagAt == JVM_CONSTANT.MethodRef || tagAt == JVM_CONSTANT.InterfaceMethodref : tagAt; - } - - @Override - public int length() { - return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolLengthOffset); - } - - @Override - public Object lookupConstant(int cpi) { - assert cpi != 0; - final JVM_CONSTANT tag = getTagAt(cpi); - switch (tag) { - case Integer: - return JavaConstant.forInt(getIntAt(cpi)); - case Long: - return JavaConstant.forLong(getLongAt(cpi)); - case Float: - return JavaConstant.forFloat(getFloatAt(cpi)); - case Double: - return JavaConstant.forDouble(getDoubleAt(cpi)); - case Class: - case UnresolvedClass: - case UnresolvedClassInError: - final int opcode = -1; // opcode is not used - return lookupType(cpi, opcode); - case String: - /* - * Normally, we would expect a String here, but anonymous classes can have - * "pseudo strings" (arbitrary live objects) patched into a String entry. Such - * entries do not have a symbol in the constant pool slot. - */ - Object string = compilerToVM().resolvePossiblyCachedConstantInPool(this, cpi); - return HotSpotObjectConstantImpl.forObject(string); - case MethodHandle: - case MethodHandleInError: - case MethodType: - case MethodTypeInError: - Object obj = compilerToVM().resolveConstantInPool(this, cpi); - return HotSpotObjectConstantImpl.forObject(obj); - default: - throw new JVMCIError("Unknown constant pool tag %s", tag); - } - } - - @Override - public String lookupUtf8(int cpi) { - assertTag(cpi, JVM_CONSTANT.Utf8); - return compilerToVM().getSymbol(getEntryAt(cpi)); - } - - @Override - public Signature lookupSignature(int cpi) { - return new HotSpotSignature(runtime(), lookupUtf8(cpi)); - } - - @Override - public JavaConstant lookupAppendix(int cpi, int opcode) { - assert Bytecodes.isInvoke(opcode); - final int index = rawIndexToConstantPoolIndex(cpi, opcode); - Object appendix = compilerToVM().lookupAppendixInPool(this, index); - if (appendix == null) { - return null; - } else { - return HotSpotObjectConstantImpl.forObject(appendix); - } - } - - /** - * Gets a {@link JavaType} corresponding a given resolved or unresolved type. - * - * @param type either a ResolvedJavaType or a String naming a unresolved type. - */ - private static JavaType getJavaType(final Object type) { - if (type instanceof String) { - String name = (String) type; - return HotSpotUnresolvedJavaType.create(runtime(), "L" + name + ";"); - } else { - return (JavaType) type; - } - } - - @Override - public JavaMethod lookupMethod(int cpi, int opcode) { - final int index = rawIndexToConstantPoolIndex(cpi, opcode); - final HotSpotResolvedJavaMethod method = compilerToVM().lookupMethodInPool(this, index, (byte) opcode); - if (method != null) { - return method; - } else { - // Get the method's name and signature. - String name = getNameOf(index); - HotSpotSignature signature = new HotSpotSignature(runtime(), getSignatureOf(index)); - if (opcode == Bytecodes.INVOKEDYNAMIC) { - HotSpotResolvedObjectType holder = HotSpotResolvedObjectTypeImpl.fromObjectClass(MethodHandle.class); - return new HotSpotMethodUnresolved(name, signature, holder); - } else { - final int klassIndex = getKlassRefIndexAt(index); - final Object type = compilerToVM().lookupKlassInPool(this, klassIndex); - JavaType holder = getJavaType(type); - return new HotSpotMethodUnresolved(name, signature, holder); - } - } - } - - @Override - public JavaType lookupType(int cpi, int opcode) { - final LookupTypeCacheElement elem = this.lastLookupType; - if (elem != null && elem.lastCpi == cpi) { - return elem.javaType; - } else { - final Object type = compilerToVM().lookupKlassInPool(this, cpi); - JavaType result = getJavaType(type); - if (result instanceof ResolvedJavaType) { - this.lastLookupType = new LookupTypeCacheElement(cpi, result); - } - return result; - } - } - - @Override - public JavaField lookupField(int cpi, int opcode) { - final int index = rawIndexToConstantPoolIndex(cpi, opcode); - final int nameAndTypeIndex = getNameAndTypeRefIndexAt(index); - final int nameIndex = getNameRefIndexAt(nameAndTypeIndex); - String name = lookupUtf8(nameIndex); - final int typeIndex = getSignatureRefIndexAt(nameAndTypeIndex); - String typeName = lookupUtf8(typeIndex); - JavaType type = runtime().lookupType(typeName, getHolder(), false); - - final int holderIndex = getKlassRefIndexAt(index); - JavaType holder = lookupType(holderIndex, opcode); - - if (holder instanceof HotSpotResolvedObjectTypeImpl) { - long[] info = new long[2]; - HotSpotResolvedObjectTypeImpl resolvedHolder; - try { - resolvedHolder = compilerToVM().resolveFieldInPool(this, index, (byte) opcode, info); - } catch (Throwable t) { - /* - * If there was an exception resolving the field we give up and return an unresolved - * field. - */ - return new HotSpotUnresolvedField(holder, name, type); - } - final int flags = (int) info[0]; - final long offset = info[1]; - HotSpotResolvedJavaField result = resolvedHolder.createField(name, type, offset, flags); - return result; - } else { - return new HotSpotUnresolvedField(holder, name, type); - } - } - - @Override - @SuppressWarnings("fallthrough") - public void loadReferencedType(int cpi, int opcode) { - int index; - switch (opcode) { - case Bytecodes.CHECKCAST: - case Bytecodes.INSTANCEOF: - case Bytecodes.NEW: - case Bytecodes.ANEWARRAY: - case Bytecodes.MULTIANEWARRAY: - case Bytecodes.LDC: - case Bytecodes.LDC_W: - case Bytecodes.LDC2_W: - index = cpi; - break; - case Bytecodes.INVOKEDYNAMIC: { - // invokedynamic instructions point to a constant pool cache entry. - index = decodeConstantPoolCacheIndex(cpi) + config().constantPoolCpCacheIndexTag; - index = compilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); - break; - } - case Bytecodes.GETSTATIC: - case Bytecodes.PUTSTATIC: - case Bytecodes.GETFIELD: - case Bytecodes.PUTFIELD: - case Bytecodes.INVOKEVIRTUAL: - case Bytecodes.INVOKESPECIAL: - case Bytecodes.INVOKESTATIC: - case Bytecodes.INVOKEINTERFACE: { - // invoke and field instructions point to a constant pool cache entry. - index = rawIndexToConstantPoolIndex(cpi, opcode); - index = compilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); - break; - } - default: - throw JVMCIError.shouldNotReachHere("Unexpected opcode " + opcode); - } - - final JVM_CONSTANT tag = getTagAt(index); - if (tag == null) { - assert getTagAt(index - 1) == JVM_CONSTANT.Double || getTagAt(index - 1) == JVM_CONSTANT.Long; - return; - } - switch (tag) { - case MethodRef: - case Fieldref: - case InterfaceMethodref: - index = getUncachedKlassRefIndexAt(index); - // Read the tag only once because it could change between multiple reads. - final JVM_CONSTANT klassTag = getTagAt(index); - assert klassTag == JVM_CONSTANT.Class || klassTag == JVM_CONSTANT.UnresolvedClass || klassTag == JVM_CONSTANT.UnresolvedClassInError : klassTag; - // fall through - case Class: - case UnresolvedClass: - case UnresolvedClassInError: - final HotSpotResolvedObjectTypeImpl type = compilerToVM().resolveTypeInPool(this, index); - Class klass = type.mirror(); - if (!klass.isPrimitive() && !klass.isArray()) { - UNSAFE.ensureClassInitialized(klass); - } - switch (tag) { - case MethodRef: - if (Bytecodes.isInvokeHandleAlias(opcode)) { - final int methodRefCacheIndex = rawIndexToConstantPoolIndex(cpi, opcode); - if (isInvokeHandle(methodRefCacheIndex, type)) { - compilerToVM().resolveInvokeHandleInPool(this, methodRefCacheIndex); - } - } - } - break; - case InvokeDynamic: - if (isInvokedynamicIndex(cpi)) { - compilerToVM().resolveInvokeDynamicInPool(this, cpi); - } - break; - default: - // nothing - break; - } - } - - private boolean isInvokeHandle(int methodRefCacheIndex, HotSpotResolvedObjectTypeImpl klass) { - assertTag(compilerToVM().constantPoolRemapInstructionOperandFromCache(this, methodRefCacheIndex), JVM_CONSTANT.MethodRef); - return ResolvedJavaMethod.isSignaturePolymorphic(klass, getNameOf(methodRefCacheIndex), runtime().getHostJVMCIBackend().getMetaAccess()); - } - - @Override - public String toString() { - HotSpotResolvedObjectType holder = getHolder(); - return "HotSpotConstantPool<" + holder.toJavaName() + ">"; - } -} --- /dev/null 2016-05-04 09:43:29.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java 2016-05-04 09:43:29.000000000 -1000 @@ -0,0 +1,714 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; +import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; +import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; + +import java.lang.invoke.MethodHandle; + +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.meta.ConstantPool; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.JavaField; +import jdk.vm.ci.meta.JavaMethod; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; +import jdk.vm.ci.meta.Signature; + +/** + * Implementation of {@link ConstantPool} for HotSpot. + */ +final class HotSpotConstantPool implements ConstantPool, HotSpotProxified, MetaspaceWrapperObject { + + /** + * Subset of JVM bytecode opcodes used by {@link HotSpotConstantPool}. + */ + public static class Bytecodes { + public static final int LDC = 18; // 0x12 + public static final int LDC_W = 19; // 0x13 + public static final int LDC2_W = 20; // 0x14 + public static final int GETSTATIC = 178; // 0xB2 + public static final int PUTSTATIC = 179; // 0xB3 + public static final int GETFIELD = 180; // 0xB4 + public static final int PUTFIELD = 181; // 0xB5 + public static final int INVOKEVIRTUAL = 182; // 0xB6 + public static final int INVOKESPECIAL = 183; // 0xB7 + public static final int INVOKESTATIC = 184; // 0xB8 + public static final int INVOKEINTERFACE = 185; // 0xB9 + public static final int INVOKEDYNAMIC = 186; // 0xBA + public static final int NEW = 187; // 0xBB + public static final int NEWARRAY = 188; // 0xBC + public static final int ANEWARRAY = 189; // 0xBD + public static final int CHECKCAST = 192; // 0xC0 + public static final int INSTANCEOF = 193; // 0xC1 + public static final int MULTIANEWARRAY = 197; // 0xC5 + + static boolean isInvoke(int opcode) { + switch (opcode) { + case INVOKEVIRTUAL: + case INVOKESPECIAL: + case INVOKESTATIC: + case INVOKEINTERFACE: + case INVOKEDYNAMIC: + return true; + default: + return false; + } + } + + /** + * See: {@code Rewriter::maybe_rewrite_invokehandle}. + */ + static boolean isInvokeHandleAlias(int opcode) { + switch (opcode) { + case INVOKEVIRTUAL: + case INVOKESPECIAL: + return true; + default: + return false; + } + } + } + + /** + * Enum of all {@code JVM_CONSTANT} constants used in the VM. This includes the public and + * internal ones. + */ + private enum JVM_CONSTANT { + // @formatter:off + Utf8(config().jvmConstantUtf8), + Integer(config().jvmConstantInteger), + Long(config().jvmConstantLong), + Float(config().jvmConstantFloat), + Double(config().jvmConstantDouble), + Class(config().jvmConstantClass), + UnresolvedClass(config().jvmConstantUnresolvedClass), + UnresolvedClassInError(config().jvmConstantUnresolvedClassInError), + String(config().jvmConstantString), + Fieldref(config().jvmConstantFieldref), + MethodRef(config().jvmConstantMethodref), + InterfaceMethodref(config().jvmConstantInterfaceMethodref), + NameAndType(config().jvmConstantNameAndType), + MethodHandle(config().jvmConstantMethodHandle), + MethodHandleInError(config().jvmConstantMethodHandleInError), + MethodType(config().jvmConstantMethodType), + MethodTypeInError(config().jvmConstantMethodTypeInError), + InvokeDynamic(config().jvmConstantInvokeDynamic); + // @formatter:on + + private final int tag; + + private static final int ExternalMax = config().jvmConstantExternalMax; + private static final int InternalMin = config().jvmConstantInternalMin; + private static final int InternalMax = config().jvmConstantInternalMax; + + JVM_CONSTANT(int tag) { + this.tag = tag; + } + + /** + * Maps JVM_CONSTANT tags to {@link JVM_CONSTANT} values. Using a separate class for lazy + * initialization. + */ + static class TagValueMap { + private static final JVM_CONSTANT[] table = new JVM_CONSTANT[ExternalMax + 1 + (InternalMax - InternalMin) + 1]; + + static { + assert InternalMin > ExternalMax; + for (JVM_CONSTANT e : values()) { + table[indexOf(e.tag)] = e; + } + } + + private static int indexOf(int tag) { + if (tag >= InternalMin) { + return tag - InternalMin + ExternalMax + 1; + } else { + assert tag <= ExternalMax; + } + return tag; + } + + static JVM_CONSTANT get(int tag) { + JVM_CONSTANT res = table[indexOf(tag)]; + if (res != null) { + return res; + } + throw new JVMCIError("Unknown JVM_CONSTANT tag %s", tag); + } + } + + public static JVM_CONSTANT getEnum(int tag) { + return TagValueMap.get(tag); + } + } + + private static class LookupTypeCacheElement { + int lastCpi = Integer.MIN_VALUE; + JavaType javaType; + + LookupTypeCacheElement(int lastCpi, JavaType javaType) { + super(); + this.lastCpi = lastCpi; + this.javaType = javaType; + } + } + + /** + * Reference to the C++ ConstantPool object. + */ + private final long metaspaceConstantPool; + private volatile LookupTypeCacheElement lastLookupType; + + /** + * Gets the JVMCI mirror from a HotSpot constant pool.The VM is responsible for ensuring that + * the ConstantPool is kept alive for the duration of this call and the + * {@link HotSpotJVMCIMetaAccessContext} keeps it alive after that. + * + * Called from the VM. + * + * @param metaspaceConstantPool a metaspace ConstantPool object + * @return the {@link HotSpotConstantPool} corresponding to {@code metaspaceConstantPool} + */ + @SuppressWarnings("unused") + private static HotSpotConstantPool fromMetaspace(long metaspaceConstantPool) { + return new HotSpotConstantPool(metaspaceConstantPool); + } + + private HotSpotConstantPool(long metaspaceConstantPool) { + this.metaspaceConstantPool = metaspaceConstantPool; + } + + /** + * Gets the holder for this constant pool as {@link HotSpotResolvedObjectTypeImpl}. + * + * @return holder for this constant pool + */ + private HotSpotResolvedObjectType getHolder() { + return compilerToVM().getResolvedJavaType(this, config().constantPoolHolderOffset, false); + } + + /** + * Converts a raw index from the bytecodes to a constant pool index by adding a + * {@link HotSpotVMConfig#constantPoolCpCacheIndexTag constant}. + * + * @param rawIndex index from the bytecode + * @param opcode bytecode to convert the index for + * @return constant pool index + */ + private static int rawIndexToConstantPoolIndex(int rawIndex, int opcode) { + int index; + if (opcode == Bytecodes.INVOKEDYNAMIC) { + index = rawIndex; + // See: ConstantPool::is_invokedynamic_index + assert index < 0 : "not an invokedynamic constant pool index " + index; + } else { + assert opcode == Bytecodes.GETFIELD || opcode == Bytecodes.PUTFIELD || opcode == Bytecodes.GETSTATIC || opcode == Bytecodes.PUTSTATIC || opcode == Bytecodes.INVOKEINTERFACE || + opcode == Bytecodes.INVOKEVIRTUAL || opcode == Bytecodes.INVOKESPECIAL || opcode == Bytecodes.INVOKESTATIC : "unexpected invoke opcode " + opcode; + index = rawIndex + config().constantPoolCpCacheIndexTag; + } + return index; + } + + /** + * Decode a constant pool cache index to a constant pool index. + * + * See {@code ConstantPool::decode_cpcache_index}. + * + * @param index constant pool cache index + * @return decoded index + */ + private static int decodeConstantPoolCacheIndex(int index) { + if (isInvokedynamicIndex(index)) { + return decodeInvokedynamicIndex(index); + } else { + return index - config().constantPoolCpCacheIndexTag; + } + } + + /** + * See {@code ConstantPool::is_invokedynamic_index}. + */ + private static boolean isInvokedynamicIndex(int index) { + return index < 0; + } + + /** + * See {@code ConstantPool::decode_invokedynamic_index}. + */ + private static int decodeInvokedynamicIndex(int i) { + assert isInvokedynamicIndex(i) : i; + return ~i; + } + + long getMetaspaceConstantPool() { + return metaspaceConstantPool; + } + + public long getMetaspacePointer() { + return getMetaspaceConstantPool(); + } + + /** + * Gets the constant pool tag at index {@code index}. + * + * @param index constant pool index + * @return constant pool tag + */ + private JVM_CONSTANT getTagAt(int index) { + assertBounds(index); + HotSpotVMConfig config = config(); + final long metaspaceConstantPoolTags = UNSAFE.getAddress(getMetaspaceConstantPool() + config.constantPoolTagsOffset); + final int tag = UNSAFE.getByteVolatile(null, metaspaceConstantPoolTags + config.arrayU1DataOffset + index); + if (tag == 0) { + return null; + } + return JVM_CONSTANT.getEnum(tag); + } + + /** + * Gets the constant pool entry at index {@code index}. + * + * @param index constant pool index + * @return constant pool entry + */ + private long getEntryAt(int index) { + assertBounds(index); + return UNSAFE.getAddress(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + } + + /** + * Gets the integer constant pool entry at index {@code index}. + * + * @param index constant pool index + * @return integer constant pool entry at index + */ + private int getIntAt(int index) { + assertTag(index, JVM_CONSTANT.Integer); + return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + } + + /** + * Gets the long constant pool entry at index {@code index}. + * + * @param index constant pool index + * @return long constant pool entry + */ + private long getLongAt(int index) { + assertTag(index, JVM_CONSTANT.Long); + return UNSAFE.getLong(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + } + + /** + * Gets the float constant pool entry at index {@code index}. + * + * @param index constant pool index + * @return float constant pool entry + */ + private float getFloatAt(int index) { + assertTag(index, JVM_CONSTANT.Float); + return UNSAFE.getFloat(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + } + + /** + * Gets the double constant pool entry at index {@code index}. + * + * @param index constant pool index + * @return float constant pool entry + */ + private double getDoubleAt(int index) { + assertTag(index, JVM_CONSTANT.Double); + return UNSAFE.getDouble(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + } + + /** + * Gets the {@code JVM_CONSTANT_NameAndType} constant pool entry at index {@code index}. + * + * @param index constant pool index + * @return {@code JVM_CONSTANT_NameAndType} constant pool entry + */ + private int getNameAndTypeAt(int index) { + assertTag(index, JVM_CONSTANT.NameAndType); + return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + } + + /** + * Gets the {@code JVM_CONSTANT_NameAndType} reference index constant pool entry at index + * {@code index}. + * + * @param index constant pool index + * @return {@code JVM_CONSTANT_NameAndType} reference constant pool entry + */ + private int getNameAndTypeRefIndexAt(int index) { + return compilerToVM().lookupNameAndTypeRefIndexInPool(this, index); + } + + /** + * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry referenced by another + * entry denoted by {@code which}. + * + * @param which constant pool index or constant pool cache index + * @return name as {@link String} + */ + private String getNameOf(int which) { + return compilerToVM().lookupNameInPool(this, which); + } + + /** + * Gets the name reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry at + * index {@code index}. + * + * @param index constant pool index + * @return name reference index + */ + private int getNameRefIndexAt(int index) { + final int refIndex = getNameAndTypeAt(index); + // name ref index is in the low 16-bits. + return refIndex & 0xFFFF; + } + + /** + * Gets the signature of a {@code JVM_CONSTANT_NameAndType} constant pool entry referenced by + * another entry denoted by {@code which}. + * + * @param which constant pool index or constant pool cache index + * @return signature as {@link String} + */ + private String getSignatureOf(int which) { + return compilerToVM().lookupSignatureInPool(this, which); + } + + /** + * Gets the signature reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry + * at index {@code index}. + * + * @param index constant pool index + * @return signature reference index + */ + private int getSignatureRefIndexAt(int index) { + final int refIndex = getNameAndTypeAt(index); + // signature ref index is in the high 16-bits. + return refIndex >>> 16; + } + + /** + * Gets the klass reference index constant pool entry at index {@code index}. + * + * @param index constant pool index + * @return klass reference index + */ + private int getKlassRefIndexAt(int index) { + return compilerToVM().lookupKlassRefIndexInPool(this, index); + } + + /** + * Gets the uncached klass reference index constant pool entry at index {@code index}. See: + * {@code ConstantPool::uncached_klass_ref_index_at}. + * + * @param index constant pool index + * @return klass reference index + */ + private int getUncachedKlassRefIndexAt(int index) { + assertTagIsFieldOrMethod(index); + final int refIndex = UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); + // klass ref index is in the low 16-bits. + return refIndex & 0xFFFF; + } + + /** + * Asserts that the constant pool index {@code index} is in the bounds of the constant pool. + * + * @param index constant pool index + */ + private void assertBounds(int index) { + assert 0 <= index && index < length() : "index " + index + " not between 0 and " + length(); + } + + /** + * Asserts that the constant pool tag at index {@code index} is equal to {@code tag}. + * + * @param index constant pool index + * @param tag expected tag + */ + private void assertTag(int index, JVM_CONSTANT tag) { + final JVM_CONSTANT tagAt = getTagAt(index); + assert tagAt == tag : "constant pool tag at index " + index + " is " + tagAt + " but expected " + tag; + } + + /** + * Asserts that the constant pool tag at index {@code index} is a {@link JVM_CONSTANT#Fieldref}, + * or a {@link JVM_CONSTANT#MethodRef}, or a {@link JVM_CONSTANT#InterfaceMethodref}. + * + * @param index constant pool index + */ + private void assertTagIsFieldOrMethod(int index) { + final JVM_CONSTANT tagAt = getTagAt(index); + assert tagAt == JVM_CONSTANT.Fieldref || tagAt == JVM_CONSTANT.MethodRef || tagAt == JVM_CONSTANT.InterfaceMethodref : tagAt; + } + + @Override + public int length() { + return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolLengthOffset); + } + + @Override + public Object lookupConstant(int cpi) { + assert cpi != 0; + final JVM_CONSTANT tag = getTagAt(cpi); + switch (tag) { + case Integer: + return JavaConstant.forInt(getIntAt(cpi)); + case Long: + return JavaConstant.forLong(getLongAt(cpi)); + case Float: + return JavaConstant.forFloat(getFloatAt(cpi)); + case Double: + return JavaConstant.forDouble(getDoubleAt(cpi)); + case Class: + case UnresolvedClass: + case UnresolvedClassInError: + final int opcode = -1; // opcode is not used + return lookupType(cpi, opcode); + case String: + /* + * Normally, we would expect a String here, but anonymous classes can have + * "pseudo strings" (arbitrary live objects) patched into a String entry. Such + * entries do not have a symbol in the constant pool slot. + */ + Object string = compilerToVM().resolvePossiblyCachedConstantInPool(this, cpi); + return HotSpotObjectConstantImpl.forObject(string); + case MethodHandle: + case MethodHandleInError: + case MethodType: + case MethodTypeInError: + Object obj = compilerToVM().resolveConstantInPool(this, cpi); + return HotSpotObjectConstantImpl.forObject(obj); + default: + throw new JVMCIError("Unknown constant pool tag %s", tag); + } + } + + @Override + public String lookupUtf8(int cpi) { + assertTag(cpi, JVM_CONSTANT.Utf8); + return compilerToVM().getSymbol(getEntryAt(cpi)); + } + + @Override + public Signature lookupSignature(int cpi) { + return new HotSpotSignature(runtime(), lookupUtf8(cpi)); + } + + @Override + public JavaConstant lookupAppendix(int cpi, int opcode) { + assert Bytecodes.isInvoke(opcode); + final int index = rawIndexToConstantPoolIndex(cpi, opcode); + Object appendix = compilerToVM().lookupAppendixInPool(this, index); + if (appendix == null) { + return null; + } else { + return HotSpotObjectConstantImpl.forObject(appendix); + } + } + + /** + * Gets a {@link JavaType} corresponding a given resolved or unresolved type. + * + * @param type either a ResolvedJavaType or a String naming a unresolved type. + */ + private static JavaType getJavaType(final Object type) { + if (type instanceof String) { + String name = (String) type; + return HotSpotUnresolvedJavaType.create(runtime(), "L" + name + ";"); + } else { + return (JavaType) type; + } + } + + @Override + public JavaMethod lookupMethod(int cpi, int opcode) { + final int index = rawIndexToConstantPoolIndex(cpi, opcode); + final HotSpotResolvedJavaMethod method = compilerToVM().lookupMethodInPool(this, index, (byte) opcode); + if (method != null) { + return method; + } else { + // Get the method's name and signature. + String name = getNameOf(index); + HotSpotSignature signature = new HotSpotSignature(runtime(), getSignatureOf(index)); + if (opcode == Bytecodes.INVOKEDYNAMIC) { + HotSpotResolvedObjectType holder = HotSpotResolvedObjectTypeImpl.fromObjectClass(MethodHandle.class); + return new HotSpotMethodUnresolved(name, signature, holder); + } else { + final int klassIndex = getKlassRefIndexAt(index); + final Object type = compilerToVM().lookupKlassInPool(this, klassIndex); + JavaType holder = getJavaType(type); + return new HotSpotMethodUnresolved(name, signature, holder); + } + } + } + + @Override + public JavaType lookupType(int cpi, int opcode) { + final LookupTypeCacheElement elem = this.lastLookupType; + if (elem != null && elem.lastCpi == cpi) { + return elem.javaType; + } else { + final Object type = compilerToVM().lookupKlassInPool(this, cpi); + JavaType result = getJavaType(type); + if (result instanceof ResolvedJavaType) { + this.lastLookupType = new LookupTypeCacheElement(cpi, result); + } + return result; + } + } + + @Override + public JavaField lookupField(int cpi, int opcode) { + final int index = rawIndexToConstantPoolIndex(cpi, opcode); + final int nameAndTypeIndex = getNameAndTypeRefIndexAt(index); + final int nameIndex = getNameRefIndexAt(nameAndTypeIndex); + String name = lookupUtf8(nameIndex); + final int typeIndex = getSignatureRefIndexAt(nameAndTypeIndex); + String typeName = lookupUtf8(typeIndex); + JavaType type = runtime().lookupType(typeName, getHolder(), false); + + final int holderIndex = getKlassRefIndexAt(index); + JavaType holder = lookupType(holderIndex, opcode); + + if (holder instanceof HotSpotResolvedObjectTypeImpl) { + long[] info = new long[2]; + HotSpotResolvedObjectTypeImpl resolvedHolder; + try { + resolvedHolder = compilerToVM().resolveFieldInPool(this, index, (byte) opcode, info); + } catch (Throwable t) { + /* + * If there was an exception resolving the field we give up and return an unresolved + * field. + */ + return new HotSpotUnresolvedField(holder, name, type); + } + final int flags = (int) info[0]; + final long offset = info[1]; + HotSpotResolvedJavaField result = resolvedHolder.createField(name, type, offset, flags); + return result; + } else { + return new HotSpotUnresolvedField(holder, name, type); + } + } + + @Override + @SuppressWarnings("fallthrough") + public void loadReferencedType(int cpi, int opcode) { + int index; + switch (opcode) { + case Bytecodes.CHECKCAST: + case Bytecodes.INSTANCEOF: + case Bytecodes.NEW: + case Bytecodes.ANEWARRAY: + case Bytecodes.MULTIANEWARRAY: + case Bytecodes.LDC: + case Bytecodes.LDC_W: + case Bytecodes.LDC2_W: + index = cpi; + break; + case Bytecodes.INVOKEDYNAMIC: { + // invokedynamic instructions point to a constant pool cache entry. + index = decodeConstantPoolCacheIndex(cpi) + config().constantPoolCpCacheIndexTag; + index = compilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); + break; + } + case Bytecodes.GETSTATIC: + case Bytecodes.PUTSTATIC: + case Bytecodes.GETFIELD: + case Bytecodes.PUTFIELD: + case Bytecodes.INVOKEVIRTUAL: + case Bytecodes.INVOKESPECIAL: + case Bytecodes.INVOKESTATIC: + case Bytecodes.INVOKEINTERFACE: { + // invoke and field instructions point to a constant pool cache entry. + index = rawIndexToConstantPoolIndex(cpi, opcode); + index = compilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); + break; + } + default: + throw JVMCIError.shouldNotReachHere("Unexpected opcode " + opcode); + } + + final JVM_CONSTANT tag = getTagAt(index); + if (tag == null) { + assert getTagAt(index - 1) == JVM_CONSTANT.Double || getTagAt(index - 1) == JVM_CONSTANT.Long; + return; + } + switch (tag) { + case MethodRef: + case Fieldref: + case InterfaceMethodref: + index = getUncachedKlassRefIndexAt(index); + // Read the tag only once because it could change between multiple reads. + final JVM_CONSTANT klassTag = getTagAt(index); + assert klassTag == JVM_CONSTANT.Class || klassTag == JVM_CONSTANT.UnresolvedClass || klassTag == JVM_CONSTANT.UnresolvedClassInError : klassTag; + // fall through + case Class: + case UnresolvedClass: + case UnresolvedClassInError: + final HotSpotResolvedObjectTypeImpl type = compilerToVM().resolveTypeInPool(this, index); + Class klass = type.mirror(); + if (!klass.isPrimitive() && !klass.isArray()) { + UNSAFE.ensureClassInitialized(klass); + } + switch (tag) { + case MethodRef: + if (Bytecodes.isInvokeHandleAlias(opcode)) { + final int methodRefCacheIndex = rawIndexToConstantPoolIndex(cpi, opcode); + if (isInvokeHandle(methodRefCacheIndex, type)) { + compilerToVM().resolveInvokeHandleInPool(this, methodRefCacheIndex); + } + } + } + break; + case InvokeDynamic: + if (isInvokedynamicIndex(cpi)) { + compilerToVM().resolveInvokeDynamicInPool(this, cpi); + } + break; + default: + // nothing + break; + } + } + + private boolean isInvokeHandle(int methodRefCacheIndex, HotSpotResolvedObjectTypeImpl klass) { + assertTag(compilerToVM().constantPoolRemapInstructionOperandFromCache(this, methodRefCacheIndex), JVM_CONSTANT.MethodRef); + return ResolvedJavaMethod.isSignaturePolymorphic(klass, getNameOf(methodRefCacheIndex), runtime().getHostJVMCIBackend().getMetaAccess()); + } + + @Override + public String toString() { + HotSpotResolvedObjectType holder = getHolder(); + return "HotSpotConstantPool<" + holder.toJavaName() + ">"; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java 2016-05-04 09:43:30.000000000 -1000 +++ /dev/null 2016-05-04 09:43:30.000000000 -1000 @@ -1,374 +0,0 @@ -/* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayBaseOffset; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayIndexScale; - -import java.lang.reflect.Array; -import java.util.Objects; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.MemoryAccessProvider; -import jdk.vm.ci.meta.MethodHandleAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * HotSpot implementation of {@link ConstantReflectionProvider}. - */ -public class HotSpotConstantReflectionProvider implements ConstantReflectionProvider, HotSpotProxified { - - protected final HotSpotJVMCIRuntimeProvider runtime; - protected final HotSpotMethodHandleAccessProvider methodHandleAccess; - protected final HotSpotMemoryAccessProviderImpl memoryAccess; - - public HotSpotConstantReflectionProvider(HotSpotJVMCIRuntimeProvider runtime) { - this.runtime = runtime; - this.methodHandleAccess = new HotSpotMethodHandleAccessProvider(this); - this.memoryAccess = new HotSpotMemoryAccessProviderImpl(runtime); - } - - public MethodHandleAccessProvider getMethodHandleAccess() { - return methodHandleAccess; - } - - @Override - public MemoryAccessProvider getMemoryAccessProvider() { - return memoryAccess; - } - - @Override - public Boolean constantEquals(Constant x, Constant y) { - if (x == y) { - return true; - } else if (x instanceof HotSpotObjectConstantImpl) { - return y instanceof HotSpotObjectConstantImpl && ((HotSpotObjectConstantImpl) x).object() == ((HotSpotObjectConstantImpl) y).object(); - } else { - return Objects.equals(x, y); - } - } - - @Override - public Integer readArrayLength(JavaConstant array) { - if (array == null || array.getJavaKind() != JavaKind.Object || array.isNull()) { - return null; - } - - Object arrayObject = ((HotSpotObjectConstantImpl) array).object(); - if (!arrayObject.getClass().isArray()) { - return null; - } - return Array.getLength(arrayObject); - } - - public JavaConstant readConstantArrayElement(JavaConstant array, int index) { - if (array instanceof HotSpotObjectConstantImpl && ((HotSpotObjectConstantImpl) array).getStableDimension() > 0) { - JavaConstant element = readArrayElement(array, index); - if (element != null && (((HotSpotObjectConstantImpl) array).isDefaultStable() || !element.isDefaultForKind())) { - return element; - } - } - return null; - } - - /** - * Try to convert {@code offset} into an an index into {@code array}. - * - * @return the computed index or -1 if the offset isn't within the array - */ - private int indexForOffset(JavaConstant array, long offset) { - if (array.getJavaKind() != JavaKind.Object || array.isNull()) { - return -1; - } - Class componentType = ((HotSpotObjectConstantImpl) array).object().getClass().getComponentType(); - JavaKind kind = runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType(componentType).getJavaKind(); - int arraybase = getArrayBaseOffset(kind); - int scale = getArrayIndexScale(kind); - if (offset < arraybase) { - return -1; - } - long index = offset - arraybase; - if (index % scale != 0) { - return -1; - } - long result = index / scale; - if (result >= Integer.MAX_VALUE) { - return -1; - } - return (int) result; - } - - public JavaConstant readConstantArrayElementForOffset(JavaConstant array, long offset) { - if (array instanceof HotSpotObjectConstantImpl && ((HotSpotObjectConstantImpl) array).getStableDimension() > 0) { - return readConstantArrayElement(array, indexForOffset(array, offset)); - } - return null; - } - - @Override - public JavaConstant readArrayElement(JavaConstant array, int index) { - if (array == null || array.getJavaKind() != JavaKind.Object || array.isNull()) { - return null; - } - Object a = ((HotSpotObjectConstantImpl) array).object(); - - if (!a.getClass().isArray() || index < 0 || index >= Array.getLength(a)) { - return null; - } - - if (a instanceof Object[]) { - Object element = ((Object[]) a)[index]; - if (((HotSpotObjectConstantImpl) array).getStableDimension() > 1) { - return HotSpotObjectConstantImpl.forStableArray(element, ((HotSpotObjectConstantImpl) array).getStableDimension() - 1, ((HotSpotObjectConstantImpl) array).isDefaultStable()); - } else { - return HotSpotObjectConstantImpl.forObject(element); - } - } else { - return JavaConstant.forBoxedPrimitive(Array.get(a, index)); - } - } - - /** - * Check if the constant is a boxed value that is guaranteed to be cached by the platform. - * Otherwise the generated code might be the only reference to the boxed value and since object - * references from nmethods are weak this can cause GC problems. - * - * @param source - * @return true if the box is cached - */ - private static boolean isBoxCached(JavaConstant source) { - switch (source.getJavaKind()) { - case Boolean: - return true; - case Char: - return source.asInt() <= 127; - case Byte: - case Short: - case Int: - return source.asInt() >= -128 && source.asInt() <= 127; - case Long: - return source.asLong() >= -128 && source.asLong() <= 127; - case Float: - case Double: - return false; - default: - throw new IllegalArgumentException("unexpected kind " + source.getJavaKind()); - } - } - - @Override - public JavaConstant boxPrimitive(JavaConstant source) { - if (source == null || !source.getJavaKind().isPrimitive() || !isBoxCached(source)) { - return null; - } - return HotSpotObjectConstantImpl.forObject(source.asBoxedPrimitive()); - } - - @Override - public JavaConstant unboxPrimitive(JavaConstant source) { - if (source == null || !source.getJavaKind().isObject()) { - return null; - } - if (source.isNull()) { - return null; - } - return JavaConstant.forBoxedPrimitive(((HotSpotObjectConstantImpl) source).object()); - } - - public JavaConstant forString(String value) { - return HotSpotObjectConstantImpl.forObject(value); - } - - public JavaConstant forObject(Object value) { - return HotSpotObjectConstantImpl.forObject(value); - } - - @Override - public ResolvedJavaType asJavaType(Constant constant) { - if (constant instanceof HotSpotObjectConstant) { - Object obj = ((HotSpotObjectConstantImpl) constant).object(); - if (obj instanceof Class) { - return runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType((Class) obj); - } - } - if (constant instanceof HotSpotMetaspaceConstant) { - MetaspaceWrapperObject obj = HotSpotMetaspaceConstantImpl.getMetaspaceObject(constant); - if (obj instanceof HotSpotResolvedObjectTypeImpl) { - return (ResolvedJavaType) obj; - } - } - return null; - } - - private static final String SystemClassName = "Ljava/lang/System;"; - - /** - * Determines if a static field is constant for the purpose of - * {@link #readConstantFieldValue(ResolvedJavaField, JavaConstant)}. - */ - protected boolean isStaticFieldConstant(HotSpotResolvedJavaField staticField) { - if (staticField.isFinal() || (staticField.isStable() && runtime.getConfig().foldStableValues)) { - ResolvedJavaType holder = staticField.getDeclaringClass(); - if (holder.isInitialized() && !holder.getName().equals(SystemClassName)) { - return true; - } - } - return false; - } - - /** - * Determines if a value read from a {@code final} instance field is considered constant. The - * implementation in {@link HotSpotConstantReflectionProvider} returns true if {@code value} is - * not the {@link JavaConstant#isDefaultForKind default value} for its kind or if - * {@link Option#TrustFinalDefaultFields} is true. - * - * @param value a value read from a {@code final} instance field - * @param receiverClass the {@link Object#getClass() class} of object from which the - * {@code value} was read - */ - protected boolean isFinalInstanceFieldValueConstant(JavaConstant value, Class receiverClass) { - return !value.isDefaultForKind() || Option.TrustFinalDefaultFields.getBoolean(); - } - - /** - * Determines if a value read from a {@link Stable} instance field is considered constant. The - * implementation in {@link HotSpotConstantReflectionProvider} returns true if {@code value} is - * not the {@link JavaConstant#isDefaultForKind default value} for its kind. - * - * @param value a value read from a {@link Stable} field - * @param receiverClass the {@link Object#getClass() class} of object from which the - * {@code value} was read - */ - protected boolean isStableInstanceFieldValueConstant(JavaConstant value, Class receiverClass) { - return !value.isDefaultForKind(); - } - - public JavaConstant readConstantFieldValue(ResolvedJavaField field, JavaConstant receiver) { - HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; - - if (hotspotField.isStatic()) { - if (isStaticFieldConstant(hotspotField)) { - JavaConstant value = readFieldValue(field, receiver); - if (hotspotField.isFinal() || !value.isDefaultForKind()) { - return value; - } - } - } else { - /* - * for non-static final fields, we must assume that they are only initialized if they - * have a non-default value. - */ - Object object = receiver.isNull() ? null : ((HotSpotObjectConstantImpl) receiver).object(); - - // Canonicalization may attempt to process an unsafe read before - // processing a guard (e.g. a null check or a type check) for this read - // so we need to check the object being read - if (object != null) { - if (hotspotField.isFinal()) { - if (hotspotField.isInObject(object)) { - JavaConstant value = readFieldValue(field, receiver); - if (isFinalInstanceFieldValueConstant(value, object.getClass())) { - return value; - } - } - } else if (hotspotField.isStable() && runtime.getConfig().foldStableValues) { - if (hotspotField.isInObject(object)) { - JavaConstant value = readFieldValue(field, receiver); - if (isStableInstanceFieldValueConstant(value, object.getClass())) { - return value; - } - } - } - } - } - return null; - } - - public JavaConstant readFieldValue(ResolvedJavaField field, JavaConstant receiver) { - HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; - if (!hotspotField.isStable()) { - return readNonStableFieldValue(field, receiver); - } else if (runtime.getConfig().foldStableValues) { - return readStableFieldValue(field, receiver, hotspotField.isDefaultStable()); - } else { - return null; - } - } - - private JavaConstant readNonStableFieldValue(ResolvedJavaField field, JavaConstant receiver) { - HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; - if (hotspotField.isStatic()) { - HotSpotResolvedJavaType holder = (HotSpotResolvedJavaType) hotspotField.getDeclaringClass(); - if (holder.isInitialized()) { - return memoryAccess.readUnsafeConstant(hotspotField.getJavaKind(), HotSpotObjectConstantImpl.forObject(holder.mirror()), hotspotField.offset()); - } - } else { - if (receiver.isNonNull() && hotspotField.isInObject(((HotSpotObjectConstantImpl) receiver).object())) { - return memoryAccess.readUnsafeConstant(hotspotField.getJavaKind(), receiver, hotspotField.offset()); - } - } - return null; - } - - public JavaConstant readStableFieldValue(ResolvedJavaField field, JavaConstant receiver, boolean isDefaultStable) { - JavaConstant fieldValue = readNonStableFieldValue(field, receiver); - if (fieldValue != null && fieldValue.isNonNull()) { - JavaType declaredType = field.getType(); - if (declaredType.getComponentType() != null) { - int stableDimension = getArrayDimension(declaredType); - return HotSpotObjectConstantImpl.forStableArray(((HotSpotObjectConstantImpl) fieldValue).object(), stableDimension, isDefaultStable); - } - } - return fieldValue; - } - - private static int getArrayDimension(JavaType type) { - int dimensions = 0; - JavaType componentType = type; - while ((componentType = componentType.getComponentType()) != null) { - dimensions++; - } - return dimensions; - } - - @Override - public JavaConstant asJavaClass(ResolvedJavaType type) { - return HotSpotObjectConstantImpl.forObject(((HotSpotResolvedJavaType) type).mirror()); - } - - @Override - public Constant asObjectHub(ResolvedJavaType type) { - if (type instanceof HotSpotResolvedObjectType) { - return ((HotSpotResolvedObjectType) type).klass(); - } else { - throw JVMCIError.unimplemented(); - } - } -} --- /dev/null 2016-05-04 09:43:30.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java 2016-05-04 09:43:30.000000000 -1000 @@ -0,0 +1,374 @@ +/* + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayBaseOffset; +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayIndexScale; + +import java.lang.reflect.Array; +import java.util.Objects; + +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; +import jdk.vm.ci.meta.Constant; +import jdk.vm.ci.meta.ConstantReflectionProvider; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.MemoryAccessProvider; +import jdk.vm.ci.meta.MethodHandleAccessProvider; +import jdk.vm.ci.meta.ResolvedJavaField; +import jdk.vm.ci.meta.ResolvedJavaType; + +/** + * HotSpot implementation of {@link ConstantReflectionProvider}. + */ +public class HotSpotConstantReflectionProvider implements ConstantReflectionProvider, HotSpotProxified { + + protected final HotSpotJVMCIRuntimeProvider runtime; + protected final HotSpotMethodHandleAccessProvider methodHandleAccess; + protected final HotSpotMemoryAccessProviderImpl memoryAccess; + + public HotSpotConstantReflectionProvider(HotSpotJVMCIRuntimeProvider runtime) { + this.runtime = runtime; + this.methodHandleAccess = new HotSpotMethodHandleAccessProvider(this); + this.memoryAccess = new HotSpotMemoryAccessProviderImpl(runtime); + } + + public MethodHandleAccessProvider getMethodHandleAccess() { + return methodHandleAccess; + } + + @Override + public MemoryAccessProvider getMemoryAccessProvider() { + return memoryAccess; + } + + @Override + public Boolean constantEquals(Constant x, Constant y) { + if (x == y) { + return true; + } else if (x instanceof HotSpotObjectConstantImpl) { + return y instanceof HotSpotObjectConstantImpl && ((HotSpotObjectConstantImpl) x).object() == ((HotSpotObjectConstantImpl) y).object(); + } else { + return Objects.equals(x, y); + } + } + + @Override + public Integer readArrayLength(JavaConstant array) { + if (array == null || array.getJavaKind() != JavaKind.Object || array.isNull()) { + return null; + } + + Object arrayObject = ((HotSpotObjectConstantImpl) array).object(); + if (!arrayObject.getClass().isArray()) { + return null; + } + return Array.getLength(arrayObject); + } + + public JavaConstant readConstantArrayElement(JavaConstant array, int index) { + if (array instanceof HotSpotObjectConstantImpl && ((HotSpotObjectConstantImpl) array).getStableDimension() > 0) { + JavaConstant element = readArrayElement(array, index); + if (element != null && (((HotSpotObjectConstantImpl) array).isDefaultStable() || !element.isDefaultForKind())) { + return element; + } + } + return null; + } + + /** + * Try to convert {@code offset} into an an index into {@code array}. + * + * @return the computed index or -1 if the offset isn't within the array + */ + private int indexForOffset(JavaConstant array, long offset) { + if (array.getJavaKind() != JavaKind.Object || array.isNull()) { + return -1; + } + Class componentType = ((HotSpotObjectConstantImpl) array).object().getClass().getComponentType(); + JavaKind kind = runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType(componentType).getJavaKind(); + int arraybase = getArrayBaseOffset(kind); + int scale = getArrayIndexScale(kind); + if (offset < arraybase) { + return -1; + } + long index = offset - arraybase; + if (index % scale != 0) { + return -1; + } + long result = index / scale; + if (result >= Integer.MAX_VALUE) { + return -1; + } + return (int) result; + } + + public JavaConstant readConstantArrayElementForOffset(JavaConstant array, long offset) { + if (array instanceof HotSpotObjectConstantImpl && ((HotSpotObjectConstantImpl) array).getStableDimension() > 0) { + return readConstantArrayElement(array, indexForOffset(array, offset)); + } + return null; + } + + @Override + public JavaConstant readArrayElement(JavaConstant array, int index) { + if (array == null || array.getJavaKind() != JavaKind.Object || array.isNull()) { + return null; + } + Object a = ((HotSpotObjectConstantImpl) array).object(); + + if (!a.getClass().isArray() || index < 0 || index >= Array.getLength(a)) { + return null; + } + + if (a instanceof Object[]) { + Object element = ((Object[]) a)[index]; + if (((HotSpotObjectConstantImpl) array).getStableDimension() > 1) { + return HotSpotObjectConstantImpl.forStableArray(element, ((HotSpotObjectConstantImpl) array).getStableDimension() - 1, ((HotSpotObjectConstantImpl) array).isDefaultStable()); + } else { + return HotSpotObjectConstantImpl.forObject(element); + } + } else { + return JavaConstant.forBoxedPrimitive(Array.get(a, index)); + } + } + + /** + * Check if the constant is a boxed value that is guaranteed to be cached by the platform. + * Otherwise the generated code might be the only reference to the boxed value and since object + * references from nmethods are weak this can cause GC problems. + * + * @param source + * @return true if the box is cached + */ + private static boolean isBoxCached(JavaConstant source) { + switch (source.getJavaKind()) { + case Boolean: + return true; + case Char: + return source.asInt() <= 127; + case Byte: + case Short: + case Int: + return source.asInt() >= -128 && source.asInt() <= 127; + case Long: + return source.asLong() >= -128 && source.asLong() <= 127; + case Float: + case Double: + return false; + default: + throw new IllegalArgumentException("unexpected kind " + source.getJavaKind()); + } + } + + @Override + public JavaConstant boxPrimitive(JavaConstant source) { + if (source == null || !source.getJavaKind().isPrimitive() || !isBoxCached(source)) { + return null; + } + return HotSpotObjectConstantImpl.forObject(source.asBoxedPrimitive()); + } + + @Override + public JavaConstant unboxPrimitive(JavaConstant source) { + if (source == null || !source.getJavaKind().isObject()) { + return null; + } + if (source.isNull()) { + return null; + } + return JavaConstant.forBoxedPrimitive(((HotSpotObjectConstantImpl) source).object()); + } + + public JavaConstant forString(String value) { + return HotSpotObjectConstantImpl.forObject(value); + } + + public JavaConstant forObject(Object value) { + return HotSpotObjectConstantImpl.forObject(value); + } + + @Override + public ResolvedJavaType asJavaType(Constant constant) { + if (constant instanceof HotSpotObjectConstant) { + Object obj = ((HotSpotObjectConstantImpl) constant).object(); + if (obj instanceof Class) { + return runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType((Class) obj); + } + } + if (constant instanceof HotSpotMetaspaceConstant) { + MetaspaceWrapperObject obj = HotSpotMetaspaceConstantImpl.getMetaspaceObject(constant); + if (obj instanceof HotSpotResolvedObjectTypeImpl) { + return (ResolvedJavaType) obj; + } + } + return null; + } + + private static final String SystemClassName = "Ljava/lang/System;"; + + /** + * Determines if a static field is constant for the purpose of + * {@link #readConstantFieldValue(ResolvedJavaField, JavaConstant)}. + */ + protected boolean isStaticFieldConstant(HotSpotResolvedJavaField staticField) { + if (staticField.isFinal() || (staticField.isStable() && runtime.getConfig().foldStableValues)) { + ResolvedJavaType holder = staticField.getDeclaringClass(); + if (holder.isInitialized() && !holder.getName().equals(SystemClassName)) { + return true; + } + } + return false; + } + + /** + * Determines if a value read from a {@code final} instance field is considered constant. The + * implementation in {@link HotSpotConstantReflectionProvider} returns true if {@code value} is + * not the {@link JavaConstant#isDefaultForKind default value} for its kind or if + * {@link Option#TrustFinalDefaultFields} is true. + * + * @param value a value read from a {@code final} instance field + * @param receiverClass the {@link Object#getClass() class} of object from which the + * {@code value} was read + */ + protected boolean isFinalInstanceFieldValueConstant(JavaConstant value, Class receiverClass) { + return !value.isDefaultForKind() || Option.TrustFinalDefaultFields.getBoolean(); + } + + /** + * Determines if a value read from a {@link Stable} instance field is considered constant. The + * implementation in {@link HotSpotConstantReflectionProvider} returns true if {@code value} is + * not the {@link JavaConstant#isDefaultForKind default value} for its kind. + * + * @param value a value read from a {@link Stable} field + * @param receiverClass the {@link Object#getClass() class} of object from which the + * {@code value} was read + */ + protected boolean isStableInstanceFieldValueConstant(JavaConstant value, Class receiverClass) { + return !value.isDefaultForKind(); + } + + public JavaConstant readConstantFieldValue(ResolvedJavaField field, JavaConstant receiver) { + HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; + + if (hotspotField.isStatic()) { + if (isStaticFieldConstant(hotspotField)) { + JavaConstant value = readFieldValue(field, receiver); + if (hotspotField.isFinal() || !value.isDefaultForKind()) { + return value; + } + } + } else { + /* + * for non-static final fields, we must assume that they are only initialized if they + * have a non-default value. + */ + Object object = receiver.isNull() ? null : ((HotSpotObjectConstantImpl) receiver).object(); + + // Canonicalization may attempt to process an unsafe read before + // processing a guard (e.g. a null check or a type check) for this read + // so we need to check the object being read + if (object != null) { + if (hotspotField.isFinal()) { + if (hotspotField.isInObject(object)) { + JavaConstant value = readFieldValue(field, receiver); + if (isFinalInstanceFieldValueConstant(value, object.getClass())) { + return value; + } + } + } else if (hotspotField.isStable() && runtime.getConfig().foldStableValues) { + if (hotspotField.isInObject(object)) { + JavaConstant value = readFieldValue(field, receiver); + if (isStableInstanceFieldValueConstant(value, object.getClass())) { + return value; + } + } + } + } + } + return null; + } + + public JavaConstant readFieldValue(ResolvedJavaField field, JavaConstant receiver) { + HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; + if (!hotspotField.isStable()) { + return readNonStableFieldValue(field, receiver); + } else if (runtime.getConfig().foldStableValues) { + return readStableFieldValue(field, receiver, hotspotField.isDefaultStable()); + } else { + return null; + } + } + + private JavaConstant readNonStableFieldValue(ResolvedJavaField field, JavaConstant receiver) { + HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; + if (hotspotField.isStatic()) { + HotSpotResolvedJavaType holder = (HotSpotResolvedJavaType) hotspotField.getDeclaringClass(); + if (holder.isInitialized()) { + return memoryAccess.readUnsafeConstant(hotspotField.getJavaKind(), HotSpotObjectConstantImpl.forObject(holder.mirror()), hotspotField.offset()); + } + } else { + if (receiver.isNonNull() && hotspotField.isInObject(((HotSpotObjectConstantImpl) receiver).object())) { + return memoryAccess.readUnsafeConstant(hotspotField.getJavaKind(), receiver, hotspotField.offset()); + } + } + return null; + } + + public JavaConstant readStableFieldValue(ResolvedJavaField field, JavaConstant receiver, boolean isDefaultStable) { + JavaConstant fieldValue = readNonStableFieldValue(field, receiver); + if (fieldValue != null && fieldValue.isNonNull()) { + JavaType declaredType = field.getType(); + if (declaredType.getComponentType() != null) { + int stableDimension = getArrayDimension(declaredType); + return HotSpotObjectConstantImpl.forStableArray(((HotSpotObjectConstantImpl) fieldValue).object(), stableDimension, isDefaultStable); + } + } + return fieldValue; + } + + private static int getArrayDimension(JavaType type) { + int dimensions = 0; + JavaType componentType = type; + while ((componentType = componentType.getComponentType()) != null) { + dimensions++; + } + return dimensions; + } + + @Override + public JavaConstant asJavaClass(ResolvedJavaType type) { + return HotSpotObjectConstantImpl.forObject(((HotSpotResolvedJavaType) type).mirror()); + } + + @Override + public Constant asObjectHub(ResolvedJavaType type) { + if (type instanceof HotSpotResolvedObjectType) { + return ((HotSpotResolvedObjectType) type).klass(); + } else { + throw JVMCIError.unimplemented(); + } + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotForeignCallTarget.java 2016-05-04 09:43:30.000000000 -1000 +++ /dev/null 2016-05-04 09:43:30.000000000 -1000 @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.InvokeTarget; - -public class HotSpotForeignCallTarget implements InvokeTarget { - - /** - * The entry point address of this call's target. - */ - protected long address; - - public HotSpotForeignCallTarget(long address) { - this.address = address; - } -} --- /dev/null 2016-05-04 09:43:30.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotForeignCallTarget.java 2016-05-04 09:43:30.000000000 -1000 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.InvokeTarget; + +public class HotSpotForeignCallTarget implements InvokeTarget { + + /** + * The entry point address of this call's target. + */ + protected long address; + + public HotSpotForeignCallTarget(long address) { + this.address = address; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java 2016-05-04 09:43:31.000000000 -1000 +++ /dev/null 2016-05-04 09:43:31.000000000 -1000 @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.inittimer.SuppressFBWarnings; -import jdk.internal.misc.Unsafe; - -/** - * Implementation of {@link InstalledCode} for HotSpot. - */ -public abstract class HotSpotInstalledCode extends InstalledCode { - - /** - * Total size of the code blob. - */ - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private int size; - - /** - * Start address of the code. - */ - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private long codeStart; - - /** - * Size of the code. - */ - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private int codeSize; - - public HotSpotInstalledCode(String name) { - super(name); - } - - /** - * @return the total size of this code blob - */ - public int getSize() { - return size; - } - - @Override - public abstract String toString(); - - @Override - public long getStart() { - return codeStart; - } - - public long getCodeSize() { - return codeSize; - } - - @Override - public byte[] getCode() { - if (!isValid()) { - return null; - } - byte[] code = new byte[codeSize]; - UNSAFE.copyMemory(null, codeStart, code, Unsafe.ARRAY_BYTE_BASE_OFFSET, codeSize); - return code; - } -} --- /dev/null 2016-05-04 09:43:31.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java 2016-05-04 09:43:30.000000000 -1000 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; +import jdk.vm.ci.code.InstalledCode; +import jdk.vm.ci.inittimer.SuppressFBWarnings; +import jdk.internal.misc.Unsafe; + +/** + * Implementation of {@link InstalledCode} for HotSpot. + */ +public abstract class HotSpotInstalledCode extends InstalledCode { + + /** + * Total size of the code blob. + */ + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private int size; + + /** + * Start address of the code. + */ + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private long codeStart; + + /** + * Size of the code. + */ + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private int codeSize; + + public HotSpotInstalledCode(String name) { + super(name); + } + + /** + * @return the total size of this code blob + */ + public int getSize() { + return size; + } + + @Override + public abstract String toString(); + + @Override + public long getStart() { + return codeStart; + } + + public long getCodeSize() { + return codeSize; + } + + @Override + public byte[] getCode() { + if (!isValid()) { + return null; + } + byte[] code = new byte[codeSize]; + UNSAFE.copyMemory(null, codeStart, code, Unsafe.ARRAY_BYTE_BASE_OFFSET, codeSize); + return code; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIBackendFactory.java 2016-05-04 09:43:31.000000000 -1000 +++ /dev/null 2016-05-04 09:43:31.000000000 -1000 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.runtime.JVMCIBackend; - -public interface HotSpotJVMCIBackendFactory { - - JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host); - - /** - * Gets the CPU architecture of this backend. - */ - String getArchitecture(); -} --- /dev/null 2016-05-04 09:43:31.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIBackendFactory.java 2016-05-04 09:43:31.000000000 -1000 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.runtime.JVMCIBackend; + +public interface HotSpotJVMCIBackendFactory { + + JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host); + + /** + * Gets the CPU architecture of this backend. + */ + String getArchitecture(); +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java 2016-05-04 09:43:32.000000000 -1000 +++ /dev/null 2016-05-04 09:43:32.000000000 -1000 @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.CompilationRequest; -import jdk.vm.ci.code.CompilationRequestResult; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; -import jdk.vm.ci.runtime.JVMCICompiler; -import jdk.vm.ci.runtime.JVMCICompilerFactory; -import jdk.vm.ci.runtime.JVMCIRuntime; -import jdk.vm.ci.services.Services; - -final class HotSpotJVMCICompilerConfig { - - private static class DummyCompilerFactory implements JVMCICompilerFactory, JVMCICompiler { - - public CompilationRequestResult compileMethod(CompilationRequest request) { - throw new JVMCIError("no JVMCI compiler selected"); - } - - public String getCompilerName() { - return ""; - } - - public JVMCICompiler createCompiler(JVMCIRuntime runtime) { - return this; - } - } - - /** - * Factory of the selected system compiler. - */ - private static JVMCICompilerFactory compilerFactory; - - /** - * Gets the selected system compiler factory. - * - * @return the selected system compiler factory - */ - static JVMCICompilerFactory getCompilerFactory() { - if (compilerFactory == null) { - JVMCICompilerFactory factory = null; - String compilerName = Option.Compiler.getString(); - if (compilerName != null) { - for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) { - if (f.getCompilerName().equals(compilerName)) { - factory = f; - } - } - if (factory == null) { - throw new JVMCIError("JVMCI compiler '%s' not found", compilerName); - } - } else { - factory = new DummyCompilerFactory(); - } - compilerFactory = factory; - } - return compilerFactory; - } -} --- /dev/null 2016-05-04 09:43:32.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java 2016-05-04 09:43:31.000000000 -1000 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.code.CompilationRequest; +import jdk.vm.ci.code.CompilationRequestResult; +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; +import jdk.vm.ci.runtime.JVMCICompiler; +import jdk.vm.ci.runtime.JVMCICompilerFactory; +import jdk.vm.ci.runtime.JVMCIRuntime; +import jdk.vm.ci.services.Services; + +final class HotSpotJVMCICompilerConfig { + + private static class DummyCompilerFactory implements JVMCICompilerFactory, JVMCICompiler { + + public CompilationRequestResult compileMethod(CompilationRequest request) { + throw new JVMCIError("no JVMCI compiler selected"); + } + + public String getCompilerName() { + return ""; + } + + public JVMCICompiler createCompiler(JVMCIRuntime runtime) { + return this; + } + } + + /** + * Factory of the selected system compiler. + */ + private static JVMCICompilerFactory compilerFactory; + + /** + * Gets the selected system compiler factory. + * + * @return the selected system compiler factory + */ + static JVMCICompilerFactory getCompilerFactory() { + if (compilerFactory == null) { + JVMCICompilerFactory factory = null; + String compilerName = Option.Compiler.getString(); + if (compilerName != null) { + for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) { + if (f.getCompilerName().equals(compilerName)) { + factory = f; + } + } + if (factory == null) { + throw new JVMCIError("JVMCI compiler '%s' not found", compilerName); + } + } else { + factory = new DummyCompilerFactory(); + } + compilerFactory = factory; + } + return compilerFactory; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIMetaAccessContext.java 2016-05-04 09:43:32.000000000 -1000 +++ /dev/null 2016-05-04 09:43:32.000000000 -1000 @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.lang.ref.Reference; -import java.lang.ref.ReferenceQueue; -import java.lang.ref.WeakReference; -import java.util.Arrays; -import java.util.Iterator; -import java.util.Map; -import java.util.WeakHashMap; - -import jdk.vm.ci.meta.JVMCIMetaAccessContext; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * This class manages the set of metadata roots that must be scanned during garbage collection. - * Because of class redefinition Method* and ConstantPool* can be freed if they don't appear to be - * in use so they must be tracked when there are live references to them from Java. - * - * The general theory of operation is that all {@link MetaspaceWrapperObject}s are created by - * calling into the VM which calls back out to actually create the wrapper instance. During the call - * the VM keeps the metadata reference alive through the use of metadata handles. Once the call - * completes the wrapper object is registered here and will be scanned during metadata scanning. The - * weakness of the reference to the wrapper object allows them to be reclaimed when they are no - * longer used. - * - */ -public class HotSpotJVMCIMetaAccessContext implements JVMCIMetaAccessContext { - - /** - * The set of currently live contexts used for tracking of live metadata. Examined from the VM - * during garbage collection. - */ - private static WeakReference[] allContexts = new WeakReference[0]; - - /** - * This is a chunked list of metadata roots. It can be read from VM native code so it's been - * marked volatile to ensure the order of updates are respected. - */ - private volatile Object[] metadataRoots; - - private ChunkedList> list = new ChunkedList<>(); - - /** - * The number of weak references freed since the last time the list was shrunk. - */ - private int freed; - - /** - * The {@link ReferenceQueue} tracking the weak references created by this context. - */ - private final ReferenceQueue queue = new ReferenceQueue<>(); - - static synchronized void add(HotSpotJVMCIMetaAccessContext context) { - for (int i = 0; i < allContexts.length; i++) { - if (allContexts[i] == null || allContexts[i].get() == null) { - allContexts[i] = new WeakReference<>(context); - return; - } - } - int index = allContexts.length; - allContexts = Arrays.copyOf(allContexts, index + 2); - allContexts[index] = new WeakReference<>(context); - } - - HotSpotJVMCIMetaAccessContext() { - add(this); - } - - /** - * Periodically trim the list of tracked metadata. A new list is created to replace the old to - * avoid concurrent scanning issues. - */ - private void clean() { - Reference ref = queue.poll(); - if (ref == null) { - return; - } - while (ref != null) { - freed++; - ref = queue.poll(); - } - if (freed > list.size() / 2) { - ChunkedList> newList = new ChunkedList<>(); - for (WeakReference element : list) { - /* - * The referent could become null anywhere in here but it doesn't matter. It will - * get cleaned up next time. - */ - if (element != null && element.get() != null) { - newList.add(element); - } - } - list = newList; - metadataRoots = list.getHead(); - freed = 0; - } - } - - /** - * Add a {@link MetaspaceWrapperObject} to tracked by the GC. It's assumed that the caller is - * responsible for keeping the reference alive for the duration of the call. Once registration - * is complete then the VM will ensure it's kept alive. - * - * @param metaspaceObject - */ - - public synchronized void add(MetaspaceWrapperObject metaspaceObject) { - clean(); - list.add(new WeakReference<>(metaspaceObject, queue)); - if (list.getHead() != metadataRoots) { - /* - * The list enlarged so update the head. - */ - metadataRoots = list.getHead(); - } - } - - protected ResolvedJavaType createClass(Class javaClass) { - if (javaClass.isPrimitive()) { - JavaKind kind = JavaKind.fromJavaClass(javaClass); - return new HotSpotResolvedPrimitiveType(kind); - } else { - return new HotSpotResolvedObjectTypeImpl(javaClass, this); - } - } - - private final Map, WeakReference> typeMap = new WeakHashMap<>(); - - @Override - public synchronized ResolvedJavaType fromClass(Class javaClass) { - WeakReference typeRef = typeMap.get(javaClass); - ResolvedJavaType type = typeRef != null ? typeRef.get() : null; - if (type == null) { - type = createClass(javaClass); - typeMap.put(javaClass, new WeakReference<>(type)); - } - return type; - } - - /** - * A very simple append only chunked list implementation. - */ - static class ChunkedList implements Iterable { - private static final int CHUNK_SIZE = 32; - - private static final int NEXT_CHUNK_INDEX = CHUNK_SIZE - 1; - - private Object[] head; - private int index; - private int size; - - ChunkedList() { - head = new Object[CHUNK_SIZE]; - index = 0; - } - - void add(T element) { - if (index == NEXT_CHUNK_INDEX) { - Object[] newHead = new Object[CHUNK_SIZE]; - newHead[index] = head; - head = newHead; - index = 0; - } - head[index++] = element; - size++; - } - - Object[] getHead() { - return head; - } - - public Iterator iterator() { - return new ChunkIterator<>(); - } - - int size() { - return size; - } - - class ChunkIterator implements Iterator { - - ChunkIterator() { - currentChunk = head; - currentIndex = -1; - findNext(); - } - - Object[] currentChunk; - int currentIndex; - V next; - - @SuppressWarnings("unchecked") - V findNext() { - V result; - do { - currentIndex++; - if (currentIndex == NEXT_CHUNK_INDEX) { - currentChunk = (Object[]) currentChunk[currentIndex]; - currentIndex = 0; - if (currentChunk == null) { - return null; - } - } - result = (V) currentChunk[currentIndex]; - } while (result == null); - return result; - } - - public boolean hasNext() { - return next != null; - } - - public V next() { - V result = next; - next = findNext(); - return result; - } - - } - - } -} --- /dev/null 2016-05-04 09:43:32.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIMetaAccessContext.java 2016-05-04 09:43:32.000000000 -1000 @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.util.Arrays; +import java.util.Iterator; +import java.util.Map; +import java.util.WeakHashMap; + +import jdk.vm.ci.meta.JVMCIMetaAccessContext; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.ResolvedJavaType; + +/** + * This class manages the set of metadata roots that must be scanned during garbage collection. + * Because of class redefinition Method* and ConstantPool* can be freed if they don't appear to be + * in use so they must be tracked when there are live references to them from Java. + * + * The general theory of operation is that all {@link MetaspaceWrapperObject}s are created by + * calling into the VM which calls back out to actually create the wrapper instance. During the call + * the VM keeps the metadata reference alive through the use of metadata handles. Once the call + * completes the wrapper object is registered here and will be scanned during metadata scanning. The + * weakness of the reference to the wrapper object allows them to be reclaimed when they are no + * longer used. + * + */ +public class HotSpotJVMCIMetaAccessContext implements JVMCIMetaAccessContext { + + /** + * The set of currently live contexts used for tracking of live metadata. Examined from the VM + * during garbage collection. + */ + private static WeakReference[] allContexts = new WeakReference[0]; + + /** + * This is a chunked list of metadata roots. It can be read from VM native code so it's been + * marked volatile to ensure the order of updates are respected. + */ + private volatile Object[] metadataRoots; + + private ChunkedList> list = new ChunkedList<>(); + + /** + * The number of weak references freed since the last time the list was shrunk. + */ + private int freed; + + /** + * The {@link ReferenceQueue} tracking the weak references created by this context. + */ + private final ReferenceQueue queue = new ReferenceQueue<>(); + + static synchronized void add(HotSpotJVMCIMetaAccessContext context) { + for (int i = 0; i < allContexts.length; i++) { + if (allContexts[i] == null || allContexts[i].get() == null) { + allContexts[i] = new WeakReference<>(context); + return; + } + } + int index = allContexts.length; + allContexts = Arrays.copyOf(allContexts, index + 2); + allContexts[index] = new WeakReference<>(context); + } + + HotSpotJVMCIMetaAccessContext() { + add(this); + } + + /** + * Periodically trim the list of tracked metadata. A new list is created to replace the old to + * avoid concurrent scanning issues. + */ + private void clean() { + Reference ref = queue.poll(); + if (ref == null) { + return; + } + while (ref != null) { + freed++; + ref = queue.poll(); + } + if (freed > list.size() / 2) { + ChunkedList> newList = new ChunkedList<>(); + for (WeakReference element : list) { + /* + * The referent could become null anywhere in here but it doesn't matter. It will + * get cleaned up next time. + */ + if (element != null && element.get() != null) { + newList.add(element); + } + } + list = newList; + metadataRoots = list.getHead(); + freed = 0; + } + } + + /** + * Add a {@link MetaspaceWrapperObject} to tracked by the GC. It's assumed that the caller is + * responsible for keeping the reference alive for the duration of the call. Once registration + * is complete then the VM will ensure it's kept alive. + * + * @param metaspaceObject + */ + + public synchronized void add(MetaspaceWrapperObject metaspaceObject) { + clean(); + list.add(new WeakReference<>(metaspaceObject, queue)); + if (list.getHead() != metadataRoots) { + /* + * The list enlarged so update the head. + */ + metadataRoots = list.getHead(); + } + } + + protected ResolvedJavaType createClass(Class javaClass) { + if (javaClass.isPrimitive()) { + JavaKind kind = JavaKind.fromJavaClass(javaClass); + return new HotSpotResolvedPrimitiveType(kind); + } else { + return new HotSpotResolvedObjectTypeImpl(javaClass, this); + } + } + + private final Map, WeakReference> typeMap = new WeakHashMap<>(); + + @Override + public synchronized ResolvedJavaType fromClass(Class javaClass) { + WeakReference typeRef = typeMap.get(javaClass); + ResolvedJavaType type = typeRef != null ? typeRef.get() : null; + if (type == null) { + type = createClass(javaClass); + typeMap.put(javaClass, new WeakReference<>(type)); + } + return type; + } + + /** + * A very simple append only chunked list implementation. + */ + static class ChunkedList implements Iterable { + private static final int CHUNK_SIZE = 32; + + private static final int NEXT_CHUNK_INDEX = CHUNK_SIZE - 1; + + private Object[] head; + private int index; + private int size; + + ChunkedList() { + head = new Object[CHUNK_SIZE]; + index = 0; + } + + void add(T element) { + if (index == NEXT_CHUNK_INDEX) { + Object[] newHead = new Object[CHUNK_SIZE]; + newHead[index] = head; + head = newHead; + index = 0; + } + head[index++] = element; + size++; + } + + Object[] getHead() { + return head; + } + + public Iterator iterator() { + return new ChunkIterator<>(); + } + + int size() { + return size; + } + + class ChunkIterator implements Iterator { + + ChunkIterator() { + currentChunk = head; + currentIndex = -1; + findNext(); + } + + Object[] currentChunk; + int currentIndex; + V next; + + @SuppressWarnings("unchecked") + V findNext() { + V result; + do { + currentIndex++; + if (currentIndex == NEXT_CHUNK_INDEX) { + currentChunk = (Object[]) currentChunk[currentIndex]; + currentIndex = 0; + if (currentChunk == null) { + return null; + } + } + result = (V) currentChunk[currentIndex]; + } while (result == null); + return result; + } + + public boolean hasNext() { + return next != null; + } + + public V next() { + V result = next; + next = findNext(); + return result; + } + + } + + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java 2016-05-04 09:43:33.000000000 -1000 +++ /dev/null 2016-05-04 09:43:33.000000000 -1000 @@ -1,465 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.inittimer.InitTimer.timer; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.TreeMap; - -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CompilationRequestResult; -import jdk.vm.ci.code.CompiledCode; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.inittimer.InitTimer; -import jdk.vm.ci.inittimer.SuppressFBWarnings; -import jdk.vm.ci.meta.JVMCIMetaAccessContext; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.runtime.JVMCI; -import jdk.vm.ci.runtime.JVMCIBackend; -import jdk.vm.ci.runtime.JVMCICompiler; -import jdk.vm.ci.services.Services; -import jdk.internal.misc.VM; - -//JaCoCo Exclude - -/** - * HotSpot implementation of a JVMCI runtime. - * - * The initialization of this class is very fragile since it's initialized both through - * {@link JVMCI#initialize()} or through calling {@link HotSpotJVMCIRuntime#runtime()} and - * {@link HotSpotJVMCIRuntime#runtime()} is also called by {@link JVMCI#initialize()}. So this class - * can't have a static initializer and any required initialization must be done as part of - * {@link #runtime()}. This allows the initialization to funnel back through - * {@link JVMCI#initialize()} without deadlocking. - */ -public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider, HotSpotProxified { - - @SuppressWarnings("try") - static class DelayedInit { - private static final HotSpotJVMCIRuntime instance; - - static { - try (InitTimer t = timer("HotSpotJVMCIRuntime.")) { - instance = new HotSpotJVMCIRuntime(); - } - } - } - - /** - * Gets the singleton {@link HotSpotJVMCIRuntime} object. - */ - public static HotSpotJVMCIRuntime runtime() { - JVMCI.initialize(); - return DelayedInit.instance; - } - - /** - * A list of all supported JVMCI options. - */ - public enum Option { - Compiler(String.class, null, "Selects the system compiler."), - ImplicitStableValues(boolean.class, true, "Mark well-known stable fields as such."), - // Note: The following one is not used (see InitTimer.ENABLED). - InitTimer(boolean.class, false, "Specifies if initialization timing is enabled."), - PrintConfig(boolean.class, false, "Prints all HotSpotVMConfig fields."), - PrintFlags(boolean.class, false, "Prints all JVMCI flags and exits."), - ShowFlags(boolean.class, false, "Prints all JVMCI flags and continues."), - TraceMethodDataFilter(String.class, null, ""), - TrustFinalDefaultFields(boolean.class, true, "Determines whether to treat final fields with default values as constant."); - - /** - * The prefix for system properties that are JVMCI options. - */ - private static final String JVMCI_OPTION_PROPERTY_PREFIX = "jvmci."; - - /** - * Marker for uninitialized flags. - */ - private static final String UNINITIALIZED = "UNINITIALIZED"; - - private final Class type; - private Object value; - private final Object defaultValue; - private boolean isDefault; - private final String help; - - Option(Class type, Object defaultValue, String help) { - assert Character.isUpperCase(name().charAt(0)) : "Option name must start with upper-case letter: " + name(); - this.type = type; - this.value = UNINITIALIZED; - this.defaultValue = defaultValue; - this.help = help; - } - - @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "sentinel must be String since it's a static final in an enum") - private Object getValue() { - if (value == UNINITIALIZED) { - String propertyValue = VM.getSavedProperty(JVMCI_OPTION_PROPERTY_PREFIX + name()); - if (propertyValue == null) { - this.value = defaultValue; - this.isDefault = true; - } else { - if (type == boolean.class) { - this.value = Boolean.parseBoolean(propertyValue); - } else if (type == String.class) { - this.value = propertyValue; - } else { - throw new JVMCIError("Unexpected option type " + type); - } - this.isDefault = false; - } - // Saved properties should not be interned - let's be sure - assert value != UNINITIALIZED; - } - return value; - } - - /** - * Returns the option's value as boolean. - * - * @return option's value - */ - public boolean getBoolean() { - return (boolean) getValue(); - } - - /** - * Returns the option's value as String. - * - * @return option's value - */ - public String getString() { - return (String) getValue(); - } - - /** - * Prints all option flags to {@code out}. - * - * @param out stream to print to - */ - public static void printFlags(PrintStream out) { - out.println("[List of JVMCI options]"); - for (Option option : values()) { - Object value = option.getValue(); - String assign = option.isDefault ? ":=" : " ="; - out.printf("%9s %-40s %s %-14s %s%n", option.type.getSimpleName(), option, assign, value, option.help); - } - } - } - - public static HotSpotJVMCIBackendFactory findFactory(String architecture) { - for (HotSpotJVMCIBackendFactory factory : Services.load(HotSpotJVMCIBackendFactory.class)) { - if (factory.getArchitecture().equalsIgnoreCase(architecture)) { - return factory; - } - } - - throw new JVMCIError("No JVMCI runtime available for the %s architecture", architecture); - } - - /** - * Gets the kind of a word value on the {@linkplain #getHostJVMCIBackend() host} backend. - */ - public static JavaKind getHostWordKind() { - return runtime().getHostJVMCIBackend().getCodeCache().getTarget().wordJavaKind; - } - - protected final CompilerToVM compilerToVm; - - protected final HotSpotVMConfig config; - private final JVMCIBackend hostBackend; - - private volatile JVMCICompiler compiler; - protected final JVMCIMetaAccessContext metaAccessContext; - - private final Map, JVMCIBackend> backends = new HashMap<>(); - - private final Iterable vmEventListeners; - - @SuppressWarnings("unused") private final String[] trivialPrefixes; - - @SuppressWarnings("try") - private HotSpotJVMCIRuntime() { - compilerToVm = new CompilerToVM(); - - try (InitTimer t = timer("HotSpotVMConfig")) { - config = new HotSpotVMConfig(compilerToVm); - } - - String hostArchitecture = config.getHostArchitectureName(); - - HotSpotJVMCIBackendFactory factory; - try (InitTimer t = timer("find factory:", hostArchitecture)) { - factory = findFactory(hostArchitecture); - } - - try (InitTimer t = timer("create JVMCI backend:", hostArchitecture)) { - hostBackend = registerBackend(factory.createJVMCIBackend(this, null)); - } - - vmEventListeners = Services.load(HotSpotVMEventListener.class); - - JVMCIMetaAccessContext context = null; - for (HotSpotVMEventListener vmEventListener : vmEventListeners) { - context = vmEventListener.createMetaAccessContext(this); - if (context != null) { - break; - } - } - if (context == null) { - context = new HotSpotJVMCIMetaAccessContext(); - } - metaAccessContext = context; - - boolean printFlags = Option.PrintFlags.getBoolean(); - boolean showFlags = Option.ShowFlags.getBoolean(); - if (printFlags || showFlags) { - Option.printFlags(System.out); - if (printFlags) { - System.exit(0); - } - } - - if (Option.PrintConfig.getBoolean()) { - printConfig(config, compilerToVm); - } - - trivialPrefixes = HotSpotJVMCICompilerConfig.getCompilerFactory().getTrivialPrefixes(); - } - - private JVMCIBackend registerBackend(JVMCIBackend backend) { - Class arch = backend.getCodeCache().getTarget().arch.getClass(); - JVMCIBackend oldValue = backends.put(arch, backend); - assert oldValue == null : "cannot overwrite existing backend for architecture " + arch.getSimpleName(); - return backend; - } - - public ResolvedJavaType fromClass(Class javaClass) { - return metaAccessContext.fromClass(javaClass); - } - - public HotSpotVMConfig getConfig() { - return config; - } - - public CompilerToVM getCompilerToVM() { - return compilerToVm; - } - - public JVMCIMetaAccessContext getMetaAccessContext() { - return metaAccessContext; - } - - public JVMCICompiler getCompiler() { - if (compiler == null) { - synchronized (this) { - if (compiler == null) { - compiler = HotSpotJVMCICompilerConfig.getCompilerFactory().createCompiler(this); - } - } - } - return compiler; - } - - public JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve) { - Objects.requireNonNull(accessingType, "cannot resolve type without an accessing class"); - // If the name represents a primitive type we can short-circuit the lookup. - if (name.length() == 1) { - JavaKind kind = JavaKind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); - return fromClass(kind.toJavaClass()); - } - - // Resolve non-primitive types in the VM. - HotSpotResolvedObjectTypeImpl hsAccessingType = (HotSpotResolvedObjectTypeImpl) accessingType; - final HotSpotResolvedObjectTypeImpl klass = compilerToVm.lookupType(name, hsAccessingType.mirror(), resolve); - - if (klass == null) { - assert resolve == false; - return HotSpotUnresolvedJavaType.create(this, name); - } - return klass; - } - - public JVMCIBackend getHostJVMCIBackend() { - return hostBackend; - } - - public JVMCIBackend getJVMCIBackend(Class arch) { - assert arch != Architecture.class; - return backends.get(arch); - } - - public Map, JVMCIBackend> getJVMCIBackends() { - return Collections.unmodifiableMap(backends); - } - - /** - * Called from the VM. - */ - @SuppressWarnings({"unused"}) - private CompilationRequestResult compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) { - CompilationRequestResult result = getCompiler().compileMethod(new HotSpotCompilationRequest(method, entryBCI, jvmciEnv, id)); - assert result != null : "compileMethod must always return something"; - return result; - } - - /** - * Shuts down the runtime. - * - * Called from the VM. - */ - @SuppressWarnings({"unused"}) - private void shutdown() throws Exception { - for (HotSpotVMEventListener vmEventListener : vmEventListeners) { - vmEventListener.notifyShutdown(); - } - } - - /** - * Notify on successful install into the CodeCache. - * - * @param hotSpotCodeCacheProvider - * @param installedCode - * @param compiledCode - */ - void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) { - for (HotSpotVMEventListener vmEventListener : vmEventListeners) { - vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode); - } - } - - private static void printConfig(HotSpotVMConfig config, CompilerToVM vm) { - Field[] fields = config.getClass().getDeclaredFields(); - Map sortedFields = new TreeMap<>(); - for (Field f : fields) { - if (!f.isSynthetic() && !Modifier.isStatic(f.getModifiers())) { - f.setAccessible(true); - sortedFields.put(f.getName(), f); - } - } - for (Field f : sortedFields.values()) { - try { - String line = String.format("%9s %-40s = %s%n", f.getType().getSimpleName(), f.getName(), pretty(f.get(config))); - byte[] lineBytes = line.getBytes(); - vm.writeDebugOutput(lineBytes, 0, lineBytes.length); - vm.flushDebugOutput(); - } catch (Exception e) { - } - } - } - - private static String pretty(Object value) { - if (value == null) { - return "null"; - } - - Class klass = value.getClass(); - if (value instanceof String) { - return "\"" + value + "\""; - } else if (value instanceof Method) { - return "method \"" + ((Method) value).getName() + "\""; - } else if (value instanceof Class) { - return "class \"" + ((Class) value).getSimpleName() + "\""; - } else if (value instanceof Integer) { - if ((Integer) value < 10) { - return value.toString(); - } - return value + " (0x" + Integer.toHexString((Integer) value) + ")"; - } else if (value instanceof Long) { - if ((Long) value < 10 && (Long) value > -10) { - return value + "l"; - } - return value + "l (0x" + Long.toHexString((Long) value) + "l)"; - } else if (klass.isArray()) { - StringBuilder str = new StringBuilder(); - int dimensions = 0; - while (klass.isArray()) { - dimensions++; - klass = klass.getComponentType(); - } - int length = Array.getLength(value); - str.append(klass.getSimpleName()).append('[').append(length).append(']'); - for (int i = 1; i < dimensions; i++) { - str.append("[]"); - } - str.append(" {"); - for (int i = 0; i < length; i++) { - str.append(pretty(Array.get(value, i))); - if (i < length - 1) { - str.append(", "); - } - } - str.append('}'); - return str.toString(); - } - return value.toString(); - } - - public OutputStream getLogStream() { - return new OutputStream() { - - @Override - public void write(byte[] b, int off, int len) throws IOException { - if (b == null) { - throw new NullPointerException(); - } else if (off < 0 || off > b.length || len < 0 || (off + len) > b.length || (off + len) < 0) { - throw new IndexOutOfBoundsException(); - } else if (len == 0) { - return; - } - compilerToVm.writeDebugOutput(b, off, len); - } - - @Override - public void write(int b) throws IOException { - write(new byte[]{(byte) b}, 0, 1); - } - - @Override - public void flush() throws IOException { - compilerToVm.flushDebugOutput(); - } - }; - } - - /** - * Collects the current values of all JVMCI benchmark counters, summed up over all threads. - */ - public long[] collectCounters() { - return compilerToVm.collectCounters(); - } -} --- /dev/null 2016-05-04 09:43:33.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java 2016-05-04 09:43:32.000000000 -1000 @@ -0,0 +1,465 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.inittimer.InitTimer.timer; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.ServiceLoader; +import java.util.TreeMap; + +import jdk.internal.misc.VM; +import jdk.vm.ci.code.Architecture; +import jdk.vm.ci.code.CompilationRequestResult; +import jdk.vm.ci.code.CompiledCode; +import jdk.vm.ci.code.InstalledCode; +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.inittimer.InitTimer; +import jdk.vm.ci.inittimer.SuppressFBWarnings; +import jdk.vm.ci.meta.JVMCIMetaAccessContext; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.ResolvedJavaType; +import jdk.vm.ci.runtime.JVMCI; +import jdk.vm.ci.runtime.JVMCIBackend; +import jdk.vm.ci.runtime.JVMCICompiler; + +//JaCoCo Exclude + +/** + * HotSpot implementation of a JVMCI runtime. + * + * The initialization of this class is very fragile since it's initialized both through + * {@link JVMCI#initialize()} or through calling {@link HotSpotJVMCIRuntime#runtime()} and + * {@link HotSpotJVMCIRuntime#runtime()} is also called by {@link JVMCI#initialize()}. So this class + * can't have a static initializer and any required initialization must be done as part of + * {@link #runtime()}. This allows the initialization to funnel back through + * {@link JVMCI#initialize()} without deadlocking. + */ +public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider, HotSpotProxified { + + @SuppressWarnings("try") + static class DelayedInit { + private static final HotSpotJVMCIRuntime instance; + + static { + try (InitTimer t = timer("HotSpotJVMCIRuntime.")) { + instance = new HotSpotJVMCIRuntime(); + } + } + } + + /** + * Gets the singleton {@link HotSpotJVMCIRuntime} object. + */ + public static HotSpotJVMCIRuntime runtime() { + JVMCI.initialize(); + return DelayedInit.instance; + } + + /** + * A list of all supported JVMCI options. + */ + public enum Option { + Compiler(String.class, null, "Selects the system compiler."), + ImplicitStableValues(boolean.class, true, "Mark well-known stable fields as such."), + // Note: The following one is not used (see InitTimer.ENABLED). + InitTimer(boolean.class, false, "Specifies if initialization timing is enabled."), + PrintConfig(boolean.class, false, "Prints all HotSpotVMConfig fields."), + PrintFlags(boolean.class, false, "Prints all JVMCI flags and exits."), + ShowFlags(boolean.class, false, "Prints all JVMCI flags and continues."), + TraceMethodDataFilter(String.class, null, ""), + TrustFinalDefaultFields(boolean.class, true, "Determines whether to treat final fields with default values as constant."); + + /** + * The prefix for system properties that are JVMCI options. + */ + private static final String JVMCI_OPTION_PROPERTY_PREFIX = "jvmci."; + + /** + * Marker for uninitialized flags. + */ + private static final String UNINITIALIZED = "UNINITIALIZED"; + + private final Class type; + private Object value; + private final Object defaultValue; + private boolean isDefault; + private final String help; + + Option(Class type, Object defaultValue, String help) { + assert Character.isUpperCase(name().charAt(0)) : "Option name must start with upper-case letter: " + name(); + this.type = type; + this.value = UNINITIALIZED; + this.defaultValue = defaultValue; + this.help = help; + } + + @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "sentinel must be String since it's a static final in an enum") + private Object getValue() { + if (value == UNINITIALIZED) { + String propertyValue = VM.getSavedProperty(JVMCI_OPTION_PROPERTY_PREFIX + name()); + if (propertyValue == null) { + this.value = defaultValue; + this.isDefault = true; + } else { + if (type == boolean.class) { + this.value = Boolean.parseBoolean(propertyValue); + } else if (type == String.class) { + this.value = propertyValue; + } else { + throw new JVMCIError("Unexpected option type " + type); + } + this.isDefault = false; + } + // Saved properties should not be interned - let's be sure + assert value != UNINITIALIZED; + } + return value; + } + + /** + * Returns the option's value as boolean. + * + * @return option's value + */ + public boolean getBoolean() { + return (boolean) getValue(); + } + + /** + * Returns the option's value as String. + * + * @return option's value + */ + public String getString() { + return (String) getValue(); + } + + /** + * Prints all option flags to {@code out}. + * + * @param out stream to print to + */ + public static void printFlags(PrintStream out) { + out.println("[List of JVMCI options]"); + for (Option option : values()) { + Object value = option.getValue(); + String assign = option.isDefault ? ":=" : " ="; + out.printf("%9s %-40s %s %-14s %s%n", option.type.getSimpleName(), option, assign, value, option.help); + } + } + } + + public static HotSpotJVMCIBackendFactory findFactory(String architecture) { + for (HotSpotJVMCIBackendFactory factory : ServiceLoader.load(HotSpotJVMCIBackendFactory.class)) { + if (factory.getArchitecture().equalsIgnoreCase(architecture)) { + return factory; + } + } + + throw new JVMCIError("No JVMCI runtime available for the %s architecture", architecture); + } + + /** + * Gets the kind of a word value on the {@linkplain #getHostJVMCIBackend() host} backend. + */ + public static JavaKind getHostWordKind() { + return runtime().getHostJVMCIBackend().getCodeCache().getTarget().wordJavaKind; + } + + protected final CompilerToVM compilerToVm; + + protected final HotSpotVMConfig config; + private final JVMCIBackend hostBackend; + + private volatile JVMCICompiler compiler; + protected final JVMCIMetaAccessContext metaAccessContext; + + private final Map, JVMCIBackend> backends = new HashMap<>(); + + private final Iterable vmEventListeners; + + @SuppressWarnings("unused") private final String[] trivialPrefixes; + + @SuppressWarnings("try") + private HotSpotJVMCIRuntime() { + compilerToVm = new CompilerToVM(); + + try (InitTimer t = timer("HotSpotVMConfig")) { + config = new HotSpotVMConfig(compilerToVm); + } + + String hostArchitecture = config.getHostArchitectureName(); + + HotSpotJVMCIBackendFactory factory; + try (InitTimer t = timer("find factory:", hostArchitecture)) { + factory = findFactory(hostArchitecture); + } + + try (InitTimer t = timer("create JVMCI backend:", hostArchitecture)) { + hostBackend = registerBackend(factory.createJVMCIBackend(this, null)); + } + + vmEventListeners = ServiceLoader.load(HotSpotVMEventListener.class); + + JVMCIMetaAccessContext context = null; + for (HotSpotVMEventListener vmEventListener : vmEventListeners) { + context = vmEventListener.createMetaAccessContext(this); + if (context != null) { + break; + } + } + if (context == null) { + context = new HotSpotJVMCIMetaAccessContext(); + } + metaAccessContext = context; + + boolean printFlags = Option.PrintFlags.getBoolean(); + boolean showFlags = Option.ShowFlags.getBoolean(); + if (printFlags || showFlags) { + Option.printFlags(System.out); + if (printFlags) { + System.exit(0); + } + } + + if (Option.PrintConfig.getBoolean()) { + printConfig(config, compilerToVm); + } + + trivialPrefixes = HotSpotJVMCICompilerConfig.getCompilerFactory().getTrivialPrefixes(); + } + + private JVMCIBackend registerBackend(JVMCIBackend backend) { + Class arch = backend.getCodeCache().getTarget().arch.getClass(); + JVMCIBackend oldValue = backends.put(arch, backend); + assert oldValue == null : "cannot overwrite existing backend for architecture " + arch.getSimpleName(); + return backend; + } + + public ResolvedJavaType fromClass(Class javaClass) { + return metaAccessContext.fromClass(javaClass); + } + + public HotSpotVMConfig getConfig() { + return config; + } + + public CompilerToVM getCompilerToVM() { + return compilerToVm; + } + + public JVMCIMetaAccessContext getMetaAccessContext() { + return metaAccessContext; + } + + public JVMCICompiler getCompiler() { + if (compiler == null) { + synchronized (this) { + if (compiler == null) { + compiler = HotSpotJVMCICompilerConfig.getCompilerFactory().createCompiler(this); + } + } + } + return compiler; + } + + public JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve) { + Objects.requireNonNull(accessingType, "cannot resolve type without an accessing class"); + // If the name represents a primitive type we can short-circuit the lookup. + if (name.length() == 1) { + JavaKind kind = JavaKind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); + return fromClass(kind.toJavaClass()); + } + + // Resolve non-primitive types in the VM. + HotSpotResolvedObjectTypeImpl hsAccessingType = (HotSpotResolvedObjectTypeImpl) accessingType; + final HotSpotResolvedObjectTypeImpl klass = compilerToVm.lookupType(name, hsAccessingType.mirror(), resolve); + + if (klass == null) { + assert resolve == false; + return HotSpotUnresolvedJavaType.create(this, name); + } + return klass; + } + + public JVMCIBackend getHostJVMCIBackend() { + return hostBackend; + } + + public JVMCIBackend getJVMCIBackend(Class arch) { + assert arch != Architecture.class; + return backends.get(arch); + } + + public Map, JVMCIBackend> getJVMCIBackends() { + return Collections.unmodifiableMap(backends); + } + + /** + * Called from the VM. + */ + @SuppressWarnings({"unused"}) + private CompilationRequestResult compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) { + CompilationRequestResult result = getCompiler().compileMethod(new HotSpotCompilationRequest(method, entryBCI, jvmciEnv, id)); + assert result != null : "compileMethod must always return something"; + return result; + } + + /** + * Shuts down the runtime. + * + * Called from the VM. + */ + @SuppressWarnings({"unused"}) + private void shutdown() throws Exception { + for (HotSpotVMEventListener vmEventListener : vmEventListeners) { + vmEventListener.notifyShutdown(); + } + } + + /** + * Notify on successful install into the CodeCache. + * + * @param hotSpotCodeCacheProvider + * @param installedCode + * @param compiledCode + */ + void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) { + for (HotSpotVMEventListener vmEventListener : vmEventListeners) { + vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode); + } + } + + private static void printConfig(HotSpotVMConfig config, CompilerToVM vm) { + Field[] fields = config.getClass().getDeclaredFields(); + Map sortedFields = new TreeMap<>(); + for (Field f : fields) { + if (!f.isSynthetic() && !Modifier.isStatic(f.getModifiers())) { + f.setAccessible(true); + sortedFields.put(f.getName(), f); + } + } + for (Field f : sortedFields.values()) { + try { + String line = String.format("%9s %-40s = %s%n", f.getType().getSimpleName(), f.getName(), pretty(f.get(config))); + byte[] lineBytes = line.getBytes(); + vm.writeDebugOutput(lineBytes, 0, lineBytes.length); + vm.flushDebugOutput(); + } catch (Exception e) { + } + } + } + + private static String pretty(Object value) { + if (value == null) { + return "null"; + } + + Class klass = value.getClass(); + if (value instanceof String) { + return "\"" + value + "\""; + } else if (value instanceof Method) { + return "method \"" + ((Method) value).getName() + "\""; + } else if (value instanceof Class) { + return "class \"" + ((Class) value).getSimpleName() + "\""; + } else if (value instanceof Integer) { + if ((Integer) value < 10) { + return value.toString(); + } + return value + " (0x" + Integer.toHexString((Integer) value) + ")"; + } else if (value instanceof Long) { + if ((Long) value < 10 && (Long) value > -10) { + return value + "l"; + } + return value + "l (0x" + Long.toHexString((Long) value) + "l)"; + } else if (klass.isArray()) { + StringBuilder str = new StringBuilder(); + int dimensions = 0; + while (klass.isArray()) { + dimensions++; + klass = klass.getComponentType(); + } + int length = Array.getLength(value); + str.append(klass.getSimpleName()).append('[').append(length).append(']'); + for (int i = 1; i < dimensions; i++) { + str.append("[]"); + } + str.append(" {"); + for (int i = 0; i < length; i++) { + str.append(pretty(Array.get(value, i))); + if (i < length - 1) { + str.append(", "); + } + } + str.append('}'); + return str.toString(); + } + return value.toString(); + } + + public OutputStream getLogStream() { + return new OutputStream() { + + @Override + public void write(byte[] b, int off, int len) throws IOException { + if (b == null) { + throw new NullPointerException(); + } else if (off < 0 || off > b.length || len < 0 || (off + len) > b.length || (off + len) < 0) { + throw new IndexOutOfBoundsException(); + } else if (len == 0) { + return; + } + compilerToVm.writeDebugOutput(b, off, len); + } + + @Override + public void write(int b) throws IOException { + write(new byte[]{(byte) b}, 0, 1); + } + + @Override + public void flush() throws IOException { + compilerToVm.flushDebugOutput(); + } + }; + } + + /** + * Collects the current values of all JVMCI benchmark counters, summed up over all threads. + */ + public long[] collectCounters() { + return compilerToVm.collectCounters(); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java 2016-05-04 09:43:33.000000000 -1000 +++ /dev/null 2016-05-04 09:43:33.000000000 -1000 @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.io.OutputStream; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.JVMCIMetaAccessContext; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.runtime.JVMCIRuntime; -import jdk.internal.misc.Unsafe; - -//JaCoCo Exclude - -/** - * Configuration information for the HotSpot JVMCI runtime. - */ -public interface HotSpotJVMCIRuntimeProvider extends JVMCIRuntime { - - HotSpotVMConfig getConfig(); - - CompilerToVM getCompilerToVM(); - - /** - * Gets an output stream that writes to the HotSpot's {@code tty} stream. - */ - OutputStream getLogStream(); - - /** - * Converts a name to a Java type. This method attempts to resolve {@code name} to a - * {@link ResolvedJavaType}. - * - * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format - * @param accessingType the context of resolution which must be non-null - * @param resolve specifies whether resolution failure results in an unresolved type being - * return or a {@link LinkageError} being thrown - * @return a Java type for {@code name} which is guaranteed to be of type - * {@link ResolvedJavaType} if {@code resolve == true} - * @throws LinkageError if {@code resolve == true} and the resolution failed - * @throws NullPointerException if {@code accessingClass} is {@code null} - */ - JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve); - - /** - * Gets the JVMCI mirror for a {@link Class} object. - * - * @return the {@link ResolvedJavaType} corresponding to {@code javaClass} - */ - ResolvedJavaType fromClass(Class clazz); - - JVMCIMetaAccessContext getMetaAccessContext(); - - /** - * The offset from the origin of an array to the first element. - * - * @return the offset in bytes - */ - static int getArrayBaseOffset(JavaKind kind) { - switch (kind) { - case Boolean: - return Unsafe.ARRAY_BOOLEAN_BASE_OFFSET; - case Byte: - return Unsafe.ARRAY_BYTE_BASE_OFFSET; - case Char: - return Unsafe.ARRAY_CHAR_BASE_OFFSET; - case Short: - return Unsafe.ARRAY_SHORT_BASE_OFFSET; - case Int: - return Unsafe.ARRAY_INT_BASE_OFFSET; - case Long: - return Unsafe.ARRAY_LONG_BASE_OFFSET; - case Float: - return Unsafe.ARRAY_FLOAT_BASE_OFFSET; - case Double: - return Unsafe.ARRAY_DOUBLE_BASE_OFFSET; - case Object: - return Unsafe.ARRAY_OBJECT_BASE_OFFSET; - default: - throw new JVMCIError("%s", kind); - } - } - - /** - * The scale used for the index when accessing elements of an array of this kind. - * - * @return the scale in order to convert the index into a byte offset - */ - static int getArrayIndexScale(JavaKind kind) { - switch (kind) { - case Boolean: - return Unsafe.ARRAY_BOOLEAN_INDEX_SCALE; - case Byte: - return Unsafe.ARRAY_BYTE_INDEX_SCALE; - case Char: - return Unsafe.ARRAY_CHAR_INDEX_SCALE; - case Short: - return Unsafe.ARRAY_SHORT_INDEX_SCALE; - case Int: - return Unsafe.ARRAY_INT_INDEX_SCALE; - case Long: - return Unsafe.ARRAY_LONG_INDEX_SCALE; - case Float: - return Unsafe.ARRAY_FLOAT_INDEX_SCALE; - case Double: - return Unsafe.ARRAY_DOUBLE_INDEX_SCALE; - case Object: - return Unsafe.ARRAY_OBJECT_INDEX_SCALE; - default: - throw new JVMCIError("%s", kind); - } - } -} --- /dev/null 2016-05-04 09:43:33.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java 2016-05-04 09:43:33.000000000 -1000 @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import java.io.OutputStream; + +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.meta.JVMCIMetaAccessContext; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.ResolvedJavaType; +import jdk.vm.ci.runtime.JVMCIRuntime; +import jdk.internal.misc.Unsafe; + +//JaCoCo Exclude + +/** + * Configuration information for the HotSpot JVMCI runtime. + */ +public interface HotSpotJVMCIRuntimeProvider extends JVMCIRuntime { + + HotSpotVMConfig getConfig(); + + CompilerToVM getCompilerToVM(); + + /** + * Gets an output stream that writes to the HotSpot's {@code tty} stream. + */ + OutputStream getLogStream(); + + /** + * Converts a name to a Java type. This method attempts to resolve {@code name} to a + * {@link ResolvedJavaType}. + * + * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format + * @param accessingType the context of resolution which must be non-null + * @param resolve specifies whether resolution failure results in an unresolved type being + * return or a {@link LinkageError} being thrown + * @return a Java type for {@code name} which is guaranteed to be of type + * {@link ResolvedJavaType} if {@code resolve == true} + * @throws LinkageError if {@code resolve == true} and the resolution failed + * @throws NullPointerException if {@code accessingClass} is {@code null} + */ + JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve); + + /** + * Gets the JVMCI mirror for a {@link Class} object. + * + * @return the {@link ResolvedJavaType} corresponding to {@code javaClass} + */ + ResolvedJavaType fromClass(Class clazz); + + JVMCIMetaAccessContext getMetaAccessContext(); + + /** + * The offset from the origin of an array to the first element. + * + * @return the offset in bytes + */ + static int getArrayBaseOffset(JavaKind kind) { + switch (kind) { + case Boolean: + return Unsafe.ARRAY_BOOLEAN_BASE_OFFSET; + case Byte: + return Unsafe.ARRAY_BYTE_BASE_OFFSET; + case Char: + return Unsafe.ARRAY_CHAR_BASE_OFFSET; + case Short: + return Unsafe.ARRAY_SHORT_BASE_OFFSET; + case Int: + return Unsafe.ARRAY_INT_BASE_OFFSET; + case Long: + return Unsafe.ARRAY_LONG_BASE_OFFSET; + case Float: + return Unsafe.ARRAY_FLOAT_BASE_OFFSET; + case Double: + return Unsafe.ARRAY_DOUBLE_BASE_OFFSET; + case Object: + return Unsafe.ARRAY_OBJECT_BASE_OFFSET; + default: + throw new JVMCIError("%s", kind); + } + } + + /** + * The scale used for the index when accessing elements of an array of this kind. + * + * @return the scale in order to convert the index into a byte offset + */ + static int getArrayIndexScale(JavaKind kind) { + switch (kind) { + case Boolean: + return Unsafe.ARRAY_BOOLEAN_INDEX_SCALE; + case Byte: + return Unsafe.ARRAY_BYTE_INDEX_SCALE; + case Char: + return Unsafe.ARRAY_CHAR_INDEX_SCALE; + case Short: + return Unsafe.ARRAY_SHORT_INDEX_SCALE; + case Int: + return Unsafe.ARRAY_INT_INDEX_SCALE; + case Long: + return Unsafe.ARRAY_LONG_INDEX_SCALE; + case Float: + return Unsafe.ARRAY_FLOAT_INDEX_SCALE; + case Double: + return Unsafe.ARRAY_DOUBLE_INDEX_SCALE; + case Object: + return Unsafe.ARRAY_OBJECT_INDEX_SCALE; + default: + throw new JVMCIError("%s", kind); + } + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJavaType.java 2016-05-04 09:43:34.000000000 -1000 +++ /dev/null 2016-05-04 09:43:34.000000000 -1000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.JavaType; - -/** - * Common base class for all HotSpot {@link JavaType} implementations. - */ -public abstract class HotSpotJavaType implements JavaType { - - private final String name; - - public HotSpotJavaType(String name) { - this.name = name; - } - - @Override - public final String getName() { - return name; - } -} --- /dev/null 2016-05-04 09:43:34.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJavaType.java 2016-05-04 09:43:34.000000000 -1000 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.JavaType; + +/** + * Common base class for all HotSpot {@link JavaType} implementations. + */ +public abstract class HotSpotJavaType implements JavaType { + + private final String name; + + public HotSpotJavaType(String name) { + this.name = name; + } + + @Override + public final String getName() { + return name; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java 2016-05-04 09:43:34.000000000 -1000 +++ /dev/null 2016-05-04 09:43:34.000000000 -1000 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.hotspot.HotSpotVMConfig.CompressEncoding; -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.MemoryAccessProvider; - -/** - * HotSpot specific extension of {@link MemoryAccessProvider}. - */ -public interface HotSpotMemoryAccessProvider extends MemoryAccessProvider { - - JavaConstant readNarrowOopConstant(Constant base, long displacement, CompressEncoding encoding); - - Constant readKlassPointerConstant(Constant base, long displacement); - - Constant readNarrowKlassPointerConstant(Constant base, long displacement, CompressEncoding encoding); - - Constant readMethodPointerConstant(Constant base, long displacement); - - Constant readSymbolConstant(Constant base, long displacement); -} --- /dev/null 2016-05-04 09:43:34.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java 2016-05-04 09:43:34.000000000 -1000 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.hotspot.HotSpotVMConfig.CompressEncoding; +import jdk.vm.ci.meta.Constant; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.MemoryAccessProvider; + +/** + * HotSpot specific extension of {@link MemoryAccessProvider}. + */ +public interface HotSpotMemoryAccessProvider extends MemoryAccessProvider { + + JavaConstant readNarrowOopConstant(Constant base, long displacement, CompressEncoding encoding); + + Constant readKlassPointerConstant(Constant base, long displacement); + + Constant readNarrowKlassPointerConstant(Constant base, long displacement, CompressEncoding encoding); + + Constant readMethodPointerConstant(Constant base, long displacement); + + Constant readSymbolConstant(Constant base, long displacement); +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java 2016-05-04 09:43:35.000000000 -1000 +++ /dev/null 2016-05-04 09:43:35.000000000 -1000 @@ -1,247 +0,0 @@ -/* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; -import jdk.vm.ci.hotspot.HotSpotVMConfig.CompressEncoding; -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.MemoryAccessProvider; -import jdk.vm.ci.meta.PrimitiveConstant; - -/** - * HotSpot implementation of {@link MemoryAccessProvider}. - */ -class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, HotSpotProxified { - - protected final HotSpotJVMCIRuntimeProvider runtime; - - HotSpotMemoryAccessProviderImpl(HotSpotJVMCIRuntimeProvider runtime) { - this.runtime = runtime; - } - - private static Object asObject(Constant base) { - if (base instanceof HotSpotObjectConstantImpl) { - return ((HotSpotObjectConstantImpl) base).object(); - } else { - return null; - } - } - - private boolean isValidObjectFieldDisplacement(Constant base, long displacement) { - if (base instanceof HotSpotMetaspaceConstant) { - MetaspaceWrapperObject metaspaceObject = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base); - if (metaspaceObject instanceof HotSpotResolvedObjectTypeImpl) { - if (displacement == runtime.getConfig().classMirrorOffset) { - // Klass::_java_mirror is valid for all Klass* values - return true; - } - } else { - throw new IllegalArgumentException(String.valueOf(metaspaceObject)); - } - } - return false; - } - - private static long asRawPointer(Constant base) { - if (base instanceof HotSpotMetaspaceConstantImpl) { - MetaspaceWrapperObject meta = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base); - return meta.getMetaspacePointer(); - } else if (base instanceof PrimitiveConstant) { - PrimitiveConstant prim = (PrimitiveConstant) base; - if (prim.getJavaKind().isNumericInteger()) { - return prim.asLong(); - } - } - throw new IllegalArgumentException(String.valueOf(base)); - } - - private static long readRawValue(Constant baseConstant, long displacement, int bits) { - Object base = asObject(baseConstant); - if (base != null) { - switch (bits) { - case Byte.SIZE: - return UNSAFE.getByte(base, displacement); - case Short.SIZE: - return UNSAFE.getShort(base, displacement); - case Integer.SIZE: - return UNSAFE.getInt(base, displacement); - case Long.SIZE: - return UNSAFE.getLong(base, displacement); - default: - throw new IllegalArgumentException(String.valueOf(bits)); - } - } else { - long pointer = asRawPointer(baseConstant); - switch (bits) { - case Byte.SIZE: - return UNSAFE.getByte(pointer + displacement); - case Short.SIZE: - return UNSAFE.getShort(pointer + displacement); - case Integer.SIZE: - return UNSAFE.getInt(pointer + displacement); - case Long.SIZE: - return UNSAFE.getLong(pointer + displacement); - default: - throw new IllegalArgumentException(String.valueOf(bits)); - } - } - } - - private boolean verifyReadRawObject(Object expected, Constant base, long displacement, boolean compressed) { - if (compressed == runtime.getConfig().useCompressedOops) { - Object obj = asObject(base); - if (obj != null) { - assert expected == UNSAFE.getObject(obj, displacement) : "readUnsafeOop doesn't agree with unsafe.getObject"; - } - } - if (base instanceof HotSpotMetaspaceConstant) { - MetaspaceWrapperObject metaspaceObject = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base); - if (metaspaceObject instanceof HotSpotResolvedObjectTypeImpl) { - if (displacement == runtime.getConfig().classMirrorOffset) { - assert expected == ((HotSpotResolvedObjectTypeImpl) metaspaceObject).mirror(); - } - } - } - return true; - } - - private Object readRawObject(Constant baseConstant, long initialDisplacement, boolean compressed) { - long displacement = initialDisplacement; - - Object ret; - Object base = asObject(baseConstant); - if (base == null) { - assert !compressed; - displacement += asRawPointer(baseConstant); - ret = runtime.getCompilerToVM().readUncompressedOop(displacement); - } else { - assert runtime.getConfig().useCompressedOops == compressed; - ret = UNSAFE.getObject(base, displacement); - } - assert verifyReadRawObject(ret, baseConstant, initialDisplacement, compressed); - return ret; - } - - @Override - public JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant baseConstant, long displacement) { - if (kind == null) { - throw new IllegalArgumentException("null JavaKind"); - } - if (kind == JavaKind.Object) { - Object o = readRawObject(baseConstant, displacement, runtime.getConfig().useCompressedOops); - return HotSpotObjectConstantImpl.forObject(o); - } else { - int bits = kind.getByteCount() * Byte.SIZE; - return readPrimitiveConstant(kind, baseConstant, displacement, bits); - } - } - - @Override - public JavaConstant readPrimitiveConstant(JavaKind kind, Constant baseConstant, long initialDisplacement, int bits) { - try { - long rawValue = readRawValue(baseConstant, initialDisplacement, bits); - switch (kind) { - case Boolean: - return JavaConstant.forBoolean(rawValue != 0); - case Byte: - return JavaConstant.forByte((byte) rawValue); - case Char: - return JavaConstant.forChar((char) rawValue); - case Short: - return JavaConstant.forShort((short) rawValue); - case Int: - return JavaConstant.forInt((int) rawValue); - case Long: - return JavaConstant.forLong(rawValue); - case Float: - return JavaConstant.forFloat(Float.intBitsToFloat((int) rawValue)); - case Double: - return JavaConstant.forDouble(Double.longBitsToDouble(rawValue)); - default: - throw new IllegalArgumentException("Unsupported kind: " + kind); - } - } catch (NullPointerException e) { - return null; - } - } - - @Override - public JavaConstant readObjectConstant(Constant base, long displacement) { - if (!isValidObjectFieldDisplacement(base, displacement)) { - return null; - } - return HotSpotObjectConstantImpl.forObject(readRawObject(base, displacement, false)); - } - - @Override - public JavaConstant readNarrowOopConstant(Constant base, long displacement, CompressEncoding encoding) { - assert encoding.equals(runtime.getConfig().getOopEncoding()) : "unexpected oop encoding: " + encoding + " != " + runtime.getConfig().getOopEncoding(); - return HotSpotObjectConstantImpl.forObject(readRawObject(base, displacement, true), true); - } - - private HotSpotResolvedObjectTypeImpl readKlass(Constant base, long displacement, boolean compressed) { - assert (base instanceof HotSpotMetaspaceConstantImpl) || (base instanceof HotSpotObjectConstantImpl) : base.getClass(); - Object baseObject = (base instanceof HotSpotMetaspaceConstantImpl) ? ((HotSpotMetaspaceConstantImpl) base).asResolvedJavaType() : ((HotSpotObjectConstantImpl) base).object(); - return runtime.getCompilerToVM().getResolvedJavaType(baseObject, displacement, compressed); - } - - @Override - public Constant readKlassPointerConstant(Constant base, long displacement) { - HotSpotResolvedObjectTypeImpl klass = readKlass(base, displacement, false); - if (klass == null) { - return JavaConstant.NULL_POINTER; - } - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(klass, false); - } - - @Override - public Constant readNarrowKlassPointerConstant(Constant base, long displacement, CompressEncoding encoding) { - HotSpotResolvedObjectTypeImpl klass = readKlass(base, displacement, true); - if (klass == null) { - return HotSpotCompressedNullConstant.COMPRESSED_NULL; - } - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(klass, true); - } - - @Override - public Constant readMethodPointerConstant(Constant base, long displacement) { - assert (base instanceof HotSpotObjectConstantImpl); - Object baseObject = ((HotSpotObjectConstantImpl) base).object(); - HotSpotResolvedJavaMethodImpl method = runtime.getCompilerToVM().getResolvedJavaMethod(baseObject, displacement); - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(method, false); - } - - @Override - public Constant readSymbolConstant(Constant base, long displacement) { - int bits = runtime.getConfig().symbolPointerSize * Byte.SIZE; - long pointer = readRawValue(base, displacement, bits); - if (pointer == 0) { - return JavaConstant.NULL_POINTER; - } else { - String symbol = runtime.getCompilerToVM().getSymbol(pointer); - return new HotSpotSymbol(symbol, pointer).asConstant(); - } - } -} --- /dev/null 2016-05-04 09:43:35.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java 2016-05-04 09:43:35.000000000 -1000 @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; +import jdk.vm.ci.hotspot.HotSpotVMConfig.CompressEncoding; +import jdk.vm.ci.meta.Constant; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.MemoryAccessProvider; +import jdk.vm.ci.meta.PrimitiveConstant; + +/** + * HotSpot implementation of {@link MemoryAccessProvider}. + */ +class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, HotSpotProxified { + + protected final HotSpotJVMCIRuntimeProvider runtime; + + HotSpotMemoryAccessProviderImpl(HotSpotJVMCIRuntimeProvider runtime) { + this.runtime = runtime; + } + + private static Object asObject(Constant base) { + if (base instanceof HotSpotObjectConstantImpl) { + return ((HotSpotObjectConstantImpl) base).object(); + } else { + return null; + } + } + + private boolean isValidObjectFieldDisplacement(Constant base, long displacement) { + if (base instanceof HotSpotMetaspaceConstant) { + MetaspaceWrapperObject metaspaceObject = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base); + if (metaspaceObject instanceof HotSpotResolvedObjectTypeImpl) { + if (displacement == runtime.getConfig().classMirrorOffset) { + // Klass::_java_mirror is valid for all Klass* values + return true; + } + } else { + throw new IllegalArgumentException(String.valueOf(metaspaceObject)); + } + } + return false; + } + + private static long asRawPointer(Constant base) { + if (base instanceof HotSpotMetaspaceConstantImpl) { + MetaspaceWrapperObject meta = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base); + return meta.getMetaspacePointer(); + } else if (base instanceof PrimitiveConstant) { + PrimitiveConstant prim = (PrimitiveConstant) base; + if (prim.getJavaKind().isNumericInteger()) { + return prim.asLong(); + } + } + throw new IllegalArgumentException(String.valueOf(base)); + } + + private static long readRawValue(Constant baseConstant, long displacement, int bits) { + Object base = asObject(baseConstant); + if (base != null) { + switch (bits) { + case Byte.SIZE: + return UNSAFE.getByte(base, displacement); + case Short.SIZE: + return UNSAFE.getShort(base, displacement); + case Integer.SIZE: + return UNSAFE.getInt(base, displacement); + case Long.SIZE: + return UNSAFE.getLong(base, displacement); + default: + throw new IllegalArgumentException(String.valueOf(bits)); + } + } else { + long pointer = asRawPointer(baseConstant); + switch (bits) { + case Byte.SIZE: + return UNSAFE.getByte(pointer + displacement); + case Short.SIZE: + return UNSAFE.getShort(pointer + displacement); + case Integer.SIZE: + return UNSAFE.getInt(pointer + displacement); + case Long.SIZE: + return UNSAFE.getLong(pointer + displacement); + default: + throw new IllegalArgumentException(String.valueOf(bits)); + } + } + } + + private boolean verifyReadRawObject(Object expected, Constant base, long displacement, boolean compressed) { + if (compressed == runtime.getConfig().useCompressedOops) { + Object obj = asObject(base); + if (obj != null) { + assert expected == UNSAFE.getObject(obj, displacement) : "readUnsafeOop doesn't agree with unsafe.getObject"; + } + } + if (base instanceof HotSpotMetaspaceConstant) { + MetaspaceWrapperObject metaspaceObject = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base); + if (metaspaceObject instanceof HotSpotResolvedObjectTypeImpl) { + if (displacement == runtime.getConfig().classMirrorOffset) { + assert expected == ((HotSpotResolvedObjectTypeImpl) metaspaceObject).mirror(); + } + } + } + return true; + } + + private Object readRawObject(Constant baseConstant, long initialDisplacement, boolean compressed) { + long displacement = initialDisplacement; + + Object ret; + Object base = asObject(baseConstant); + if (base == null) { + assert !compressed; + displacement += asRawPointer(baseConstant); + ret = runtime.getCompilerToVM().readUncompressedOop(displacement); + } else { + assert runtime.getConfig().useCompressedOops == compressed; + ret = UNSAFE.getObject(base, displacement); + } + assert verifyReadRawObject(ret, baseConstant, initialDisplacement, compressed); + return ret; + } + + @Override + public JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant baseConstant, long displacement) { + if (kind == null) { + throw new IllegalArgumentException("null JavaKind"); + } + if (kind == JavaKind.Object) { + Object o = readRawObject(baseConstant, displacement, runtime.getConfig().useCompressedOops); + return HotSpotObjectConstantImpl.forObject(o); + } else { + int bits = kind.getByteCount() * Byte.SIZE; + return readPrimitiveConstant(kind, baseConstant, displacement, bits); + } + } + + @Override + public JavaConstant readPrimitiveConstant(JavaKind kind, Constant baseConstant, long initialDisplacement, int bits) { + try { + long rawValue = readRawValue(baseConstant, initialDisplacement, bits); + switch (kind) { + case Boolean: + return JavaConstant.forBoolean(rawValue != 0); + case Byte: + return JavaConstant.forByte((byte) rawValue); + case Char: + return JavaConstant.forChar((char) rawValue); + case Short: + return JavaConstant.forShort((short) rawValue); + case Int: + return JavaConstant.forInt((int) rawValue); + case Long: + return JavaConstant.forLong(rawValue); + case Float: + return JavaConstant.forFloat(Float.intBitsToFloat((int) rawValue)); + case Double: + return JavaConstant.forDouble(Double.longBitsToDouble(rawValue)); + default: + throw new IllegalArgumentException("Unsupported kind: " + kind); + } + } catch (NullPointerException e) { + return null; + } + } + + @Override + public JavaConstant readObjectConstant(Constant base, long displacement) { + if (!isValidObjectFieldDisplacement(base, displacement)) { + return null; + } + return HotSpotObjectConstantImpl.forObject(readRawObject(base, displacement, false)); + } + + @Override + public JavaConstant readNarrowOopConstant(Constant base, long displacement, CompressEncoding encoding) { + assert encoding.equals(runtime.getConfig().getOopEncoding()) : "unexpected oop encoding: " + encoding + " != " + runtime.getConfig().getOopEncoding(); + return HotSpotObjectConstantImpl.forObject(readRawObject(base, displacement, true), true); + } + + private HotSpotResolvedObjectTypeImpl readKlass(Constant base, long displacement, boolean compressed) { + assert (base instanceof HotSpotMetaspaceConstantImpl) || (base instanceof HotSpotObjectConstantImpl) : base.getClass(); + Object baseObject = (base instanceof HotSpotMetaspaceConstantImpl) ? ((HotSpotMetaspaceConstantImpl) base).asResolvedJavaType() : ((HotSpotObjectConstantImpl) base).object(); + return runtime.getCompilerToVM().getResolvedJavaType(baseObject, displacement, compressed); + } + + @Override + public Constant readKlassPointerConstant(Constant base, long displacement) { + HotSpotResolvedObjectTypeImpl klass = readKlass(base, displacement, false); + if (klass == null) { + return JavaConstant.NULL_POINTER; + } + return HotSpotMetaspaceConstantImpl.forMetaspaceObject(klass, false); + } + + @Override + public Constant readNarrowKlassPointerConstant(Constant base, long displacement, CompressEncoding encoding) { + HotSpotResolvedObjectTypeImpl klass = readKlass(base, displacement, true); + if (klass == null) { + return HotSpotCompressedNullConstant.COMPRESSED_NULL; + } + return HotSpotMetaspaceConstantImpl.forMetaspaceObject(klass, true); + } + + @Override + public Constant readMethodPointerConstant(Constant base, long displacement) { + assert (base instanceof HotSpotObjectConstantImpl); + Object baseObject = ((HotSpotObjectConstantImpl) base).object(); + HotSpotResolvedJavaMethodImpl method = runtime.getCompilerToVM().getResolvedJavaMethod(baseObject, displacement); + return HotSpotMetaspaceConstantImpl.forMetaspaceObject(method, false); + } + + @Override + public Constant readSymbolConstant(Constant base, long displacement) { + int bits = runtime.getConfig().symbolPointerSize * Byte.SIZE; + long pointer = readRawValue(base, displacement, bits); + if (pointer == 0) { + return JavaConstant.NULL_POINTER; + } else { + String symbol = runtime.getCompilerToVM().getSymbol(pointer); + return new HotSpotSymbol(symbol, pointer).asConstant(); + } + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java 2016-05-04 09:43:35.000000000 -1000 +++ /dev/null 2016-05-04 09:43:35.000000000 -1000 @@ -1,352 +0,0 @@ -/* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayBaseOffset; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayIndexScale; -import static jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.fromObjectClass; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import java.lang.reflect.Array; -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; - -import jdk.vm.ci.code.CodeUtil; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.DeoptimizationAction; -import jdk.vm.ci.meta.DeoptimizationReason; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.Signature; - -// JaCoCo Exclude - -/** - * HotSpot implementation of {@link MetaAccessProvider}. - */ -public class HotSpotMetaAccessProvider implements MetaAccessProvider, HotSpotProxified { - - protected final HotSpotJVMCIRuntimeProvider runtime; - - public HotSpotMetaAccessProvider(HotSpotJVMCIRuntimeProvider runtime) { - this.runtime = runtime; - } - - public ResolvedJavaType lookupJavaType(Class clazz) { - if (clazz == null) { - throw new IllegalArgumentException("Class parameter was null"); - } - return runtime.fromClass(clazz); - } - - public HotSpotResolvedObjectType lookupJavaType(JavaConstant constant) { - if (constant.isNull() || !(constant instanceof HotSpotObjectConstant)) { - return null; - } - return ((HotSpotObjectConstant) constant).getType(); - } - - public Signature parseMethodDescriptor(String signature) { - return new HotSpotSignature(runtime, signature); - } - - public HotSpotSymbol lookupSymbol(String symbol) { - long pointer = runtime.getCompilerToVM().lookupSymbol(symbol); - if (pointer == 0) { - return null; - } else { - return new HotSpotSymbol(symbol, pointer); - } - } - - /** - * {@link Field} object of {@link Method#slot}. - */ - private Field reflectionMethodSlot = getReflectionSlotField(Method.class); - - /** - * {@link Field} object of {@link Constructor#slot}. - */ - private Field reflectionConstructorSlot = getReflectionSlotField(Constructor.class); - - private static Field getReflectionSlotField(Class reflectionClass) { - try { - Field field = reflectionClass.getDeclaredField("slot"); - field.setAccessible(true); - return field; - } catch (NoSuchFieldException | SecurityException e) { - throw new JVMCIError(e); - } - } - - public ResolvedJavaMethod lookupJavaMethod(Executable reflectionMethod) { - try { - Class holder = reflectionMethod.getDeclaringClass(); - Field slotField = reflectionMethod instanceof Constructor ? reflectionConstructorSlot : reflectionMethodSlot; - final int slot = slotField.getInt(reflectionMethod); - return runtime.getCompilerToVM().getResolvedJavaMethodAtSlot(holder, slot); - } catch (IllegalArgumentException | IllegalAccessException e) { - throw new JVMCIError(e); - } - } - - public ResolvedJavaField lookupJavaField(Field reflectionField) { - Class fieldHolder = reflectionField.getDeclaringClass(); - - HotSpotResolvedObjectType holder = fromObjectClass(fieldHolder); - if (Modifier.isStatic(reflectionField.getModifiers())) { - final long offset = UNSAFE.staticFieldOffset(reflectionField); - for (ResolvedJavaField field : holder.getStaticFields()) { - if (offset == ((HotSpotResolvedJavaField) field).offset()) { - return field; - } - } - } else { - final long offset = UNSAFE.objectFieldOffset(reflectionField); - for (ResolvedJavaField field : holder.getInstanceFields(false)) { - if (offset == ((HotSpotResolvedJavaField) field).offset()) { - return field; - } - } - } - - throw new JVMCIError("unresolved field %s", reflectionField); - } - - private static int intMaskRight(int n) { - assert n <= 32; - return n == 32 ? -1 : (1 << n) - 1; - } - - @Override - public JavaConstant encodeDeoptActionAndReason(DeoptimizationAction action, DeoptimizationReason reason, int debugId) { - HotSpotVMConfig config = runtime.getConfig(); - int actionValue = convertDeoptAction(action); - int reasonValue = convertDeoptReason(reason); - int debugValue = debugId & intMaskRight(config.deoptimizationDebugIdBits); - JavaConstant c = JavaConstant.forInt(~((debugValue << config.deoptimizationDebugIdShift) | (reasonValue << config.deoptimizationReasonShift) | (actionValue << config.deoptimizationActionShift))); - assert c.asInt() < 0; - return c; - } - - public DeoptimizationReason decodeDeoptReason(JavaConstant constant) { - HotSpotVMConfig config = runtime.getConfig(); - int reasonValue = ((~constant.asInt()) >> config.deoptimizationReasonShift) & intMaskRight(config.deoptimizationReasonBits); - DeoptimizationReason reason = convertDeoptReason(reasonValue); - return reason; - } - - public DeoptimizationAction decodeDeoptAction(JavaConstant constant) { - HotSpotVMConfig config = runtime.getConfig(); - int actionValue = ((~constant.asInt()) >> config.deoptimizationActionShift) & intMaskRight(config.deoptimizationActionBits); - DeoptimizationAction action = convertDeoptAction(actionValue); - return action; - } - - public int decodeDebugId(JavaConstant constant) { - HotSpotVMConfig config = runtime.getConfig(); - return ((~constant.asInt()) >> config.deoptimizationDebugIdShift) & intMaskRight(config.deoptimizationDebugIdBits); - } - - public int convertDeoptAction(DeoptimizationAction action) { - HotSpotVMConfig config = runtime.getConfig(); - switch (action) { - case None: - return config.deoptActionNone; - case RecompileIfTooManyDeopts: - return config.deoptActionMaybeRecompile; - case InvalidateReprofile: - return config.deoptActionReinterpret; - case InvalidateRecompile: - return config.deoptActionMakeNotEntrant; - case InvalidateStopCompiling: - return config.deoptActionMakeNotCompilable; - default: - throw new JVMCIError("%s", action); - } - } - - public DeoptimizationAction convertDeoptAction(int action) { - HotSpotVMConfig config = runtime.getConfig(); - if (action == config.deoptActionNone) { - return DeoptimizationAction.None; - } - if (action == config.deoptActionMaybeRecompile) { - return DeoptimizationAction.RecompileIfTooManyDeopts; - } - if (action == config.deoptActionReinterpret) { - return DeoptimizationAction.InvalidateReprofile; - } - if (action == config.deoptActionMakeNotEntrant) { - return DeoptimizationAction.InvalidateRecompile; - } - if (action == config.deoptActionMakeNotCompilable) { - return DeoptimizationAction.InvalidateStopCompiling; - } - throw new JVMCIError("%d", action); - } - - public int convertDeoptReason(DeoptimizationReason reason) { - HotSpotVMConfig config = runtime.getConfig(); - switch (reason) { - case None: - return config.deoptReasonNone; - case NullCheckException: - return config.deoptReasonNullCheck; - case BoundsCheckException: - return config.deoptReasonRangeCheck; - case ClassCastException: - return config.deoptReasonClassCheck; - case ArrayStoreException: - return config.deoptReasonArrayCheck; - case UnreachedCode: - return config.deoptReasonUnreached0; - case TypeCheckedInliningViolated: - return config.deoptReasonTypeCheckInlining; - case OptimizedTypeCheckViolated: - return config.deoptReasonOptimizedTypeCheck; - case NotCompiledExceptionHandler: - return config.deoptReasonNotCompiledExceptionHandler; - case Unresolved: - return config.deoptReasonUnresolved; - case JavaSubroutineMismatch: - return config.deoptReasonJsrMismatch; - case ArithmeticException: - return config.deoptReasonDiv0Check; - case RuntimeConstraint: - return config.deoptReasonConstraint; - case LoopLimitCheck: - return config.deoptReasonLoopLimitCheck; - case Aliasing: - return config.deoptReasonAliasing; - case TransferToInterpreter: - return config.deoptReasonTransferToInterpreter; - default: - throw new JVMCIError("%s", reason); - } - } - - public DeoptimizationReason convertDeoptReason(int reason) { - HotSpotVMConfig config = runtime.getConfig(); - if (reason == config.deoptReasonNone) { - return DeoptimizationReason.None; - } - if (reason == config.deoptReasonNullCheck) { - return DeoptimizationReason.NullCheckException; - } - if (reason == config.deoptReasonRangeCheck) { - return DeoptimizationReason.BoundsCheckException; - } - if (reason == config.deoptReasonClassCheck) { - return DeoptimizationReason.ClassCastException; - } - if (reason == config.deoptReasonArrayCheck) { - return DeoptimizationReason.ArrayStoreException; - } - if (reason == config.deoptReasonUnreached0) { - return DeoptimizationReason.UnreachedCode; - } - if (reason == config.deoptReasonTypeCheckInlining) { - return DeoptimizationReason.TypeCheckedInliningViolated; - } - if (reason == config.deoptReasonOptimizedTypeCheck) { - return DeoptimizationReason.OptimizedTypeCheckViolated; - } - if (reason == config.deoptReasonNotCompiledExceptionHandler) { - return DeoptimizationReason.NotCompiledExceptionHandler; - } - if (reason == config.deoptReasonUnresolved) { - return DeoptimizationReason.Unresolved; - } - if (reason == config.deoptReasonJsrMismatch) { - return DeoptimizationReason.JavaSubroutineMismatch; - } - if (reason == config.deoptReasonDiv0Check) { - return DeoptimizationReason.ArithmeticException; - } - if (reason == config.deoptReasonConstraint) { - return DeoptimizationReason.RuntimeConstraint; - } - if (reason == config.deoptReasonLoopLimitCheck) { - return DeoptimizationReason.LoopLimitCheck; - } - if (reason == config.deoptReasonAliasing) { - return DeoptimizationReason.Aliasing; - } - if (reason == config.deoptReasonTransferToInterpreter) { - return DeoptimizationReason.TransferToInterpreter; - } - throw new JVMCIError("%x", reason); - } - - @Override - public long getMemorySize(JavaConstant constant) { - if (constant.getJavaKind() == JavaKind.Object) { - HotSpotResolvedObjectType lookupJavaType = lookupJavaType(constant); - - if (lookupJavaType == null) { - return 0; - } else { - if (lookupJavaType.isArray()) { - // TODO(tw): Add compressed pointer support. - int length = Array.getLength(((HotSpotObjectConstantImpl) constant).object()); - ResolvedJavaType elementType = lookupJavaType.getComponentType(); - JavaKind elementKind = elementType.getJavaKind(); - final int headerSize = getArrayBaseOffset(elementKind); - TargetDescription target = runtime.getHostJVMCIBackend().getTarget(); - int sizeOfElement = getArrayIndexScale(elementKind); - int alignment = target.wordSize; - int log2ElementSize = CodeUtil.log2(sizeOfElement); - return computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize); - } - return lookupJavaType.instanceSize(); - } - } else { - return constant.getJavaKind().getByteCount(); - } - } - - /** - * Computes the size of the memory chunk allocated for an array. This size accounts for the - * array header size, body size and any padding after the last element to satisfy object - * alignment requirements. - * - * @param length the number of elements in the array - * @param alignment the object alignment requirement - * @param headerSize the size of the array header - * @param log2ElementSize log2 of the size of an element in the array - */ - public static int computeArrayAllocationSize(int length, int alignment, int headerSize, int log2ElementSize) { - int size = (length << log2ElementSize) + headerSize + (alignment - 1); - int mask = ~(alignment - 1); - return size & mask; - } -} --- /dev/null 2016-05-04 09:43:35.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java 2016-05-04 09:43:35.000000000 -1000 @@ -0,0 +1,352 @@ +/* + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayBaseOffset; +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayIndexScale; +import static jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.fromObjectClass; +import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; + +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.lang.reflect.Executable; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +import jdk.vm.ci.code.CodeUtil; +import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.meta.DeoptimizationAction; +import jdk.vm.ci.meta.DeoptimizationReason; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.MetaAccessProvider; +import jdk.vm.ci.meta.ResolvedJavaField; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; +import jdk.vm.ci.meta.Signature; + +// JaCoCo Exclude + +/** + * HotSpot implementation of {@link MetaAccessProvider}. + */ +public class HotSpotMetaAccessProvider implements MetaAccessProvider, HotSpotProxified { + + protected final HotSpotJVMCIRuntimeProvider runtime; + + public HotSpotMetaAccessProvider(HotSpotJVMCIRuntimeProvider runtime) { + this.runtime = runtime; + } + + public ResolvedJavaType lookupJavaType(Class clazz) { + if (clazz == null) { + throw new IllegalArgumentException("Class parameter was null"); + } + return runtime.fromClass(clazz); + } + + public HotSpotResolvedObjectType lookupJavaType(JavaConstant constant) { + if (constant.isNull() || !(constant instanceof HotSpotObjectConstant)) { + return null; + } + return ((HotSpotObjectConstant) constant).getType(); + } + + public Signature parseMethodDescriptor(String signature) { + return new HotSpotSignature(runtime, signature); + } + + public HotSpotSymbol lookupSymbol(String symbol) { + long pointer = runtime.getCompilerToVM().lookupSymbol(symbol); + if (pointer == 0) { + return null; + } else { + return new HotSpotSymbol(symbol, pointer); + } + } + + /** + * {@link Field} object of {@link Method#slot}. + */ + private Field reflectionMethodSlot = getReflectionSlotField(Method.class); + + /** + * {@link Field} object of {@link Constructor#slot}. + */ + private Field reflectionConstructorSlot = getReflectionSlotField(Constructor.class); + + private static Field getReflectionSlotField(Class reflectionClass) { + try { + Field field = reflectionClass.getDeclaredField("slot"); + field.setAccessible(true); + return field; + } catch (NoSuchFieldException | SecurityException e) { + throw new JVMCIError(e); + } + } + + public ResolvedJavaMethod lookupJavaMethod(Executable reflectionMethod) { + try { + Class holder = reflectionMethod.getDeclaringClass(); + Field slotField = reflectionMethod instanceof Constructor ? reflectionConstructorSlot : reflectionMethodSlot; + final int slot = slotField.getInt(reflectionMethod); + return runtime.getCompilerToVM().getResolvedJavaMethodAtSlot(holder, slot); + } catch (IllegalArgumentException | IllegalAccessException e) { + throw new JVMCIError(e); + } + } + + public ResolvedJavaField lookupJavaField(Field reflectionField) { + Class fieldHolder = reflectionField.getDeclaringClass(); + + HotSpotResolvedObjectType holder = fromObjectClass(fieldHolder); + if (Modifier.isStatic(reflectionField.getModifiers())) { + final long offset = UNSAFE.staticFieldOffset(reflectionField); + for (ResolvedJavaField field : holder.getStaticFields()) { + if (offset == ((HotSpotResolvedJavaField) field).offset()) { + return field; + } + } + } else { + final long offset = UNSAFE.objectFieldOffset(reflectionField); + for (ResolvedJavaField field : holder.getInstanceFields(false)) { + if (offset == ((HotSpotResolvedJavaField) field).offset()) { + return field; + } + } + } + + throw new JVMCIError("unresolved field %s", reflectionField); + } + + private static int intMaskRight(int n) { + assert n <= 32; + return n == 32 ? -1 : (1 << n) - 1; + } + + @Override + public JavaConstant encodeDeoptActionAndReason(DeoptimizationAction action, DeoptimizationReason reason, int debugId) { + HotSpotVMConfig config = runtime.getConfig(); + int actionValue = convertDeoptAction(action); + int reasonValue = convertDeoptReason(reason); + int debugValue = debugId & intMaskRight(config.deoptimizationDebugIdBits); + JavaConstant c = JavaConstant.forInt(~((debugValue << config.deoptimizationDebugIdShift) | (reasonValue << config.deoptimizationReasonShift) | (actionValue << config.deoptimizationActionShift))); + assert c.asInt() < 0; + return c; + } + + public DeoptimizationReason decodeDeoptReason(JavaConstant constant) { + HotSpotVMConfig config = runtime.getConfig(); + int reasonValue = ((~constant.asInt()) >> config.deoptimizationReasonShift) & intMaskRight(config.deoptimizationReasonBits); + DeoptimizationReason reason = convertDeoptReason(reasonValue); + return reason; + } + + public DeoptimizationAction decodeDeoptAction(JavaConstant constant) { + HotSpotVMConfig config = runtime.getConfig(); + int actionValue = ((~constant.asInt()) >> config.deoptimizationActionShift) & intMaskRight(config.deoptimizationActionBits); + DeoptimizationAction action = convertDeoptAction(actionValue); + return action; + } + + public int decodeDebugId(JavaConstant constant) { + HotSpotVMConfig config = runtime.getConfig(); + return ((~constant.asInt()) >> config.deoptimizationDebugIdShift) & intMaskRight(config.deoptimizationDebugIdBits); + } + + public int convertDeoptAction(DeoptimizationAction action) { + HotSpotVMConfig config = runtime.getConfig(); + switch (action) { + case None: + return config.deoptActionNone; + case RecompileIfTooManyDeopts: + return config.deoptActionMaybeRecompile; + case InvalidateReprofile: + return config.deoptActionReinterpret; + case InvalidateRecompile: + return config.deoptActionMakeNotEntrant; + case InvalidateStopCompiling: + return config.deoptActionMakeNotCompilable; + default: + throw new JVMCIError("%s", action); + } + } + + public DeoptimizationAction convertDeoptAction(int action) { + HotSpotVMConfig config = runtime.getConfig(); + if (action == config.deoptActionNone) { + return DeoptimizationAction.None; + } + if (action == config.deoptActionMaybeRecompile) { + return DeoptimizationAction.RecompileIfTooManyDeopts; + } + if (action == config.deoptActionReinterpret) { + return DeoptimizationAction.InvalidateReprofile; + } + if (action == config.deoptActionMakeNotEntrant) { + return DeoptimizationAction.InvalidateRecompile; + } + if (action == config.deoptActionMakeNotCompilable) { + return DeoptimizationAction.InvalidateStopCompiling; + } + throw new JVMCIError("%d", action); + } + + public int convertDeoptReason(DeoptimizationReason reason) { + HotSpotVMConfig config = runtime.getConfig(); + switch (reason) { + case None: + return config.deoptReasonNone; + case NullCheckException: + return config.deoptReasonNullCheck; + case BoundsCheckException: + return config.deoptReasonRangeCheck; + case ClassCastException: + return config.deoptReasonClassCheck; + case ArrayStoreException: + return config.deoptReasonArrayCheck; + case UnreachedCode: + return config.deoptReasonUnreached0; + case TypeCheckedInliningViolated: + return config.deoptReasonTypeCheckInlining; + case OptimizedTypeCheckViolated: + return config.deoptReasonOptimizedTypeCheck; + case NotCompiledExceptionHandler: + return config.deoptReasonNotCompiledExceptionHandler; + case Unresolved: + return config.deoptReasonUnresolved; + case JavaSubroutineMismatch: + return config.deoptReasonJsrMismatch; + case ArithmeticException: + return config.deoptReasonDiv0Check; + case RuntimeConstraint: + return config.deoptReasonConstraint; + case LoopLimitCheck: + return config.deoptReasonLoopLimitCheck; + case Aliasing: + return config.deoptReasonAliasing; + case TransferToInterpreter: + return config.deoptReasonTransferToInterpreter; + default: + throw new JVMCIError("%s", reason); + } + } + + public DeoptimizationReason convertDeoptReason(int reason) { + HotSpotVMConfig config = runtime.getConfig(); + if (reason == config.deoptReasonNone) { + return DeoptimizationReason.None; + } + if (reason == config.deoptReasonNullCheck) { + return DeoptimizationReason.NullCheckException; + } + if (reason == config.deoptReasonRangeCheck) { + return DeoptimizationReason.BoundsCheckException; + } + if (reason == config.deoptReasonClassCheck) { + return DeoptimizationReason.ClassCastException; + } + if (reason == config.deoptReasonArrayCheck) { + return DeoptimizationReason.ArrayStoreException; + } + if (reason == config.deoptReasonUnreached0) { + return DeoptimizationReason.UnreachedCode; + } + if (reason == config.deoptReasonTypeCheckInlining) { + return DeoptimizationReason.TypeCheckedInliningViolated; + } + if (reason == config.deoptReasonOptimizedTypeCheck) { + return DeoptimizationReason.OptimizedTypeCheckViolated; + } + if (reason == config.deoptReasonNotCompiledExceptionHandler) { + return DeoptimizationReason.NotCompiledExceptionHandler; + } + if (reason == config.deoptReasonUnresolved) { + return DeoptimizationReason.Unresolved; + } + if (reason == config.deoptReasonJsrMismatch) { + return DeoptimizationReason.JavaSubroutineMismatch; + } + if (reason == config.deoptReasonDiv0Check) { + return DeoptimizationReason.ArithmeticException; + } + if (reason == config.deoptReasonConstraint) { + return DeoptimizationReason.RuntimeConstraint; + } + if (reason == config.deoptReasonLoopLimitCheck) { + return DeoptimizationReason.LoopLimitCheck; + } + if (reason == config.deoptReasonAliasing) { + return DeoptimizationReason.Aliasing; + } + if (reason == config.deoptReasonTransferToInterpreter) { + return DeoptimizationReason.TransferToInterpreter; + } + throw new JVMCIError("%x", reason); + } + + @Override + public long getMemorySize(JavaConstant constant) { + if (constant.getJavaKind() == JavaKind.Object) { + HotSpotResolvedObjectType lookupJavaType = lookupJavaType(constant); + + if (lookupJavaType == null) { + return 0; + } else { + if (lookupJavaType.isArray()) { + // TODO(tw): Add compressed pointer support. + int length = Array.getLength(((HotSpotObjectConstantImpl) constant).object()); + ResolvedJavaType elementType = lookupJavaType.getComponentType(); + JavaKind elementKind = elementType.getJavaKind(); + final int headerSize = getArrayBaseOffset(elementKind); + TargetDescription target = runtime.getHostJVMCIBackend().getTarget(); + int sizeOfElement = getArrayIndexScale(elementKind); + int alignment = target.wordSize; + int log2ElementSize = CodeUtil.log2(sizeOfElement); + return computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize); + } + return lookupJavaType.instanceSize(); + } + } else { + return constant.getJavaKind().getByteCount(); + } + } + + /** + * Computes the size of the memory chunk allocated for an array. This size accounts for the + * array header size, body size and any padding after the last element to satisfy object + * alignment requirements. + * + * @param length the number of elements in the array + * @param alignment the object alignment requirement + * @param headerSize the size of the array header + * @param log2ElementSize log2 of the size of an element in the array + */ + public static int computeArrayAllocationSize(int length, int alignment, int headerSize, int log2ElementSize) { + int size = (length << log2ElementSize) + headerSize + (alignment - 1); + int mask = ~(alignment - 1); + return size & mask; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaData.java 2016-05-04 09:43:36.000000000 -1000 +++ /dev/null 2016-05-04 09:43:36.000000000 -1000 @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.inittimer.SuppressFBWarnings; - -public class HotSpotMetaData { - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private byte[] pcDescBytes; - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private byte[] scopesDescBytes; - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private byte[] relocBytes; - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private byte[] exceptionBytes; - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private byte[] oopMaps; - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private String[] metadata; - - public byte[] pcDescBytes() { - return pcDescBytes != null ? pcDescBytes : new byte[0]; - } - - public byte[] scopesDescBytes() { - return scopesDescBytes != null ? scopesDescBytes : new byte[0]; - } - - public byte[] relocBytes() { - return relocBytes != null ? relocBytes : new byte[0]; - } - - public byte[] exceptionBytes() { - return exceptionBytes != null ? exceptionBytes : new byte[0]; - } - - public byte[] oopMaps() { - return oopMaps != null ? oopMaps : new byte[0]; - } - - public String[] metadataEntries() { - return metadata != null ? metadata : new String[0]; - } -} --- /dev/null 2016-05-04 09:43:36.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaData.java 2016-05-04 09:43:36.000000000 -1000 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.inittimer.SuppressFBWarnings; + +public class HotSpotMetaData { + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private byte[] pcDescBytes; + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private byte[] scopesDescBytes; + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private byte[] relocBytes; + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private byte[] exceptionBytes; + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private byte[] oopMaps; + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private String[] metadata; + + public byte[] pcDescBytes() { + return pcDescBytes != null ? pcDescBytes : new byte[0]; + } + + public byte[] scopesDescBytes() { + return scopesDescBytes != null ? scopesDescBytes : new byte[0]; + } + + public byte[] relocBytes() { + return relocBytes != null ? relocBytes : new byte[0]; + } + + public byte[] exceptionBytes() { + return exceptionBytes != null ? exceptionBytes : new byte[0]; + } + + public byte[] oopMaps() { + return oopMaps != null ? oopMaps : new byte[0]; + } + + public String[] metadataEntries() { + return metadata != null ? metadata : new String[0]; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstant.java 2016-05-04 09:43:36.000000000 -1000 +++ /dev/null 2016-05-04 09:43:36.000000000 -1000 @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.VMConstant; - -public interface HotSpotMetaspaceConstant extends HotSpotConstant, VMConstant { - - HotSpotResolvedObjectType asResolvedJavaType(); - - HotSpotResolvedJavaMethod asResolvedJavaMethod(); - - HotSpotSymbol asSymbol(); -} --- /dev/null 2016-05-04 09:43:36.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstant.java 2016-05-04 09:43:36.000000000 -1000 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.VMConstant; + +public interface HotSpotMetaspaceConstant extends HotSpotConstant, VMConstant { + + HotSpotResolvedObjectType asResolvedJavaType(); + + HotSpotResolvedJavaMethod asResolvedJavaMethod(); + + HotSpotSymbol asSymbol(); +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java 2016-05-04 09:43:37.000000000 -1000 +++ /dev/null 2016-05-04 09:43:37.000000000 -1000 @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.Objects; - -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.VMConstant; - -final class HotSpotMetaspaceConstantImpl implements HotSpotMetaspaceConstant, VMConstant, HotSpotProxified { - - static HotSpotMetaspaceConstantImpl forMetaspaceObject(MetaspaceWrapperObject metaspaceObject, boolean compressed) { - return new HotSpotMetaspaceConstantImpl(metaspaceObject, compressed); - } - - static MetaspaceWrapperObject getMetaspaceObject(Constant constant) { - return ((HotSpotMetaspaceConstantImpl) constant).metaspaceObject; - } - - private final MetaspaceWrapperObject metaspaceObject; - private final boolean compressed; - - private HotSpotMetaspaceConstantImpl(MetaspaceWrapperObject metaspaceObject, boolean compressed) { - this.metaspaceObject = metaspaceObject; - this.compressed = compressed; - } - - @Override - public int hashCode() { - return System.identityHashCode(metaspaceObject) ^ (compressed ? 1 : 2); - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (!(o instanceof HotSpotMetaspaceConstantImpl)) { - return false; - } - - HotSpotMetaspaceConstantImpl other = (HotSpotMetaspaceConstantImpl) o; - return Objects.equals(this.metaspaceObject, other.metaspaceObject) && this.compressed == other.compressed; - } - - @Override - public String toValueString() { - return String.format("meta{%s%s}", metaspaceObject, compressed ? ";compressed" : ""); - } - - @Override - public String toString() { - return toValueString(); - } - - public boolean isDefaultForKind() { - return false; - } - - public boolean isCompressed() { - return compressed; - } - - public Constant compress() { - assert !isCompressed(); - HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(metaspaceObject, true); - assert res.isCompressed(); - return res; - } - - public Constant uncompress() { - assert isCompressed(); - HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(metaspaceObject, false); - assert !res.isCompressed(); - return res; - } - - public HotSpotResolvedObjectType asResolvedJavaType() { - if (metaspaceObject instanceof HotSpotResolvedObjectType) { - return (HotSpotResolvedObjectType) metaspaceObject; - } - return null; - } - - public HotSpotResolvedJavaMethod asResolvedJavaMethod() { - if (metaspaceObject instanceof HotSpotResolvedJavaMethod) { - return (HotSpotResolvedJavaMethod) metaspaceObject; - } - return null; - } - - public HotSpotSymbol asSymbol() { - if (metaspaceObject instanceof HotSpotSymbol) { - return (HotSpotSymbol) metaspaceObject; - } - return null; - } -} --- /dev/null 2016-05-04 09:43:37.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java 2016-05-04 09:43:36.000000000 -1000 @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import java.util.Objects; + +import jdk.vm.ci.meta.Constant; +import jdk.vm.ci.meta.VMConstant; + +final class HotSpotMetaspaceConstantImpl implements HotSpotMetaspaceConstant, VMConstant, HotSpotProxified { + + static HotSpotMetaspaceConstantImpl forMetaspaceObject(MetaspaceWrapperObject metaspaceObject, boolean compressed) { + return new HotSpotMetaspaceConstantImpl(metaspaceObject, compressed); + } + + static MetaspaceWrapperObject getMetaspaceObject(Constant constant) { + return ((HotSpotMetaspaceConstantImpl) constant).metaspaceObject; + } + + private final MetaspaceWrapperObject metaspaceObject; + private final boolean compressed; + + private HotSpotMetaspaceConstantImpl(MetaspaceWrapperObject metaspaceObject, boolean compressed) { + this.metaspaceObject = metaspaceObject; + this.compressed = compressed; + } + + @Override + public int hashCode() { + return System.identityHashCode(metaspaceObject) ^ (compressed ? 1 : 2); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (!(o instanceof HotSpotMetaspaceConstantImpl)) { + return false; + } + + HotSpotMetaspaceConstantImpl other = (HotSpotMetaspaceConstantImpl) o; + return Objects.equals(this.metaspaceObject, other.metaspaceObject) && this.compressed == other.compressed; + } + + @Override + public String toValueString() { + return String.format("meta{%s%s}", metaspaceObject, compressed ? ";compressed" : ""); + } + + @Override + public String toString() { + return toValueString(); + } + + public boolean isDefaultForKind() { + return false; + } + + public boolean isCompressed() { + return compressed; + } + + public Constant compress() { + assert !isCompressed(); + HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(metaspaceObject, true); + assert res.isCompressed(); + return res; + } + + public Constant uncompress() { + assert isCompressed(); + HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(metaspaceObject, false); + assert !res.isCompressed(); + return res; + } + + public HotSpotResolvedObjectType asResolvedJavaType() { + if (metaspaceObject instanceof HotSpotResolvedObjectType) { + return (HotSpotResolvedObjectType) metaspaceObject; + } + return null; + } + + public HotSpotResolvedJavaMethod asResolvedJavaMethod() { + if (metaspaceObject instanceof HotSpotResolvedJavaMethod) { + return (HotSpotResolvedJavaMethod) metaspaceObject; + } + return null; + } + + public HotSpotSymbol asSymbol() { + if (metaspaceObject instanceof HotSpotSymbol) { + return (HotSpotSymbol) metaspaceObject; + } + return null; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethod.java 2016-05-04 09:43:37.000000000 -1000 +++ /dev/null 2016-05-04 09:43:37.000000000 -1000 @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static java.util.FormattableFlags.ALTERNATE; -import static java.util.FormattableFlags.LEFT_JUSTIFY; -import static java.util.FormattableFlags.UPPERCASE; - -import java.util.Formattable; -import java.util.Formatter; - -import jdk.vm.ci.meta.JavaMethod; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -abstract class HotSpotMethod implements JavaMethod, Formattable /* , JavaMethodContex */{ - - public static String applyFormattingFlagsAndWidth(String s, int flags, int width) { - if (flags == 0 && width < 0) { - return s; - } - StringBuilder sb = new StringBuilder(s); - - // apply width and justification - int len = sb.length(); - if (len < width) { - for (int i = 0; i < width - len; i++) { - if ((flags & LEFT_JUSTIFY) == LEFT_JUSTIFY) { - sb.append(' '); - } else { - sb.insert(0, ' '); - } - } - } - - String res = sb.toString(); - if ((flags & UPPERCASE) == UPPERCASE) { - res = res.toUpperCase(); - } - return res; - } - - protected String name; - - /** - * Controls whether {@link #toString()} includes the qualified or simple name of the class in - * which the method is declared. - */ - public static final boolean FULLY_QUALIFIED_METHOD_NAME = false; - - protected HotSpotMethod(String name) { - this.name = name; - } - - @Override - public final String getName() { - return name; - } - - @Override - public final String toString() { - char h = FULLY_QUALIFIED_METHOD_NAME ? 'H' : 'h'; - String suffix = this instanceof ResolvedJavaMethod ? "" : ", unresolved"; - String fmt = String.format("HotSpotMethod<%%%c.%%n(%%p)%s>", h, suffix); - return format(fmt); - } - - public void formatTo(Formatter formatter, int flags, int width, int precision) { - String base = (flags & ALTERNATE) == ALTERNATE ? getName() : toString(); - formatter.format(applyFormattingFlagsAndWidth(base, flags & ~ALTERNATE, width)); - } - - public JavaMethod asJavaMethod() { - return this; - } -} --- /dev/null 2016-05-04 09:43:37.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethod.java 2016-05-04 09:43:37.000000000 -1000 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static java.util.FormattableFlags.ALTERNATE; +import static java.util.FormattableFlags.LEFT_JUSTIFY; +import static java.util.FormattableFlags.UPPERCASE; + +import java.util.Formattable; +import java.util.Formatter; + +import jdk.vm.ci.meta.JavaMethod; +import jdk.vm.ci.meta.ResolvedJavaMethod; + +abstract class HotSpotMethod implements JavaMethod, Formattable /* , JavaMethodContex */{ + + public static String applyFormattingFlagsAndWidth(String s, int flags, int width) { + if (flags == 0 && width < 0) { + return s; + } + StringBuilder sb = new StringBuilder(s); + + // apply width and justification + int len = sb.length(); + if (len < width) { + for (int i = 0; i < width - len; i++) { + if ((flags & LEFT_JUSTIFY) == LEFT_JUSTIFY) { + sb.append(' '); + } else { + sb.insert(0, ' '); + } + } + } + + String res = sb.toString(); + if ((flags & UPPERCASE) == UPPERCASE) { + res = res.toUpperCase(); + } + return res; + } + + protected String name; + + /** + * Controls whether {@link #toString()} includes the qualified or simple name of the class in + * which the method is declared. + */ + public static final boolean FULLY_QUALIFIED_METHOD_NAME = false; + + protected HotSpotMethod(String name) { + this.name = name; + } + + @Override + public final String getName() { + return name; + } + + @Override + public final String toString() { + char h = FULLY_QUALIFIED_METHOD_NAME ? 'H' : 'h'; + String suffix = this instanceof ResolvedJavaMethod ? "" : ", unresolved"; + String fmt = String.format("HotSpotMethod<%%%c.%%n(%%p)%s>", h, suffix); + return format(fmt); + } + + public void formatTo(Formatter formatter, int flags, int width, int precision) { + String base = (flags & ALTERNATE) == ALTERNATE ? getName() : toString(); + formatter.format(applyFormattingFlagsAndWidth(base, flags & ~ALTERNATE, width)); + } + + public JavaMethod asJavaMethod() { + return this; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java 2016-05-04 09:43:38.000000000 -1000 +++ /dev/null 2016-05-04 09:43:38.000000000 -1000 @@ -1,915 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static java.lang.String.format; -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import java.util.Arrays; - -import jdk.vm.ci.hotspot.HotSpotMethodDataAccessor.Tag; -import jdk.vm.ci.meta.DeoptimizationReason; -import jdk.vm.ci.meta.JavaMethodProfile; -import jdk.vm.ci.meta.JavaMethodProfile.ProfiledMethod; -import jdk.vm.ci.meta.JavaTypeProfile; -import jdk.vm.ci.meta.JavaTypeProfile.ProfiledType; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.TriState; -import jdk.internal.misc.Unsafe; - -/** - * Access to a HotSpot MethodData structure (defined in methodData.hpp). - */ -public final class HotSpotMethodData { - - private static final HotSpotVMConfig config = config(); - private static final HotSpotMethodDataAccessor NO_DATA_NO_EXCEPTION_ACCESSOR = new NoMethodData(TriState.FALSE); - private static final HotSpotMethodDataAccessor NO_DATA_EXCEPTION_POSSIBLY_NOT_RECORDED_ACCESSOR = new NoMethodData(TriState.UNKNOWN); - - // sorted by tag - // @formatter:off - private static final HotSpotMethodDataAccessor[] PROFILE_DATA_ACCESSORS = { - null, - new BitData(), - new CounterData(), - new JumpData(), - new ReceiverTypeData(), - new VirtualCallData(), - new RetData(), - new BranchData(), - new MultiBranchData(), - new ArgInfoData(), - new UnknownProfileData(Tag.CallTypeData), - new VirtualCallTypeData(), - new UnknownProfileData(Tag.ParametersTypeData), - new UnknownProfileData(Tag.SpeculativeTrapData), - }; - // @formatter:on - - /** - * Reference to the C++ MethodData object. - */ - private final long metaspaceMethodData; - @SuppressWarnings("unused") private final HotSpotResolvedJavaMethodImpl method; - - public HotSpotMethodData(long metaspaceMethodData, HotSpotResolvedJavaMethodImpl method) { - this.metaspaceMethodData = metaspaceMethodData; - this.method = method; - } - - /** - * @return value of the MethodData::_data_size field - */ - private int normalDataSize() { - return UNSAFE.getInt(metaspaceMethodData + config.methodDataDataSize); - } - - /** - * Returns the size of the extra data records. This method does the same calculation as - * MethodData::extra_data_size(). - * - * @return size of extra data records - */ - private int extraDataSize() { - final int extraDataBase = config.methodDataOopDataOffset + normalDataSize(); - final int extraDataLimit = UNSAFE.getInt(metaspaceMethodData + config.methodDataSize); - return extraDataLimit - extraDataBase; - } - - public boolean hasNormalData() { - return normalDataSize() > 0; - } - - public boolean hasExtraData() { - return extraDataSize() > 0; - } - - public int getExtraDataBeginOffset() { - return normalDataSize(); - } - - public boolean isWithin(int position) { - return position >= 0 && position < normalDataSize() + extraDataSize(); - } - - public int getDeoptimizationCount(DeoptimizationReason reason) { - HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) runtime().getHostJVMCIBackend().getMetaAccess(); - int reasonIndex = metaAccess.convertDeoptReason(reason); - return UNSAFE.getByte(metaspaceMethodData + config.methodDataOopTrapHistoryOffset + reasonIndex) & 0xFF; - } - - public int getOSRDeoptimizationCount(DeoptimizationReason reason) { - HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) runtime().getHostJVMCIBackend().getMetaAccess(); - int reasonIndex = metaAccess.convertDeoptReason(reason); - return UNSAFE.getByte(metaspaceMethodData + config.methodDataOopTrapHistoryOffset + config.deoptReasonOSROffset + reasonIndex) & 0xFF; - } - - public HotSpotMethodDataAccessor getNormalData(int position) { - if (position >= normalDataSize()) { - return null; - } - - HotSpotMethodDataAccessor result = getData(position); - final Tag tag = AbstractMethodData.readTag(this, position); - assert result != null : "NO_DATA tag is not allowed " + tag; - return result; - } - - public HotSpotMethodDataAccessor getExtraData(int position) { - if (position >= normalDataSize() + extraDataSize()) { - return null; - } - HotSpotMethodDataAccessor data = getData(position); - if (data != null) { - return data; - } - return data; - } - - public static HotSpotMethodDataAccessor getNoDataAccessor(boolean exceptionPossiblyNotRecorded) { - if (exceptionPossiblyNotRecorded) { - return NO_DATA_EXCEPTION_POSSIBLY_NOT_RECORDED_ACCESSOR; - } else { - return NO_DATA_NO_EXCEPTION_ACCESSOR; - } - } - - private HotSpotMethodDataAccessor getData(int position) { - assert position >= 0 : "out of bounds"; - final Tag tag = AbstractMethodData.readTag(this, position); - HotSpotMethodDataAccessor accessor = PROFILE_DATA_ACCESSORS[tag.getValue()]; - assert accessor == null || accessor.getTag() == tag : "wrong data accessor " + accessor + " for tag " + tag; - return accessor; - } - - private int readUnsignedByte(int position, int offsetInBytes) { - long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); - return UNSAFE.getByte(metaspaceMethodData + fullOffsetInBytes) & 0xFF; - } - - private int readUnsignedShort(int position, int offsetInBytes) { - long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); - return UNSAFE.getShort(metaspaceMethodData + fullOffsetInBytes) & 0xFFFF; - } - - /** - * Since the values are stored in cells (platform words) this method uses - * {@link Unsafe#getAddress} to read the right value on both little and big endian machines. - */ - private long readUnsignedInt(int position, int offsetInBytes) { - long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); - return UNSAFE.getAddress(metaspaceMethodData + fullOffsetInBytes) & 0xFFFFFFFFL; - } - - private int readUnsignedIntAsSignedInt(int position, int offsetInBytes) { - long value = readUnsignedInt(position, offsetInBytes); - return truncateLongToInt(value); - } - - /** - * Since the values are stored in cells (platform words) this method uses - * {@link Unsafe#getAddress} to read the right value on both little and big endian machines. - */ - private int readInt(int position, int offsetInBytes) { - long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); - return (int) UNSAFE.getAddress(metaspaceMethodData + fullOffsetInBytes); - } - - private HotSpotResolvedJavaMethod readMethod(int position, int offsetInBytes) { - long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); - return compilerToVM().getResolvedJavaMethod(null, metaspaceMethodData + fullOffsetInBytes); - } - - private HotSpotResolvedObjectTypeImpl readKlass(int position, int offsetInBytes) { - long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); - return compilerToVM().getResolvedJavaType(null, metaspaceMethodData + fullOffsetInBytes, false); - } - - private static int truncateLongToInt(long value) { - return value > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) value; - } - - private static int computeFullOffset(int position, int offsetInBytes) { - return config.methodDataOopDataOffset + position + offsetInBytes; - } - - private static int cellIndexToOffset(int cells) { - return config.dataLayoutHeaderSize + cellsToBytes(cells); - } - - private static int cellsToBytes(int cells) { - return cells * config.dataLayoutCellSize; - } - - /** - * Returns whether profiling ran long enough that the profile information is mature. Other - * informational data will still be valid even if the profile isn't mature. - */ - public boolean isProfileMature() { - return runtime().getCompilerToVM().isMature(metaspaceMethodData); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - String nl = String.format("%n"); - String nlIndent = String.format("%n%38s", ""); - if (hasNormalData()) { - int pos = 0; - HotSpotMethodDataAccessor data; - while ((data = getNormalData(pos)) != null) { - if (pos != 0) { - sb.append(nl); - } - int bci = data.getBCI(this, pos); - sb.append(String.format("%-6d bci: %-6d%-20s", pos, bci, data.getClass().getSimpleName())); - sb.append(data.appendTo(new StringBuilder(), this, pos).toString().replace(nl, nlIndent)); - pos = pos + data.getSize(this, pos); - } - } - - if (hasExtraData()) { - int pos = getExtraDataBeginOffset(); - HotSpotMethodDataAccessor data; - while ((data = getExtraData(pos)) != null) { - if (pos == getExtraDataBeginOffset()) { - sb.append(nl).append("--- Extra data:"); - } - int bci = data.getBCI(this, pos); - sb.append(String.format("%n%-6d bci: %-6d%-20s", pos, bci, data.getClass().getSimpleName())); - sb.append(data.appendTo(new StringBuilder(), this, pos).toString().replace(nl, nlIndent)); - pos = pos + data.getSize(this, pos); - } - - } - return sb.toString(); - } - - private abstract static class AbstractMethodData implements HotSpotMethodDataAccessor { - - /** - * Corresponds to {@code exception_seen_flag}. - */ - private static final int EXCEPTIONS_MASK = 1 << config.bitDataExceptionSeenFlag; - - private final Tag tag; - protected final int staticSize; - - protected AbstractMethodData(Tag tag, int staticSize) { - this.tag = tag; - this.staticSize = staticSize; - } - - public Tag getTag() { - return tag; - } - - public static Tag readTag(HotSpotMethodData data, int position) { - final int tag = data.readUnsignedByte(position, config.dataLayoutTagOffset); - return Tag.getEnum(tag); - } - - @Override - public int getBCI(HotSpotMethodData data, int position) { - return data.readUnsignedShort(position, config.dataLayoutBCIOffset); - } - - @Override - public final int getSize(HotSpotMethodData data, int position) { - int size = staticSize + getDynamicSize(data, position); - // Sanity check against VM - int vmSize = HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position); - assert size == vmSize : size + " != " + vmSize; - return size; - } - - @Override - public TriState getExceptionSeen(HotSpotMethodData data, int position) { - return TriState.get((getFlags(data, position) & EXCEPTIONS_MASK) != 0); - } - - @Override - public JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position) { - return null; - } - - @Override - public JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position) { - return null; - } - - @Override - public double getBranchTakenProbability(HotSpotMethodData data, int position) { - return -1; - } - - @Override - public double[] getSwitchProbabilities(HotSpotMethodData data, int position) { - return null; - } - - @Override - public int getExecutionCount(HotSpotMethodData data, int position) { - return -1; - } - - @Override - public TriState getNullSeen(HotSpotMethodData data, int position) { - return TriState.UNKNOWN; - } - - protected int getFlags(HotSpotMethodData data, int position) { - return data.readUnsignedByte(position, config.dataLayoutFlagsOffset); - } - - /** - * @param data - * @param position - */ - protected int getDynamicSize(HotSpotMethodData data, int position) { - return 0; - } - - public abstract StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos); - } - - private static class NoMethodData extends AbstractMethodData { - - private static final int NO_DATA_SIZE = cellIndexToOffset(0); - - private final TriState exceptionSeen; - - protected NoMethodData(TriState exceptionSeen) { - super(Tag.No, NO_DATA_SIZE); - this.exceptionSeen = exceptionSeen; - } - - @Override - public int getBCI(HotSpotMethodData data, int position) { - return -1; - } - - @Override - public TriState getExceptionSeen(HotSpotMethodData data, int position) { - return exceptionSeen; - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return sb; - } - } - - private static class BitData extends AbstractMethodData { - - private static final int BIT_DATA_SIZE = cellIndexToOffset(0); - private static final int BIT_DATA_NULL_SEEN_FLAG = 1 << config.bitDataNullSeenFlag; - - private BitData() { - super(Tag.BitData, BIT_DATA_SIZE); - } - - protected BitData(Tag tag, int staticSize) { - super(tag, staticSize); - } - - @Override - public TriState getNullSeen(HotSpotMethodData data, int position) { - return TriState.get((getFlags(data, position) & BIT_DATA_NULL_SEEN_FLAG) != 0); - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return sb.append(format("exception_seen(%s)", getExceptionSeen(data, pos))); - } - } - - private static class CounterData extends BitData { - - private static final int COUNTER_DATA_SIZE = cellIndexToOffset(1); - private static final int COUNTER_DATA_COUNT_OFFSET = cellIndexToOffset(config.methodDataCountOffset); - - CounterData() { - super(Tag.CounterData, COUNTER_DATA_SIZE); - } - - protected CounterData(Tag tag, int staticSize) { - super(tag, staticSize); - } - - @Override - public int getExecutionCount(HotSpotMethodData data, int position) { - return getCounterValue(data, position); - } - - protected int getCounterValue(HotSpotMethodData data, int position) { - return data.readUnsignedIntAsSignedInt(position, COUNTER_DATA_COUNT_OFFSET); - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return sb.append(format("count(%d) null_seen(%s) exception_seen(%s)", getCounterValue(data, pos), getNullSeen(data, pos), getExceptionSeen(data, pos))); - } - } - - private static class JumpData extends AbstractMethodData { - - private static final int JUMP_DATA_SIZE = cellIndexToOffset(2); - protected static final int TAKEN_COUNT_OFFSET = cellIndexToOffset(config.jumpDataTakenOffset); - protected static final int TAKEN_DISPLACEMENT_OFFSET = cellIndexToOffset(config.jumpDataDisplacementOffset); - - JumpData() { - super(Tag.JumpData, JUMP_DATA_SIZE); - } - - protected JumpData(Tag tag, int staticSize) { - super(tag, staticSize); - } - - @Override - public double getBranchTakenProbability(HotSpotMethodData data, int position) { - return getExecutionCount(data, position) != 0 ? 1 : 0; - } - - @Override - public int getExecutionCount(HotSpotMethodData data, int position) { - return data.readUnsignedIntAsSignedInt(position, TAKEN_COUNT_OFFSET); - } - - public int getTakenDisplacement(HotSpotMethodData data, int position) { - return data.readInt(position, TAKEN_DISPLACEMENT_OFFSET); - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return sb.append(format("taken(%d) displacement(%d)", getExecutionCount(data, pos), getTakenDisplacement(data, pos))); - } - } - - static class RawItemProfile { - final int entries; - final T[] items; - final long[] counts; - final long totalCount; - - RawItemProfile(int entries, T[] items, long[] counts, long totalCount) { - this.entries = entries; - this.items = items; - this.counts = counts; - this.totalCount = totalCount; - } - } - - private abstract static class AbstractTypeData extends CounterData { - - protected static final int TYPE_DATA_ROW_SIZE = cellsToBytes(config.receiverTypeDataReceiverTypeRowCellCount); - - protected static final int NONPROFILED_COUNT_OFFSET = cellIndexToOffset(config.receiverTypeDataNonprofiledCountOffset); - protected static final int TYPE_DATA_FIRST_TYPE_OFFSET = cellIndexToOffset(config.receiverTypeDataReceiver0Offset); - protected static final int TYPE_DATA_FIRST_TYPE_COUNT_OFFSET = cellIndexToOffset(config.receiverTypeDataCount0Offset); - - protected AbstractTypeData(Tag tag, int staticSize) { - super(tag, staticSize); - } - - @Override - public JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position) { - return createTypeProfile(getNullSeen(data, position), getRawTypeProfile(data, position)); - } - - private RawItemProfile getRawTypeProfile(HotSpotMethodData data, int position) { - int typeProfileWidth = config.typeProfileWidth; - - ResolvedJavaType[] types = new ResolvedJavaType[typeProfileWidth]; - long[] counts = new long[typeProfileWidth]; - long totalCount = 0; - int entries = 0; - - outer: for (int i = 0; i < typeProfileWidth; i++) { - HotSpotResolvedObjectTypeImpl receiverKlass = data.readKlass(position, getTypeOffset(i)); - if (receiverKlass != null) { - HotSpotResolvedObjectTypeImpl klass = receiverKlass; - long count = data.readUnsignedInt(position, getTypeCountOffset(i)); - /* - * Because of races in the profile collection machinery it's possible for a - * class to appear multiple times so merge them to make the profile look - * rational. - */ - for (int j = 0; j < entries; j++) { - if (types[j].equals(klass)) { - totalCount += count; - counts[j] += count; - continue outer; - } - } - types[entries] = klass; - totalCount += count; - counts[entries] = count; - entries++; - } - } - - totalCount += getTypesNotRecordedExecutionCount(data, position); - return new RawItemProfile<>(entries, types, counts, totalCount); - } - - protected abstract long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position); - - private static JavaTypeProfile createTypeProfile(TriState nullSeen, RawItemProfile profile) { - if (profile.entries <= 0 || profile.totalCount <= 0) { - return null; - } - - ProfiledType[] ptypes = new ProfiledType[profile.entries]; - double totalProbability = 0.0; - for (int i = 0; i < profile.entries; i++) { - double p = profile.counts[i]; - p = p / profile.totalCount; - totalProbability += p; - ptypes[i] = new ProfiledType(profile.items[i], p); - } - - Arrays.sort(ptypes); - - double notRecordedTypeProbability = profile.entries < config.typeProfileWidth ? 0.0 : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability)); - assert notRecordedTypeProbability == 0 || profile.entries == config.typeProfileWidth; - return new JavaTypeProfile(nullSeen, notRecordedTypeProbability, ptypes); - } - - private static int getTypeOffset(int row) { - return TYPE_DATA_FIRST_TYPE_OFFSET + row * TYPE_DATA_ROW_SIZE; - } - - protected static int getTypeCountOffset(int row) { - return TYPE_DATA_FIRST_TYPE_COUNT_OFFSET + row * TYPE_DATA_ROW_SIZE; - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - RawItemProfile profile = getRawTypeProfile(data, pos); - TriState nullSeen = getNullSeen(data, pos); - TriState exceptionSeen = getExceptionSeen(data, pos); - sb.append(format("count(%d) null_seen(%s) exception_seen(%s) nonprofiled_count(%d) entries(%d)", getCounterValue(data, pos), nullSeen, exceptionSeen, - getTypesNotRecordedExecutionCount(data, pos), profile.entries)); - for (int i = 0; i < profile.entries; i++) { - long count = profile.counts[i]; - sb.append(format("%n %s (%d, %4.2f)", profile.items[i].toJavaName(), count, (double) count / profile.totalCount)); - } - return sb; - } - } - - private static class ReceiverTypeData extends AbstractTypeData { - - private static final int TYPE_CHECK_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; - - ReceiverTypeData() { - super(Tag.ReceiverTypeData, TYPE_CHECK_DATA_SIZE); - } - - protected ReceiverTypeData(Tag tag, int staticSize) { - super(tag, staticSize); - } - - @Override - public int getExecutionCount(HotSpotMethodData data, int position) { - return -1; - } - - @Override - protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) { - return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET); - } - } - - private static class VirtualCallData extends ReceiverTypeData { - - private static final int VIRTUAL_CALL_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * (config.typeProfileWidth + config.methodProfileWidth); - private static final int VIRTUAL_CALL_DATA_FIRST_METHOD_OFFSET = TYPE_DATA_FIRST_TYPE_OFFSET + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; - private static final int VIRTUAL_CALL_DATA_FIRST_METHOD_COUNT_OFFSET = TYPE_DATA_FIRST_TYPE_COUNT_OFFSET + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; - - VirtualCallData() { - super(Tag.VirtualCallData, VIRTUAL_CALL_DATA_SIZE); - } - - protected VirtualCallData(Tag tag, int staticSize) { - super(tag, staticSize); - } - - @Override - public int getExecutionCount(HotSpotMethodData data, int position) { - final int typeProfileWidth = config.typeProfileWidth; - - long total = 0; - for (int i = 0; i < typeProfileWidth; i++) { - total += data.readUnsignedInt(position, getTypeCountOffset(i)); - } - - total += getCounterValue(data, position); - return truncateLongToInt(total); - } - - @Override - protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) { - return getCounterValue(data, position); - } - - private static long getMethodsNotRecordedExecutionCount(HotSpotMethodData data, int position) { - return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET); - } - - @Override - public JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position) { - return createMethodProfile(getRawMethodProfile(data, position)); - } - - private static RawItemProfile getRawMethodProfile(HotSpotMethodData data, int position) { - int profileWidth = config.methodProfileWidth; - - ResolvedJavaMethod[] methods = new ResolvedJavaMethod[profileWidth]; - long[] counts = new long[profileWidth]; - long totalCount = 0; - int entries = 0; - - for (int i = 0; i < profileWidth; i++) { - HotSpotResolvedJavaMethod method = data.readMethod(position, getMethodOffset(i)); - if (method != null) { - methods[entries] = method; - long count = data.readUnsignedInt(position, getMethodCountOffset(i)); - totalCount += count; - counts[entries] = count; - - entries++; - } - } - - totalCount += getMethodsNotRecordedExecutionCount(data, position); - return new RawItemProfile<>(entries, methods, counts, totalCount); - } - - private static JavaMethodProfile createMethodProfile(RawItemProfile profile) { - if (profile.entries <= 0 || profile.totalCount <= 0) { - return null; - } - - ProfiledMethod[] pmethods = new ProfiledMethod[profile.entries]; - double totalProbability = 0.0; - for (int i = 0; i < profile.entries; i++) { - double p = profile.counts[i]; - p = p / profile.totalCount; - totalProbability += p; - pmethods[i] = new ProfiledMethod(profile.items[i], p); - } - - Arrays.sort(pmethods); - - double notRecordedMethodProbability = profile.entries < config.methodProfileWidth ? 0.0 : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability)); - assert notRecordedMethodProbability == 0 || profile.entries == config.methodProfileWidth; - return new JavaMethodProfile(notRecordedMethodProbability, pmethods); - } - - private static int getMethodOffset(int row) { - return VIRTUAL_CALL_DATA_FIRST_METHOD_OFFSET + row * TYPE_DATA_ROW_SIZE; - } - - private static int getMethodCountOffset(int row) { - return VIRTUAL_CALL_DATA_FIRST_METHOD_COUNT_OFFSET + row * TYPE_DATA_ROW_SIZE; - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - RawItemProfile profile = getRawMethodProfile(data, pos); - super.appendTo(sb.append(format("exception_seen(%s) ", getExceptionSeen(data, pos))), data, pos).append(format("%nmethod_entries(%d)", profile.entries)); - for (int i = 0; i < profile.entries; i++) { - long count = profile.counts[i]; - sb.append(format("%n %s (%d, %4.2f)", profile.items[i].format("%H.%n(%p)"), count, (double) count / profile.totalCount)); - } - return sb; - } - } - - private static class VirtualCallTypeData extends VirtualCallData { - - VirtualCallTypeData() { - super(Tag.VirtualCallTypeData, 0); - } - - @Override - protected int getDynamicSize(HotSpotMethodData data, int position) { - assert staticSize == 0; - return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position); - } - } - - private static class RetData extends CounterData { - - private static final int RET_DATA_ROW_SIZE = cellsToBytes(3); - private static final int RET_DATA_SIZE = cellIndexToOffset(1) + RET_DATA_ROW_SIZE * config.bciProfileWidth; - - RetData() { - super(Tag.RetData, RET_DATA_SIZE); - } - } - - private static class BranchData extends JumpData { - - private static final int BRANCH_DATA_SIZE = cellIndexToOffset(3); - private static final int NOT_TAKEN_COUNT_OFFSET = cellIndexToOffset(config.branchDataNotTakenOffset); - - BranchData() { - super(Tag.BranchData, BRANCH_DATA_SIZE); - } - - @Override - public double getBranchTakenProbability(HotSpotMethodData data, int position) { - long takenCount = data.readUnsignedInt(position, TAKEN_COUNT_OFFSET); - long notTakenCount = data.readUnsignedInt(position, NOT_TAKEN_COUNT_OFFSET); - long total = takenCount + notTakenCount; - - return total <= 0 ? -1 : takenCount / (double) total; - } - - @Override - public int getExecutionCount(HotSpotMethodData data, int position) { - long count = data.readUnsignedInt(position, TAKEN_COUNT_OFFSET) + data.readUnsignedInt(position, NOT_TAKEN_COUNT_OFFSET); - return truncateLongToInt(count); - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - long taken = data.readUnsignedInt(pos, TAKEN_COUNT_OFFSET); - long notTaken = data.readUnsignedInt(pos, NOT_TAKEN_COUNT_OFFSET); - double takenProbability = getBranchTakenProbability(data, pos); - return sb.append(format("taken(%d, %4.2f) not_taken(%d, %4.2f) displacement(%d)", taken, takenProbability, notTaken, 1.0D - takenProbability, getTakenDisplacement(data, pos))); - } - } - - private static class ArrayData extends AbstractMethodData { - - private static final int ARRAY_DATA_LENGTH_OFFSET = cellIndexToOffset(config.arrayDataArrayLenOffset); - protected static final int ARRAY_DATA_START_OFFSET = cellIndexToOffset(config.arrayDataArrayStartOffset); - - ArrayData(Tag tag, int staticSize) { - super(tag, staticSize); - } - - @Override - protected int getDynamicSize(HotSpotMethodData data, int position) { - return cellsToBytes(getLength(data, position)); - } - - protected static int getLength(HotSpotMethodData data, int position) { - return data.readInt(position, ARRAY_DATA_LENGTH_OFFSET); - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return sb.append(format("length(%d)", getLength(data, pos))); - } - } - - private static class MultiBranchData extends ArrayData { - - private static final int MULTI_BRANCH_DATA_SIZE = cellIndexToOffset(1); - private static final int MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS = config.multiBranchDataPerCaseCellCount; - private static final int MULTI_BRANCH_DATA_ROW_SIZE = cellsToBytes(MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS); - private static final int MULTI_BRANCH_DATA_FIRST_COUNT_OFFSET = ARRAY_DATA_START_OFFSET + cellsToBytes(0); - private static final int MULTI_BRANCH_DATA_FIRST_DISPLACEMENT_OFFSET = ARRAY_DATA_START_OFFSET + cellsToBytes(1); - - MultiBranchData() { - super(Tag.MultiBranchData, MULTI_BRANCH_DATA_SIZE); - } - - @Override - public double[] getSwitchProbabilities(HotSpotMethodData data, int position) { - int arrayLength = getLength(data, position); - assert arrayLength > 0 : "switch must have at least the default case"; - assert arrayLength % MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS == 0 : "array must have full rows"; - - int length = arrayLength / MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS; - long totalCount = 0; - double[] result = new double[length]; - - // default case is first in HotSpot but last for the compiler - long count = readCount(data, position, 0); - totalCount += count; - result[length - 1] = count; - - for (int i = 1; i < length; i++) { - count = readCount(data, position, i); - totalCount += count; - result[i - 1] = count; - } - - if (totalCount <= 0) { - return null; - } else { - for (int i = 0; i < length; i++) { - result[i] = result[i] / totalCount; - } - return result; - } - } - - private static long readCount(HotSpotMethodData data, int position, int i) { - int offset; - long count; - offset = getCountOffset(i); - count = data.readUnsignedInt(position, offset); - return count; - } - - @Override - public int getExecutionCount(HotSpotMethodData data, int position) { - int arrayLength = getLength(data, position); - assert arrayLength > 0 : "switch must have at least the default case"; - assert arrayLength % MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS == 0 : "array must have full rows"; - - int length = arrayLength / MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS; - long totalCount = 0; - for (int i = 0; i < length; i++) { - int offset = getCountOffset(i); - totalCount += data.readUnsignedInt(position, offset); - } - - return truncateLongToInt(totalCount); - } - - private static int getCountOffset(int index) { - return MULTI_BRANCH_DATA_FIRST_COUNT_OFFSET + index * MULTI_BRANCH_DATA_ROW_SIZE; - } - - private static int getDisplacementOffset(int index) { - return MULTI_BRANCH_DATA_FIRST_DISPLACEMENT_OFFSET + index * MULTI_BRANCH_DATA_ROW_SIZE; - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - int entries = getLength(data, pos) / MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS; - sb.append(format("entries(%d)", entries)); - for (int i = 0; i < entries; i++) { - sb.append(format("%n %d: count(%d) displacement(%d)", i, data.readUnsignedInt(pos, getCountOffset(i)), data.readUnsignedInt(pos, getDisplacementOffset(i)))); - } - return sb; - } - } - - private static class ArgInfoData extends ArrayData { - - private static final int ARG_INFO_DATA_SIZE = cellIndexToOffset(1); - - ArgInfoData() { - super(Tag.ArgInfoData, ARG_INFO_DATA_SIZE); - } - } - - private static class UnknownProfileData extends AbstractMethodData { - UnknownProfileData(Tag tag) { - super(tag, 0); - } - - @Override - protected int getDynamicSize(HotSpotMethodData data, int position) { - assert staticSize == 0; - return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position); - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - // TODO Auto-generated method stub - return null; - } - } - - public void setCompiledIRSize(int size) { - UNSAFE.putInt(metaspaceMethodData + config.methodDataIRSizeOffset, size); - } - - public int getCompiledIRSize() { - return UNSAFE.getInt(metaspaceMethodData + config.methodDataIRSizeOffset); - } -} --- /dev/null 2016-05-04 09:43:38.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java 2016-05-04 09:43:37.000000000 -1000 @@ -0,0 +1,915 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static java.lang.String.format; +import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; +import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; +import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; + +import java.util.Arrays; + +import jdk.vm.ci.hotspot.HotSpotMethodDataAccessor.Tag; +import jdk.vm.ci.meta.DeoptimizationReason; +import jdk.vm.ci.meta.JavaMethodProfile; +import jdk.vm.ci.meta.JavaMethodProfile.ProfiledMethod; +import jdk.vm.ci.meta.JavaTypeProfile; +import jdk.vm.ci.meta.JavaTypeProfile.ProfiledType; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; +import jdk.vm.ci.meta.TriState; +import jdk.internal.misc.Unsafe; + +/** + * Access to a HotSpot MethodData structure (defined in methodData.hpp). + */ +public final class HotSpotMethodData { + + private static final HotSpotVMConfig config = config(); + private static final HotSpotMethodDataAccessor NO_DATA_NO_EXCEPTION_ACCESSOR = new NoMethodData(TriState.FALSE); + private static final HotSpotMethodDataAccessor NO_DATA_EXCEPTION_POSSIBLY_NOT_RECORDED_ACCESSOR = new NoMethodData(TriState.UNKNOWN); + + // sorted by tag + // @formatter:off + private static final HotSpotMethodDataAccessor[] PROFILE_DATA_ACCESSORS = { + null, + new BitData(), + new CounterData(), + new JumpData(), + new ReceiverTypeData(), + new VirtualCallData(), + new RetData(), + new BranchData(), + new MultiBranchData(), + new ArgInfoData(), + new UnknownProfileData(Tag.CallTypeData), + new VirtualCallTypeData(), + new UnknownProfileData(Tag.ParametersTypeData), + new UnknownProfileData(Tag.SpeculativeTrapData), + }; + // @formatter:on + + /** + * Reference to the C++ MethodData object. + */ + private final long metaspaceMethodData; + @SuppressWarnings("unused") private final HotSpotResolvedJavaMethodImpl method; + + public HotSpotMethodData(long metaspaceMethodData, HotSpotResolvedJavaMethodImpl method) { + this.metaspaceMethodData = metaspaceMethodData; + this.method = method; + } + + /** + * @return value of the MethodData::_data_size field + */ + private int normalDataSize() { + return UNSAFE.getInt(metaspaceMethodData + config.methodDataDataSize); + } + + /** + * Returns the size of the extra data records. This method does the same calculation as + * MethodData::extra_data_size(). + * + * @return size of extra data records + */ + private int extraDataSize() { + final int extraDataBase = config.methodDataOopDataOffset + normalDataSize(); + final int extraDataLimit = UNSAFE.getInt(metaspaceMethodData + config.methodDataSize); + return extraDataLimit - extraDataBase; + } + + public boolean hasNormalData() { + return normalDataSize() > 0; + } + + public boolean hasExtraData() { + return extraDataSize() > 0; + } + + public int getExtraDataBeginOffset() { + return normalDataSize(); + } + + public boolean isWithin(int position) { + return position >= 0 && position < normalDataSize() + extraDataSize(); + } + + public int getDeoptimizationCount(DeoptimizationReason reason) { + HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) runtime().getHostJVMCIBackend().getMetaAccess(); + int reasonIndex = metaAccess.convertDeoptReason(reason); + return UNSAFE.getByte(metaspaceMethodData + config.methodDataOopTrapHistoryOffset + reasonIndex) & 0xFF; + } + + public int getOSRDeoptimizationCount(DeoptimizationReason reason) { + HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) runtime().getHostJVMCIBackend().getMetaAccess(); + int reasonIndex = metaAccess.convertDeoptReason(reason); + return UNSAFE.getByte(metaspaceMethodData + config.methodDataOopTrapHistoryOffset + config.deoptReasonOSROffset + reasonIndex) & 0xFF; + } + + public HotSpotMethodDataAccessor getNormalData(int position) { + if (position >= normalDataSize()) { + return null; + } + + HotSpotMethodDataAccessor result = getData(position); + final Tag tag = AbstractMethodData.readTag(this, position); + assert result != null : "NO_DATA tag is not allowed " + tag; + return result; + } + + public HotSpotMethodDataAccessor getExtraData(int position) { + if (position >= normalDataSize() + extraDataSize()) { + return null; + } + HotSpotMethodDataAccessor data = getData(position); + if (data != null) { + return data; + } + return data; + } + + public static HotSpotMethodDataAccessor getNoDataAccessor(boolean exceptionPossiblyNotRecorded) { + if (exceptionPossiblyNotRecorded) { + return NO_DATA_EXCEPTION_POSSIBLY_NOT_RECORDED_ACCESSOR; + } else { + return NO_DATA_NO_EXCEPTION_ACCESSOR; + } + } + + private HotSpotMethodDataAccessor getData(int position) { + assert position >= 0 : "out of bounds"; + final Tag tag = AbstractMethodData.readTag(this, position); + HotSpotMethodDataAccessor accessor = PROFILE_DATA_ACCESSORS[tag.getValue()]; + assert accessor == null || accessor.getTag() == tag : "wrong data accessor " + accessor + " for tag " + tag; + return accessor; + } + + private int readUnsignedByte(int position, int offsetInBytes) { + long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); + return UNSAFE.getByte(metaspaceMethodData + fullOffsetInBytes) & 0xFF; + } + + private int readUnsignedShort(int position, int offsetInBytes) { + long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); + return UNSAFE.getShort(metaspaceMethodData + fullOffsetInBytes) & 0xFFFF; + } + + /** + * Since the values are stored in cells (platform words) this method uses + * {@link Unsafe#getAddress} to read the right value on both little and big endian machines. + */ + private long readUnsignedInt(int position, int offsetInBytes) { + long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); + return UNSAFE.getAddress(metaspaceMethodData + fullOffsetInBytes) & 0xFFFFFFFFL; + } + + private int readUnsignedIntAsSignedInt(int position, int offsetInBytes) { + long value = readUnsignedInt(position, offsetInBytes); + return truncateLongToInt(value); + } + + /** + * Since the values are stored in cells (platform words) this method uses + * {@link Unsafe#getAddress} to read the right value on both little and big endian machines. + */ + private int readInt(int position, int offsetInBytes) { + long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); + return (int) UNSAFE.getAddress(metaspaceMethodData + fullOffsetInBytes); + } + + private HotSpotResolvedJavaMethod readMethod(int position, int offsetInBytes) { + long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); + return compilerToVM().getResolvedJavaMethod(null, metaspaceMethodData + fullOffsetInBytes); + } + + private HotSpotResolvedObjectTypeImpl readKlass(int position, int offsetInBytes) { + long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); + return compilerToVM().getResolvedJavaType(null, metaspaceMethodData + fullOffsetInBytes, false); + } + + private static int truncateLongToInt(long value) { + return value > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) value; + } + + private static int computeFullOffset(int position, int offsetInBytes) { + return config.methodDataOopDataOffset + position + offsetInBytes; + } + + private static int cellIndexToOffset(int cells) { + return config.dataLayoutHeaderSize + cellsToBytes(cells); + } + + private static int cellsToBytes(int cells) { + return cells * config.dataLayoutCellSize; + } + + /** + * Returns whether profiling ran long enough that the profile information is mature. Other + * informational data will still be valid even if the profile isn't mature. + */ + public boolean isProfileMature() { + return runtime().getCompilerToVM().isMature(metaspaceMethodData); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + String nl = String.format("%n"); + String nlIndent = String.format("%n%38s", ""); + if (hasNormalData()) { + int pos = 0; + HotSpotMethodDataAccessor data; + while ((data = getNormalData(pos)) != null) { + if (pos != 0) { + sb.append(nl); + } + int bci = data.getBCI(this, pos); + sb.append(String.format("%-6d bci: %-6d%-20s", pos, bci, data.getClass().getSimpleName())); + sb.append(data.appendTo(new StringBuilder(), this, pos).toString().replace(nl, nlIndent)); + pos = pos + data.getSize(this, pos); + } + } + + if (hasExtraData()) { + int pos = getExtraDataBeginOffset(); + HotSpotMethodDataAccessor data; + while ((data = getExtraData(pos)) != null) { + if (pos == getExtraDataBeginOffset()) { + sb.append(nl).append("--- Extra data:"); + } + int bci = data.getBCI(this, pos); + sb.append(String.format("%n%-6d bci: %-6d%-20s", pos, bci, data.getClass().getSimpleName())); + sb.append(data.appendTo(new StringBuilder(), this, pos).toString().replace(nl, nlIndent)); + pos = pos + data.getSize(this, pos); + } + + } + return sb.toString(); + } + + private abstract static class AbstractMethodData implements HotSpotMethodDataAccessor { + + /** + * Corresponds to {@code exception_seen_flag}. + */ + private static final int EXCEPTIONS_MASK = 1 << config.bitDataExceptionSeenFlag; + + private final Tag tag; + protected final int staticSize; + + protected AbstractMethodData(Tag tag, int staticSize) { + this.tag = tag; + this.staticSize = staticSize; + } + + public Tag getTag() { + return tag; + } + + public static Tag readTag(HotSpotMethodData data, int position) { + final int tag = data.readUnsignedByte(position, config.dataLayoutTagOffset); + return Tag.getEnum(tag); + } + + @Override + public int getBCI(HotSpotMethodData data, int position) { + return data.readUnsignedShort(position, config.dataLayoutBCIOffset); + } + + @Override + public final int getSize(HotSpotMethodData data, int position) { + int size = staticSize + getDynamicSize(data, position); + // Sanity check against VM + int vmSize = HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position); + assert size == vmSize : size + " != " + vmSize; + return size; + } + + @Override + public TriState getExceptionSeen(HotSpotMethodData data, int position) { + return TriState.get((getFlags(data, position) & EXCEPTIONS_MASK) != 0); + } + + @Override + public JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position) { + return null; + } + + @Override + public JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position) { + return null; + } + + @Override + public double getBranchTakenProbability(HotSpotMethodData data, int position) { + return -1; + } + + @Override + public double[] getSwitchProbabilities(HotSpotMethodData data, int position) { + return null; + } + + @Override + public int getExecutionCount(HotSpotMethodData data, int position) { + return -1; + } + + @Override + public TriState getNullSeen(HotSpotMethodData data, int position) { + return TriState.UNKNOWN; + } + + protected int getFlags(HotSpotMethodData data, int position) { + return data.readUnsignedByte(position, config.dataLayoutFlagsOffset); + } + + /** + * @param data + * @param position + */ + protected int getDynamicSize(HotSpotMethodData data, int position) { + return 0; + } + + public abstract StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos); + } + + private static class NoMethodData extends AbstractMethodData { + + private static final int NO_DATA_SIZE = cellIndexToOffset(0); + + private final TriState exceptionSeen; + + protected NoMethodData(TriState exceptionSeen) { + super(Tag.No, NO_DATA_SIZE); + this.exceptionSeen = exceptionSeen; + } + + @Override + public int getBCI(HotSpotMethodData data, int position) { + return -1; + } + + @Override + public TriState getExceptionSeen(HotSpotMethodData data, int position) { + return exceptionSeen; + } + + @Override + public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { + return sb; + } + } + + private static class BitData extends AbstractMethodData { + + private static final int BIT_DATA_SIZE = cellIndexToOffset(0); + private static final int BIT_DATA_NULL_SEEN_FLAG = 1 << config.bitDataNullSeenFlag; + + private BitData() { + super(Tag.BitData, BIT_DATA_SIZE); + } + + protected BitData(Tag tag, int staticSize) { + super(tag, staticSize); + } + + @Override + public TriState getNullSeen(HotSpotMethodData data, int position) { + return TriState.get((getFlags(data, position) & BIT_DATA_NULL_SEEN_FLAG) != 0); + } + + @Override + public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { + return sb.append(format("exception_seen(%s)", getExceptionSeen(data, pos))); + } + } + + private static class CounterData extends BitData { + + private static final int COUNTER_DATA_SIZE = cellIndexToOffset(1); + private static final int COUNTER_DATA_COUNT_OFFSET = cellIndexToOffset(config.methodDataCountOffset); + + CounterData() { + super(Tag.CounterData, COUNTER_DATA_SIZE); + } + + protected CounterData(Tag tag, int staticSize) { + super(tag, staticSize); + } + + @Override + public int getExecutionCount(HotSpotMethodData data, int position) { + return getCounterValue(data, position); + } + + protected int getCounterValue(HotSpotMethodData data, int position) { + return data.readUnsignedIntAsSignedInt(position, COUNTER_DATA_COUNT_OFFSET); + } + + @Override + public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { + return sb.append(format("count(%d) null_seen(%s) exception_seen(%s)", getCounterValue(data, pos), getNullSeen(data, pos), getExceptionSeen(data, pos))); + } + } + + private static class JumpData extends AbstractMethodData { + + private static final int JUMP_DATA_SIZE = cellIndexToOffset(2); + protected static final int TAKEN_COUNT_OFFSET = cellIndexToOffset(config.jumpDataTakenOffset); + protected static final int TAKEN_DISPLACEMENT_OFFSET = cellIndexToOffset(config.jumpDataDisplacementOffset); + + JumpData() { + super(Tag.JumpData, JUMP_DATA_SIZE); + } + + protected JumpData(Tag tag, int staticSize) { + super(tag, staticSize); + } + + @Override + public double getBranchTakenProbability(HotSpotMethodData data, int position) { + return getExecutionCount(data, position) != 0 ? 1 : 0; + } + + @Override + public int getExecutionCount(HotSpotMethodData data, int position) { + return data.readUnsignedIntAsSignedInt(position, TAKEN_COUNT_OFFSET); + } + + public int getTakenDisplacement(HotSpotMethodData data, int position) { + return data.readInt(position, TAKEN_DISPLACEMENT_OFFSET); + } + + @Override + public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { + return sb.append(format("taken(%d) displacement(%d)", getExecutionCount(data, pos), getTakenDisplacement(data, pos))); + } + } + + static class RawItemProfile { + final int entries; + final T[] items; + final long[] counts; + final long totalCount; + + RawItemProfile(int entries, T[] items, long[] counts, long totalCount) { + this.entries = entries; + this.items = items; + this.counts = counts; + this.totalCount = totalCount; + } + } + + private abstract static class AbstractTypeData extends CounterData { + + protected static final int TYPE_DATA_ROW_SIZE = cellsToBytes(config.receiverTypeDataReceiverTypeRowCellCount); + + protected static final int NONPROFILED_COUNT_OFFSET = cellIndexToOffset(config.receiverTypeDataNonprofiledCountOffset); + protected static final int TYPE_DATA_FIRST_TYPE_OFFSET = cellIndexToOffset(config.receiverTypeDataReceiver0Offset); + protected static final int TYPE_DATA_FIRST_TYPE_COUNT_OFFSET = cellIndexToOffset(config.receiverTypeDataCount0Offset); + + protected AbstractTypeData(Tag tag, int staticSize) { + super(tag, staticSize); + } + + @Override + public JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position) { + return createTypeProfile(getNullSeen(data, position), getRawTypeProfile(data, position)); + } + + private RawItemProfile getRawTypeProfile(HotSpotMethodData data, int position) { + int typeProfileWidth = config.typeProfileWidth; + + ResolvedJavaType[] types = new ResolvedJavaType[typeProfileWidth]; + long[] counts = new long[typeProfileWidth]; + long totalCount = 0; + int entries = 0; + + outer: for (int i = 0; i < typeProfileWidth; i++) { + HotSpotResolvedObjectTypeImpl receiverKlass = data.readKlass(position, getTypeOffset(i)); + if (receiverKlass != null) { + HotSpotResolvedObjectTypeImpl klass = receiverKlass; + long count = data.readUnsignedInt(position, getTypeCountOffset(i)); + /* + * Because of races in the profile collection machinery it's possible for a + * class to appear multiple times so merge them to make the profile look + * rational. + */ + for (int j = 0; j < entries; j++) { + if (types[j].equals(klass)) { + totalCount += count; + counts[j] += count; + continue outer; + } + } + types[entries] = klass; + totalCount += count; + counts[entries] = count; + entries++; + } + } + + totalCount += getTypesNotRecordedExecutionCount(data, position); + return new RawItemProfile<>(entries, types, counts, totalCount); + } + + protected abstract long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position); + + private static JavaTypeProfile createTypeProfile(TriState nullSeen, RawItemProfile profile) { + if (profile.entries <= 0 || profile.totalCount <= 0) { + return null; + } + + ProfiledType[] ptypes = new ProfiledType[profile.entries]; + double totalProbability = 0.0; + for (int i = 0; i < profile.entries; i++) { + double p = profile.counts[i]; + p = p / profile.totalCount; + totalProbability += p; + ptypes[i] = new ProfiledType(profile.items[i], p); + } + + Arrays.sort(ptypes); + + double notRecordedTypeProbability = profile.entries < config.typeProfileWidth ? 0.0 : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability)); + assert notRecordedTypeProbability == 0 || profile.entries == config.typeProfileWidth; + return new JavaTypeProfile(nullSeen, notRecordedTypeProbability, ptypes); + } + + private static int getTypeOffset(int row) { + return TYPE_DATA_FIRST_TYPE_OFFSET + row * TYPE_DATA_ROW_SIZE; + } + + protected static int getTypeCountOffset(int row) { + return TYPE_DATA_FIRST_TYPE_COUNT_OFFSET + row * TYPE_DATA_ROW_SIZE; + } + + @Override + public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { + RawItemProfile profile = getRawTypeProfile(data, pos); + TriState nullSeen = getNullSeen(data, pos); + TriState exceptionSeen = getExceptionSeen(data, pos); + sb.append(format("count(%d) null_seen(%s) exception_seen(%s) nonprofiled_count(%d) entries(%d)", getCounterValue(data, pos), nullSeen, exceptionSeen, + getTypesNotRecordedExecutionCount(data, pos), profile.entries)); + for (int i = 0; i < profile.entries; i++) { + long count = profile.counts[i]; + sb.append(format("%n %s (%d, %4.2f)", profile.items[i].toJavaName(), count, (double) count / profile.totalCount)); + } + return sb; + } + } + + private static class ReceiverTypeData extends AbstractTypeData { + + private static final int TYPE_CHECK_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; + + ReceiverTypeData() { + super(Tag.ReceiverTypeData, TYPE_CHECK_DATA_SIZE); + } + + protected ReceiverTypeData(Tag tag, int staticSize) { + super(tag, staticSize); + } + + @Override + public int getExecutionCount(HotSpotMethodData data, int position) { + return -1; + } + + @Override + protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) { + return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET); + } + } + + private static class VirtualCallData extends ReceiverTypeData { + + private static final int VIRTUAL_CALL_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * (config.typeProfileWidth + config.methodProfileWidth); + private static final int VIRTUAL_CALL_DATA_FIRST_METHOD_OFFSET = TYPE_DATA_FIRST_TYPE_OFFSET + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; + private static final int VIRTUAL_CALL_DATA_FIRST_METHOD_COUNT_OFFSET = TYPE_DATA_FIRST_TYPE_COUNT_OFFSET + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; + + VirtualCallData() { + super(Tag.VirtualCallData, VIRTUAL_CALL_DATA_SIZE); + } + + protected VirtualCallData(Tag tag, int staticSize) { + super(tag, staticSize); + } + + @Override + public int getExecutionCount(HotSpotMethodData data, int position) { + final int typeProfileWidth = config.typeProfileWidth; + + long total = 0; + for (int i = 0; i < typeProfileWidth; i++) { + total += data.readUnsignedInt(position, getTypeCountOffset(i)); + } + + total += getCounterValue(data, position); + return truncateLongToInt(total); + } + + @Override + protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) { + return getCounterValue(data, position); + } + + private static long getMethodsNotRecordedExecutionCount(HotSpotMethodData data, int position) { + return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET); + } + + @Override + public JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position) { + return createMethodProfile(getRawMethodProfile(data, position)); + } + + private static RawItemProfile getRawMethodProfile(HotSpotMethodData data, int position) { + int profileWidth = config.methodProfileWidth; + + ResolvedJavaMethod[] methods = new ResolvedJavaMethod[profileWidth]; + long[] counts = new long[profileWidth]; + long totalCount = 0; + int entries = 0; + + for (int i = 0; i < profileWidth; i++) { + HotSpotResolvedJavaMethod method = data.readMethod(position, getMethodOffset(i)); + if (method != null) { + methods[entries] = method; + long count = data.readUnsignedInt(position, getMethodCountOffset(i)); + totalCount += count; + counts[entries] = count; + + entries++; + } + } + + totalCount += getMethodsNotRecordedExecutionCount(data, position); + return new RawItemProfile<>(entries, methods, counts, totalCount); + } + + private static JavaMethodProfile createMethodProfile(RawItemProfile profile) { + if (profile.entries <= 0 || profile.totalCount <= 0) { + return null; + } + + ProfiledMethod[] pmethods = new ProfiledMethod[profile.entries]; + double totalProbability = 0.0; + for (int i = 0; i < profile.entries; i++) { + double p = profile.counts[i]; + p = p / profile.totalCount; + totalProbability += p; + pmethods[i] = new ProfiledMethod(profile.items[i], p); + } + + Arrays.sort(pmethods); + + double notRecordedMethodProbability = profile.entries < config.methodProfileWidth ? 0.0 : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability)); + assert notRecordedMethodProbability == 0 || profile.entries == config.methodProfileWidth; + return new JavaMethodProfile(notRecordedMethodProbability, pmethods); + } + + private static int getMethodOffset(int row) { + return VIRTUAL_CALL_DATA_FIRST_METHOD_OFFSET + row * TYPE_DATA_ROW_SIZE; + } + + private static int getMethodCountOffset(int row) { + return VIRTUAL_CALL_DATA_FIRST_METHOD_COUNT_OFFSET + row * TYPE_DATA_ROW_SIZE; + } + + @Override + public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { + RawItemProfile profile = getRawMethodProfile(data, pos); + super.appendTo(sb.append(format("exception_seen(%s) ", getExceptionSeen(data, pos))), data, pos).append(format("%nmethod_entries(%d)", profile.entries)); + for (int i = 0; i < profile.entries; i++) { + long count = profile.counts[i]; + sb.append(format("%n %s (%d, %4.2f)", profile.items[i].format("%H.%n(%p)"), count, (double) count / profile.totalCount)); + } + return sb; + } + } + + private static class VirtualCallTypeData extends VirtualCallData { + + VirtualCallTypeData() { + super(Tag.VirtualCallTypeData, 0); + } + + @Override + protected int getDynamicSize(HotSpotMethodData data, int position) { + assert staticSize == 0; + return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position); + } + } + + private static class RetData extends CounterData { + + private static final int RET_DATA_ROW_SIZE = cellsToBytes(3); + private static final int RET_DATA_SIZE = cellIndexToOffset(1) + RET_DATA_ROW_SIZE * config.bciProfileWidth; + + RetData() { + super(Tag.RetData, RET_DATA_SIZE); + } + } + + private static class BranchData extends JumpData { + + private static final int BRANCH_DATA_SIZE = cellIndexToOffset(3); + private static final int NOT_TAKEN_COUNT_OFFSET = cellIndexToOffset(config.branchDataNotTakenOffset); + + BranchData() { + super(Tag.BranchData, BRANCH_DATA_SIZE); + } + + @Override + public double getBranchTakenProbability(HotSpotMethodData data, int position) { + long takenCount = data.readUnsignedInt(position, TAKEN_COUNT_OFFSET); + long notTakenCount = data.readUnsignedInt(position, NOT_TAKEN_COUNT_OFFSET); + long total = takenCount + notTakenCount; + + return total <= 0 ? -1 : takenCount / (double) total; + } + + @Override + public int getExecutionCount(HotSpotMethodData data, int position) { + long count = data.readUnsignedInt(position, TAKEN_COUNT_OFFSET) + data.readUnsignedInt(position, NOT_TAKEN_COUNT_OFFSET); + return truncateLongToInt(count); + } + + @Override + public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { + long taken = data.readUnsignedInt(pos, TAKEN_COUNT_OFFSET); + long notTaken = data.readUnsignedInt(pos, NOT_TAKEN_COUNT_OFFSET); + double takenProbability = getBranchTakenProbability(data, pos); + return sb.append(format("taken(%d, %4.2f) not_taken(%d, %4.2f) displacement(%d)", taken, takenProbability, notTaken, 1.0D - takenProbability, getTakenDisplacement(data, pos))); + } + } + + private static class ArrayData extends AbstractMethodData { + + private static final int ARRAY_DATA_LENGTH_OFFSET = cellIndexToOffset(config.arrayDataArrayLenOffset); + protected static final int ARRAY_DATA_START_OFFSET = cellIndexToOffset(config.arrayDataArrayStartOffset); + + ArrayData(Tag tag, int staticSize) { + super(tag, staticSize); + } + + @Override + protected int getDynamicSize(HotSpotMethodData data, int position) { + return cellsToBytes(getLength(data, position)); + } + + protected static int getLength(HotSpotMethodData data, int position) { + return data.readInt(position, ARRAY_DATA_LENGTH_OFFSET); + } + + @Override + public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { + return sb.append(format("length(%d)", getLength(data, pos))); + } + } + + private static class MultiBranchData extends ArrayData { + + private static final int MULTI_BRANCH_DATA_SIZE = cellIndexToOffset(1); + private static final int MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS = config.multiBranchDataPerCaseCellCount; + private static final int MULTI_BRANCH_DATA_ROW_SIZE = cellsToBytes(MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS); + private static final int MULTI_BRANCH_DATA_FIRST_COUNT_OFFSET = ARRAY_DATA_START_OFFSET + cellsToBytes(0); + private static final int MULTI_BRANCH_DATA_FIRST_DISPLACEMENT_OFFSET = ARRAY_DATA_START_OFFSET + cellsToBytes(1); + + MultiBranchData() { + super(Tag.MultiBranchData, MULTI_BRANCH_DATA_SIZE); + } + + @Override + public double[] getSwitchProbabilities(HotSpotMethodData data, int position) { + int arrayLength = getLength(data, position); + assert arrayLength > 0 : "switch must have at least the default case"; + assert arrayLength % MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS == 0 : "array must have full rows"; + + int length = arrayLength / MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS; + long totalCount = 0; + double[] result = new double[length]; + + // default case is first in HotSpot but last for the compiler + long count = readCount(data, position, 0); + totalCount += count; + result[length - 1] = count; + + for (int i = 1; i < length; i++) { + count = readCount(data, position, i); + totalCount += count; + result[i - 1] = count; + } + + if (totalCount <= 0) { + return null; + } else { + for (int i = 0; i < length; i++) { + result[i] = result[i] / totalCount; + } + return result; + } + } + + private static long readCount(HotSpotMethodData data, int position, int i) { + int offset; + long count; + offset = getCountOffset(i); + count = data.readUnsignedInt(position, offset); + return count; + } + + @Override + public int getExecutionCount(HotSpotMethodData data, int position) { + int arrayLength = getLength(data, position); + assert arrayLength > 0 : "switch must have at least the default case"; + assert arrayLength % MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS == 0 : "array must have full rows"; + + int length = arrayLength / MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS; + long totalCount = 0; + for (int i = 0; i < length; i++) { + int offset = getCountOffset(i); + totalCount += data.readUnsignedInt(position, offset); + } + + return truncateLongToInt(totalCount); + } + + private static int getCountOffset(int index) { + return MULTI_BRANCH_DATA_FIRST_COUNT_OFFSET + index * MULTI_BRANCH_DATA_ROW_SIZE; + } + + private static int getDisplacementOffset(int index) { + return MULTI_BRANCH_DATA_FIRST_DISPLACEMENT_OFFSET + index * MULTI_BRANCH_DATA_ROW_SIZE; + } + + @Override + public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { + int entries = getLength(data, pos) / MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS; + sb.append(format("entries(%d)", entries)); + for (int i = 0; i < entries; i++) { + sb.append(format("%n %d: count(%d) displacement(%d)", i, data.readUnsignedInt(pos, getCountOffset(i)), data.readUnsignedInt(pos, getDisplacementOffset(i)))); + } + return sb; + } + } + + private static class ArgInfoData extends ArrayData { + + private static final int ARG_INFO_DATA_SIZE = cellIndexToOffset(1); + + ArgInfoData() { + super(Tag.ArgInfoData, ARG_INFO_DATA_SIZE); + } + } + + private static class UnknownProfileData extends AbstractMethodData { + UnknownProfileData(Tag tag) { + super(tag, 0); + } + + @Override + protected int getDynamicSize(HotSpotMethodData data, int position) { + assert staticSize == 0; + return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position); + } + + @Override + public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { + // TODO Auto-generated method stub + return null; + } + } + + public void setCompiledIRSize(int size) { + UNSAFE.putInt(metaspaceMethodData + config.methodDataIRSizeOffset, size); + } + + public int getCompiledIRSize() { + return UNSAFE.getInt(metaspaceMethodData + config.methodDataIRSizeOffset); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodDataAccessor.java 2016-05-04 09:43:38.000000000 -1000 +++ /dev/null 2016-05-04 09:43:38.000000000 -1000 @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; -import jdk.vm.ci.meta.JavaMethodProfile; -import jdk.vm.ci.meta.JavaTypeProfile; -import jdk.vm.ci.meta.ProfilingInfo; -import jdk.vm.ci.meta.TriState; - -/** - * Interface for accessor objects that encapsulate the logic for accessing the different kinds of - * data in a HotSpot methodDataOop. This interface is similar to the interface {@link ProfilingInfo} - * , but most methods require a MethodDataObject and the exact position within the methodData. - */ -public interface HotSpotMethodDataAccessor { - - /** - * {@code DataLayout} tag values. - */ - enum Tag { - No(config().dataLayoutNoTag), - BitData(config().dataLayoutBitDataTag), - CounterData(config().dataLayoutCounterDataTag), - JumpData(config().dataLayoutJumpDataTag), - ReceiverTypeData(config().dataLayoutReceiverTypeDataTag), - VirtualCallData(config().dataLayoutVirtualCallDataTag), - RetData(config().dataLayoutRetDataTag), - BranchData(config().dataLayoutBranchDataTag), - MultiBranchData(config().dataLayoutMultiBranchDataTag), - ArgInfoData(config().dataLayoutArgInfoDataTag), - CallTypeData(config().dataLayoutCallTypeDataTag), - VirtualCallTypeData(config().dataLayoutVirtualCallTypeDataTag), - ParametersTypeData(config().dataLayoutParametersTypeDataTag), - SpeculativeTrapData(config().dataLayoutSpeculativeTrapDataTag); - - private final int value; - - Tag(int value) { - this.value = value; - } - - public int getValue() { - return value; - } - - public static Tag getEnum(int value) { - Tag result = values()[value]; - assert value == result.value; - return result; - } - } - - /** - * Returns the {@link Tag} stored in the LayoutData header. - * - * @return tag stored in the LayoutData header - */ - Tag getTag(); - - /** - * Returns the BCI stored in the LayoutData header. - * - * @return An integer ≥ 0 and ≤ Short.MAX_VALUE, or -1 if not supported. - */ - int getBCI(HotSpotMethodData data, int position); - - /** - * Computes the size for the specific data at the given position. - * - * @return An integer > 0. - */ - int getSize(HotSpotMethodData data, int position); - - JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position); - - JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position); - - double getBranchTakenProbability(HotSpotMethodData data, int position); - - double[] getSwitchProbabilities(HotSpotMethodData data, int position); - - TriState getExceptionSeen(HotSpotMethodData data, int position); - - TriState getNullSeen(HotSpotMethodData data, int position); - - int getExecutionCount(HotSpotMethodData data, int position); - - StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos); -} --- /dev/null 2016-05-04 09:43:38.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodDataAccessor.java 2016-05-04 09:43:38.000000000 -1000 @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; +import jdk.vm.ci.meta.JavaMethodProfile; +import jdk.vm.ci.meta.JavaTypeProfile; +import jdk.vm.ci.meta.ProfilingInfo; +import jdk.vm.ci.meta.TriState; + +/** + * Interface for accessor objects that encapsulate the logic for accessing the different kinds of + * data in a HotSpot methodDataOop. This interface is similar to the interface {@link ProfilingInfo} + * , but most methods require a MethodDataObject and the exact position within the methodData. + */ +public interface HotSpotMethodDataAccessor { + + /** + * {@code DataLayout} tag values. + */ + enum Tag { + No(config().dataLayoutNoTag), + BitData(config().dataLayoutBitDataTag), + CounterData(config().dataLayoutCounterDataTag), + JumpData(config().dataLayoutJumpDataTag), + ReceiverTypeData(config().dataLayoutReceiverTypeDataTag), + VirtualCallData(config().dataLayoutVirtualCallDataTag), + RetData(config().dataLayoutRetDataTag), + BranchData(config().dataLayoutBranchDataTag), + MultiBranchData(config().dataLayoutMultiBranchDataTag), + ArgInfoData(config().dataLayoutArgInfoDataTag), + CallTypeData(config().dataLayoutCallTypeDataTag), + VirtualCallTypeData(config().dataLayoutVirtualCallTypeDataTag), + ParametersTypeData(config().dataLayoutParametersTypeDataTag), + SpeculativeTrapData(config().dataLayoutSpeculativeTrapDataTag); + + private final int value; + + Tag(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + public static Tag getEnum(int value) { + Tag result = values()[value]; + assert value == result.value; + return result; + } + } + + /** + * Returns the {@link Tag} stored in the LayoutData header. + * + * @return tag stored in the LayoutData header + */ + Tag getTag(); + + /** + * Returns the BCI stored in the LayoutData header. + * + * @return An integer ≥ 0 and ≤ Short.MAX_VALUE, or -1 if not supported. + */ + int getBCI(HotSpotMethodData data, int position); + + /** + * Computes the size for the specific data at the given position. + * + * @return An integer > 0. + */ + int getSize(HotSpotMethodData data, int position); + + JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position); + + JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position); + + double getBranchTakenProbability(HotSpotMethodData data, int position); + + double[] getSwitchProbabilities(HotSpotMethodData data, int position); + + TriState getExceptionSeen(HotSpotMethodData data, int position); + + TriState getNullSeen(HotSpotMethodData data, int position); + + int getExecutionCount(HotSpotMethodData data, int position); + + StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos); +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java 2016-05-04 09:43:38.000000000 -1000 +++ /dev/null 2016-05-04 09:43:38.000000000 -1000 @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.fromObjectClass; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.MethodHandleAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; - -public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider, HotSpotProxified { - - private final ConstantReflectionProvider constantReflection; - - public HotSpotMethodHandleAccessProvider(ConstantReflectionProvider constantReflection) { - this.constantReflection = constantReflection; - } - - /** - * Lazy initialization to break class initialization cycle. Field and method lookup is only - * possible after the {@link HotSpotJVMCIRuntime} is fully initialized. - */ - static class LazyInitialization { - static final ResolvedJavaField methodHandleFormField; - static final ResolvedJavaField lambdaFormVmentryField; - static final ResolvedJavaMethod lambdaFormCompileToBytecodeMethod; - static final HotSpotResolvedJavaField memberNameVmtargetField; - - /** - * Search for an instance field with the given name in a class. - * - * @param className name of the class to search in - * @param fieldName name of the field to be searched - * @return resolved java field - * @throws ClassNotFoundException - */ - private static ResolvedJavaField findFieldInClass(String className, String fieldName) throws ClassNotFoundException { - Class clazz = Class.forName(className); - ResolvedJavaType type = runtime().fromClass(clazz); - ResolvedJavaField[] fields = type.getInstanceFields(false); - for (ResolvedJavaField field : fields) { - if (field.getName().equals(fieldName)) { - return field; - } - } - return null; - } - - private static ResolvedJavaMethod findMethodInClass(String className, String methodName) throws ClassNotFoundException { - Class clazz = Class.forName(className); - HotSpotResolvedObjectTypeImpl type = fromObjectClass(clazz); - ResolvedJavaMethod result = null; - for (ResolvedJavaMethod method : type.getDeclaredMethods()) { - if (method.getName().equals(methodName)) { - assert result == null : "more than one method found: " + className + "." + methodName; - result = method; - } - } - assert result != null : "method not found: " + className + "." + methodName; - return result; - } - - static { - try { - methodHandleFormField = findFieldInClass("java.lang.invoke.MethodHandle", "form"); - lambdaFormVmentryField = findFieldInClass("java.lang.invoke.LambdaForm", "vmentry"); - lambdaFormCompileToBytecodeMethod = findMethodInClass("java.lang.invoke.LambdaForm", "compileToBytecode"); - memberNameVmtargetField = (HotSpotResolvedJavaField) findFieldInClass("java.lang.invoke.MemberName", "vmtarget"); - } catch (Throwable ex) { - throw new JVMCIError(ex); - } - } - } - - @Override - public IntrinsicMethod lookupMethodHandleIntrinsic(ResolvedJavaMethod method) { - int intrinsicId = ((HotSpotResolvedJavaMethodImpl) method).intrinsicId(); - if (intrinsicId != 0) { - return getMethodHandleIntrinsic(intrinsicId); - } - return null; - } - - public static IntrinsicMethod getMethodHandleIntrinsic(int intrinsicId) { - HotSpotVMConfig config = runtime().getConfig(); - if (intrinsicId == config.vmIntrinsicInvokeBasic) { - return IntrinsicMethod.INVOKE_BASIC; - } else if (intrinsicId == config.vmIntrinsicLinkToInterface) { - return IntrinsicMethod.LINK_TO_INTERFACE; - } else if (intrinsicId == config.vmIntrinsicLinkToSpecial) { - return IntrinsicMethod.LINK_TO_SPECIAL; - } else if (intrinsicId == config.vmIntrinsicLinkToStatic) { - return IntrinsicMethod.LINK_TO_STATIC; - } else if (intrinsicId == config.vmIntrinsicLinkToVirtual) { - return IntrinsicMethod.LINK_TO_VIRTUAL; - } - return null; - } - - @Override - public ResolvedJavaMethod resolveInvokeBasicTarget(JavaConstant methodHandle, boolean forceBytecodeGeneration) { - if (methodHandle.isNull()) { - return null; - } - - /* Load non-public field: LambdaForm MethodHandle.form */ - JavaConstant lambdaForm = constantReflection.readFieldValue(LazyInitialization.methodHandleFormField, methodHandle); - if (lambdaForm == null || lambdaForm.isNull()) { - return null; - } - - JavaConstant memberName; - if (forceBytecodeGeneration) { - /* Invoke non-public method: MemberName LambdaForm.compileToBytecode() */ - memberName = LazyInitialization.lambdaFormCompileToBytecodeMethod.invoke(lambdaForm, new JavaConstant[0]); - } else { - /* Load non-public field: MemberName LambdaForm.vmentry */ - memberName = constantReflection.readFieldValue(LazyInitialization.lambdaFormVmentryField, lambdaForm); - } - return getTargetMethod(memberName); - } - - @Override - public ResolvedJavaMethod resolveLinkToTarget(JavaConstant memberName) { - return getTargetMethod(memberName); - } - - /** - * Returns the {@link ResolvedJavaMethod} for the vmtarget of a java.lang.invoke.MemberName. - */ - private static ResolvedJavaMethod getTargetMethod(JavaConstant memberName) { - if (memberName.isNull()) { - return null; - } - - Object object = ((HotSpotObjectConstantImpl) memberName).object(); - /* Read the ResolvedJavaMethod from the injected field MemberName.vmtarget */ - return compilerToVM().getResolvedJavaMethod(object, LazyInitialization.memberNameVmtargetField.offset()); - } -} --- /dev/null 2016-05-04 09:43:38.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java 2016-05-04 09:43:38.000000000 -1000 @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; +import static jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.fromObjectClass; +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.meta.ConstantReflectionProvider; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.MethodHandleAccessProvider; +import jdk.vm.ci.meta.ResolvedJavaField; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; + +public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider, HotSpotProxified { + + private final ConstantReflectionProvider constantReflection; + + public HotSpotMethodHandleAccessProvider(ConstantReflectionProvider constantReflection) { + this.constantReflection = constantReflection; + } + + /** + * Lazy initialization to break class initialization cycle. Field and method lookup is only + * possible after the {@link HotSpotJVMCIRuntime} is fully initialized. + */ + static class LazyInitialization { + static final ResolvedJavaField methodHandleFormField; + static final ResolvedJavaField lambdaFormVmentryField; + static final ResolvedJavaMethod lambdaFormCompileToBytecodeMethod; + static final HotSpotResolvedJavaField memberNameVmtargetField; + + /** + * Search for an instance field with the given name in a class. + * + * @param className name of the class to search in + * @param fieldName name of the field to be searched + * @return resolved java field + * @throws ClassNotFoundException + */ + private static ResolvedJavaField findFieldInClass(String className, String fieldName) throws ClassNotFoundException { + Class clazz = Class.forName(className); + ResolvedJavaType type = runtime().fromClass(clazz); + ResolvedJavaField[] fields = type.getInstanceFields(false); + for (ResolvedJavaField field : fields) { + if (field.getName().equals(fieldName)) { + return field; + } + } + return null; + } + + private static ResolvedJavaMethod findMethodInClass(String className, String methodName) throws ClassNotFoundException { + Class clazz = Class.forName(className); + HotSpotResolvedObjectTypeImpl type = fromObjectClass(clazz); + ResolvedJavaMethod result = null; + for (ResolvedJavaMethod method : type.getDeclaredMethods()) { + if (method.getName().equals(methodName)) { + assert result == null : "more than one method found: " + className + "." + methodName; + result = method; + } + } + assert result != null : "method not found: " + className + "." + methodName; + return result; + } + + static { + try { + methodHandleFormField = findFieldInClass("java.lang.invoke.MethodHandle", "form"); + lambdaFormVmentryField = findFieldInClass("java.lang.invoke.LambdaForm", "vmentry"); + lambdaFormCompileToBytecodeMethod = findMethodInClass("java.lang.invoke.LambdaForm", "compileToBytecode"); + memberNameVmtargetField = (HotSpotResolvedJavaField) findFieldInClass("java.lang.invoke.MemberName", "vmtarget"); + } catch (Throwable ex) { + throw new JVMCIError(ex); + } + } + } + + @Override + public IntrinsicMethod lookupMethodHandleIntrinsic(ResolvedJavaMethod method) { + int intrinsicId = ((HotSpotResolvedJavaMethodImpl) method).intrinsicId(); + if (intrinsicId != 0) { + return getMethodHandleIntrinsic(intrinsicId); + } + return null; + } + + public static IntrinsicMethod getMethodHandleIntrinsic(int intrinsicId) { + HotSpotVMConfig config = runtime().getConfig(); + if (intrinsicId == config.vmIntrinsicInvokeBasic) { + return IntrinsicMethod.INVOKE_BASIC; + } else if (intrinsicId == config.vmIntrinsicLinkToInterface) { + return IntrinsicMethod.LINK_TO_INTERFACE; + } else if (intrinsicId == config.vmIntrinsicLinkToSpecial) { + return IntrinsicMethod.LINK_TO_SPECIAL; + } else if (intrinsicId == config.vmIntrinsicLinkToStatic) { + return IntrinsicMethod.LINK_TO_STATIC; + } else if (intrinsicId == config.vmIntrinsicLinkToVirtual) { + return IntrinsicMethod.LINK_TO_VIRTUAL; + } + return null; + } + + @Override + public ResolvedJavaMethod resolveInvokeBasicTarget(JavaConstant methodHandle, boolean forceBytecodeGeneration) { + if (methodHandle.isNull()) { + return null; + } + + /* Load non-public field: LambdaForm MethodHandle.form */ + JavaConstant lambdaForm = constantReflection.readFieldValue(LazyInitialization.methodHandleFormField, methodHandle); + if (lambdaForm == null || lambdaForm.isNull()) { + return null; + } + + JavaConstant memberName; + if (forceBytecodeGeneration) { + /* Invoke non-public method: MemberName LambdaForm.compileToBytecode() */ + memberName = LazyInitialization.lambdaFormCompileToBytecodeMethod.invoke(lambdaForm, new JavaConstant[0]); + } else { + /* Load non-public field: MemberName LambdaForm.vmentry */ + memberName = constantReflection.readFieldValue(LazyInitialization.lambdaFormVmentryField, lambdaForm); + } + return getTargetMethod(memberName); + } + + @Override + public ResolvedJavaMethod resolveLinkToTarget(JavaConstant memberName) { + return getTargetMethod(memberName); + } + + /** + * Returns the {@link ResolvedJavaMethod} for the vmtarget of a java.lang.invoke.MemberName. + */ + private static ResolvedJavaMethod getTargetMethod(JavaConstant memberName) { + if (memberName.isNull()) { + return null; + } + + Object object = ((HotSpotObjectConstantImpl) memberName).object(); + /* Read the ResolvedJavaMethod from the injected field MemberName.vmtarget */ + return compilerToVM().getResolvedJavaMethod(object, LazyInitialization.memberNameVmtargetField.offset()); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodUnresolved.java 2016-05-04 09:43:39.000000000 -1000 +++ /dev/null 2016-05-04 09:43:39.000000000 -1000 @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.JavaMethod; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.Signature; - -/** - * Implementation of {@link JavaMethod} for unresolved HotSpot methods. - */ -final class HotSpotMethodUnresolved extends HotSpotMethod { - - private final Signature signature; - protected JavaType holder; - - HotSpotMethodUnresolved(String name, Signature signature, JavaType holder) { - super(name); - this.holder = holder; - this.signature = signature; - } - - @Override - public Signature getSignature() { - return signature; - } - - @Override - public JavaType getDeclaringClass() { - return holder; - } - - @Override - public int hashCode() { - return super.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || !(obj instanceof HotSpotMethodUnresolved)) { - return false; - } - HotSpotMethodUnresolved that = (HotSpotMethodUnresolved) obj; - return this.name.equals(that.name) && this.signature.equals(that.signature) && this.holder.equals(that.holder); - } -} --- /dev/null 2016-05-04 09:43:39.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodUnresolved.java 2016-05-04 09:43:39.000000000 -1000 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.JavaMethod; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.Signature; + +/** + * Implementation of {@link JavaMethod} for unresolved HotSpot methods. + */ +final class HotSpotMethodUnresolved extends HotSpotMethod { + + private final Signature signature; + protected JavaType holder; + + HotSpotMethodUnresolved(String name, Signature signature, JavaType holder) { + super(name); + this.holder = holder; + this.signature = signature; + } + + @Override + public Signature getSignature() { + return signature; + } + + @Override + public JavaType getDeclaringClass() { + return holder; + } + + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || !(obj instanceof HotSpotMethodUnresolved)) { + return false; + } + HotSpotMethodUnresolved that = (HotSpotMethodUnresolved) obj; + return this.name.equals(that.name) && this.signature.equals(that.signature) && this.holder.equals(that.holder); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotNmethod.java 2016-05-04 09:43:39.000000000 -1000 +++ /dev/null 2016-05-04 09:43:39.000000000 -1000 @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.code.InvalidInstalledCodeException; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -/** - * Implementation of {@link InstalledCode} for code installed as an nmethod. The nmethod stores a - * weak reference to an instance of this class. This is necessary to keep the nmethod from being - * unloaded while the associated {@link HotSpotNmethod} instance is alive. - *

- * Note that there is no (current) way for the reference from an nmethod to a {@link HotSpotNmethod} - * instance to be anything but weak. This is due to the fact that HotSpot does not treat nmethods as - * strong GC roots. - */ -public class HotSpotNmethod extends HotSpotInstalledCode { - - /** - * This (indirect) Method* reference is safe since class redefinition preserves all methods - * associated with nmethods in the code cache. - */ - private final HotSpotResolvedJavaMethod method; - - private final boolean isDefault; - - public HotSpotNmethod(HotSpotResolvedJavaMethod method, String name, boolean isDefault) { - super(name); - this.method = method; - this.isDefault = isDefault; - } - - public boolean isDefault() { - return isDefault; - } - - public ResolvedJavaMethod getMethod() { - return method; - } - - @Override - public void invalidate() { - compilerToVM().invalidateInstalledCode(this); - } - - @Override - public String toString() { - return String.format("InstalledNmethod[method=%s, codeBlob=0x%x, isDefault=%b, name=%s]", method, getAddress(), isDefault, name); - } - - protected boolean checkThreeObjectArgs() { - assert method.getSignature().getParameterCount(!method.isStatic()) == 3; - assert method.getSignature().getParameterKind(0) == JavaKind.Object; - assert method.getSignature().getParameterKind(1) == JavaKind.Object; - assert !method.isStatic() || method.getSignature().getParameterKind(2) == JavaKind.Object; - return true; - } - - private boolean checkArgs(Object... args) { - JavaType[] sig = method.toParameterTypes(); - assert args.length == sig.length : method.format("%H.%n(%p): expected ") + sig.length + " args, got " + args.length; - for (int i = 0; i < sig.length; i++) { - Object arg = args[i]; - if (arg == null) { - assert sig[i].getJavaKind() == JavaKind.Object : method.format("%H.%n(%p): expected arg ") + i + " to be Object, not " + sig[i]; - } else if (sig[i].getJavaKind() != JavaKind.Object) { - assert sig[i].getJavaKind().toBoxedJavaClass() == arg.getClass() : method.format("%H.%n(%p): expected arg ") + i + " to be " + sig[i] + ", not " + arg.getClass(); - } - } - return true; - } - - @Override - public Object executeVarargs(Object... args) throws InvalidInstalledCodeException { - assert checkArgs(args); - return compilerToVM().executeInstalledCode(args, this); - } - - @Override - public long getStart() { - return isValid() ? super.getStart() : 0; - } -} --- /dev/null 2016-05-04 09:43:39.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotNmethod.java 2016-05-04 09:43:39.000000000 -1000 @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; +import jdk.vm.ci.code.InstalledCode; +import jdk.vm.ci.code.InvalidInstalledCodeException; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.ResolvedJavaMethod; + +/** + * Implementation of {@link InstalledCode} for code installed as an nmethod. The nmethod stores a + * weak reference to an instance of this class. This is necessary to keep the nmethod from being + * unloaded while the associated {@link HotSpotNmethod} instance is alive. + *

+ * Note that there is no (current) way for the reference from an nmethod to a {@link HotSpotNmethod} + * instance to be anything but weak. This is due to the fact that HotSpot does not treat nmethods as + * strong GC roots. + */ +public class HotSpotNmethod extends HotSpotInstalledCode { + + /** + * This (indirect) Method* reference is safe since class redefinition preserves all methods + * associated with nmethods in the code cache. + */ + private final HotSpotResolvedJavaMethod method; + + private final boolean isDefault; + + public HotSpotNmethod(HotSpotResolvedJavaMethod method, String name, boolean isDefault) { + super(name); + this.method = method; + this.isDefault = isDefault; + } + + public boolean isDefault() { + return isDefault; + } + + public ResolvedJavaMethod getMethod() { + return method; + } + + @Override + public void invalidate() { + compilerToVM().invalidateInstalledCode(this); + } + + @Override + public String toString() { + return String.format("InstalledNmethod[method=%s, codeBlob=0x%x, isDefault=%b, name=%s]", method, getAddress(), isDefault, name); + } + + protected boolean checkThreeObjectArgs() { + assert method.getSignature().getParameterCount(!method.isStatic()) == 3; + assert method.getSignature().getParameterKind(0) == JavaKind.Object; + assert method.getSignature().getParameterKind(1) == JavaKind.Object; + assert !method.isStatic() || method.getSignature().getParameterKind(2) == JavaKind.Object; + return true; + } + + private boolean checkArgs(Object... args) { + JavaType[] sig = method.toParameterTypes(); + assert args.length == sig.length : method.format("%H.%n(%p): expected ") + sig.length + " args, got " + args.length; + for (int i = 0; i < sig.length; i++) { + Object arg = args[i]; + if (arg == null) { + assert sig[i].getJavaKind() == JavaKind.Object : method.format("%H.%n(%p): expected arg ") + i + " to be Object, not " + sig[i]; + } else if (sig[i].getJavaKind() != JavaKind.Object) { + assert sig[i].getJavaKind().toBoxedJavaClass() == arg.getClass() : method.format("%H.%n(%p): expected arg ") + i + " to be " + sig[i] + ", not " + arg.getClass(); + } + } + return true; + } + + @Override + public Object executeVarargs(Object... args) throws InvalidInstalledCodeException { + assert checkArgs(args); + return compilerToVM().executeInstalledCode(args, this); + } + + @Override + public long getStart() { + return isValid() ? super.getStart() : 0; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotObjectConstant.java 2016-05-04 09:43:40.000000000 -1000 +++ /dev/null 2016-05-04 09:43:40.000000000 -1000 @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.lang.invoke.CallSite; -import java.util.Objects; - -import jdk.vm.ci.meta.Assumptions; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.VMConstant; - -/** - * Represents a constant non-{@code null} object reference, within the compiler and across the - * compiler/runtime interface. - */ -public interface HotSpotObjectConstant extends JavaConstant, HotSpotConstant, VMConstant { - - JavaConstant compress(); - - JavaConstant uncompress(); - - /** - * Gets the resolved Java type of the object represented by this constant. - */ - HotSpotResolvedObjectType getType(); - - /** - * Gets the result of {@link Class#getClassLoader()} for the {@link Class} object represented by - * this constant. - * - * @return {@code null} if this constant does not represent a {@link Class} object - */ - JavaConstant getClassLoader(); - - /** - * Gets the {@linkplain System#identityHashCode(Object) identity} has code for the object - * represented by this constant. - */ - int getIdentityHashCode(); - - /** - * Gets the result of {@link Class#getComponentType()} for the {@link Class} object represented - * by this constant. - * - * @return {@code null} if this constant does not represent a {@link Class} object - */ - JavaConstant getComponentType(); - - /** - * Gets the result of {@link Class#getSuperclass()} for the {@link Class} object represented by - * this constant. - * - * @return {@code null} if this constant does not represent a {@link Class} object - */ - JavaConstant getSuperclass(); - - /** - * Gets the result of {@link CallSite#getTarget()} for the {@link CallSite} object represented - * by this constant. - * - * @param assumptions used to register an assumption that the {@link CallSite}'s target does not - * change - * @return {@code null} if this constant does not represent a {@link CallSite} object - */ - JavaConstant getCallSiteTarget(Assumptions assumptions); - - /** - * Determines if this constant represents an {@linkplain String#intern() interned} string. - */ - boolean isInternedString(); - - /** - * Gets the object represented by this constant represents if it is of a given type. - * - * @param type the expected type of the object represented by this constant. If the object is - * required to be of this type, then wrap the call to this method in - * {@link Objects#requireNonNull(Object)}. - * @return the object value represented by this constant if it is an - * {@link ResolvedJavaType#isInstance(JavaConstant) instance of} {@code type} otherwise - * {@code null} - */ - T asObject(Class type); - - /** - * Gets the object represented by this constant represents if it is of a given type. - * - * @param type the expected type of the object represented by this constant. If the object is - * required to be of this type, then wrap the call to this method in - * {@link Objects#requireNonNull(Object)}. - * @return the object value represented by this constant if it is an - * {@link ResolvedJavaType#isInstance(JavaConstant) instance of} {@code type} otherwise - * {@code null} - */ - Object asObject(ResolvedJavaType type); -} --- /dev/null 2016-05-04 09:43:40.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotObjectConstant.java 2016-05-04 09:43:40.000000000 -1000 @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import java.lang.invoke.CallSite; +import java.util.Objects; + +import jdk.vm.ci.meta.Assumptions; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.ResolvedJavaType; +import jdk.vm.ci.meta.VMConstant; + +/** + * Represents a constant non-{@code null} object reference, within the compiler and across the + * compiler/runtime interface. + */ +public interface HotSpotObjectConstant extends JavaConstant, HotSpotConstant, VMConstant { + + JavaConstant compress(); + + JavaConstant uncompress(); + + /** + * Gets the resolved Java type of the object represented by this constant. + */ + HotSpotResolvedObjectType getType(); + + /** + * Gets the result of {@link Class#getClassLoader()} for the {@link Class} object represented by + * this constant. + * + * @return {@code null} if this constant does not represent a {@link Class} object + */ + JavaConstant getClassLoader(); + + /** + * Gets the {@linkplain System#identityHashCode(Object) identity} has code for the object + * represented by this constant. + */ + int getIdentityHashCode(); + + /** + * Gets the result of {@link Class#getComponentType()} for the {@link Class} object represented + * by this constant. + * + * @return {@code null} if this constant does not represent a {@link Class} object + */ + JavaConstant getComponentType(); + + /** + * Gets the result of {@link Class#getSuperclass()} for the {@link Class} object represented by + * this constant. + * + * @return {@code null} if this constant does not represent a {@link Class} object + */ + JavaConstant getSuperclass(); + + /** + * Gets the result of {@link CallSite#getTarget()} for the {@link CallSite} object represented + * by this constant. + * + * @param assumptions used to register an assumption that the {@link CallSite}'s target does not + * change + * @return {@code null} if this constant does not represent a {@link CallSite} object + */ + JavaConstant getCallSiteTarget(Assumptions assumptions); + + /** + * Determines if this constant represents an {@linkplain String#intern() interned} string. + */ + boolean isInternedString(); + + /** + * Gets the object represented by this constant represents if it is of a given type. + * + * @param type the expected type of the object represented by this constant. If the object is + * required to be of this type, then wrap the call to this method in + * {@link Objects#requireNonNull(Object)}. + * @return the object value represented by this constant if it is an + * {@link ResolvedJavaType#isInstance(JavaConstant) instance of} {@code type} otherwise + * {@code null} + */ + T asObject(Class type); + + /** + * Gets the object represented by this constant represents if it is of a given type. + * + * @param type the expected type of the object represented by this constant. If the object is + * required to be of this type, then wrap the call to this method in + * {@link Objects#requireNonNull(Object)}. + * @return the object value represented by this constant if it is an + * {@link ResolvedJavaType#isInstance(JavaConstant) instance of} {@code type} otherwise + * {@code null} + */ + Object asObject(ResolvedJavaType type); +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java 2016-05-04 09:43:40.000000000 -1000 +++ /dev/null 2016-05-04 09:43:40.000000000 -1000 @@ -1,284 +0,0 @@ -/* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.fromObjectClass; - -import java.lang.invoke.CallSite; -import java.lang.invoke.ConstantCallSite; -import java.lang.invoke.MethodHandle; - -import jdk.vm.ci.inittimer.SuppressFBWarnings; -import jdk.vm.ci.meta.Assumptions; -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Represents a constant non-{@code null} object reference, within the compiler and across the - * compiler/runtime interface. - */ -final class HotSpotObjectConstantImpl implements HotSpotObjectConstant, HotSpotProxified { - - static JavaConstant forObject(Object object) { - return forObject(object, false); - } - - static JavaConstant forObject(Object object, boolean compressed) { - if (object == null) { - return compressed ? HotSpotCompressedNullConstant.COMPRESSED_NULL : JavaConstant.NULL_POINTER; - } else { - return new HotSpotObjectConstantImpl(object, compressed); - } - } - - static JavaConstant forStableArray(Object object, int stableDimension, boolean isDefaultStable) { - if (object == null) { - return JavaConstant.NULL_POINTER; - } else { - assert object.getClass().isArray(); - return new HotSpotObjectConstantImpl(object, false, stableDimension, isDefaultStable); - } - } - - public static JavaConstant forBoxedValue(JavaKind kind, Object value) { - if (kind == JavaKind.Object) { - return HotSpotObjectConstantImpl.forObject(value); - } else { - return JavaConstant.forBoxedPrimitive(value); - } - } - - static Object asBoxedValue(Constant constant) { - if (JavaConstant.isNull(constant)) { - return null; - } else if (constant instanceof HotSpotObjectConstantImpl) { - return ((HotSpotObjectConstantImpl) constant).object; - } else { - return ((JavaConstant) constant).asBoxedPrimitive(); - } - } - - private final Object object; - private final boolean compressed; - private final byte stableDimension; - private final boolean isDefaultStable; - - private HotSpotObjectConstantImpl(Object object, boolean compressed, int stableDimension, boolean isDefaultStable) { - this.object = object; - this.compressed = compressed; - this.stableDimension = (byte) stableDimension; - this.isDefaultStable = isDefaultStable; - assert object != null; - assert stableDimension == 0 || (object != null && object.getClass().isArray()); - assert stableDimension >= 0 && stableDimension <= 255; - assert !isDefaultStable || stableDimension > 0; - } - - private HotSpotObjectConstantImpl(Object object, boolean compressed) { - this(object, compressed, 0, false); - } - - @Override - public JavaKind getJavaKind() { - return JavaKind.Object; - } - - /** - * Package-private accessor for the object represented by this constant. - */ - Object object() { - return object; - } - - public boolean isCompressed() { - return compressed; - } - - public JavaConstant compress() { - assert !compressed; - return new HotSpotObjectConstantImpl(object, true, stableDimension, isDefaultStable); - } - - public JavaConstant uncompress() { - assert compressed; - return new HotSpotObjectConstantImpl(object, false, stableDimension, isDefaultStable); - } - - public HotSpotResolvedObjectType getType() { - return fromObjectClass(object.getClass()); - } - - public JavaConstant getClassLoader() { - if (object instanceof Class) { - /* - * This is an intrinsic for getClassLoader0, which occurs after any security checks. We - * can't call that directly so just call getClassLoader. - */ - return HotSpotObjectConstantImpl.forObject(((Class) object).getClassLoader()); - } - return null; - } - - public int getIdentityHashCode() { - return System.identityHashCode(object); - } - - public JavaConstant getComponentType() { - if (object instanceof Class) { - return HotSpotObjectConstantImpl.forObject(((Class) object).getComponentType()); - } - return null; - } - - public JavaConstant getSuperclass() { - if (object instanceof Class) { - return HotSpotObjectConstantImpl.forObject(((Class) object).getSuperclass()); - } - return null; - } - - public JavaConstant getCallSiteTarget(Assumptions assumptions) { - if (object instanceof CallSite) { - CallSite callSite = (CallSite) object; - MethodHandle target = callSite.getTarget(); - if (!(callSite instanceof ConstantCallSite)) { - if (assumptions == null) { - return null; - } - assumptions.record(new Assumptions.CallSiteTargetValue(callSite, target)); - } - return HotSpotObjectConstantImpl.forObject(target); - } - return null; - } - - @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "reference equality is what we want") - public boolean isInternedString() { - if (object instanceof String) { - String s = (String) object; - return s.intern() == s; - } - return false; - } - - public T asObject(Class type) { - if (type.isInstance(object)) { - return type.cast(object); - } - return null; - } - - public Object asObject(ResolvedJavaType type) { - if (type.isInstance(this)) { - return object; - } - return null; - } - - @Override - public boolean isNull() { - return false; - } - - @Override - public boolean isDefaultForKind() { - return false; - } - - @Override - public Object asBoxedPrimitive() { - throw new IllegalArgumentException(); - } - - @Override - public int asInt() { - throw new IllegalArgumentException(); - } - - @Override - public boolean asBoolean() { - throw new IllegalArgumentException(); - } - - @Override - public long asLong() { - throw new IllegalArgumentException(); - } - - @Override - public float asFloat() { - throw new IllegalArgumentException(); - } - - @Override - public double asDouble() { - throw new IllegalArgumentException(); - } - - @Override - public int hashCode() { - return System.identityHashCode(object); - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } else if (o instanceof HotSpotObjectConstantImpl) { - HotSpotObjectConstantImpl other = (HotSpotObjectConstantImpl) o; - return object == other.object && compressed == other.compressed && stableDimension == other.stableDimension && isDefaultStable == other.isDefaultStable; - } - return false; - } - - @Override - public String toValueString() { - if (object instanceof String) { - return "\"" + (String) object + "\""; - } else { - return JavaKind.Object.format(object); - } - } - - @Override - public String toString() { - return (compressed ? "NarrowOop" : getJavaKind().getJavaName()) + "[" + JavaKind.Object.format(object) + "]"; - } - - /** - * Number of stable dimensions if this constant is a stable array. - */ - public int getStableDimension() { - return stableDimension & 0xff; - } - - /** - * Returns {@code true} if this is a stable array constant and its elements should be considered - * as stable regardless of whether they are default values. - */ - public boolean isDefaultStable() { - return isDefaultStable; - } -} --- /dev/null 2016-05-04 09:43:40.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java 2016-05-04 09:43:40.000000000 -1000 @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.fromObjectClass; + +import java.lang.invoke.CallSite; +import java.lang.invoke.ConstantCallSite; +import java.lang.invoke.MethodHandle; + +import jdk.vm.ci.inittimer.SuppressFBWarnings; +import jdk.vm.ci.meta.Assumptions; +import jdk.vm.ci.meta.Constant; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.ResolvedJavaType; + +/** + * Represents a constant non-{@code null} object reference, within the compiler and across the + * compiler/runtime interface. + */ +final class HotSpotObjectConstantImpl implements HotSpotObjectConstant, HotSpotProxified { + + static JavaConstant forObject(Object object) { + return forObject(object, false); + } + + static JavaConstant forObject(Object object, boolean compressed) { + if (object == null) { + return compressed ? HotSpotCompressedNullConstant.COMPRESSED_NULL : JavaConstant.NULL_POINTER; + } else { + return new HotSpotObjectConstantImpl(object, compressed); + } + } + + static JavaConstant forStableArray(Object object, int stableDimension, boolean isDefaultStable) { + if (object == null) { + return JavaConstant.NULL_POINTER; + } else { + assert object.getClass().isArray(); + return new HotSpotObjectConstantImpl(object, false, stableDimension, isDefaultStable); + } + } + + public static JavaConstant forBoxedValue(JavaKind kind, Object value) { + if (kind == JavaKind.Object) { + return HotSpotObjectConstantImpl.forObject(value); + } else { + return JavaConstant.forBoxedPrimitive(value); + } + } + + static Object asBoxedValue(Constant constant) { + if (JavaConstant.isNull(constant)) { + return null; + } else if (constant instanceof HotSpotObjectConstantImpl) { + return ((HotSpotObjectConstantImpl) constant).object; + } else { + return ((JavaConstant) constant).asBoxedPrimitive(); + } + } + + private final Object object; + private final boolean compressed; + private final byte stableDimension; + private final boolean isDefaultStable; + + private HotSpotObjectConstantImpl(Object object, boolean compressed, int stableDimension, boolean isDefaultStable) { + this.object = object; + this.compressed = compressed; + this.stableDimension = (byte) stableDimension; + this.isDefaultStable = isDefaultStable; + assert object != null; + assert stableDimension == 0 || (object != null && object.getClass().isArray()); + assert stableDimension >= 0 && stableDimension <= 255; + assert !isDefaultStable || stableDimension > 0; + } + + private HotSpotObjectConstantImpl(Object object, boolean compressed) { + this(object, compressed, 0, false); + } + + @Override + public JavaKind getJavaKind() { + return JavaKind.Object; + } + + /** + * Package-private accessor for the object represented by this constant. + */ + Object object() { + return object; + } + + public boolean isCompressed() { + return compressed; + } + + public JavaConstant compress() { + assert !compressed; + return new HotSpotObjectConstantImpl(object, true, stableDimension, isDefaultStable); + } + + public JavaConstant uncompress() { + assert compressed; + return new HotSpotObjectConstantImpl(object, false, stableDimension, isDefaultStable); + } + + public HotSpotResolvedObjectType getType() { + return fromObjectClass(object.getClass()); + } + + public JavaConstant getClassLoader() { + if (object instanceof Class) { + /* + * This is an intrinsic for getClassLoader0, which occurs after any security checks. We + * can't call that directly so just call getClassLoader. + */ + return HotSpotObjectConstantImpl.forObject(((Class) object).getClassLoader()); + } + return null; + } + + public int getIdentityHashCode() { + return System.identityHashCode(object); + } + + public JavaConstant getComponentType() { + if (object instanceof Class) { + return HotSpotObjectConstantImpl.forObject(((Class) object).getComponentType()); + } + return null; + } + + public JavaConstant getSuperclass() { + if (object instanceof Class) { + return HotSpotObjectConstantImpl.forObject(((Class) object).getSuperclass()); + } + return null; + } + + public JavaConstant getCallSiteTarget(Assumptions assumptions) { + if (object instanceof CallSite) { + CallSite callSite = (CallSite) object; + MethodHandle target = callSite.getTarget(); + if (!(callSite instanceof ConstantCallSite)) { + if (assumptions == null) { + return null; + } + assumptions.record(new Assumptions.CallSiteTargetValue(callSite, target)); + } + return HotSpotObjectConstantImpl.forObject(target); + } + return null; + } + + @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "reference equality is what we want") + public boolean isInternedString() { + if (object instanceof String) { + String s = (String) object; + return s.intern() == s; + } + return false; + } + + public T asObject(Class type) { + if (type.isInstance(object)) { + return type.cast(object); + } + return null; + } + + public Object asObject(ResolvedJavaType type) { + if (type.isInstance(this)) { + return object; + } + return null; + } + + @Override + public boolean isNull() { + return false; + } + + @Override + public boolean isDefaultForKind() { + return false; + } + + @Override + public Object asBoxedPrimitive() { + throw new IllegalArgumentException(); + } + + @Override + public int asInt() { + throw new IllegalArgumentException(); + } + + @Override + public boolean asBoolean() { + throw new IllegalArgumentException(); + } + + @Override + public long asLong() { + throw new IllegalArgumentException(); + } + + @Override + public float asFloat() { + throw new IllegalArgumentException(); + } + + @Override + public double asDouble() { + throw new IllegalArgumentException(); + } + + @Override + public int hashCode() { + return System.identityHashCode(object); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } else if (o instanceof HotSpotObjectConstantImpl) { + HotSpotObjectConstantImpl other = (HotSpotObjectConstantImpl) o; + return object == other.object && compressed == other.compressed && stableDimension == other.stableDimension && isDefaultStable == other.isDefaultStable; + } + return false; + } + + @Override + public String toValueString() { + if (object instanceof String) { + return "\"" + (String) object + "\""; + } else { + return JavaKind.Object.format(object); + } + } + + @Override + public String toString() { + return (compressed ? "NarrowOop" : getJavaKind().getJavaName()) + "[" + JavaKind.Object.format(object) + "]"; + } + + /** + * Number of stable dimensions if this constant is a stable array. + */ + public int getStableDimension() { + return stableDimension & 0xff; + } + + /** + * Returns {@code true} if this is a stable array constant and its elements should be considered + * as stable regardless of whether they are default values. + */ + public boolean isDefaultStable() { + return isDefaultStable; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotOopMap.java 2016-05-04 09:43:41.000000000 -1000 +++ /dev/null 2016-05-04 09:43:41.000000000 -1000 @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.inittimer.SuppressFBWarnings; - -public class HotSpotOopMap { - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private int offset; - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private int count; - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private byte[] data; - - public byte[] data() { - return data; - } - - public int count() { - return count; - } - - public int offset() { - return offset; - } -} --- /dev/null 2016-05-04 09:43:41.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotOopMap.java 2016-05-04 09:43:40.000000000 -1000 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.inittimer.SuppressFBWarnings; + +public class HotSpotOopMap { + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private int offset; + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private int count; + @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private byte[] data; + + public byte[] data() { + return data; + } + + public int count() { + return count; + } + + public int offset() { + return offset; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java 2016-05-04 09:43:41.000000000 -1000 +++ /dev/null 2016-05-04 09:43:41.000000000 -1000 @@ -1,241 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.DeoptimizationReason; -import jdk.vm.ci.meta.JavaMethodProfile; -import jdk.vm.ci.meta.JavaTypeProfile; -import jdk.vm.ci.meta.ProfilingInfo; -import jdk.vm.ci.meta.TriState; - -public final class HotSpotProfilingInfo implements ProfilingInfo, HotSpotProxified { - - // private static final DebugMetric metricInsufficentSpace = - // Debug.metric("InsufficientSpaceForProfilingData"); - - private final HotSpotMethodData methodData; - private final HotSpotResolvedJavaMethod method; - - private boolean isMature; - private int position; - private int hintPosition; - private int hintBCI; - private HotSpotMethodDataAccessor dataAccessor; - - private boolean includeNormal; - private boolean includeOSR; - - public HotSpotProfilingInfo(HotSpotMethodData methodData, HotSpotResolvedJavaMethod method, boolean includeNormal, boolean includeOSR) { - this.methodData = methodData; - this.method = method; - this.includeNormal = includeNormal; - this.includeOSR = includeOSR; - this.isMature = methodData.isProfileMature(); - hintPosition = 0; - hintBCI = -1; - } - - @Override - public int getCodeSize() { - return method.getCodeSize(); - } - - @Override - public JavaTypeProfile getTypeProfile(int bci) { - if (!isMature) { - return null; - } - findBCI(bci, false); - return dataAccessor.getTypeProfile(methodData, position); - } - - @Override - public JavaMethodProfile getMethodProfile(int bci) { - if (!isMature) { - return null; - } - findBCI(bci, false); - return dataAccessor.getMethodProfile(methodData, position); - } - - @Override - public double getBranchTakenProbability(int bci) { - if (!isMature) { - return -1; - } - findBCI(bci, false); - return dataAccessor.getBranchTakenProbability(methodData, position); - } - - @Override - public double[] getSwitchProbabilities(int bci) { - if (!isMature) { - return null; - } - findBCI(bci, false); - return dataAccessor.getSwitchProbabilities(methodData, position); - } - - @Override - public TriState getExceptionSeen(int bci) { - findBCI(bci, true); - return dataAccessor.getExceptionSeen(methodData, position); - } - - @Override - public TriState getNullSeen(int bci) { - findBCI(bci, false); - return dataAccessor.getNullSeen(methodData, position); - } - - @Override - public int getExecutionCount(int bci) { - if (!isMature) { - return -1; - } - findBCI(bci, false); - return dataAccessor.getExecutionCount(methodData, position); - } - - @Override - public int getDeoptimizationCount(DeoptimizationReason reason) { - int count = 0; - if (includeNormal) { - count += methodData.getDeoptimizationCount(reason); - } - if (includeOSR) { - count += methodData.getOSRDeoptimizationCount(reason); - } - return count; - } - - private void findBCI(int targetBCI, boolean searchExtraData) { - assert targetBCI >= 0 : "invalid BCI"; - - if (methodData.hasNormalData()) { - int currentPosition = targetBCI < hintBCI ? 0 : hintPosition; - HotSpotMethodDataAccessor currentAccessor; - while ((currentAccessor = methodData.getNormalData(currentPosition)) != null) { - int currentBCI = currentAccessor.getBCI(methodData, currentPosition); - if (currentBCI == targetBCI) { - normalDataFound(currentAccessor, currentPosition, currentBCI); - return; - } else if (currentBCI > targetBCI) { - break; - } - currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition); - } - } - - boolean exceptionPossiblyNotRecorded = false; - if (searchExtraData && methodData.hasExtraData()) { - int currentPosition = methodData.getExtraDataBeginOffset(); - HotSpotMethodDataAccessor currentAccessor; - while ((currentAccessor = methodData.getExtraData(currentPosition)) != null) { - int currentBCI = currentAccessor.getBCI(methodData, currentPosition); - if (currentBCI == targetBCI) { - extraDataFound(currentAccessor, currentPosition); - return; - } - currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition); - } - - if (!methodData.isWithin(currentPosition)) { - exceptionPossiblyNotRecorded = true; - // metricInsufficentSpace.increment(); - } - } - - noDataFound(exceptionPossiblyNotRecorded); - } - - private void normalDataFound(HotSpotMethodDataAccessor data, int pos, int bci) { - setCurrentData(data, pos); - this.hintPosition = position; - this.hintBCI = bci; - } - - private void extraDataFound(HotSpotMethodDataAccessor data, int pos) { - setCurrentData(data, pos); - } - - private void noDataFound(boolean exceptionPossiblyNotRecorded) { - HotSpotMethodDataAccessor accessor = HotSpotMethodData.getNoDataAccessor(exceptionPossiblyNotRecorded); - setCurrentData(accessor, -1); - } - - private void setCurrentData(HotSpotMethodDataAccessor dataAccessor, int position) { - this.dataAccessor = dataAccessor; - this.position = position; - } - - @Override - public boolean isMature() { - return isMature; - } - - public void ignoreMature() { - isMature = true; - } - - @Override - public String toString() { - return "HotSpotProfilingInfo<" + this.toString(null, "; ") + ">"; - } - - @Override - public void setMature() { - isMature = true; - } - - /** - * {@code MethodData::_jvmci_ir_size} (currently) supports at most one JVMCI compiler IR type - * which will be determined by the first JVMCI compiler that calls - * {@link #setCompilerIRSize(Class, int)}. - */ - private static volatile Class supportedCompilerIRType; - - @Override - public boolean setCompilerIRSize(Class irType, int size) { - if (supportedCompilerIRType == null) { - synchronized (HotSpotProfilingInfo.class) { - if (supportedCompilerIRType == null) { - supportedCompilerIRType = irType; - } - } - } - if (supportedCompilerIRType != irType) { - return false; - } - methodData.setCompiledIRSize(size); - return true; - } - - @Override - public int getCompilerIRSize(Class irType) { - if (irType == supportedCompilerIRType) { - return methodData.getCompiledIRSize(); - } - return -1; - } -} --- /dev/null 2016-05-04 09:43:41.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java 2016-05-04 09:43:41.000000000 -1000 @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.DeoptimizationReason; +import jdk.vm.ci.meta.JavaMethodProfile; +import jdk.vm.ci.meta.JavaTypeProfile; +import jdk.vm.ci.meta.ProfilingInfo; +import jdk.vm.ci.meta.TriState; + +public final class HotSpotProfilingInfo implements ProfilingInfo, HotSpotProxified { + + // private static final DebugMetric metricInsufficentSpace = + // Debug.metric("InsufficientSpaceForProfilingData"); + + private final HotSpotMethodData methodData; + private final HotSpotResolvedJavaMethod method; + + private boolean isMature; + private int position; + private int hintPosition; + private int hintBCI; + private HotSpotMethodDataAccessor dataAccessor; + + private boolean includeNormal; + private boolean includeOSR; + + public HotSpotProfilingInfo(HotSpotMethodData methodData, HotSpotResolvedJavaMethod method, boolean includeNormal, boolean includeOSR) { + this.methodData = methodData; + this.method = method; + this.includeNormal = includeNormal; + this.includeOSR = includeOSR; + this.isMature = methodData.isProfileMature(); + hintPosition = 0; + hintBCI = -1; + } + + @Override + public int getCodeSize() { + return method.getCodeSize(); + } + + @Override + public JavaTypeProfile getTypeProfile(int bci) { + if (!isMature) { + return null; + } + findBCI(bci, false); + return dataAccessor.getTypeProfile(methodData, position); + } + + @Override + public JavaMethodProfile getMethodProfile(int bci) { + if (!isMature) { + return null; + } + findBCI(bci, false); + return dataAccessor.getMethodProfile(methodData, position); + } + + @Override + public double getBranchTakenProbability(int bci) { + if (!isMature) { + return -1; + } + findBCI(bci, false); + return dataAccessor.getBranchTakenProbability(methodData, position); + } + + @Override + public double[] getSwitchProbabilities(int bci) { + if (!isMature) { + return null; + } + findBCI(bci, false); + return dataAccessor.getSwitchProbabilities(methodData, position); + } + + @Override + public TriState getExceptionSeen(int bci) { + findBCI(bci, true); + return dataAccessor.getExceptionSeen(methodData, position); + } + + @Override + public TriState getNullSeen(int bci) { + findBCI(bci, false); + return dataAccessor.getNullSeen(methodData, position); + } + + @Override + public int getExecutionCount(int bci) { + if (!isMature) { + return -1; + } + findBCI(bci, false); + return dataAccessor.getExecutionCount(methodData, position); + } + + @Override + public int getDeoptimizationCount(DeoptimizationReason reason) { + int count = 0; + if (includeNormal) { + count += methodData.getDeoptimizationCount(reason); + } + if (includeOSR) { + count += methodData.getOSRDeoptimizationCount(reason); + } + return count; + } + + private void findBCI(int targetBCI, boolean searchExtraData) { + assert targetBCI >= 0 : "invalid BCI"; + + if (methodData.hasNormalData()) { + int currentPosition = targetBCI < hintBCI ? 0 : hintPosition; + HotSpotMethodDataAccessor currentAccessor; + while ((currentAccessor = methodData.getNormalData(currentPosition)) != null) { + int currentBCI = currentAccessor.getBCI(methodData, currentPosition); + if (currentBCI == targetBCI) { + normalDataFound(currentAccessor, currentPosition, currentBCI); + return; + } else if (currentBCI > targetBCI) { + break; + } + currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition); + } + } + + boolean exceptionPossiblyNotRecorded = false; + if (searchExtraData && methodData.hasExtraData()) { + int currentPosition = methodData.getExtraDataBeginOffset(); + HotSpotMethodDataAccessor currentAccessor; + while ((currentAccessor = methodData.getExtraData(currentPosition)) != null) { + int currentBCI = currentAccessor.getBCI(methodData, currentPosition); + if (currentBCI == targetBCI) { + extraDataFound(currentAccessor, currentPosition); + return; + } + currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition); + } + + if (!methodData.isWithin(currentPosition)) { + exceptionPossiblyNotRecorded = true; + // metricInsufficentSpace.increment(); + } + } + + noDataFound(exceptionPossiblyNotRecorded); + } + + private void normalDataFound(HotSpotMethodDataAccessor data, int pos, int bci) { + setCurrentData(data, pos); + this.hintPosition = position; + this.hintBCI = bci; + } + + private void extraDataFound(HotSpotMethodDataAccessor data, int pos) { + setCurrentData(data, pos); + } + + private void noDataFound(boolean exceptionPossiblyNotRecorded) { + HotSpotMethodDataAccessor accessor = HotSpotMethodData.getNoDataAccessor(exceptionPossiblyNotRecorded); + setCurrentData(accessor, -1); + } + + private void setCurrentData(HotSpotMethodDataAccessor dataAccessor, int position) { + this.dataAccessor = dataAccessor; + this.position = position; + } + + @Override + public boolean isMature() { + return isMature; + } + + public void ignoreMature() { + isMature = true; + } + + @Override + public String toString() { + return "HotSpotProfilingInfo<" + this.toString(null, "; ") + ">"; + } + + @Override + public void setMature() { + isMature = true; + } + + /** + * {@code MethodData::_jvmci_ir_size} (currently) supports at most one JVMCI compiler IR type + * which will be determined by the first JVMCI compiler that calls + * {@link #setCompilerIRSize(Class, int)}. + */ + private static volatile Class supportedCompilerIRType; + + @Override + public boolean setCompilerIRSize(Class irType, int size) { + if (supportedCompilerIRType == null) { + synchronized (HotSpotProfilingInfo.class) { + if (supportedCompilerIRType == null) { + supportedCompilerIRType = irType; + } + } + } + if (supportedCompilerIRType != irType) { + return false; + } + methodData.setCompiledIRSize(size); + return true; + } + + @Override + public int getCompilerIRSize(Class irType) { + if (irType == supportedCompilerIRType) { + return methodData.getCompiledIRSize(); + } + return -1; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotProxified.java 2016-05-04 09:43:42.000000000 -1000 +++ /dev/null 2016-05-04 09:43:42.000000000 -1000 @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -/** - * Marker interface for classes whose values are proxied during replay compilation capture. - */ -public interface HotSpotProxified { -} --- /dev/null 2016-05-04 09:43:42.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotProxified.java 2016-05-04 09:43:41.000000000 -1000 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +/** + * Marker interface for classes whose values are proxied during replay compilation capture. + */ +public interface HotSpotProxified { +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotReferenceMap.java 2016-05-04 09:43:42.000000000 -1000 +++ /dev/null 2016-05-04 09:43:42.000000000 -1000 @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.Arrays; - -import jdk.vm.ci.code.Location; -import jdk.vm.ci.code.ReferenceMap; - -public final class HotSpotReferenceMap extends ReferenceMap { - - final Location[] objects; - final Location[] derivedBase; - final int[] sizeInBytes; - final int maxRegisterSize; - - public HotSpotReferenceMap(Location[] objects, Location[] derivedBase, int[] sizeInBytes, int maxRegisterSize) { - this.objects = objects; - this.derivedBase = derivedBase; - this.sizeInBytes = sizeInBytes; - this.maxRegisterSize = maxRegisterSize; - } - - @Override - public int hashCode() { - throw new UnsupportedOperationException(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof HotSpotReferenceMap) { - HotSpotReferenceMap that = (HotSpotReferenceMap) obj; - if (Arrays.equals(objects, that.objects)) { - return true; - } - } - return false; - } - - @Override - public String toString() { - return Arrays.toString(objects); - } -} --- /dev/null 2016-05-04 09:43:42.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotReferenceMap.java 2016-05-04 09:43:42.000000000 -1000 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import java.util.Arrays; + +import jdk.vm.ci.code.Location; +import jdk.vm.ci.code.ReferenceMap; + +public final class HotSpotReferenceMap extends ReferenceMap { + + final Location[] objects; + final Location[] derivedBase; + final int[] sizeInBytes; + final int maxRegisterSize; + + public HotSpotReferenceMap(Location[] objects, Location[] derivedBase, int[] sizeInBytes, int maxRegisterSize) { + this.objects = objects; + this.derivedBase = derivedBase; + this.sizeInBytes = sizeInBytes; + this.maxRegisterSize = maxRegisterSize; + } + + @Override + public int hashCode() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof HotSpotReferenceMap) { + HotSpotReferenceMap that = (HotSpotReferenceMap) obj; + if (Arrays.equals(objects, that.objects)) { + return true; + } + } + return false; + } + + @Override + public String toString() { + return Arrays.toString(objects); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaField.java 2016-05-04 09:43:42.000000000 -1000 +++ /dev/null 2016-05-04 09:43:43.000000000 -1000 @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.ResolvedJavaField; - -/** - * Represents a field in a HotSpot type. - */ -public interface HotSpotResolvedJavaField extends ResolvedJavaField { - - /** - * Determines if a given object contains this field. - * - * @return true iff this is a non-static field and its declaring class is assignable from - * {@code object}'s class - */ - boolean isInObject(Object object); - - int offset(); - - /** - * Determines if this field should be treated as a constant. - */ - boolean isStable(); - - /** - * Determines if this field should be considered constant if it has the default value for its - * type (e.g, 0, null, etc.). The result of this method is undefined if this field is not - * {@linkplain #isStable() stable}. - */ - boolean isDefaultStable(); -} --- /dev/null 2016-05-04 09:43:43.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaField.java 2016-05-04 09:43:42.000000000 -1000 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.ResolvedJavaField; + +/** + * Represents a field in a HotSpot type. + */ +public interface HotSpotResolvedJavaField extends ResolvedJavaField { + + /** + * Determines if a given object contains this field. + * + * @return true iff this is a non-static field and its declaring class is assignable from + * {@code object}'s class + */ + boolean isInObject(Object object); + + int offset(); + + /** + * Determines if this field should be treated as a constant. + */ + boolean isStable(); + + /** + * Determines if this field should be considered constant if it has the default value for its + * type (e.g, 0, null, etc.). The result of this method is undefined if this field is not + * {@linkplain #isStable() stable}. + */ + boolean isDefaultStable(); +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java 2016-05-04 09:43:43.000000000 -1000 +++ /dev/null 2016-05-04 09:43:43.000000000 -1000 @@ -1,302 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.LocationIdentity; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ModifiersProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Represents a field in a HotSpot type. - */ -class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField, HotSpotProxified { - - private final HotSpotResolvedObjectTypeImpl holder; - private final String name; - private JavaType type; - private final int offset; - - /** - * This value contains all flags as stored in the VM including internal ones. - */ - private final int modifiers; - private final LocationIdentity locationIdentity = new FieldLocationIdentity(this); - - public static class FieldLocationIdentity extends LocationIdentity { - HotSpotResolvedJavaField inner; - - FieldLocationIdentity(HotSpotResolvedJavaFieldImpl inner) { - this.inner = inner; - } - - @Override - public boolean isImmutable() { - return false; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof FieldLocationIdentity) { - FieldLocationIdentity fieldLocationIdentity = (FieldLocationIdentity) obj; - return inner.equals(fieldLocationIdentity.inner); - - } - return false; - } - - @Override - public int hashCode() { - return inner.hashCode(); - } - - @Override - public String toString() { - return inner.getName(); - } - } - - HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, String name, JavaType type, long offset, int modifiers) { - this.holder = holder; - this.name = name; - this.type = type; - assert offset != -1; - assert offset == (int) offset : "offset larger than int"; - this.offset = (int) offset; - this.modifiers = modifiers; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof HotSpotResolvedJavaField) { - HotSpotResolvedJavaFieldImpl that = (HotSpotResolvedJavaFieldImpl) obj; - if (that.offset != this.offset || that.isStatic() != this.isStatic()) { - return false; - } else if (this.holder.equals(that.holder)) { - assert this.name.equals(that.name) && this.type.equals(that.type); - return true; - } - } - return false; - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - @Override - public int getModifiers() { - return modifiers & ModifiersProvider.jvmFieldModifiers(); - } - - @Override - public boolean isInternal() { - return (modifiers & config().jvmAccFieldInternal) != 0; - } - - /** - * Determines if a given object contains this field. - * - * @return true iff this is a non-static field and its declaring class is assignable from - * {@code object}'s class - */ - public boolean isInObject(Object object) { - if (isStatic()) { - return false; - } - return getDeclaringClass().isAssignableFrom(HotSpotResolvedObjectTypeImpl.fromObjectClass(object.getClass())); - } - - @Override - public HotSpotResolvedObjectTypeImpl getDeclaringClass() { - return holder; - } - - @Override - public String getName() { - return name; - } - - @Override - public JavaType getType() { - // Pull field into local variable to prevent a race causing - // a ClassCastException below - JavaType currentType = type; - if (currentType instanceof HotSpotUnresolvedJavaType) { - // Don't allow unresolved types to hang around forever - HotSpotUnresolvedJavaType unresolvedType = (HotSpotUnresolvedJavaType) currentType; - ResolvedJavaType resolved = unresolvedType.reresolve(holder); - if (resolved != null) { - type = resolved; - } - } - return type; - } - - public int offset() { - return offset; - } - - @Override - public String toString() { - return format("HotSpotField<%H.%n %t:") + offset + ">"; - } - - @Override - public boolean isSynthetic() { - return (config().jvmAccSynthetic & modifiers) != 0; - } - - /** - * Checks if this field has the {@link Stable} annotation. - * - * @return true if field has {@link Stable} annotation, false otherwise - */ - public boolean isStable() { - if ((config().jvmAccFieldStable & modifiers) != 0) { - return true; - } - assert getAnnotation(Stable.class) == null; - if (Option.ImplicitStableValues.getBoolean() && isImplicitStableField()) { - return true; - } - return false; - } - - @Override - public Annotation[] getAnnotations() { - Field javaField = toJava(); - if (javaField != null) { - return javaField.getAnnotations(); - } - return new Annotation[0]; - } - - @Override - public T getAnnotation(Class annotationClass) { - Field javaField = toJava(); - if (javaField != null) { - return javaField.getAnnotation(annotationClass); - } - return null; - } - - private Field toJavaCache; - - private Field toJava() { - if (toJavaCache != null) { - return toJavaCache; - } - - if (isInternal()) { - return null; - } - try { - return toJavaCache = holder.mirror().getDeclaredField(name); - } catch (NoSuchFieldException | NoClassDefFoundError e) { - return null; - } - } - - private boolean isArray() { - JavaType fieldType = getType(); - return fieldType instanceof ResolvedJavaType && ((ResolvedJavaType) fieldType).isArray(); - } - - private boolean isImplicitStableField() { - if (isSyntheticEnumSwitchMap()) { - return true; - } - if (isWellKnownImplicitStableField()) { - return true; - } - return false; - } - - public boolean isDefaultStable() { - assert this.isStable(); - if (isSyntheticEnumSwitchMap()) { - return true; - } - return false; - } - - private boolean isSyntheticEnumSwitchMap() { - if (isSynthetic() && isStatic() && isArray()) { - if (isFinal() && name.equals("$VALUES") || name.equals("ENUM$VALUES")) { - // generated int[] field for EnumClass::values() - return true; - } else if (name.startsWith("$SwitchMap$") || name.startsWith("$SWITCH_TABLE$")) { - // javac and ecj generate a static field in an inner class for a switch on an enum - // named $SwitchMap$p$k$g$EnumClass and $SWITCH_TABLE$p$k$g$EnumClass, respectively - return true; - } - } - return false; - } - - private boolean isWellKnownImplicitStableField() { - return WellKnownImplicitStableField.test(this); - } - - static class WellKnownImplicitStableField { - /** - * @return {@code true} if the field is a well-known stable field. - */ - public static boolean test(HotSpotResolvedJavaField field) { - return field.equals(STRING_VALUE_FIELD); - } - - private static final ResolvedJavaField STRING_VALUE_FIELD; - - static { - try { - MetaAccessProvider metaAccess = runtime().getHostJVMCIBackend().getMetaAccess(); - STRING_VALUE_FIELD = metaAccess.lookupJavaField(String.class.getDeclaredField("value")); - } catch (SecurityException | NoSuchFieldException e) { - throw new JVMCIError(e); - } - } - } - - public LocationIdentity getLocationIdentity() { - return locationIdentity; - } -} --- /dev/null 2016-05-04 09:43:43.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java 2016-05-04 09:43:43.000000000 -1000 @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; +import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; + +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.LocationIdentity; +import jdk.vm.ci.meta.MetaAccessProvider; +import jdk.vm.ci.meta.ModifiersProvider; +import jdk.vm.ci.meta.ResolvedJavaField; +import jdk.vm.ci.meta.ResolvedJavaType; + +/** + * Represents a field in a HotSpot type. + */ +class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField, HotSpotProxified { + + private final HotSpotResolvedObjectTypeImpl holder; + private final String name; + private JavaType type; + private final int offset; + + /** + * This value contains all flags as stored in the VM including internal ones. + */ + private final int modifiers; + private final LocationIdentity locationIdentity = new FieldLocationIdentity(this); + + public static class FieldLocationIdentity extends LocationIdentity { + HotSpotResolvedJavaField inner; + + FieldLocationIdentity(HotSpotResolvedJavaFieldImpl inner) { + this.inner = inner; + } + + @Override + public boolean isImmutable() { + return false; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof FieldLocationIdentity) { + FieldLocationIdentity fieldLocationIdentity = (FieldLocationIdentity) obj; + return inner.equals(fieldLocationIdentity.inner); + + } + return false; + } + + @Override + public int hashCode() { + return inner.hashCode(); + } + + @Override + public String toString() { + return inner.getName(); + } + } + + HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, String name, JavaType type, long offset, int modifiers) { + this.holder = holder; + this.name = name; + this.type = type; + assert offset != -1; + assert offset == (int) offset : "offset larger than int"; + this.offset = (int) offset; + this.modifiers = modifiers; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof HotSpotResolvedJavaField) { + HotSpotResolvedJavaFieldImpl that = (HotSpotResolvedJavaFieldImpl) obj; + if (that.offset != this.offset || that.isStatic() != this.isStatic()) { + return false; + } else if (this.holder.equals(that.holder)) { + assert this.name.equals(that.name) && this.type.equals(that.type); + return true; + } + } + return false; + } + + @Override + public int hashCode() { + return name.hashCode(); + } + + @Override + public int getModifiers() { + return modifiers & ModifiersProvider.jvmFieldModifiers(); + } + + @Override + public boolean isInternal() { + return (modifiers & config().jvmAccFieldInternal) != 0; + } + + /** + * Determines if a given object contains this field. + * + * @return true iff this is a non-static field and its declaring class is assignable from + * {@code object}'s class + */ + public boolean isInObject(Object object) { + if (isStatic()) { + return false; + } + return getDeclaringClass().isAssignableFrom(HotSpotResolvedObjectTypeImpl.fromObjectClass(object.getClass())); + } + + @Override + public HotSpotResolvedObjectTypeImpl getDeclaringClass() { + return holder; + } + + @Override + public String getName() { + return name; + } + + @Override + public JavaType getType() { + // Pull field into local variable to prevent a race causing + // a ClassCastException below + JavaType currentType = type; + if (currentType instanceof HotSpotUnresolvedJavaType) { + // Don't allow unresolved types to hang around forever + HotSpotUnresolvedJavaType unresolvedType = (HotSpotUnresolvedJavaType) currentType; + ResolvedJavaType resolved = unresolvedType.reresolve(holder); + if (resolved != null) { + type = resolved; + } + } + return type; + } + + public int offset() { + return offset; + } + + @Override + public String toString() { + return format("HotSpotField<%H.%n %t:") + offset + ">"; + } + + @Override + public boolean isSynthetic() { + return (config().jvmAccSynthetic & modifiers) != 0; + } + + /** + * Checks if this field has the {@link Stable} annotation. + * + * @return true if field has {@link Stable} annotation, false otherwise + */ + public boolean isStable() { + if ((config().jvmAccFieldStable & modifiers) != 0) { + return true; + } + assert getAnnotation(Stable.class) == null; + if (Option.ImplicitStableValues.getBoolean() && isImplicitStableField()) { + return true; + } + return false; + } + + @Override + public Annotation[] getAnnotations() { + Field javaField = toJava(); + if (javaField != null) { + return javaField.getAnnotations(); + } + return new Annotation[0]; + } + + @Override + public T getAnnotation(Class annotationClass) { + Field javaField = toJava(); + if (javaField != null) { + return javaField.getAnnotation(annotationClass); + } + return null; + } + + private Field toJavaCache; + + private Field toJava() { + if (toJavaCache != null) { + return toJavaCache; + } + + if (isInternal()) { + return null; + } + try { + return toJavaCache = holder.mirror().getDeclaredField(name); + } catch (NoSuchFieldException | NoClassDefFoundError e) { + return null; + } + } + + private boolean isArray() { + JavaType fieldType = getType(); + return fieldType instanceof ResolvedJavaType && ((ResolvedJavaType) fieldType).isArray(); + } + + private boolean isImplicitStableField() { + if (isSyntheticEnumSwitchMap()) { + return true; + } + if (isWellKnownImplicitStableField()) { + return true; + } + return false; + } + + public boolean isDefaultStable() { + assert this.isStable(); + if (isSyntheticEnumSwitchMap()) { + return true; + } + return false; + } + + private boolean isSyntheticEnumSwitchMap() { + if (isSynthetic() && isStatic() && isArray()) { + if (isFinal() && name.equals("$VALUES") || name.equals("ENUM$VALUES")) { + // generated int[] field for EnumClass::values() + return true; + } else if (name.startsWith("$SwitchMap$") || name.startsWith("$SWITCH_TABLE$")) { + // javac and ecj generate a static field in an inner class for a switch on an enum + // named $SwitchMap$p$k$g$EnumClass and $SWITCH_TABLE$p$k$g$EnumClass, respectively + return true; + } + } + return false; + } + + private boolean isWellKnownImplicitStableField() { + return WellKnownImplicitStableField.test(this); + } + + static class WellKnownImplicitStableField { + /** + * @return {@code true} if the field is a well-known stable field. + */ + public static boolean test(HotSpotResolvedJavaField field) { + return field.equals(STRING_VALUE_FIELD); + } + + private static final ResolvedJavaField STRING_VALUE_FIELD; + + static { + try { + MetaAccessProvider metaAccess = runtime().getHostJVMCIBackend().getMetaAccess(); + STRING_VALUE_FIELD = metaAccess.lookupJavaField(String.class.getDeclaredField("value")); + } catch (SecurityException | NoSuchFieldException e) { + throw new JVMCIError(e); + } + } + } + + public LocationIdentity getLocationIdentity() { + return locationIdentity; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethod.java 2016-05-04 09:43:43.000000000 -1000 +++ /dev/null 2016-05-04 09:43:43.000000000 -1000 @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.lang.reflect.Modifier; - -import jdk.vm.ci.meta.JavaMethod; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Implementation of {@link JavaMethod} for resolved HotSpot methods. - */ -public interface HotSpotResolvedJavaMethod extends ResolvedJavaMethod { - - /** - * Returns true if this method has a {@code CallerSensitive} annotation. - * - * @return true if CallerSensitive annotation present, false otherwise - */ - boolean isCallerSensitive(); - - HotSpotResolvedObjectType getDeclaringClass(); - - /** - * Returns true if this method has a {@code ForceInline} annotation. - * - * @return true if ForceInline annotation present, false otherwise - */ - boolean isForceInline(); - - /** - * Returns true if this method has a {@code DontInline} annotation. - * - * @return true if DontInline annotation present, false otherwise - */ - boolean isDontInline(); - - /** - * Returns true if this method has a {@code ReservedStackAccess} annotation. - * - * @return true if ReservedStackAccess annotation present, false otherwise - */ - boolean hasReservedStackAccess(); - - /** - * Manually adds a DontInline annotation to this method. - */ - void setNotInlineable(); - - /** - * Returns true if this method is one of the special methods that is ignored by security stack - * walks. - * - * @return true if special method ignored by security stack walks, false otherwise - */ - boolean ignoredBySecurityStackWalk(); - - ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver); - - /** - * Returns whether this method has compiled code. - * - * @return true if this method has compiled code, false otherwise - */ - boolean hasCompiledCode(); - - /** - * @param level - * @return true if the currently installed code was generated at {@code level}. - */ - boolean hasCompiledCodeAtLevel(int level); - - default boolean isDefault() { - if (isConstructor()) { - return false; - } - // Copied from java.lang.Method.isDefault() - int mask = Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC; - return ((getModifiers() & mask) == Modifier.PUBLIC) && getDeclaringClass().isInterface(); - } - - /** - * Returns the offset of this method into the v-table. The method must have a v-table entry as - * indicated by {@link #isInVirtualMethodTable(ResolvedJavaType)}, otherwise an exception is - * thrown. - * - * @return the offset of this method into the v-table - */ - int vtableEntryOffset(ResolvedJavaType resolved); - - int intrinsicId(); - - /** - * Allocates a compile id for this method by asking the VM for one. - * - * @param entryBCI entry bci - * @return compile id - */ - int allocateCompileId(int entryBCI); - - boolean hasCodeAtLevel(int entryBCI, int level); -} --- /dev/null 2016-05-04 09:43:43.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethod.java 2016-05-04 09:43:43.000000000 -1000 @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import java.lang.reflect.Modifier; + +import jdk.vm.ci.meta.JavaMethod; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; + +/** + * Implementation of {@link JavaMethod} for resolved HotSpot methods. + */ +public interface HotSpotResolvedJavaMethod extends ResolvedJavaMethod { + + /** + * Returns true if this method has a {@code CallerSensitive} annotation. + * + * @return true if CallerSensitive annotation present, false otherwise + */ + boolean isCallerSensitive(); + + HotSpotResolvedObjectType getDeclaringClass(); + + /** + * Returns true if this method has a {@code ForceInline} annotation. + * + * @return true if ForceInline annotation present, false otherwise + */ + boolean isForceInline(); + + /** + * Returns true if this method has a {@code DontInline} annotation. + * + * @return true if DontInline annotation present, false otherwise + */ + boolean isDontInline(); + + /** + * Returns true if this method has a {@code ReservedStackAccess} annotation. + * + * @return true if ReservedStackAccess annotation present, false otherwise + */ + boolean hasReservedStackAccess(); + + /** + * Manually adds a DontInline annotation to this method. + */ + void setNotInlineable(); + + /** + * Returns true if this method is one of the special methods that is ignored by security stack + * walks. + * + * @return true if special method ignored by security stack walks, false otherwise + */ + boolean ignoredBySecurityStackWalk(); + + ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver); + + /** + * Returns whether this method has compiled code. + * + * @return true if this method has compiled code, false otherwise + */ + boolean hasCompiledCode(); + + /** + * @param level + * @return true if the currently installed code was generated at {@code level}. + */ + boolean hasCompiledCodeAtLevel(int level); + + default boolean isDefault() { + if (isConstructor()) { + return false; + } + // Copied from java.lang.Method.isDefault() + int mask = Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC; + return ((getModifiers() & mask) == Modifier.PUBLIC) && getDeclaringClass().isInterface(); + } + + /** + * Returns the offset of this method into the v-table. The method must have a v-table entry as + * indicated by {@link #isInVirtualMethodTable(ResolvedJavaType)}, otherwise an exception is + * thrown. + * + * @return the offset of this method into the v-table + */ + int vtableEntryOffset(ResolvedJavaType resolved); + + int intrinsicId(); + + /** + * Allocates a compile id for this method by asking the VM for one. + * + * @param entryBCI entry bci + * @return compile id + */ + int allocateCompileId(int entryBCI); + + boolean hasCodeAtLevel(int entryBCI, int level); +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java 2016-05-04 09:43:44.000000000 -1000 +++ /dev/null 2016-05-04 09:43:44.000000000 -1000 @@ -1,724 +0,0 @@ -/* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Executable; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.ConstantPool; -import jdk.vm.ci.meta.DefaultProfilingInfo; -import jdk.vm.ci.meta.ExceptionHandler; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaMethod; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.LineNumberTable; -import jdk.vm.ci.meta.LineNumberTableImpl; -import jdk.vm.ci.meta.Local; -import jdk.vm.ci.meta.LocalImpl; -import jdk.vm.ci.meta.LocalVariableTable; -import jdk.vm.ci.meta.LocalVariableTableImpl; -import jdk.vm.ci.meta.ModifiersProvider; -import jdk.vm.ci.meta.ProfilingInfo; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.Signature; -import jdk.vm.ci.meta.SpeculationLog; -import jdk.vm.ci.meta.TriState; - -/** - * Implementation of {@link JavaMethod} for resolved HotSpot methods. - */ -final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSpotResolvedJavaMethod, HotSpotProxified, MetaspaceWrapperObject { - - /** - * Reference to metaspace Method object. - */ - private final long metaspaceMethod; - - private final HotSpotResolvedObjectTypeImpl holder; - private final HotSpotConstantPool constantPool; - private final HotSpotSignature signature; - private HotSpotMethodData methodData; - private byte[] code; - private Executable toJavaCache; - - /** - * Gets the holder of a HotSpot metaspace method native object. - * - * @param metaspaceMethod a metaspace Method object - * @return the {@link ResolvedJavaType} corresponding to the holder of the - * {@code metaspaceMethod} - */ - private static HotSpotResolvedObjectTypeImpl getHolder(long metaspaceMethod) { - HotSpotVMConfig config = config(); - final long metaspaceConstMethod = UNSAFE.getAddress(metaspaceMethod + config.methodConstMethodOffset); - final long metaspaceConstantPool = UNSAFE.getAddress(metaspaceConstMethod + config.constMethodConstantsOffset); - return compilerToVM().getResolvedJavaType(null, metaspaceConstantPool + config.constantPoolHolderOffset, false); - } - - /** - * Gets the JVMCI mirror from a HotSpot method. The VM is responsible for ensuring that the - * Method* is kept alive for the duration of this call and the - * {@link HotSpotJVMCIMetaAccessContext} keeps it alive after that. - * - * Called from the VM. - * - * @param metaspaceMethod a metaspace Method object - * @return the {@link ResolvedJavaMethod} corresponding to {@code metaspaceMethod} - */ - @SuppressWarnings("unused") - private static HotSpotResolvedJavaMethod fromMetaspace(long metaspaceMethod) { - HotSpotResolvedObjectTypeImpl holder = getHolder(metaspaceMethod); - return holder.createMethod(metaspaceMethod); - } - - HotSpotResolvedJavaMethodImpl(HotSpotResolvedObjectTypeImpl holder, long metaspaceMethod) { - // It would be too much work to get the method name here so we fill it in later. - super(null); - this.metaspaceMethod = metaspaceMethod; - this.holder = holder; - - HotSpotVMConfig config = config(); - final long constMethod = getConstMethod(); - - /* - * Get the constant pool from the metaspace method. Some methods (e.g. intrinsics for - * signature-polymorphic method handle methods) have their own constant pool instead of the - * one from their holder. - */ - final long metaspaceConstantPool = UNSAFE.getAddress(constMethod + config.constMethodConstantsOffset); - if (metaspaceConstantPool == holder.getConstantPool().getMetaspaceConstantPool()) { - this.constantPool = holder.getConstantPool(); - } else { - this.constantPool = compilerToVM().getConstantPool(null, constMethod + config.constMethodConstantsOffset); - } - - final int nameIndex = UNSAFE.getChar(constMethod + config.constMethodNameIndexOffset); - this.name = constantPool.lookupUtf8(nameIndex); - - final int signatureIndex = UNSAFE.getChar(constMethod + config.constMethodSignatureIndexOffset); - this.signature = (HotSpotSignature) constantPool.lookupSignature(signatureIndex); - } - - /** - * Returns a pointer to this method's constant method data structure ( - * {@code Method::_constMethod}). This pointer isn't wrapped since it should be safe to use it - * within the context of this HotSpotResolvedJavaMethodImpl since the Method* and ConstMethod* - * are kept alive as a pair. - * - * @return pointer to this method's ConstMethod - */ - private long getConstMethod() { - assert metaspaceMethod != 0; - return UNSAFE.getAddress(metaspaceMethod + config().methodConstMethodOffset); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof HotSpotResolvedJavaMethodImpl) { - HotSpotResolvedJavaMethodImpl that = (HotSpotResolvedJavaMethodImpl) obj; - return that.metaspaceMethod == metaspaceMethod; - } - return false; - } - - @Override - public int hashCode() { - return (int) metaspaceMethod; - } - - /** - * Returns this method's flags ({@code Method::_flags}). - * - * @return flags of this method - */ - private int getFlags() { - return UNSAFE.getShort(metaspaceMethod + config().methodFlagsOffset); - } - - /** - * Returns this method's constant method flags ({@code ConstMethod::_flags}). - * - * @return flags of this method's ConstMethod - */ - private int getConstMethodFlags() { - return UNSAFE.getChar(getConstMethod() + config().constMethodFlagsOffset); - } - - @Override - public HotSpotResolvedObjectTypeImpl getDeclaringClass() { - return holder; - } - - /** - * Gets the address of the C++ Method object for this method. - */ - public Constant getMetaspaceMethodConstant() { - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(this, false); - } - - public long getMetaspacePointer() { - return metaspaceMethod; - } - - @Override - public Constant getEncoding() { - return getMetaspaceMethodConstant(); - } - - /** - * Gets the complete set of modifiers for this method which includes the JVM specification - * modifiers as well as the HotSpot internal modifiers. - */ - public int getAllModifiers() { - return UNSAFE.getInt(metaspaceMethod + config().methodAccessFlagsOffset); - } - - @Override - public int getModifiers() { - return getAllModifiers() & ModifiersProvider.jvmMethodModifiers(); - } - - @Override - public boolean canBeStaticallyBound() { - return (isFinal() || isPrivate() || isStatic() || holder.isLeaf()) && isConcrete(); - } - - @Override - public byte[] getCode() { - if (getCodeSize() == 0) { - return null; - } - if (code == null && holder.isLinked()) { - code = compilerToVM().getBytecode(this); - assert code.length == getCodeSize() : "expected: " + getCodeSize() + ", actual: " + code.length; - } - return code; - } - - @Override - public int getCodeSize() { - return UNSAFE.getChar(getConstMethod() + config().constMethodCodeSizeOffset); - } - - @Override - public ExceptionHandler[] getExceptionHandlers() { - final boolean hasExceptionTable = (getConstMethodFlags() & config().constMethodHasExceptionTable) != 0; - if (!hasExceptionTable) { - return new ExceptionHandler[0]; - } - - HotSpotVMConfig config = config(); - final int exceptionTableLength = compilerToVM().getExceptionTableLength(this); - ExceptionHandler[] handlers = new ExceptionHandler[exceptionTableLength]; - long exceptionTableElement = compilerToVM().getExceptionTableStart(this); - - for (int i = 0; i < exceptionTableLength; i++) { - final int startPc = UNSAFE.getChar(exceptionTableElement + config.exceptionTableElementStartPcOffset); - final int endPc = UNSAFE.getChar(exceptionTableElement + config.exceptionTableElementEndPcOffset); - final int handlerPc = UNSAFE.getChar(exceptionTableElement + config.exceptionTableElementHandlerPcOffset); - int catchTypeIndex = UNSAFE.getChar(exceptionTableElement + config.exceptionTableElementCatchTypeIndexOffset); - - JavaType catchType; - if (catchTypeIndex == 0) { - catchType = null; - } else { - final int opcode = -1; // opcode is not used - catchType = constantPool.lookupType(catchTypeIndex, opcode); - - // Check for Throwable which catches everything. - if (catchType instanceof HotSpotResolvedObjectTypeImpl) { - HotSpotResolvedObjectTypeImpl resolvedType = (HotSpotResolvedObjectTypeImpl) catchType; - if (resolvedType.mirror() == Throwable.class) { - catchTypeIndex = 0; - catchType = null; - } - } - } - handlers[i] = new ExceptionHandler(startPc, endPc, handlerPc, catchTypeIndex, catchType); - - // Go to the next ExceptionTableElement - exceptionTableElement += config.exceptionTableElementSize; - } - - return handlers; - } - - /** - * Returns true if this method has a {@code CallerSensitive} annotation. - * - * @return true if CallerSensitive annotation present, false otherwise - */ - public boolean isCallerSensitive() { - return (getFlags() & config().methodFlagsCallerSensitive) != 0; - } - - /** - * Returns true if this method has a {@code ForceInline} annotation. - * - * @return true if ForceInline annotation present, false otherwise - */ - public boolean isForceInline() { - return (getFlags() & config().methodFlagsForceInline) != 0; - } - - /** - * Returns true if this method has a {@code DontInline} annotation. - * - * @return true if DontInline annotation present, false otherwise - */ - public boolean isDontInline() { - return (getFlags() & config().methodFlagsDontInline) != 0; - } - - /** - * Returns true if this method has a {@code ReservedStackAccess} annotation. - * - * @return true if ReservedStackAccess annotation present, false otherwise - */ - public boolean hasReservedStackAccess() { - return (getFlags() & config().methodFlagsReservedStackAccess) != 0; - } - - /** - * Manually adds a DontInline annotation to this method. - */ - public void setNotInlineable() { - compilerToVM().doNotInlineOrCompile(this); - } - - /** - * Returns true if this method is one of the special methods that is ignored by security stack - * walks. - * - * @return true if special method ignored by security stack walks, false otherwise - */ - public boolean ignoredBySecurityStackWalk() { - return compilerToVM().methodIsIgnoredBySecurityStackWalk(this); - } - - @Override - public boolean isClassInitializer() { - return "".equals(name) && isStatic(); - } - - @Override - public boolean isConstructor() { - return "".equals(name) && !isStatic(); - } - - @Override - public int getMaxLocals() { - if (isAbstract() || isNative()) { - return 0; - } - HotSpotVMConfig config = config(); - return UNSAFE.getChar(getConstMethod() + config.methodMaxLocalsOffset); - } - - @Override - public int getMaxStackSize() { - if (isAbstract() || isNative()) { - return 0; - } - HotSpotVMConfig config = config(); - return config.extraStackEntries + UNSAFE.getChar(getConstMethod() + config.constMethodMaxStackOffset); - } - - @Override - public StackTraceElement asStackTraceElement(int bci) { - if (bci < 0 || bci >= getCodeSize()) { - // HotSpot code can only construct stack trace elements for valid bcis - StackTraceElement ste = compilerToVM().getStackTraceElement(this, 0); - return new StackTraceElement(ste.getClassName(), ste.getMethodName(), ste.getFileName(), -1); - } - return compilerToVM().getStackTraceElement(this, bci); - } - - public ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver) { - if (receiver.isInterface()) { - // Cannot trust interfaces. Because of: - // interface I { void foo(); } - // class A { public void foo() {} } - // class B extends A implements I { } - // class C extends B { public void foo() { } } - // class D extends B { } - // Would lead to identify C.foo() as the unique concrete method for I.foo() without - // seeing A.foo(). - return null; - } - if (this.isDefault()) { - // CHA for default methods doesn't work and may crash the VM - return null; - } - return compilerToVM().findUniqueConcreteMethod(((HotSpotResolvedObjectTypeImpl) receiver), this); - } - - @Override - public HotSpotSignature getSignature() { - return signature; - } - - /** - * Gets the value of {@code Method::_code}. - * - * @return the value of {@code Method::_code} - */ - private long getCompiledCode() { - HotSpotVMConfig config = config(); - return UNSAFE.getAddress(metaspaceMethod + config.methodCodeOffset); - } - - /** - * Returns whether this method has compiled code. - * - * @return true if this method has compiled code, false otherwise - */ - public boolean hasCompiledCode() { - return getCompiledCode() != 0L; - } - - /** - * @param level - * @return true if the currently installed code was generated at {@code level}. - */ - public boolean hasCompiledCodeAtLevel(int level) { - long compiledCode = getCompiledCode(); - if (compiledCode != 0) { - return UNSAFE.getInt(compiledCode + config().nmethodCompLevelOffset) == level; - } - return false; - } - - @Override - public ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) { - ProfilingInfo info; - - if (methodData == null) { - long metaspaceMethodData = UNSAFE.getAddress(metaspaceMethod + config().methodDataOffset); - if (metaspaceMethodData != 0) { - methodData = new HotSpotMethodData(metaspaceMethodData, this); - String methodDataFilter = Option.TraceMethodDataFilter.getString(); - if (methodDataFilter != null && this.format("%H.%n").contains(methodDataFilter)) { - System.out.println("Raw method data for " + this.format("%H.%n(%p)") + ":"); - System.out.println(methodData.toString()); - } - } - } - - if (methodData == null || (!methodData.hasNormalData() && !methodData.hasExtraData())) { - // Be optimistic and return false for exceptionSeen. A methodDataOop is allocated in - // case of a deoptimization. - info = DefaultProfilingInfo.get(TriState.FALSE); - } else { - info = new HotSpotProfilingInfo(methodData, this, includeNormal, includeOSR); - } - return info; - } - - @Override - public void reprofile() { - compilerToVM().reprofile(this); - } - - @Override - public ConstantPool getConstantPool() { - return constantPool; - } - - @Override - public Annotation[][] getParameterAnnotations() { - Executable javaMethod = toJava(); - return javaMethod == null ? null : javaMethod.getParameterAnnotations(); - } - - @Override - public Annotation[] getAnnotations() { - Executable javaMethod = toJava(); - return javaMethod == null ? new Annotation[0] : javaMethod.getAnnotations(); - } - - @Override - public T getAnnotation(Class annotationClass) { - Executable javaMethod = toJava(); - return javaMethod == null ? null : javaMethod.getAnnotation(annotationClass); - } - - public boolean isDefault() { - if (isConstructor()) { - return false; - } - // Copied from java.lang.Method.isDefault() - int mask = Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC; - return ((getModifiers() & mask) == Modifier.PUBLIC) && getDeclaringClass().isInterface(); - } - - @Override - public Type[] getGenericParameterTypes() { - Executable javaMethod = toJava(); - return javaMethod == null ? null : javaMethod.getGenericParameterTypes(); - } - - public Class[] signatureToTypes() { - Signature sig = getSignature(); - int count = sig.getParameterCount(false); - Class[] result = new Class[count]; - for (int i = 0; i < result.length; ++i) { - JavaType parameterType = sig.getParameterType(i, holder); - HotSpotResolvedJavaType resolvedParameterType = (HotSpotResolvedJavaType) parameterType.resolve(holder); - result[i] = resolvedParameterType.mirror(); - } - return result; - } - - private Executable toJava() { - if (toJavaCache != null) { - return toJavaCache; - } - try { - Class[] parameterTypes = signatureToTypes(); - Executable result = isConstructor() ? holder.mirror().getDeclaredConstructor(parameterTypes) : holder.mirror().getDeclaredMethod(name, parameterTypes); - toJavaCache = result; - return result; - } catch (NoSuchMethodException | NoClassDefFoundError e) { - return null; - } - } - - @Override - public boolean canBeInlined() { - if (isDontInline()) { - return false; - } - return compilerToVM().canInlineMethod(this); - } - - @Override - public boolean shouldBeInlined() { - if (isForceInline()) { - return true; - } - return compilerToVM().shouldInlineMethod(this); - } - - @Override - public LineNumberTable getLineNumberTable() { - final boolean hasLineNumberTable = (getConstMethodFlags() & config().constMethodHasLineNumberTable) != 0; - if (!hasLineNumberTable) { - return null; - } - - long[] values = compilerToVM().getLineNumberTable(this); - if (values == null || values.length == 0) { - // Empty table so treat is as non-existent - return null; - } - assert values.length % 2 == 0; - int[] bci = new int[values.length / 2]; - int[] line = new int[values.length / 2]; - - for (int i = 0; i < values.length / 2; i++) { - bci[i] = (int) values[i * 2]; - line[i] = (int) values[i * 2 + 1]; - } - - return new LineNumberTableImpl(line, bci); - } - - @Override - public LocalVariableTable getLocalVariableTable() { - final boolean hasLocalVariableTable = (getConstMethodFlags() & config().constMethodHasLocalVariableTable) != 0; - if (!hasLocalVariableTable) { - return null; - } - - HotSpotVMConfig config = config(); - long localVariableTableElement = compilerToVM().getLocalVariableTableStart(this); - final int localVariableTableLength = compilerToVM().getLocalVariableTableLength(this); - Local[] locals = new Local[localVariableTableLength]; - - for (int i = 0; i < localVariableTableLength; i++) { - final int startBci = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementStartBciOffset); - final int endBci = startBci + UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementLengthOffset); - final int nameCpIndex = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementNameCpIndexOffset); - final int typeCpIndex = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementDescriptorCpIndexOffset); - final int slot = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementSlotOffset); - - String localName = getConstantPool().lookupUtf8(nameCpIndex); - String localType = getConstantPool().lookupUtf8(typeCpIndex); - - locals[i] = new LocalImpl(localName, runtime().lookupType(localType, holder, false), startBci, endBci, slot); - - // Go to the next LocalVariableTableElement - localVariableTableElement += config.localVariableTableElementSize; - } - - return new LocalVariableTableImpl(locals); - } - - /** - * Returns the offset of this method into the v-table. The method must have a v-table entry as - * indicated by {@link #isInVirtualMethodTable(ResolvedJavaType)}, otherwise an exception is - * thrown. - * - * @return the offset of this method into the v-table - */ - public int vtableEntryOffset(ResolvedJavaType resolved) { - if (!isInVirtualMethodTable(resolved)) { - throw new JVMCIError("%s does not have a vtable entry in type %s", this, resolved); - } - HotSpotVMConfig config = config(); - final int vtableIndex = getVtableIndex((HotSpotResolvedObjectTypeImpl) resolved); - return config.klassVtableStartOffset + vtableIndex * config.vtableEntrySize + config.vtableEntryMethodOffset; - } - - @Override - public boolean isInVirtualMethodTable(ResolvedJavaType resolved) { - if (resolved instanceof HotSpotResolvedObjectTypeImpl) { - HotSpotResolvedObjectTypeImpl hotspotResolved = (HotSpotResolvedObjectTypeImpl) resolved; - int vtableIndex = getVtableIndex(hotspotResolved); - return vtableIndex >= 0 && vtableIndex < hotspotResolved.getVtableLength(); - } - return false; - } - - private int getVtableIndex(HotSpotResolvedObjectTypeImpl resolved) { - if (!holder.isLinked()) { - return config().invalidVtableIndex; - } - if (holder.isInterface()) { - if (resolved.isInterface()) { - return config().invalidVtableIndex; - } - return getVtableIndexForInterfaceMethod(resolved); - } - return getVtableIndex(); - } - - /** - * Returns this method's virtual table index. - * - * @return virtual table index - */ - private int getVtableIndex() { - assert !holder.isInterface(); - HotSpotVMConfig config = config(); - int result = UNSAFE.getInt(metaspaceMethod + config.methodVtableIndexOffset); - assert result >= config.nonvirtualVtableIndex : "must be linked"; - return result; - } - - private int getVtableIndexForInterfaceMethod(ResolvedJavaType resolved) { - HotSpotResolvedObjectTypeImpl hotspotType = (HotSpotResolvedObjectTypeImpl) resolved; - return compilerToVM().getVtableIndexForInterfaceMethod(hotspotType, this); - } - - /** - * The {@link SpeculationLog} for methods compiled by JVMCI hang off this per-declaring-type - * {@link ClassValue}. The raw Method* value is safe to use as a key in the map as a) it is - * never moves and b) we never read from it. - *

- * One implication is that we will preserve {@link SpeculationLog}s for methods that have been - * redefined via class redefinition. It's tempting to periodically flush such logs but we cannot - * read the JVM_ACC_IS_OBSOLETE bit (or anything else) via the raw pointer as obsoleted methods - * are subject to clean up and deletion (see InstanceKlass::purge_previous_versions_internal). - */ - private static final ClassValue> SpeculationLogs = new ClassValue>() { - @Override - protected Map computeValue(java.lang.Class type) { - return new HashMap<>(4); - } - }; - - public SpeculationLog getSpeculationLog() { - Map map = SpeculationLogs.get(holder.mirror()); - synchronized (map) { - SpeculationLog log = map.get(this.metaspaceMethod); - if (log == null) { - log = new HotSpotSpeculationLog(); - map.put(metaspaceMethod, log); - } - return log; - } - } - - public int intrinsicId() { - HotSpotVMConfig config = config(); - return UNSAFE.getChar(metaspaceMethod + config.methodIntrinsicIdOffset); - } - - @Override - public JavaConstant invoke(JavaConstant receiver, JavaConstant[] arguments) { - assert !isConstructor(); - Method javaMethod = (Method) toJava(); - javaMethod.setAccessible(true); - - Object[] objArguments = new Object[arguments.length]; - for (int i = 0; i < arguments.length; i++) { - objArguments[i] = HotSpotObjectConstantImpl.asBoxedValue(arguments[i]); - } - Object objReceiver = receiver != null && !receiver.isNull() ? ((HotSpotObjectConstantImpl) receiver).object() : null; - - try { - Object objResult = javaMethod.invoke(objReceiver, objArguments); - return javaMethod.getReturnType() == void.class ? null : HotSpotObjectConstantImpl.forBoxedValue(getSignature().getReturnKind(), objResult); - - } catch (IllegalAccessException | InvocationTargetException ex) { - throw new IllegalArgumentException(ex); - } - } - - /** - * Allocates a compile id for this method by asking the VM for one. - * - * @param entryBCI entry bci - * @return compile id - */ - public int allocateCompileId(int entryBCI) { - return compilerToVM().allocateCompileId(this, entryBCI); - } - - public boolean hasCodeAtLevel(int entryBCI, int level) { - if (entryBCI == config().invocationEntryBci) { - return hasCompiledCodeAtLevel(level); - } - return compilerToVM().hasCompiledCodeForOSR(this, entryBCI, level); - } -} --- /dev/null 2016-05-04 09:43:44.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java 2016-05-04 09:43:44.000000000 -1000 @@ -0,0 +1,724 @@ +/* + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; +import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; +import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Executable; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.Map; + +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; +import jdk.vm.ci.meta.Constant; +import jdk.vm.ci.meta.ConstantPool; +import jdk.vm.ci.meta.DefaultProfilingInfo; +import jdk.vm.ci.meta.ExceptionHandler; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.JavaMethod; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.LineNumberTable; +import jdk.vm.ci.meta.LineNumberTableImpl; +import jdk.vm.ci.meta.Local; +import jdk.vm.ci.meta.LocalImpl; +import jdk.vm.ci.meta.LocalVariableTable; +import jdk.vm.ci.meta.LocalVariableTableImpl; +import jdk.vm.ci.meta.ModifiersProvider; +import jdk.vm.ci.meta.ProfilingInfo; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; +import jdk.vm.ci.meta.Signature; +import jdk.vm.ci.meta.SpeculationLog; +import jdk.vm.ci.meta.TriState; + +/** + * Implementation of {@link JavaMethod} for resolved HotSpot methods. + */ +final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSpotResolvedJavaMethod, HotSpotProxified, MetaspaceWrapperObject { + + /** + * Reference to metaspace Method object. + */ + private final long metaspaceMethod; + + private final HotSpotResolvedObjectTypeImpl holder; + private final HotSpotConstantPool constantPool; + private final HotSpotSignature signature; + private HotSpotMethodData methodData; + private byte[] code; + private Executable toJavaCache; + + /** + * Gets the holder of a HotSpot metaspace method native object. + * + * @param metaspaceMethod a metaspace Method object + * @return the {@link ResolvedJavaType} corresponding to the holder of the + * {@code metaspaceMethod} + */ + private static HotSpotResolvedObjectTypeImpl getHolder(long metaspaceMethod) { + HotSpotVMConfig config = config(); + final long metaspaceConstMethod = UNSAFE.getAddress(metaspaceMethod + config.methodConstMethodOffset); + final long metaspaceConstantPool = UNSAFE.getAddress(metaspaceConstMethod + config.constMethodConstantsOffset); + return compilerToVM().getResolvedJavaType(null, metaspaceConstantPool + config.constantPoolHolderOffset, false); + } + + /** + * Gets the JVMCI mirror from a HotSpot method. The VM is responsible for ensuring that the + * Method* is kept alive for the duration of this call and the + * {@link HotSpotJVMCIMetaAccessContext} keeps it alive after that. + * + * Called from the VM. + * + * @param metaspaceMethod a metaspace Method object + * @return the {@link ResolvedJavaMethod} corresponding to {@code metaspaceMethod} + */ + @SuppressWarnings("unused") + private static HotSpotResolvedJavaMethod fromMetaspace(long metaspaceMethod) { + HotSpotResolvedObjectTypeImpl holder = getHolder(metaspaceMethod); + return holder.createMethod(metaspaceMethod); + } + + HotSpotResolvedJavaMethodImpl(HotSpotResolvedObjectTypeImpl holder, long metaspaceMethod) { + // It would be too much work to get the method name here so we fill it in later. + super(null); + this.metaspaceMethod = metaspaceMethod; + this.holder = holder; + + HotSpotVMConfig config = config(); + final long constMethod = getConstMethod(); + + /* + * Get the constant pool from the metaspace method. Some methods (e.g. intrinsics for + * signature-polymorphic method handle methods) have their own constant pool instead of the + * one from their holder. + */ + final long metaspaceConstantPool = UNSAFE.getAddress(constMethod + config.constMethodConstantsOffset); + if (metaspaceConstantPool == holder.getConstantPool().getMetaspaceConstantPool()) { + this.constantPool = holder.getConstantPool(); + } else { + this.constantPool = compilerToVM().getConstantPool(null, constMethod + config.constMethodConstantsOffset); + } + + final int nameIndex = UNSAFE.getChar(constMethod + config.constMethodNameIndexOffset); + this.name = constantPool.lookupUtf8(nameIndex); + + final int signatureIndex = UNSAFE.getChar(constMethod + config.constMethodSignatureIndexOffset); + this.signature = (HotSpotSignature) constantPool.lookupSignature(signatureIndex); + } + + /** + * Returns a pointer to this method's constant method data structure ( + * {@code Method::_constMethod}). This pointer isn't wrapped since it should be safe to use it + * within the context of this HotSpotResolvedJavaMethodImpl since the Method* and ConstMethod* + * are kept alive as a pair. + * + * @return pointer to this method's ConstMethod + */ + private long getConstMethod() { + assert metaspaceMethod != 0; + return UNSAFE.getAddress(metaspaceMethod + config().methodConstMethodOffset); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof HotSpotResolvedJavaMethodImpl) { + HotSpotResolvedJavaMethodImpl that = (HotSpotResolvedJavaMethodImpl) obj; + return that.metaspaceMethod == metaspaceMethod; + } + return false; + } + + @Override + public int hashCode() { + return (int) metaspaceMethod; + } + + /** + * Returns this method's flags ({@code Method::_flags}). + * + * @return flags of this method + */ + private int getFlags() { + return UNSAFE.getShort(metaspaceMethod + config().methodFlagsOffset); + } + + /** + * Returns this method's constant method flags ({@code ConstMethod::_flags}). + * + * @return flags of this method's ConstMethod + */ + private int getConstMethodFlags() { + return UNSAFE.getChar(getConstMethod() + config().constMethodFlagsOffset); + } + + @Override + public HotSpotResolvedObjectTypeImpl getDeclaringClass() { + return holder; + } + + /** + * Gets the address of the C++ Method object for this method. + */ + public Constant getMetaspaceMethodConstant() { + return HotSpotMetaspaceConstantImpl.forMetaspaceObject(this, false); + } + + public long getMetaspacePointer() { + return metaspaceMethod; + } + + @Override + public Constant getEncoding() { + return getMetaspaceMethodConstant(); + } + + /** + * Gets the complete set of modifiers for this method which includes the JVM specification + * modifiers as well as the HotSpot internal modifiers. + */ + public int getAllModifiers() { + return UNSAFE.getInt(metaspaceMethod + config().methodAccessFlagsOffset); + } + + @Override + public int getModifiers() { + return getAllModifiers() & ModifiersProvider.jvmMethodModifiers(); + } + + @Override + public boolean canBeStaticallyBound() { + return (isFinal() || isPrivate() || isStatic() || holder.isLeaf()) && isConcrete(); + } + + @Override + public byte[] getCode() { + if (getCodeSize() == 0) { + return null; + } + if (code == null && holder.isLinked()) { + code = compilerToVM().getBytecode(this); + assert code.length == getCodeSize() : "expected: " + getCodeSize() + ", actual: " + code.length; + } + return code; + } + + @Override + public int getCodeSize() { + return UNSAFE.getChar(getConstMethod() + config().constMethodCodeSizeOffset); + } + + @Override + public ExceptionHandler[] getExceptionHandlers() { + final boolean hasExceptionTable = (getConstMethodFlags() & config().constMethodHasExceptionTable) != 0; + if (!hasExceptionTable) { + return new ExceptionHandler[0]; + } + + HotSpotVMConfig config = config(); + final int exceptionTableLength = compilerToVM().getExceptionTableLength(this); + ExceptionHandler[] handlers = new ExceptionHandler[exceptionTableLength]; + long exceptionTableElement = compilerToVM().getExceptionTableStart(this); + + for (int i = 0; i < exceptionTableLength; i++) { + final int startPc = UNSAFE.getChar(exceptionTableElement + config.exceptionTableElementStartPcOffset); + final int endPc = UNSAFE.getChar(exceptionTableElement + config.exceptionTableElementEndPcOffset); + final int handlerPc = UNSAFE.getChar(exceptionTableElement + config.exceptionTableElementHandlerPcOffset); + int catchTypeIndex = UNSAFE.getChar(exceptionTableElement + config.exceptionTableElementCatchTypeIndexOffset); + + JavaType catchType; + if (catchTypeIndex == 0) { + catchType = null; + } else { + final int opcode = -1; // opcode is not used + catchType = constantPool.lookupType(catchTypeIndex, opcode); + + // Check for Throwable which catches everything. + if (catchType instanceof HotSpotResolvedObjectTypeImpl) { + HotSpotResolvedObjectTypeImpl resolvedType = (HotSpotResolvedObjectTypeImpl) catchType; + if (resolvedType.mirror() == Throwable.class) { + catchTypeIndex = 0; + catchType = null; + } + } + } + handlers[i] = new ExceptionHandler(startPc, endPc, handlerPc, catchTypeIndex, catchType); + + // Go to the next ExceptionTableElement + exceptionTableElement += config.exceptionTableElementSize; + } + + return handlers; + } + + /** + * Returns true if this method has a {@code CallerSensitive} annotation. + * + * @return true if CallerSensitive annotation present, false otherwise + */ + public boolean isCallerSensitive() { + return (getFlags() & config().methodFlagsCallerSensitive) != 0; + } + + /** + * Returns true if this method has a {@code ForceInline} annotation. + * + * @return true if ForceInline annotation present, false otherwise + */ + public boolean isForceInline() { + return (getFlags() & config().methodFlagsForceInline) != 0; + } + + /** + * Returns true if this method has a {@code DontInline} annotation. + * + * @return true if DontInline annotation present, false otherwise + */ + public boolean isDontInline() { + return (getFlags() & config().methodFlagsDontInline) != 0; + } + + /** + * Returns true if this method has a {@code ReservedStackAccess} annotation. + * + * @return true if ReservedStackAccess annotation present, false otherwise + */ + public boolean hasReservedStackAccess() { + return (getFlags() & config().methodFlagsReservedStackAccess) != 0; + } + + /** + * Manually adds a DontInline annotation to this method. + */ + public void setNotInlineable() { + compilerToVM().doNotInlineOrCompile(this); + } + + /** + * Returns true if this method is one of the special methods that is ignored by security stack + * walks. + * + * @return true if special method ignored by security stack walks, false otherwise + */ + public boolean ignoredBySecurityStackWalk() { + return compilerToVM().methodIsIgnoredBySecurityStackWalk(this); + } + + @Override + public boolean isClassInitializer() { + return "".equals(name) && isStatic(); + } + + @Override + public boolean isConstructor() { + return "".equals(name) && !isStatic(); + } + + @Override + public int getMaxLocals() { + if (isAbstract() || isNative()) { + return 0; + } + HotSpotVMConfig config = config(); + return UNSAFE.getChar(getConstMethod() + config.methodMaxLocalsOffset); + } + + @Override + public int getMaxStackSize() { + if (isAbstract() || isNative()) { + return 0; + } + HotSpotVMConfig config = config(); + return config.extraStackEntries + UNSAFE.getChar(getConstMethod() + config.constMethodMaxStackOffset); + } + + @Override + public StackTraceElement asStackTraceElement(int bci) { + if (bci < 0 || bci >= getCodeSize()) { + // HotSpot code can only construct stack trace elements for valid bcis + StackTraceElement ste = compilerToVM().getStackTraceElement(this, 0); + return new StackTraceElement(ste.getClassName(), ste.getMethodName(), ste.getFileName(), -1); + } + return compilerToVM().getStackTraceElement(this, bci); + } + + public ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver) { + if (receiver.isInterface()) { + // Cannot trust interfaces. Because of: + // interface I { void foo(); } + // class A { public void foo() {} } + // class B extends A implements I { } + // class C extends B { public void foo() { } } + // class D extends B { } + // Would lead to identify C.foo() as the unique concrete method for I.foo() without + // seeing A.foo(). + return null; + } + if (this.isDefault()) { + // CHA for default methods doesn't work and may crash the VM + return null; + } + return compilerToVM().findUniqueConcreteMethod(((HotSpotResolvedObjectTypeImpl) receiver), this); + } + + @Override + public HotSpotSignature getSignature() { + return signature; + } + + /** + * Gets the value of {@code Method::_code}. + * + * @return the value of {@code Method::_code} + */ + private long getCompiledCode() { + HotSpotVMConfig config = config(); + return UNSAFE.getAddress(metaspaceMethod + config.methodCodeOffset); + } + + /** + * Returns whether this method has compiled code. + * + * @return true if this method has compiled code, false otherwise + */ + public boolean hasCompiledCode() { + return getCompiledCode() != 0L; + } + + /** + * @param level + * @return true if the currently installed code was generated at {@code level}. + */ + public boolean hasCompiledCodeAtLevel(int level) { + long compiledCode = getCompiledCode(); + if (compiledCode != 0) { + return UNSAFE.getInt(compiledCode + config().nmethodCompLevelOffset) == level; + } + return false; + } + + @Override + public ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) { + ProfilingInfo info; + + if (methodData == null) { + long metaspaceMethodData = UNSAFE.getAddress(metaspaceMethod + config().methodDataOffset); + if (metaspaceMethodData != 0) { + methodData = new HotSpotMethodData(metaspaceMethodData, this); + String methodDataFilter = Option.TraceMethodDataFilter.getString(); + if (methodDataFilter != null && this.format("%H.%n").contains(methodDataFilter)) { + System.out.println("Raw method data for " + this.format("%H.%n(%p)") + ":"); + System.out.println(methodData.toString()); + } + } + } + + if (methodData == null || (!methodData.hasNormalData() && !methodData.hasExtraData())) { + // Be optimistic and return false for exceptionSeen. A methodDataOop is allocated in + // case of a deoptimization. + info = DefaultProfilingInfo.get(TriState.FALSE); + } else { + info = new HotSpotProfilingInfo(methodData, this, includeNormal, includeOSR); + } + return info; + } + + @Override + public void reprofile() { + compilerToVM().reprofile(this); + } + + @Override + public ConstantPool getConstantPool() { + return constantPool; + } + + @Override + public Annotation[][] getParameterAnnotations() { + Executable javaMethod = toJava(); + return javaMethod == null ? null : javaMethod.getParameterAnnotations(); + } + + @Override + public Annotation[] getAnnotations() { + Executable javaMethod = toJava(); + return javaMethod == null ? new Annotation[0] : javaMethod.getAnnotations(); + } + + @Override + public T getAnnotation(Class annotationClass) { + Executable javaMethod = toJava(); + return javaMethod == null ? null : javaMethod.getAnnotation(annotationClass); + } + + public boolean isDefault() { + if (isConstructor()) { + return false; + } + // Copied from java.lang.Method.isDefault() + int mask = Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC; + return ((getModifiers() & mask) == Modifier.PUBLIC) && getDeclaringClass().isInterface(); + } + + @Override + public Type[] getGenericParameterTypes() { + Executable javaMethod = toJava(); + return javaMethod == null ? null : javaMethod.getGenericParameterTypes(); + } + + public Class[] signatureToTypes() { + Signature sig = getSignature(); + int count = sig.getParameterCount(false); + Class[] result = new Class[count]; + for (int i = 0; i < result.length; ++i) { + JavaType parameterType = sig.getParameterType(i, holder); + HotSpotResolvedJavaType resolvedParameterType = (HotSpotResolvedJavaType) parameterType.resolve(holder); + result[i] = resolvedParameterType.mirror(); + } + return result; + } + + private Executable toJava() { + if (toJavaCache != null) { + return toJavaCache; + } + try { + Class[] parameterTypes = signatureToTypes(); + Executable result = isConstructor() ? holder.mirror().getDeclaredConstructor(parameterTypes) : holder.mirror().getDeclaredMethod(name, parameterTypes); + toJavaCache = result; + return result; + } catch (NoSuchMethodException | NoClassDefFoundError e) { + return null; + } + } + + @Override + public boolean canBeInlined() { + if (isDontInline()) { + return false; + } + return compilerToVM().canInlineMethod(this); + } + + @Override + public boolean shouldBeInlined() { + if (isForceInline()) { + return true; + } + return compilerToVM().shouldInlineMethod(this); + } + + @Override + public LineNumberTable getLineNumberTable() { + final boolean hasLineNumberTable = (getConstMethodFlags() & config().constMethodHasLineNumberTable) != 0; + if (!hasLineNumberTable) { + return null; + } + + long[] values = compilerToVM().getLineNumberTable(this); + if (values == null || values.length == 0) { + // Empty table so treat is as non-existent + return null; + } + assert values.length % 2 == 0; + int[] bci = new int[values.length / 2]; + int[] line = new int[values.length / 2]; + + for (int i = 0; i < values.length / 2; i++) { + bci[i] = (int) values[i * 2]; + line[i] = (int) values[i * 2 + 1]; + } + + return new LineNumberTableImpl(line, bci); + } + + @Override + public LocalVariableTable getLocalVariableTable() { + final boolean hasLocalVariableTable = (getConstMethodFlags() & config().constMethodHasLocalVariableTable) != 0; + if (!hasLocalVariableTable) { + return null; + } + + HotSpotVMConfig config = config(); + long localVariableTableElement = compilerToVM().getLocalVariableTableStart(this); + final int localVariableTableLength = compilerToVM().getLocalVariableTableLength(this); + Local[] locals = new Local[localVariableTableLength]; + + for (int i = 0; i < localVariableTableLength; i++) { + final int startBci = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementStartBciOffset); + final int endBci = startBci + UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementLengthOffset); + final int nameCpIndex = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementNameCpIndexOffset); + final int typeCpIndex = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementDescriptorCpIndexOffset); + final int slot = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementSlotOffset); + + String localName = getConstantPool().lookupUtf8(nameCpIndex); + String localType = getConstantPool().lookupUtf8(typeCpIndex); + + locals[i] = new LocalImpl(localName, runtime().lookupType(localType, holder, false), startBci, endBci, slot); + + // Go to the next LocalVariableTableElement + localVariableTableElement += config.localVariableTableElementSize; + } + + return new LocalVariableTableImpl(locals); + } + + /** + * Returns the offset of this method into the v-table. The method must have a v-table entry as + * indicated by {@link #isInVirtualMethodTable(ResolvedJavaType)}, otherwise an exception is + * thrown. + * + * @return the offset of this method into the v-table + */ + public int vtableEntryOffset(ResolvedJavaType resolved) { + if (!isInVirtualMethodTable(resolved)) { + throw new JVMCIError("%s does not have a vtable entry in type %s", this, resolved); + } + HotSpotVMConfig config = config(); + final int vtableIndex = getVtableIndex((HotSpotResolvedObjectTypeImpl) resolved); + return config.klassVtableStartOffset + vtableIndex * config.vtableEntrySize + config.vtableEntryMethodOffset; + } + + @Override + public boolean isInVirtualMethodTable(ResolvedJavaType resolved) { + if (resolved instanceof HotSpotResolvedObjectTypeImpl) { + HotSpotResolvedObjectTypeImpl hotspotResolved = (HotSpotResolvedObjectTypeImpl) resolved; + int vtableIndex = getVtableIndex(hotspotResolved); + return vtableIndex >= 0 && vtableIndex < hotspotResolved.getVtableLength(); + } + return false; + } + + private int getVtableIndex(HotSpotResolvedObjectTypeImpl resolved) { + if (!holder.isLinked()) { + return config().invalidVtableIndex; + } + if (holder.isInterface()) { + if (resolved.isInterface()) { + return config().invalidVtableIndex; + } + return getVtableIndexForInterfaceMethod(resolved); + } + return getVtableIndex(); + } + + /** + * Returns this method's virtual table index. + * + * @return virtual table index + */ + private int getVtableIndex() { + assert !holder.isInterface(); + HotSpotVMConfig config = config(); + int result = UNSAFE.getInt(metaspaceMethod + config.methodVtableIndexOffset); + assert result >= config.nonvirtualVtableIndex : "must be linked"; + return result; + } + + private int getVtableIndexForInterfaceMethod(ResolvedJavaType resolved) { + HotSpotResolvedObjectTypeImpl hotspotType = (HotSpotResolvedObjectTypeImpl) resolved; + return compilerToVM().getVtableIndexForInterfaceMethod(hotspotType, this); + } + + /** + * The {@link SpeculationLog} for methods compiled by JVMCI hang off this per-declaring-type + * {@link ClassValue}. The raw Method* value is safe to use as a key in the map as a) it is + * never moves and b) we never read from it. + *

+ * One implication is that we will preserve {@link SpeculationLog}s for methods that have been + * redefined via class redefinition. It's tempting to periodically flush such logs but we cannot + * read the JVM_ACC_IS_OBSOLETE bit (or anything else) via the raw pointer as obsoleted methods + * are subject to clean up and deletion (see InstanceKlass::purge_previous_versions_internal). + */ + private static final ClassValue> SpeculationLogs = new ClassValue>() { + @Override + protected Map computeValue(java.lang.Class type) { + return new HashMap<>(4); + } + }; + + public SpeculationLog getSpeculationLog() { + Map map = SpeculationLogs.get(holder.mirror()); + synchronized (map) { + SpeculationLog log = map.get(this.metaspaceMethod); + if (log == null) { + log = new HotSpotSpeculationLog(); + map.put(metaspaceMethod, log); + } + return log; + } + } + + public int intrinsicId() { + HotSpotVMConfig config = config(); + return UNSAFE.getChar(metaspaceMethod + config.methodIntrinsicIdOffset); + } + + @Override + public JavaConstant invoke(JavaConstant receiver, JavaConstant[] arguments) { + assert !isConstructor(); + Method javaMethod = (Method) toJava(); + javaMethod.setAccessible(true); + + Object[] objArguments = new Object[arguments.length]; + for (int i = 0; i < arguments.length; i++) { + objArguments[i] = HotSpotObjectConstantImpl.asBoxedValue(arguments[i]); + } + Object objReceiver = receiver != null && !receiver.isNull() ? ((HotSpotObjectConstantImpl) receiver).object() : null; + + try { + Object objResult = javaMethod.invoke(objReceiver, objArguments); + return javaMethod.getReturnType() == void.class ? null : HotSpotObjectConstantImpl.forBoxedValue(getSignature().getReturnKind(), objResult); + + } catch (IllegalAccessException | InvocationTargetException ex) { + throw new IllegalArgumentException(ex); + } + } + + /** + * Allocates a compile id for this method by asking the VM for one. + * + * @param entryBCI entry bci + * @return compile id + */ + public int allocateCompileId(int entryBCI) { + return compilerToVM().allocateCompileId(this, entryBCI); + } + + public boolean hasCodeAtLevel(int entryBCI, int level) { + if (entryBCI == config().invocationEntryBci) { + return hasCompiledCodeAtLevel(level); + } + return compilerToVM().hasCompiledCodeForOSR(this, entryBCI, level); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaType.java 2016-05-04 09:43:44.000000000 -1000 +++ /dev/null 2016-05-04 09:43:44.000000000 -1000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.ResolvedJavaType; - -public abstract class HotSpotResolvedJavaType extends HotSpotJavaType implements ResolvedJavaType { - - HotSpotResolvedJavaType(String name) { - super(name); - } - - public abstract Class mirror(); - - @Override - public final boolean equals(Object obj) { - if (!(obj instanceof HotSpotResolvedJavaType)) { - return false; - } - HotSpotResolvedJavaType that = (HotSpotResolvedJavaType) obj; - return this.mirror().equals(that.mirror()); - } - - @Override - public final int hashCode() { - return getName().hashCode(); - } - -} --- /dev/null 2016-05-04 09:43:44.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaType.java 2016-05-04 09:43:44.000000000 -1000 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.ResolvedJavaType; + +public abstract class HotSpotResolvedJavaType extends HotSpotJavaType implements ResolvedJavaType { + + HotSpotResolvedJavaType(String name) { + super(name); + } + + public abstract Class mirror(); + + @Override + public final boolean equals(Object obj) { + if (!(obj instanceof HotSpotResolvedJavaType)) { + return false; + } + HotSpotResolvedJavaType that = (HotSpotResolvedJavaType) obj; + return this.mirror().equals(that.mirror()); + } + + @Override + public final int hashCode() { + return getName().hashCode(); + } + +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectType.java 2016-05-04 09:43:45.000000000 -1000 +++ /dev/null 2016-05-04 09:43:45.000000000 -1000 @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.Assumptions.AssumptionResult; -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.ConstantPool; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. - */ -public interface HotSpotResolvedObjectType extends ResolvedJavaType { - - /** - * Gets the JVMCI mirror for a {@link Class} object. - * - * @return the {@link HotSpotResolvedJavaType} corresponding to {@code javaClass} - */ - static HotSpotResolvedObjectType fromObjectClass(Class javaClass) { - return HotSpotResolvedObjectTypeImpl.fromObjectClass(javaClass); - } - - HotSpotResolvedObjectType getArrayClass(); - - ResolvedJavaType getComponentType(); - - AssumptionResult findLeafConcreteSubtype(); - - HotSpotResolvedObjectType getSuperclass(); - - HotSpotResolvedObjectType[] getInterfaces(); - - HotSpotResolvedObjectType getSupertype(); - - HotSpotResolvedObjectType findLeastCommonAncestor(ResolvedJavaType otherType); - - HotSpotResolvedObjectType asExactType(); - - default boolean isPrimitive() { - return false; - } - - default JavaKind getJavaKind() { - return JavaKind.Object; - } - - ConstantPool getConstantPool(); - - /** - * Gets the instance size of this type. If an instance of this type cannot be fast path - * allocated, then the returned value is negative (its absolute value gives the size). Must not - * be called if this is an array or interface type. - */ - int instanceSize(); - - int getVtableLength(); - - @Override - AssumptionResult findUniqueConcreteMethod(ResolvedJavaMethod method); - - /** - * Performs a fast-path check that this type is resolved in the context of a given accessing - * class. A negative result does not mean this type is not resolved with respect to - * {@code accessingClass}. That can only be determined by - * {@linkplain HotSpotJVMCIRuntime#lookupType(String, HotSpotResolvedObjectType, boolean) - * re-resolving} the type. - */ - boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass); - - /** - * Gets the metaspace Klass boxed in a {@link JavaConstant}. - */ - Constant klass(); - - boolean isPrimaryType(); - - int superCheckOffset(); - - long prototypeMarkWord(); - - int layoutHelper(); - - HotSpotResolvedObjectType getEnclosingType(); - - ResolvedJavaMethod getClassInitializer(); - - ResolvedJavaField createField(String name, JavaType type, long offset, int modifiers); -} --- /dev/null 2016-05-04 09:43:45.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectType.java 2016-05-04 09:43:45.000000000 -1000 @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.Assumptions.AssumptionResult; +import jdk.vm.ci.meta.Constant; +import jdk.vm.ci.meta.ConstantPool; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.ResolvedJavaField; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; + +/** + * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. + */ +public interface HotSpotResolvedObjectType extends ResolvedJavaType { + + /** + * Gets the JVMCI mirror for a {@link Class} object. + * + * @return the {@link HotSpotResolvedJavaType} corresponding to {@code javaClass} + */ + static HotSpotResolvedObjectType fromObjectClass(Class javaClass) { + return HotSpotResolvedObjectTypeImpl.fromObjectClass(javaClass); + } + + HotSpotResolvedObjectType getArrayClass(); + + ResolvedJavaType getComponentType(); + + AssumptionResult findLeafConcreteSubtype(); + + HotSpotResolvedObjectType getSuperclass(); + + HotSpotResolvedObjectType[] getInterfaces(); + + HotSpotResolvedObjectType getSupertype(); + + HotSpotResolvedObjectType findLeastCommonAncestor(ResolvedJavaType otherType); + + HotSpotResolvedObjectType asExactType(); + + default boolean isPrimitive() { + return false; + } + + default JavaKind getJavaKind() { + return JavaKind.Object; + } + + ConstantPool getConstantPool(); + + /** + * Gets the instance size of this type. If an instance of this type cannot be fast path + * allocated, then the returned value is negative (its absolute value gives the size). Must not + * be called if this is an array or interface type. + */ + int instanceSize(); + + int getVtableLength(); + + @Override + AssumptionResult findUniqueConcreteMethod(ResolvedJavaMethod method); + + /** + * Performs a fast-path check that this type is resolved in the context of a given accessing + * class. A negative result does not mean this type is not resolved with respect to + * {@code accessingClass}. That can only be determined by + * {@linkplain HotSpotJVMCIRuntime#lookupType(String, HotSpotResolvedObjectType, boolean) + * re-resolving} the type. + */ + boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass); + + /** + * Gets the metaspace Klass boxed in a {@link JavaConstant}. + */ + Constant klass(); + + boolean isPrimaryType(); + + int superCheckOffset(); + + long prototypeMarkWord(); + + int layoutHelper(); + + HotSpotResolvedObjectType getEnclosingType(); + + ResolvedJavaMethod getClassInitializer(); + + ResolvedJavaField createField(String name, JavaType type, long offset, int modifiers); +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java 2016-05-04 09:43:46.000000000 -1000 +++ /dev/null 2016-05-04 09:43:46.000000000 -1000 @@ -1,890 +0,0 @@ -/* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static java.util.Objects.requireNonNull; -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Array; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.nio.ByteOrder; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.Assumptions.AssumptionResult; -import jdk.vm.ci.meta.Assumptions.ConcreteMethod; -import jdk.vm.ci.meta.Assumptions.ConcreteSubtype; -import jdk.vm.ci.meta.Assumptions.LeafType; -import jdk.vm.ci.meta.Assumptions.NoFinalizableSubclass; -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ModifiersProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.TrustedInterface; - -/** - * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. - */ -final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implements HotSpotResolvedObjectType, HotSpotProxified, MetaspaceWrapperObject { - - /** - * The Java class this type represents. - */ - private final Class javaClass; - private HashMap fieldCache; - private HashMap methodCache; - private HotSpotResolvedJavaField[] instanceFields; - private HotSpotResolvedObjectTypeImpl[] interfaces; - private HotSpotConstantPool constantPool; - final HotSpotJVMCIMetaAccessContext context; - private HotSpotResolvedObjectType arrayOfType; - - /** - * Gets the JVMCI mirror for a {@link Class} object. - * - * @return the {@link HotSpotResolvedJavaType} corresponding to {@code javaClass} - */ - static HotSpotResolvedObjectTypeImpl fromObjectClass(Class javaClass) { - return (HotSpotResolvedObjectTypeImpl) runtime().fromClass(javaClass); - } - - /** - * Gets the JVMCI mirror from a HotSpot type. Since {@link Class} is already a proxy for the - * underlying Klass*, it is used instead of the raw Klass*. - * - * Called from the VM. - * - * @param javaClass a {@link Class} object - * @return the {@link ResolvedJavaType} corresponding to {@code javaClass} - */ - @SuppressWarnings("unused") - private static HotSpotResolvedObjectTypeImpl fromMetaspace(Class javaClass) { - return fromObjectClass(javaClass); - } - - /** - * Creates the JVMCI mirror for a {@link Class} object. - * - *

- * NOTE: Creating an instance of this class does not install the mirror for the - * {@link Class} type. Use {@link #fromObjectClass(Class)} or {@link #fromMetaspace(Class)} - * instead. - *

- * - * @param javaClass the Class to create the mirror for - * @param context - */ - HotSpotResolvedObjectTypeImpl(Class javaClass, HotSpotJVMCIMetaAccessContext context) { - super(getSignatureName(javaClass)); - this.javaClass = javaClass; - this.context = context; - assert getName().charAt(0) != '[' || isArray() : getName(); - } - - /** - * Returns the name of this type as it would appear in a signature. - */ - private static String getSignatureName(Class javaClass) { - if (javaClass.isArray()) { - return javaClass.getName().replace('.', '/'); - } - return "L" + javaClass.getName().replace('.', '/') + ";"; - } - - /** - * Gets the metaspace Klass for this type. - */ - long getMetaspaceKlass() { - if (HotSpotJVMCIRuntime.getHostWordKind() == JavaKind.Long) { - return UNSAFE.getLong(javaClass, (long) config().klassOffset); - } - return UNSAFE.getInt(javaClass, (long) config().klassOffset) & 0xFFFFFFFFL; - } - - public long getMetaspacePointer() { - return getMetaspaceKlass(); - } - - @Override - public int getModifiers() { - if (isArray()) { - return (getElementalType().getModifiers() & (Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED)) | Modifier.FINAL | Modifier.ABSTRACT; - } else { - return getAccessFlags() & ModifiersProvider.jvmClassModifiers(); - } - } - - public int getAccessFlags() { - HotSpotVMConfig config = config(); - return UNSAFE.getInt(getMetaspaceKlass() + config.klassAccessFlagsOffset); - } - - @Override - public HotSpotResolvedObjectType getArrayClass() { - if (arrayOfType == null) { - arrayOfType = fromObjectClass(Array.newInstance(mirror(), 0).getClass()); - } - return arrayOfType; - } - - @Override - public ResolvedJavaType getComponentType() { - Class javaComponentType = mirror().getComponentType(); - return javaComponentType == null ? null : runtime().fromClass(javaComponentType); - } - - @Override - public AssumptionResult findLeafConcreteSubtype() { - HotSpotVMConfig config = config(); - if (isArray()) { - return getElementalType().isLeaf() ? new AssumptionResult<>(this) : null; - } else if (isInterface()) { - HotSpotResolvedObjectTypeImpl implementor = getSingleImplementor(); - /* - * If the implementor field contains itself that indicates that the interface has more - * than one implementors (see: InstanceKlass::add_implementor). - */ - if (implementor == null || implementor.equals(this)) { - return null; - } - - assert !implementor.isInterface(); - if (implementor.isAbstract() || !implementor.isLeafClass()) { - AssumptionResult leafConcreteSubtype = implementor.findLeafConcreteSubtype(); - if (leafConcreteSubtype != null) { - assert !leafConcreteSubtype.getResult().equals(implementor); - AssumptionResult newResult = new AssumptionResult<>(leafConcreteSubtype.getResult(), new ConcreteSubtype(this, implementor)); - // Accumulate leaf assumptions and return the combined result. - newResult.add(leafConcreteSubtype); - return newResult; - } - return null; - } - - return new AssumptionResult<>(implementor, new LeafType(implementor), new ConcreteSubtype(this, implementor)); - } else { - HotSpotResolvedObjectTypeImpl type = this; - while (type.isAbstract()) { - HotSpotResolvedObjectTypeImpl subklass = type.getSubklass(); - if (subklass == null || UNSAFE.getAddress(subklass.getMetaspaceKlass() + config.nextSiblingOffset) != 0) { - return null; - } - type = subklass; - } - if (type.isAbstract() || type.isInterface() || !type.isLeafClass()) { - return null; - } - if (this.isAbstract()) { - return new AssumptionResult<>(type, new LeafType(type), new ConcreteSubtype(this, type)); - } else { - assert this.equals(type); - return new AssumptionResult<>(type, new LeafType(type)); - } - } - } - - /** - * Returns if type {@code type} is a leaf class. This is the case if the - * {@code Klass::_subklass} field of the underlying class is zero. - * - * @return true if the type is a leaf class - */ - private boolean isLeafClass() { - return getSubklass() == null; - } - - /** - * Returns the {@code Klass::_subklass} field of the underlying metaspace klass for the given - * type {@code type}. - * - * @return value of the subklass field as metaspace klass pointer - */ - private HotSpotResolvedObjectTypeImpl getSubklass() { - return compilerToVM().getResolvedJavaType(this, config().subklassOffset, false); - } - - @Override - public HotSpotResolvedObjectTypeImpl getSuperclass() { - Class javaSuperclass = mirror().getSuperclass(); - return javaSuperclass == null ? null : fromObjectClass(javaSuperclass); - } - - @Override - public HotSpotResolvedObjectTypeImpl[] getInterfaces() { - if (interfaces == null) { - Class[] javaInterfaces = mirror().getInterfaces(); - HotSpotResolvedObjectTypeImpl[] result = new HotSpotResolvedObjectTypeImpl[javaInterfaces.length]; - for (int i = 0; i < javaInterfaces.length; i++) { - result[i] = fromObjectClass(javaInterfaces[i]); - } - interfaces = result; - } - return interfaces; - } - - @Override - public HotSpotResolvedObjectTypeImpl getSingleImplementor() { - if (!isInterface()) { - throw new JVMCIError("Cannot call getSingleImplementor() on a non-interface type: %s", this); - } - return compilerToVM().getImplementor(this); - } - - public HotSpotResolvedObjectTypeImpl getSupertype() { - if (isArray()) { - ResolvedJavaType componentType = getComponentType(); - if (mirror() == Object[].class || componentType.isPrimitive()) { - return fromObjectClass(Object.class); - } - return (HotSpotResolvedObjectTypeImpl) ((HotSpotResolvedObjectTypeImpl) componentType).getSupertype().getArrayClass(); - } - if (isInterface()) { - return fromObjectClass(Object.class); - } - return getSuperclass(); - } - - @Override - public HotSpotResolvedObjectType findLeastCommonAncestor(ResolvedJavaType otherType) { - if (otherType.isPrimitive()) { - return null; - } else { - HotSpotResolvedObjectTypeImpl t1 = this; - HotSpotResolvedObjectTypeImpl t2 = (HotSpotResolvedObjectTypeImpl) otherType; - while (true) { - if (t1.isAssignableFrom(t2)) { - return t1; - } - if (t2.isAssignableFrom(t1)) { - return t2; - } - t1 = t1.getSupertype(); - t2 = t2.getSupertype(); - } - } - } - - @Override - public HotSpotResolvedObjectType asExactType() { - return isLeaf() ? this : null; - } - - @Override - public AssumptionResult hasFinalizableSubclass() { - assert !isArray(); - if (!compilerToVM().hasFinalizableSubclass(this)) { - return new AssumptionResult<>(false, new NoFinalizableSubclass(this)); - } - return new AssumptionResult<>(true); - } - - @Override - public boolean hasFinalizer() { - return (getAccessFlags() & config().jvmAccHasFinalizer) != 0; - } - - @Override - public boolean isPrimitive() { - return false; - } - - @Override - public boolean isArray() { - return mirror().isArray(); - } - - @Override - public boolean isInitialized() { - return isArray() ? true : getInitState() == config().instanceKlassStateFullyInitialized; - } - - @Override - public boolean isLinked() { - return isArray() ? true : getInitState() >= config().instanceKlassStateLinked; - } - - /** - * Returns the value of the state field {@code InstanceKlass::_init_state} of the metaspace - * klass. - * - * @return state field value of this type - */ - private int getInitState() { - assert !isArray() : "_init_state only exists in InstanceKlass"; - return UNSAFE.getByte(getMetaspaceKlass() + config().instanceKlassInitStateOffset) & 0xFF; - } - - @Override - public void initialize() { - if (!isInitialized()) { - UNSAFE.ensureClassInitialized(mirror()); - assert isInitialized(); - } - } - - @Override - public boolean isInstance(JavaConstant obj) { - if (obj.getJavaKind() == JavaKind.Object && !obj.isNull()) { - return mirror().isInstance(((HotSpotObjectConstantImpl) obj).object()); - } - return false; - } - - @Override - public boolean isInstanceClass() { - return !isArray() && !isInterface(); - } - - @Override - public boolean isInterface() { - return mirror().isInterface(); - } - - @Override - public boolean isAssignableFrom(ResolvedJavaType other) { - assert other != null; - if (other instanceof HotSpotResolvedObjectTypeImpl) { - HotSpotResolvedObjectTypeImpl otherType = (HotSpotResolvedObjectTypeImpl) other; - return mirror().isAssignableFrom(otherType.mirror()); - } - return false; - } - - @Override - public boolean isJavaLangObject() { - return javaClass.equals(Object.class); - } - - @Override - public JavaKind getJavaKind() { - return JavaKind.Object; - } - - @Override - public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { - assert !callerType.isArray(); - if (isInterface()) { - // Methods can only be resolved against concrete types - return null; - } - if (method.isConcrete() && method.getDeclaringClass().equals(this) && method.isPublic()) { - return method; - } - if (!method.getDeclaringClass().isAssignableFrom(this)) { - return null; - } - HotSpotResolvedJavaMethodImpl hotSpotMethod = (HotSpotResolvedJavaMethodImpl) method; - HotSpotResolvedObjectTypeImpl hotSpotCallerType = (HotSpotResolvedObjectTypeImpl) callerType; - return compilerToVM().resolveMethod(this, hotSpotMethod, hotSpotCallerType); - } - - public HotSpotConstantPool getConstantPool() { - if (constantPool == null) { - constantPool = compilerToVM().getConstantPool(this, config().instanceKlassConstantsOffset); - } - return constantPool; - } - - /** - * Gets the instance size of this type. If an instance of this type cannot be fast path - * allocated, then the returned value is negative (its absolute value gives the size). Must not - * be called if this is an array or interface type. - */ - public int instanceSize() { - assert !isArray(); - assert !isInterface(); - - HotSpotVMConfig config = config(); - final int layoutHelper = layoutHelper(); - assert layoutHelper > config.klassLayoutHelperNeutralValue : "must be instance"; - - // See: Klass::layout_helper_size_in_bytes - int size = layoutHelper & ~config.klassLayoutHelperInstanceSlowPathBit; - - // See: Klass::layout_helper_needs_slow_path - boolean needsSlowPath = (layoutHelper & config.klassLayoutHelperInstanceSlowPathBit) != 0; - - return needsSlowPath ? -size : size; - } - - public int layoutHelper() { - HotSpotVMConfig config = config(); - return UNSAFE.getInt(getMetaspaceKlass() + config.klassLayoutHelperOffset); - } - - synchronized HotSpotResolvedJavaMethod createMethod(long metaspaceMethod) { - HotSpotResolvedJavaMethodImpl method = null; - if (methodCache == null) { - methodCache = new HashMap<>(8); - } else { - method = methodCache.get(metaspaceMethod); - } - if (method == null) { - method = new HotSpotResolvedJavaMethodImpl(this, metaspaceMethod); - methodCache.put(metaspaceMethod, method); - context.add(method); - } - return method; - } - - public int getVtableLength() { - HotSpotVMConfig config = config(); - if (isInterface() || isArray()) { - /* Everything has the core vtable of java.lang.Object */ - return config.baseVtableLength(); - } - int result = UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) / (config.vtableEntrySize / config.heapWordSize); - assert result >= config.baseVtableLength() : UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) + " " + config.vtableEntrySize; - return result; - } - - public synchronized HotSpotResolvedJavaField createField(String fieldName, JavaType type, long offset, int rawFlags) { - HotSpotResolvedJavaField result = null; - - final int flags = rawFlags & ModifiersProvider.jvmFieldModifiers(); - - final long id = offset + ((long) flags << 32); - - // Must cache the fields, because the local load elimination only works if the - // objects from two field lookups are identical. - if (fieldCache == null) { - fieldCache = new HashMap<>(8); - } else { - result = fieldCache.get(id); - } - - if (result == null) { - result = new HotSpotResolvedJavaFieldImpl(this, fieldName, type, offset, rawFlags); - fieldCache.put(id, result); - } else { - assert result.getName().equals(fieldName); - // assert result.getType().equals(type); - assert result.offset() == offset; - assert result.getModifiers() == flags; - } - - return result; - } - - @Override - public AssumptionResult findUniqueConcreteMethod(ResolvedJavaMethod method) { - HotSpotResolvedJavaMethod hmethod = (HotSpotResolvedJavaMethod) method; - HotSpotResolvedObjectType declaredHolder = hmethod.getDeclaringClass(); - /* - * Sometimes the receiver type in the graph hasn't stabilized to a subtype of declared - * holder, usually because of phis, so make sure that the type is related to the declared - * type before using it for lookup. Unlinked types should also be ignored because we can't - * resolve the proper method to invoke. Generally unlinked types in invokes should result in - * a deopt instead since they can't really be used if they aren't linked yet. - */ - if (!declaredHolder.isAssignableFrom(this) || this.isArray() || this.equals(declaredHolder) || !isLinked() || isInterface()) { - ResolvedJavaMethod result = hmethod.uniqueConcreteMethod(declaredHolder); - if (result != null) { - return new AssumptionResult<>(result, new ConcreteMethod(method, declaredHolder, result)); - } - return null; - } - /* - * The holder may be a subtype of the declaredHolder so make sure to resolve the method to - * the correct method for the subtype. - */ - HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) resolveMethod(hmethod, this); - if (resolvedMethod == null) { - // The type isn't known to implement the method. - return null; - } - - ResolvedJavaMethod result = resolvedMethod.uniqueConcreteMethod(this); - if (result != null) { - return new AssumptionResult<>(result, new ConcreteMethod(method, this, result)); - } - return null; - } - - /** - * This class represents the field information for one field contained in the fields array of an - * {@code InstanceKlass}. The implementation is similar to the native {@code FieldInfo} class. - */ - private class FieldInfo { - /** - * Native pointer into the array of Java shorts. - */ - private final long metaspaceData; - - /** - * Creates a field info for the field in the fields array at index {@code index}. - * - * @param index index to the fields array - */ - FieldInfo(int index) { - HotSpotVMConfig config = config(); - // Get Klass::_fields - final long metaspaceFields = UNSAFE.getAddress(getMetaspaceKlass() + config.instanceKlassFieldsOffset); - assert config.fieldInfoFieldSlots == 6 : "revisit the field parsing code"; - metaspaceData = metaspaceFields + config.arrayU2DataOffset + config.fieldInfoFieldSlots * Short.BYTES * index; - } - - private int getAccessFlags() { - return readFieldSlot(config().fieldInfoAccessFlagsOffset); - } - - private int getNameIndex() { - return readFieldSlot(config().fieldInfoNameIndexOffset); - } - - private int getSignatureIndex() { - return readFieldSlot(config().fieldInfoSignatureIndexOffset); - } - - public int getOffset() { - HotSpotVMConfig config = config(); - final int lowPacked = readFieldSlot(config.fieldInfoLowPackedOffset); - final int highPacked = readFieldSlot(config.fieldInfoHighPackedOffset); - final int offset = ((highPacked << Short.SIZE) | lowPacked) >> config.fieldInfoTagSize; - return offset; - } - - /** - * Helper method to read an entry (slot) from the field array. Currently field info is laid - * on top an array of Java shorts. - */ - private int readFieldSlot(int index) { - return UNSAFE.getChar(metaspaceData + Short.BYTES * index); - } - - /** - * Returns the name of this field as a {@link String}. If the field is an internal field the - * name index is pointing into the vmSymbols table. - */ - public String getName() { - final int nameIndex = getNameIndex(); - return isInternal() ? HotSpotVmSymbols.symbolAt(nameIndex) : getConstantPool().lookupUtf8(nameIndex); - } - - /** - * Returns the signature of this field as {@link String}. If the field is an internal field - * the signature index is pointing into the vmSymbols table. - */ - public String getSignature() { - final int signatureIndex = getSignatureIndex(); - return isInternal() ? HotSpotVmSymbols.symbolAt(signatureIndex) : getConstantPool().lookupUtf8(signatureIndex); - } - - public JavaType getType() { - String signature = getSignature(); - return runtime().lookupType(signature, HotSpotResolvedObjectTypeImpl.this, false); - } - - private boolean isInternal() { - return (getAccessFlags() & config().jvmAccFieldInternal) != 0; - } - - public boolean isStatic() { - return Modifier.isStatic(getAccessFlags()); - } - - public boolean hasGenericSignature() { - return (getAccessFlags() & config().jvmAccFieldHasGenericSignature) != 0; - } - } - - private static class OffsetComparator implements java.util.Comparator { - @Override - public int compare(HotSpotResolvedJavaField o1, HotSpotResolvedJavaField o2) { - return o1.offset() - o2.offset(); - } - } - - @Override - public ResolvedJavaField[] getInstanceFields(boolean includeSuperclasses) { - if (instanceFields == null) { - if (isArray() || isInterface()) { - instanceFields = new HotSpotResolvedJavaField[0]; - } else { - final int fieldCount = getFieldCount(); - ArrayList fieldsArray = new ArrayList<>(fieldCount); - - for (int i = 0; i < fieldCount; i++) { - FieldInfo field = new FieldInfo(i); - - // We are only interested in instance fields. - if (!field.isStatic()) { - HotSpotResolvedJavaField resolvedJavaField = createField(field.getName(), field.getType(), field.getOffset(), field.getAccessFlags()); - fieldsArray.add(resolvedJavaField); - } - } - - fieldsArray.sort(new OffsetComparator()); - - HotSpotResolvedJavaField[] myFields = fieldsArray.toArray(new HotSpotResolvedJavaField[0]); - - if (mirror() != Object.class) { - HotSpotResolvedJavaField[] superFields = (HotSpotResolvedJavaField[]) getSuperclass().getInstanceFields(true); - HotSpotResolvedJavaField[] fields = Arrays.copyOf(superFields, superFields.length + myFields.length); - System.arraycopy(myFields, 0, fields, superFields.length, myFields.length); - instanceFields = fields; - } else { - assert myFields.length == 0 : "java.lang.Object has fields!"; - instanceFields = myFields; - } - - } - } - if (!includeSuperclasses) { - int myFieldsStart = 0; - while (myFieldsStart < instanceFields.length && !instanceFields[myFieldsStart].getDeclaringClass().equals(this)) { - myFieldsStart++; - } - if (myFieldsStart == 0) { - return instanceFields; - } - if (myFieldsStart == instanceFields.length) { - return new HotSpotResolvedJavaField[0]; - } - return Arrays.copyOfRange(instanceFields, myFieldsStart, instanceFields.length); - } - return instanceFields; - } - - @Override - public ResolvedJavaField[] getStaticFields() { - if (isArray()) { - return new HotSpotResolvedJavaField[0]; - } else { - final int fieldCount = getFieldCount(); - ArrayList fieldsArray = new ArrayList<>(fieldCount); - - for (int i = 0; i < fieldCount; i++) { - FieldInfo field = new FieldInfo(i); - - // We are only interested in static fields. - if (field.isStatic()) { - HotSpotResolvedJavaField resolvedJavaField = createField(field.getName(), field.getType(), field.getOffset(), field.getAccessFlags()); - fieldsArray.add(resolvedJavaField); - } - } - - fieldsArray.sort(new OffsetComparator()); - return fieldsArray.toArray(new HotSpotResolvedJavaField[fieldsArray.size()]); - } - } - - /** - * Returns the actual field count of this class's internal {@code InstanceKlass::_fields} array - * by walking the array and discounting the generic signature slots at the end of the array. - * - *

- * See {@code FieldStreamBase::init_generic_signature_start_slot} - */ - private int getFieldCount() { - HotSpotVMConfig config = config(); - final long metaspaceFields = UNSAFE.getAddress(getMetaspaceKlass() + config.instanceKlassFieldsOffset); - int metaspaceFieldsLength = UNSAFE.getInt(metaspaceFields + config.arrayU1LengthOffset); - int fieldCount = 0; - - for (int i = 0, index = 0; i < metaspaceFieldsLength; i += config.fieldInfoFieldSlots, index++) { - FieldInfo field = new FieldInfo(index); - if (field.hasGenericSignature()) { - metaspaceFieldsLength--; - } - fieldCount++; - } - return fieldCount; - } - - @Override - public Class mirror() { - return javaClass; - } - - @Override - public String getSourceFileName() { - HotSpotVMConfig config = config(); - final int sourceFileNameIndex = UNSAFE.getChar(getMetaspaceKlass() + config.instanceKlassSourceFileNameIndexOffset); - if (sourceFileNameIndex == 0) { - return null; - } - return getConstantPool().lookupUtf8(sourceFileNameIndex); - } - - @Override - public Annotation[] getAnnotations() { - return mirror().getAnnotations(); - } - - @Override - public T getAnnotation(Class annotationClass) { - return mirror().getAnnotation(annotationClass); - } - - /** - * Performs a fast-path check that this type is resolved in the context of a given accessing - * class. A negative result does not mean this type is not resolved with respect to - * {@code accessingClass}. That can only be determined by - * {@linkplain HotSpotJVMCIRuntime#lookupType(String, HotSpotResolvedObjectType, boolean) - * re-resolving} the type. - */ - public boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass) { - assert accessingClass != null; - ResolvedJavaType elementType = getElementalType(); - if (elementType.isPrimitive()) { - // Primitive type resolution is context free. - return true; - } - if (elementType.getName().startsWith("Ljava/")) { - // Classes in a java.* package can only be defined by the - // boot class loader. This is enforced by ClassLoader.preDefineClass() - assert mirror().getClassLoader() == null; - return true; - } - ClassLoader thisCl = mirror().getClassLoader(); - ClassLoader accessingClassCl = ((HotSpotResolvedObjectTypeImpl) accessingClass).mirror().getClassLoader(); - return thisCl == accessingClassCl; - } - - @Override - public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { - if (isDefinitelyResolvedWithRespectTo(requireNonNull(accessingClass))) { - return this; - } - HotSpotResolvedObjectTypeImpl accessingType = (HotSpotResolvedObjectTypeImpl) accessingClass; - return (ResolvedJavaType) runtime().lookupType(getName(), accessingType, true); - } - - /** - * Gets the metaspace Klass boxed in a {@link JavaConstant}. - */ - public Constant klass() { - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(this, false); - } - - public boolean isPrimaryType() { - return config().secondarySuperCacheOffset != superCheckOffset(); - } - - public int superCheckOffset() { - HotSpotVMConfig config = config(); - return UNSAFE.getInt(getMetaspaceKlass() + config.superCheckOffsetOffset); - } - - public long prototypeMarkWord() { - HotSpotVMConfig config = config(); - if (isArray()) { - return config.arrayPrototypeMarkWord(); - } else { - return UNSAFE.getAddress(getMetaspaceKlass() + config.prototypeMarkWordOffset); - } - } - - @Override - public ResolvedJavaField findInstanceFieldWithOffset(long offset, JavaKind expectedEntryKind) { - ResolvedJavaField[] declaredFields = getInstanceFields(true); - for (ResolvedJavaField field : declaredFields) { - HotSpotResolvedJavaField resolvedField = (HotSpotResolvedJavaField) field; - long resolvedFieldOffset = resolvedField.offset(); - // @formatter:off - if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN && - expectedEntryKind.isPrimitive() && - !expectedEntryKind.equals(JavaKind.Void) && - resolvedField.getJavaKind().isPrimitive()) { - resolvedFieldOffset += - resolvedField.getJavaKind().getByteCount() - - Math.min(resolvedField.getJavaKind().getByteCount(), 4 + expectedEntryKind.getByteCount()); - } - if (resolvedFieldOffset == offset) { - return field; - } - // @formatter:on - } - return null; - } - - @Override - public boolean isLocal() { - return mirror().isLocalClass(); - } - - @Override - public boolean isMember() { - return mirror().isMemberClass(); - } - - @Override - public HotSpotResolvedObjectTypeImpl getEnclosingType() { - final Class encl = mirror().getEnclosingClass(); - return encl == null ? null : fromObjectClass(encl); - } - - @Override - public ResolvedJavaMethod[] getDeclaredConstructors() { - Constructor[] constructors = mirror().getDeclaredConstructors(); - ResolvedJavaMethod[] result = new ResolvedJavaMethod[constructors.length]; - for (int i = 0; i < constructors.length; i++) { - result[i] = runtime().getHostJVMCIBackend().getMetaAccess().lookupJavaMethod(constructors[i]); - assert result[i].isConstructor(); - } - return result; - } - - @Override - public ResolvedJavaMethod[] getDeclaredMethods() { - Method[] methods = mirror().getDeclaredMethods(); - ResolvedJavaMethod[] result = new ResolvedJavaMethod[methods.length]; - for (int i = 0; i < methods.length; i++) { - result[i] = runtime().getHostJVMCIBackend().getMetaAccess().lookupJavaMethod(methods[i]); - assert !result[i].isConstructor(); - } - return result; - } - - public ResolvedJavaMethod getClassInitializer() { - return compilerToVM().getClassInitializer(this); - } - - @Override - public String toString() { - return "HotSpotType<" + getName() + ", resolved>"; - } - - @Override - public boolean isTrustedInterfaceType() { - return TrustedInterface.class.isAssignableFrom(mirror()); - } - - @Override - public boolean isCloneableWithAllocation() { - return (getAccessFlags() & config().jvmAccIsCloneableFast) != 0; - } -} --- /dev/null 2016-05-04 09:43:46.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java 2016-05-04 09:43:45.000000000 -1000 @@ -0,0 +1,890 @@ +/* + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static java.util.Objects.requireNonNull; +import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; +import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; +import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.nio.ByteOrder; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; + +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.meta.Assumptions.AssumptionResult; +import jdk.vm.ci.meta.Assumptions.ConcreteMethod; +import jdk.vm.ci.meta.Assumptions.ConcreteSubtype; +import jdk.vm.ci.meta.Assumptions.LeafType; +import jdk.vm.ci.meta.Assumptions.NoFinalizableSubclass; +import jdk.vm.ci.meta.Constant; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.ModifiersProvider; +import jdk.vm.ci.meta.ResolvedJavaField; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; +import jdk.vm.ci.meta.TrustedInterface; + +/** + * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. + */ +final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implements HotSpotResolvedObjectType, HotSpotProxified, MetaspaceWrapperObject { + + /** + * The Java class this type represents. + */ + private final Class javaClass; + private HashMap fieldCache; + private HashMap methodCache; + private HotSpotResolvedJavaField[] instanceFields; + private HotSpotResolvedObjectTypeImpl[] interfaces; + private HotSpotConstantPool constantPool; + final HotSpotJVMCIMetaAccessContext context; + private HotSpotResolvedObjectType arrayOfType; + + /** + * Gets the JVMCI mirror for a {@link Class} object. + * + * @return the {@link HotSpotResolvedJavaType} corresponding to {@code javaClass} + */ + static HotSpotResolvedObjectTypeImpl fromObjectClass(Class javaClass) { + return (HotSpotResolvedObjectTypeImpl) runtime().fromClass(javaClass); + } + + /** + * Gets the JVMCI mirror from a HotSpot type. Since {@link Class} is already a proxy for the + * underlying Klass*, it is used instead of the raw Klass*. + * + * Called from the VM. + * + * @param javaClass a {@link Class} object + * @return the {@link ResolvedJavaType} corresponding to {@code javaClass} + */ + @SuppressWarnings("unused") + private static HotSpotResolvedObjectTypeImpl fromMetaspace(Class javaClass) { + return fromObjectClass(javaClass); + } + + /** + * Creates the JVMCI mirror for a {@link Class} object. + * + *

+ * NOTE: Creating an instance of this class does not install the mirror for the + * {@link Class} type. Use {@link #fromObjectClass(Class)} or {@link #fromMetaspace(Class)} + * instead. + *

+ * + * @param javaClass the Class to create the mirror for + * @param context + */ + HotSpotResolvedObjectTypeImpl(Class javaClass, HotSpotJVMCIMetaAccessContext context) { + super(getSignatureName(javaClass)); + this.javaClass = javaClass; + this.context = context; + assert getName().charAt(0) != '[' || isArray() : getName(); + } + + /** + * Returns the name of this type as it would appear in a signature. + */ + private static String getSignatureName(Class javaClass) { + if (javaClass.isArray()) { + return javaClass.getName().replace('.', '/'); + } + return "L" + javaClass.getName().replace('.', '/') + ";"; + } + + /** + * Gets the metaspace Klass for this type. + */ + long getMetaspaceKlass() { + if (HotSpotJVMCIRuntime.getHostWordKind() == JavaKind.Long) { + return UNSAFE.getLong(javaClass, (long) config().klassOffset); + } + return UNSAFE.getInt(javaClass, (long) config().klassOffset) & 0xFFFFFFFFL; + } + + public long getMetaspacePointer() { + return getMetaspaceKlass(); + } + + @Override + public int getModifiers() { + if (isArray()) { + return (getElementalType().getModifiers() & (Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED)) | Modifier.FINAL | Modifier.ABSTRACT; + } else { + return getAccessFlags() & ModifiersProvider.jvmClassModifiers(); + } + } + + public int getAccessFlags() { + HotSpotVMConfig config = config(); + return UNSAFE.getInt(getMetaspaceKlass() + config.klassAccessFlagsOffset); + } + + @Override + public HotSpotResolvedObjectType getArrayClass() { + if (arrayOfType == null) { + arrayOfType = fromObjectClass(Array.newInstance(mirror(), 0).getClass()); + } + return arrayOfType; + } + + @Override + public ResolvedJavaType getComponentType() { + Class javaComponentType = mirror().getComponentType(); + return javaComponentType == null ? null : runtime().fromClass(javaComponentType); + } + + @Override + public AssumptionResult findLeafConcreteSubtype() { + HotSpotVMConfig config = config(); + if (isArray()) { + return getElementalType().isLeaf() ? new AssumptionResult<>(this) : null; + } else if (isInterface()) { + HotSpotResolvedObjectTypeImpl implementor = getSingleImplementor(); + /* + * If the implementor field contains itself that indicates that the interface has more + * than one implementors (see: InstanceKlass::add_implementor). + */ + if (implementor == null || implementor.equals(this)) { + return null; + } + + assert !implementor.isInterface(); + if (implementor.isAbstract() || !implementor.isLeafClass()) { + AssumptionResult leafConcreteSubtype = implementor.findLeafConcreteSubtype(); + if (leafConcreteSubtype != null) { + assert !leafConcreteSubtype.getResult().equals(implementor); + AssumptionResult newResult = new AssumptionResult<>(leafConcreteSubtype.getResult(), new ConcreteSubtype(this, implementor)); + // Accumulate leaf assumptions and return the combined result. + newResult.add(leafConcreteSubtype); + return newResult; + } + return null; + } + + return new AssumptionResult<>(implementor, new LeafType(implementor), new ConcreteSubtype(this, implementor)); + } else { + HotSpotResolvedObjectTypeImpl type = this; + while (type.isAbstract()) { + HotSpotResolvedObjectTypeImpl subklass = type.getSubklass(); + if (subklass == null || UNSAFE.getAddress(subklass.getMetaspaceKlass() + config.nextSiblingOffset) != 0) { + return null; + } + type = subklass; + } + if (type.isAbstract() || type.isInterface() || !type.isLeafClass()) { + return null; + } + if (this.isAbstract()) { + return new AssumptionResult<>(type, new LeafType(type), new ConcreteSubtype(this, type)); + } else { + assert this.equals(type); + return new AssumptionResult<>(type, new LeafType(type)); + } + } + } + + /** + * Returns if type {@code type} is a leaf class. This is the case if the + * {@code Klass::_subklass} field of the underlying class is zero. + * + * @return true if the type is a leaf class + */ + private boolean isLeafClass() { + return getSubklass() == null; + } + + /** + * Returns the {@code Klass::_subklass} field of the underlying metaspace klass for the given + * type {@code type}. + * + * @return value of the subklass field as metaspace klass pointer + */ + private HotSpotResolvedObjectTypeImpl getSubklass() { + return compilerToVM().getResolvedJavaType(this, config().subklassOffset, false); + } + + @Override + public HotSpotResolvedObjectTypeImpl getSuperclass() { + Class javaSuperclass = mirror().getSuperclass(); + return javaSuperclass == null ? null : fromObjectClass(javaSuperclass); + } + + @Override + public HotSpotResolvedObjectTypeImpl[] getInterfaces() { + if (interfaces == null) { + Class[] javaInterfaces = mirror().getInterfaces(); + HotSpotResolvedObjectTypeImpl[] result = new HotSpotResolvedObjectTypeImpl[javaInterfaces.length]; + for (int i = 0; i < javaInterfaces.length; i++) { + result[i] = fromObjectClass(javaInterfaces[i]); + } + interfaces = result; + } + return interfaces; + } + + @Override + public HotSpotResolvedObjectTypeImpl getSingleImplementor() { + if (!isInterface()) { + throw new JVMCIError("Cannot call getSingleImplementor() on a non-interface type: %s", this); + } + return compilerToVM().getImplementor(this); + } + + public HotSpotResolvedObjectTypeImpl getSupertype() { + if (isArray()) { + ResolvedJavaType componentType = getComponentType(); + if (mirror() == Object[].class || componentType.isPrimitive()) { + return fromObjectClass(Object.class); + } + return (HotSpotResolvedObjectTypeImpl) ((HotSpotResolvedObjectTypeImpl) componentType).getSupertype().getArrayClass(); + } + if (isInterface()) { + return fromObjectClass(Object.class); + } + return getSuperclass(); + } + + @Override + public HotSpotResolvedObjectType findLeastCommonAncestor(ResolvedJavaType otherType) { + if (otherType.isPrimitive()) { + return null; + } else { + HotSpotResolvedObjectTypeImpl t1 = this; + HotSpotResolvedObjectTypeImpl t2 = (HotSpotResolvedObjectTypeImpl) otherType; + while (true) { + if (t1.isAssignableFrom(t2)) { + return t1; + } + if (t2.isAssignableFrom(t1)) { + return t2; + } + t1 = t1.getSupertype(); + t2 = t2.getSupertype(); + } + } + } + + @Override + public HotSpotResolvedObjectType asExactType() { + return isLeaf() ? this : null; + } + + @Override + public AssumptionResult hasFinalizableSubclass() { + assert !isArray(); + if (!compilerToVM().hasFinalizableSubclass(this)) { + return new AssumptionResult<>(false, new NoFinalizableSubclass(this)); + } + return new AssumptionResult<>(true); + } + + @Override + public boolean hasFinalizer() { + return (getAccessFlags() & config().jvmAccHasFinalizer) != 0; + } + + @Override + public boolean isPrimitive() { + return false; + } + + @Override + public boolean isArray() { + return mirror().isArray(); + } + + @Override + public boolean isInitialized() { + return isArray() ? true : getInitState() == config().instanceKlassStateFullyInitialized; + } + + @Override + public boolean isLinked() { + return isArray() ? true : getInitState() >= config().instanceKlassStateLinked; + } + + /** + * Returns the value of the state field {@code InstanceKlass::_init_state} of the metaspace + * klass. + * + * @return state field value of this type + */ + private int getInitState() { + assert !isArray() : "_init_state only exists in InstanceKlass"; + return UNSAFE.getByte(getMetaspaceKlass() + config().instanceKlassInitStateOffset) & 0xFF; + } + + @Override + public void initialize() { + if (!isInitialized()) { + UNSAFE.ensureClassInitialized(mirror()); + assert isInitialized(); + } + } + + @Override + public boolean isInstance(JavaConstant obj) { + if (obj.getJavaKind() == JavaKind.Object && !obj.isNull()) { + return mirror().isInstance(((HotSpotObjectConstantImpl) obj).object()); + } + return false; + } + + @Override + public boolean isInstanceClass() { + return !isArray() && !isInterface(); + } + + @Override + public boolean isInterface() { + return mirror().isInterface(); + } + + @Override + public boolean isAssignableFrom(ResolvedJavaType other) { + assert other != null; + if (other instanceof HotSpotResolvedObjectTypeImpl) { + HotSpotResolvedObjectTypeImpl otherType = (HotSpotResolvedObjectTypeImpl) other; + return mirror().isAssignableFrom(otherType.mirror()); + } + return false; + } + + @Override + public boolean isJavaLangObject() { + return javaClass.equals(Object.class); + } + + @Override + public JavaKind getJavaKind() { + return JavaKind.Object; + } + + @Override + public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { + assert !callerType.isArray(); + if (isInterface()) { + // Methods can only be resolved against concrete types + return null; + } + if (method.isConcrete() && method.getDeclaringClass().equals(this) && method.isPublic()) { + return method; + } + if (!method.getDeclaringClass().isAssignableFrom(this)) { + return null; + } + HotSpotResolvedJavaMethodImpl hotSpotMethod = (HotSpotResolvedJavaMethodImpl) method; + HotSpotResolvedObjectTypeImpl hotSpotCallerType = (HotSpotResolvedObjectTypeImpl) callerType; + return compilerToVM().resolveMethod(this, hotSpotMethod, hotSpotCallerType); + } + + public HotSpotConstantPool getConstantPool() { + if (constantPool == null) { + constantPool = compilerToVM().getConstantPool(this, config().instanceKlassConstantsOffset); + } + return constantPool; + } + + /** + * Gets the instance size of this type. If an instance of this type cannot be fast path + * allocated, then the returned value is negative (its absolute value gives the size). Must not + * be called if this is an array or interface type. + */ + public int instanceSize() { + assert !isArray(); + assert !isInterface(); + + HotSpotVMConfig config = config(); + final int layoutHelper = layoutHelper(); + assert layoutHelper > config.klassLayoutHelperNeutralValue : "must be instance"; + + // See: Klass::layout_helper_size_in_bytes + int size = layoutHelper & ~config.klassLayoutHelperInstanceSlowPathBit; + + // See: Klass::layout_helper_needs_slow_path + boolean needsSlowPath = (layoutHelper & config.klassLayoutHelperInstanceSlowPathBit) != 0; + + return needsSlowPath ? -size : size; + } + + public int layoutHelper() { + HotSpotVMConfig config = config(); + return UNSAFE.getInt(getMetaspaceKlass() + config.klassLayoutHelperOffset); + } + + synchronized HotSpotResolvedJavaMethod createMethod(long metaspaceMethod) { + HotSpotResolvedJavaMethodImpl method = null; + if (methodCache == null) { + methodCache = new HashMap<>(8); + } else { + method = methodCache.get(metaspaceMethod); + } + if (method == null) { + method = new HotSpotResolvedJavaMethodImpl(this, metaspaceMethod); + methodCache.put(metaspaceMethod, method); + context.add(method); + } + return method; + } + + public int getVtableLength() { + HotSpotVMConfig config = config(); + if (isInterface() || isArray()) { + /* Everything has the core vtable of java.lang.Object */ + return config.baseVtableLength(); + } + int result = UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) / (config.vtableEntrySize / config.heapWordSize); + assert result >= config.baseVtableLength() : UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) + " " + config.vtableEntrySize; + return result; + } + + public synchronized HotSpotResolvedJavaField createField(String fieldName, JavaType type, long offset, int rawFlags) { + HotSpotResolvedJavaField result = null; + + final int flags = rawFlags & ModifiersProvider.jvmFieldModifiers(); + + final long id = offset + ((long) flags << 32); + + // Must cache the fields, because the local load elimination only works if the + // objects from two field lookups are identical. + if (fieldCache == null) { + fieldCache = new HashMap<>(8); + } else { + result = fieldCache.get(id); + } + + if (result == null) { + result = new HotSpotResolvedJavaFieldImpl(this, fieldName, type, offset, rawFlags); + fieldCache.put(id, result); + } else { + assert result.getName().equals(fieldName); + // assert result.getType().equals(type); + assert result.offset() == offset; + assert result.getModifiers() == flags; + } + + return result; + } + + @Override + public AssumptionResult findUniqueConcreteMethod(ResolvedJavaMethod method) { + HotSpotResolvedJavaMethod hmethod = (HotSpotResolvedJavaMethod) method; + HotSpotResolvedObjectType declaredHolder = hmethod.getDeclaringClass(); + /* + * Sometimes the receiver type in the graph hasn't stabilized to a subtype of declared + * holder, usually because of phis, so make sure that the type is related to the declared + * type before using it for lookup. Unlinked types should also be ignored because we can't + * resolve the proper method to invoke. Generally unlinked types in invokes should result in + * a deopt instead since they can't really be used if they aren't linked yet. + */ + if (!declaredHolder.isAssignableFrom(this) || this.isArray() || this.equals(declaredHolder) || !isLinked() || isInterface()) { + ResolvedJavaMethod result = hmethod.uniqueConcreteMethod(declaredHolder); + if (result != null) { + return new AssumptionResult<>(result, new ConcreteMethod(method, declaredHolder, result)); + } + return null; + } + /* + * The holder may be a subtype of the declaredHolder so make sure to resolve the method to + * the correct method for the subtype. + */ + HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) resolveMethod(hmethod, this); + if (resolvedMethod == null) { + // The type isn't known to implement the method. + return null; + } + + ResolvedJavaMethod result = resolvedMethod.uniqueConcreteMethod(this); + if (result != null) { + return new AssumptionResult<>(result, new ConcreteMethod(method, this, result)); + } + return null; + } + + /** + * This class represents the field information for one field contained in the fields array of an + * {@code InstanceKlass}. The implementation is similar to the native {@code FieldInfo} class. + */ + private class FieldInfo { + /** + * Native pointer into the array of Java shorts. + */ + private final long metaspaceData; + + /** + * Creates a field info for the field in the fields array at index {@code index}. + * + * @param index index to the fields array + */ + FieldInfo(int index) { + HotSpotVMConfig config = config(); + // Get Klass::_fields + final long metaspaceFields = UNSAFE.getAddress(getMetaspaceKlass() + config.instanceKlassFieldsOffset); + assert config.fieldInfoFieldSlots == 6 : "revisit the field parsing code"; + metaspaceData = metaspaceFields + config.arrayU2DataOffset + config.fieldInfoFieldSlots * Short.BYTES * index; + } + + private int getAccessFlags() { + return readFieldSlot(config().fieldInfoAccessFlagsOffset); + } + + private int getNameIndex() { + return readFieldSlot(config().fieldInfoNameIndexOffset); + } + + private int getSignatureIndex() { + return readFieldSlot(config().fieldInfoSignatureIndexOffset); + } + + public int getOffset() { + HotSpotVMConfig config = config(); + final int lowPacked = readFieldSlot(config.fieldInfoLowPackedOffset); + final int highPacked = readFieldSlot(config.fieldInfoHighPackedOffset); + final int offset = ((highPacked << Short.SIZE) | lowPacked) >> config.fieldInfoTagSize; + return offset; + } + + /** + * Helper method to read an entry (slot) from the field array. Currently field info is laid + * on top an array of Java shorts. + */ + private int readFieldSlot(int index) { + return UNSAFE.getChar(metaspaceData + Short.BYTES * index); + } + + /** + * Returns the name of this field as a {@link String}. If the field is an internal field the + * name index is pointing into the vmSymbols table. + */ + public String getName() { + final int nameIndex = getNameIndex(); + return isInternal() ? HotSpotVmSymbols.symbolAt(nameIndex) : getConstantPool().lookupUtf8(nameIndex); + } + + /** + * Returns the signature of this field as {@link String}. If the field is an internal field + * the signature index is pointing into the vmSymbols table. + */ + public String getSignature() { + final int signatureIndex = getSignatureIndex(); + return isInternal() ? HotSpotVmSymbols.symbolAt(signatureIndex) : getConstantPool().lookupUtf8(signatureIndex); + } + + public JavaType getType() { + String signature = getSignature(); + return runtime().lookupType(signature, HotSpotResolvedObjectTypeImpl.this, false); + } + + private boolean isInternal() { + return (getAccessFlags() & config().jvmAccFieldInternal) != 0; + } + + public boolean isStatic() { + return Modifier.isStatic(getAccessFlags()); + } + + public boolean hasGenericSignature() { + return (getAccessFlags() & config().jvmAccFieldHasGenericSignature) != 0; + } + } + + private static class OffsetComparator implements java.util.Comparator { + @Override + public int compare(HotSpotResolvedJavaField o1, HotSpotResolvedJavaField o2) { + return o1.offset() - o2.offset(); + } + } + + @Override + public ResolvedJavaField[] getInstanceFields(boolean includeSuperclasses) { + if (instanceFields == null) { + if (isArray() || isInterface()) { + instanceFields = new HotSpotResolvedJavaField[0]; + } else { + final int fieldCount = getFieldCount(); + ArrayList fieldsArray = new ArrayList<>(fieldCount); + + for (int i = 0; i < fieldCount; i++) { + FieldInfo field = new FieldInfo(i); + + // We are only interested in instance fields. + if (!field.isStatic()) { + HotSpotResolvedJavaField resolvedJavaField = createField(field.getName(), field.getType(), field.getOffset(), field.getAccessFlags()); + fieldsArray.add(resolvedJavaField); + } + } + + fieldsArray.sort(new OffsetComparator()); + + HotSpotResolvedJavaField[] myFields = fieldsArray.toArray(new HotSpotResolvedJavaField[0]); + + if (mirror() != Object.class) { + HotSpotResolvedJavaField[] superFields = (HotSpotResolvedJavaField[]) getSuperclass().getInstanceFields(true); + HotSpotResolvedJavaField[] fields = Arrays.copyOf(superFields, superFields.length + myFields.length); + System.arraycopy(myFields, 0, fields, superFields.length, myFields.length); + instanceFields = fields; + } else { + assert myFields.length == 0 : "java.lang.Object has fields!"; + instanceFields = myFields; + } + + } + } + if (!includeSuperclasses) { + int myFieldsStart = 0; + while (myFieldsStart < instanceFields.length && !instanceFields[myFieldsStart].getDeclaringClass().equals(this)) { + myFieldsStart++; + } + if (myFieldsStart == 0) { + return instanceFields; + } + if (myFieldsStart == instanceFields.length) { + return new HotSpotResolvedJavaField[0]; + } + return Arrays.copyOfRange(instanceFields, myFieldsStart, instanceFields.length); + } + return instanceFields; + } + + @Override + public ResolvedJavaField[] getStaticFields() { + if (isArray()) { + return new HotSpotResolvedJavaField[0]; + } else { + final int fieldCount = getFieldCount(); + ArrayList fieldsArray = new ArrayList<>(fieldCount); + + for (int i = 0; i < fieldCount; i++) { + FieldInfo field = new FieldInfo(i); + + // We are only interested in static fields. + if (field.isStatic()) { + HotSpotResolvedJavaField resolvedJavaField = createField(field.getName(), field.getType(), field.getOffset(), field.getAccessFlags()); + fieldsArray.add(resolvedJavaField); + } + } + + fieldsArray.sort(new OffsetComparator()); + return fieldsArray.toArray(new HotSpotResolvedJavaField[fieldsArray.size()]); + } + } + + /** + * Returns the actual field count of this class's internal {@code InstanceKlass::_fields} array + * by walking the array and discounting the generic signature slots at the end of the array. + * + *

+ * See {@code FieldStreamBase::init_generic_signature_start_slot} + */ + private int getFieldCount() { + HotSpotVMConfig config = config(); + final long metaspaceFields = UNSAFE.getAddress(getMetaspaceKlass() + config.instanceKlassFieldsOffset); + int metaspaceFieldsLength = UNSAFE.getInt(metaspaceFields + config.arrayU1LengthOffset); + int fieldCount = 0; + + for (int i = 0, index = 0; i < metaspaceFieldsLength; i += config.fieldInfoFieldSlots, index++) { + FieldInfo field = new FieldInfo(index); + if (field.hasGenericSignature()) { + metaspaceFieldsLength--; + } + fieldCount++; + } + return fieldCount; + } + + @Override + public Class mirror() { + return javaClass; + } + + @Override + public String getSourceFileName() { + HotSpotVMConfig config = config(); + final int sourceFileNameIndex = UNSAFE.getChar(getMetaspaceKlass() + config.instanceKlassSourceFileNameIndexOffset); + if (sourceFileNameIndex == 0) { + return null; + } + return getConstantPool().lookupUtf8(sourceFileNameIndex); + } + + @Override + public Annotation[] getAnnotations() { + return mirror().getAnnotations(); + } + + @Override + public T getAnnotation(Class annotationClass) { + return mirror().getAnnotation(annotationClass); + } + + /** + * Performs a fast-path check that this type is resolved in the context of a given accessing + * class. A negative result does not mean this type is not resolved with respect to + * {@code accessingClass}. That can only be determined by + * {@linkplain HotSpotJVMCIRuntime#lookupType(String, HotSpotResolvedObjectType, boolean) + * re-resolving} the type. + */ + public boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass) { + assert accessingClass != null; + ResolvedJavaType elementType = getElementalType(); + if (elementType.isPrimitive()) { + // Primitive type resolution is context free. + return true; + } + if (elementType.getName().startsWith("Ljava/")) { + // Classes in a java.* package can only be defined by the + // boot class loader. This is enforced by ClassLoader.preDefineClass() + assert mirror().getClassLoader() == null; + return true; + } + ClassLoader thisCl = mirror().getClassLoader(); + ClassLoader accessingClassCl = ((HotSpotResolvedObjectTypeImpl) accessingClass).mirror().getClassLoader(); + return thisCl == accessingClassCl; + } + + @Override + public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { + if (isDefinitelyResolvedWithRespectTo(requireNonNull(accessingClass))) { + return this; + } + HotSpotResolvedObjectTypeImpl accessingType = (HotSpotResolvedObjectTypeImpl) accessingClass; + return (ResolvedJavaType) runtime().lookupType(getName(), accessingType, true); + } + + /** + * Gets the metaspace Klass boxed in a {@link JavaConstant}. + */ + public Constant klass() { + return HotSpotMetaspaceConstantImpl.forMetaspaceObject(this, false); + } + + public boolean isPrimaryType() { + return config().secondarySuperCacheOffset != superCheckOffset(); + } + + public int superCheckOffset() { + HotSpotVMConfig config = config(); + return UNSAFE.getInt(getMetaspaceKlass() + config.superCheckOffsetOffset); + } + + public long prototypeMarkWord() { + HotSpotVMConfig config = config(); + if (isArray()) { + return config.arrayPrototypeMarkWord(); + } else { + return UNSAFE.getAddress(getMetaspaceKlass() + config.prototypeMarkWordOffset); + } + } + + @Override + public ResolvedJavaField findInstanceFieldWithOffset(long offset, JavaKind expectedEntryKind) { + ResolvedJavaField[] declaredFields = getInstanceFields(true); + for (ResolvedJavaField field : declaredFields) { + HotSpotResolvedJavaField resolvedField = (HotSpotResolvedJavaField) field; + long resolvedFieldOffset = resolvedField.offset(); + // @formatter:off + if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN && + expectedEntryKind.isPrimitive() && + !expectedEntryKind.equals(JavaKind.Void) && + resolvedField.getJavaKind().isPrimitive()) { + resolvedFieldOffset += + resolvedField.getJavaKind().getByteCount() - + Math.min(resolvedField.getJavaKind().getByteCount(), 4 + expectedEntryKind.getByteCount()); + } + if (resolvedFieldOffset == offset) { + return field; + } + // @formatter:on + } + return null; + } + + @Override + public boolean isLocal() { + return mirror().isLocalClass(); + } + + @Override + public boolean isMember() { + return mirror().isMemberClass(); + } + + @Override + public HotSpotResolvedObjectTypeImpl getEnclosingType() { + final Class encl = mirror().getEnclosingClass(); + return encl == null ? null : fromObjectClass(encl); + } + + @Override + public ResolvedJavaMethod[] getDeclaredConstructors() { + Constructor[] constructors = mirror().getDeclaredConstructors(); + ResolvedJavaMethod[] result = new ResolvedJavaMethod[constructors.length]; + for (int i = 0; i < constructors.length; i++) { + result[i] = runtime().getHostJVMCIBackend().getMetaAccess().lookupJavaMethod(constructors[i]); + assert result[i].isConstructor(); + } + return result; + } + + @Override + public ResolvedJavaMethod[] getDeclaredMethods() { + Method[] methods = mirror().getDeclaredMethods(); + ResolvedJavaMethod[] result = new ResolvedJavaMethod[methods.length]; + for (int i = 0; i < methods.length; i++) { + result[i] = runtime().getHostJVMCIBackend().getMetaAccess().lookupJavaMethod(methods[i]); + assert !result[i].isConstructor(); + } + return result; + } + + public ResolvedJavaMethod getClassInitializer() { + return compilerToVM().getClassInitializer(this); + } + + @Override + public String toString() { + return "HotSpotType<" + getName() + ", resolved>"; + } + + @Override + public boolean isTrustedInterfaceType() { + return TrustedInterface.class.isAssignableFrom(mirror()); + } + + @Override + public boolean isCloneableWithAllocation() { + return (getAccessFlags() & config().jvmAccIsCloneableFast) != 0; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java 2016-05-04 09:43:46.000000000 -1000 +++ /dev/null 2016-05-04 09:43:46.000000000 -1000 @@ -1,275 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static java.util.Objects.requireNonNull; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Array; -import java.lang.reflect.Modifier; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.Assumptions.AssumptionResult; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Implementation of {@link JavaType} for primitive HotSpot types. - */ -public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType implements HotSpotProxified { - - private final JavaKind kind; - - /** - * Creates the JVMCI mirror for a primitive {@link JavaKind}. - * - *

- * NOTE: Creating an instance of this class does not install the mirror for the - * {@link Class} type. Use {@link HotSpotJVMCIRuntimeProvider#fromClass(Class)} instead. - *

- * - * @param kind the Kind to create the mirror for - */ - public HotSpotResolvedPrimitiveType(JavaKind kind) { - super(String.valueOf(Character.toUpperCase(kind.getTypeChar()))); - this.kind = kind; - assert mirror().isPrimitive() : mirror() + " not a primitive type"; - } - - @Override - public int getModifiers() { - return Modifier.ABSTRACT | Modifier.FINAL | Modifier.PUBLIC; - } - - @Override - public HotSpotResolvedObjectTypeImpl getArrayClass() { - if (kind == JavaKind.Void) { - return null; - } - Class javaArrayMirror = Array.newInstance(mirror(), 0).getClass(); - return HotSpotResolvedObjectTypeImpl.fromObjectClass(javaArrayMirror); - } - - public ResolvedJavaType getElementalType() { - return this; - } - - @Override - public ResolvedJavaType getComponentType() { - return null; - } - - @Override - public ResolvedJavaType asExactType() { - return this; - } - - @Override - public ResolvedJavaType getSuperclass() { - return null; - } - - @Override - public ResolvedJavaType[] getInterfaces() { - return new ResolvedJavaType[0]; - } - - @Override - public ResolvedJavaType getSingleImplementor() { - throw new JVMCIError("Cannot call getSingleImplementor() on a non-interface type: %s", this); - } - - @Override - public ResolvedJavaType findLeastCommonAncestor(ResolvedJavaType otherType) { - return null; - } - - @Override - public AssumptionResult hasFinalizableSubclass() { - return new AssumptionResult<>(false); - } - - @Override - public boolean hasFinalizer() { - return false; - } - - @Override - public boolean isArray() { - return false; - } - - @Override - public boolean isPrimitive() { - return true; - } - - @Override - public boolean isInitialized() { - return true; - } - - public boolean isLinked() { - return true; - } - - @Override - public boolean isInstance(JavaConstant obj) { - return false; - } - - @Override - public boolean isInstanceClass() { - return false; - } - - @Override - public boolean isInterface() { - return false; - } - - @Override - public boolean isAssignableFrom(ResolvedJavaType other) { - assert other != null; - return other.equals(this); - } - - @Override - public JavaKind getJavaKind() { - return kind; - } - - @Override - public boolean isJavaLangObject() { - return false; - } - - @Override - public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { - return null; - } - - @Override - public String toString() { - return "HotSpotResolvedPrimitiveType<" + kind + ">"; - } - - @Override - public AssumptionResult findLeafConcreteSubtype() { - return new AssumptionResult<>(this); - } - - @Override - public AssumptionResult findUniqueConcreteMethod(ResolvedJavaMethod method) { - return null; - } - - @Override - public ResolvedJavaField[] getInstanceFields(boolean includeSuperclasses) { - return new ResolvedJavaField[0]; - } - - @Override - public ResolvedJavaField[] getStaticFields() { - return new ResolvedJavaField[0]; - } - - @Override - public Annotation[] getAnnotations() { - return new Annotation[0]; - } - - @Override - public T getAnnotation(Class annotationClass) { - return null; - } - - @Override - public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { - requireNonNull(accessingClass); - return this; - } - - @Override - public void initialize() { - } - - @Override - public ResolvedJavaField findInstanceFieldWithOffset(long offset, JavaKind expectedType) { - return null; - } - - @Override - public String getSourceFileName() { - throw JVMCIError.unimplemented(); - } - - @Override - public Class mirror() { - return kind.toJavaClass(); - } - - @Override - public boolean isLocal() { - return false; - } - - @Override - public boolean isMember() { - return false; - } - - @Override - public ResolvedJavaType getEnclosingType() { - return null; - } - - @Override - public ResolvedJavaMethod[] getDeclaredConstructors() { - return new ResolvedJavaMethod[0]; - } - - @Override - public ResolvedJavaMethod[] getDeclaredMethods() { - return new ResolvedJavaMethod[0]; - } - - @Override - public ResolvedJavaMethod getClassInitializer() { - return null; - } - - @Override - public boolean isTrustedInterfaceType() { - return false; - } - - @Override - public boolean isCloneableWithAllocation() { - return false; - } -} --- /dev/null 2016-05-04 09:43:46.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java 2016-05-04 09:43:46.000000000 -1000 @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static java.util.Objects.requireNonNull; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Array; +import java.lang.reflect.Modifier; + +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.meta.Assumptions.AssumptionResult; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.ResolvedJavaField; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; + +/** + * Implementation of {@link JavaType} for primitive HotSpot types. + */ +public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType implements HotSpotProxified { + + private final JavaKind kind; + + /** + * Creates the JVMCI mirror for a primitive {@link JavaKind}. + * + *

+ * NOTE: Creating an instance of this class does not install the mirror for the + * {@link Class} type. Use {@link HotSpotJVMCIRuntimeProvider#fromClass(Class)} instead. + *

+ * + * @param kind the Kind to create the mirror for + */ + public HotSpotResolvedPrimitiveType(JavaKind kind) { + super(String.valueOf(Character.toUpperCase(kind.getTypeChar()))); + this.kind = kind; + assert mirror().isPrimitive() : mirror() + " not a primitive type"; + } + + @Override + public int getModifiers() { + return Modifier.ABSTRACT | Modifier.FINAL | Modifier.PUBLIC; + } + + @Override + public HotSpotResolvedObjectTypeImpl getArrayClass() { + if (kind == JavaKind.Void) { + return null; + } + Class javaArrayMirror = Array.newInstance(mirror(), 0).getClass(); + return HotSpotResolvedObjectTypeImpl.fromObjectClass(javaArrayMirror); + } + + public ResolvedJavaType getElementalType() { + return this; + } + + @Override + public ResolvedJavaType getComponentType() { + return null; + } + + @Override + public ResolvedJavaType asExactType() { + return this; + } + + @Override + public ResolvedJavaType getSuperclass() { + return null; + } + + @Override + public ResolvedJavaType[] getInterfaces() { + return new ResolvedJavaType[0]; + } + + @Override + public ResolvedJavaType getSingleImplementor() { + throw new JVMCIError("Cannot call getSingleImplementor() on a non-interface type: %s", this); + } + + @Override + public ResolvedJavaType findLeastCommonAncestor(ResolvedJavaType otherType) { + return null; + } + + @Override + public AssumptionResult hasFinalizableSubclass() { + return new AssumptionResult<>(false); + } + + @Override + public boolean hasFinalizer() { + return false; + } + + @Override + public boolean isArray() { + return false; + } + + @Override + public boolean isPrimitive() { + return true; + } + + @Override + public boolean isInitialized() { + return true; + } + + public boolean isLinked() { + return true; + } + + @Override + public boolean isInstance(JavaConstant obj) { + return false; + } + + @Override + public boolean isInstanceClass() { + return false; + } + + @Override + public boolean isInterface() { + return false; + } + + @Override + public boolean isAssignableFrom(ResolvedJavaType other) { + assert other != null; + return other.equals(this); + } + + @Override + public JavaKind getJavaKind() { + return kind; + } + + @Override + public boolean isJavaLangObject() { + return false; + } + + @Override + public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { + return null; + } + + @Override + public String toString() { + return "HotSpotResolvedPrimitiveType<" + kind + ">"; + } + + @Override + public AssumptionResult findLeafConcreteSubtype() { + return new AssumptionResult<>(this); + } + + @Override + public AssumptionResult findUniqueConcreteMethod(ResolvedJavaMethod method) { + return null; + } + + @Override + public ResolvedJavaField[] getInstanceFields(boolean includeSuperclasses) { + return new ResolvedJavaField[0]; + } + + @Override + public ResolvedJavaField[] getStaticFields() { + return new ResolvedJavaField[0]; + } + + @Override + public Annotation[] getAnnotations() { + return new Annotation[0]; + } + + @Override + public T getAnnotation(Class annotationClass) { + return null; + } + + @Override + public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { + requireNonNull(accessingClass); + return this; + } + + @Override + public void initialize() { + } + + @Override + public ResolvedJavaField findInstanceFieldWithOffset(long offset, JavaKind expectedType) { + return null; + } + + @Override + public String getSourceFileName() { + throw JVMCIError.unimplemented(); + } + + @Override + public Class mirror() { + return kind.toJavaClass(); + } + + @Override + public boolean isLocal() { + return false; + } + + @Override + public boolean isMember() { + return false; + } + + @Override + public ResolvedJavaType getEnclosingType() { + return null; + } + + @Override + public ResolvedJavaMethod[] getDeclaredConstructors() { + return new ResolvedJavaMethod[0]; + } + + @Override + public ResolvedJavaMethod[] getDeclaredMethods() { + return new ResolvedJavaMethod[0]; + } + + @Override + public ResolvedJavaMethod getClassInitializer() { + return null; + } + + @Override + public boolean isTrustedInterfaceType() { + return false; + } + + @Override + public boolean isCloneableWithAllocation() { + return false; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotRuntimeStub.java 2016-05-04 09:43:47.000000000 -1000 +++ /dev/null 2016-05-04 09:43:47.000000000 -1000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.code.InvalidInstalledCodeException; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -/** - * Implementation of {@link InstalledCode} for code installed as a RuntimeStub. - */ -public class HotSpotRuntimeStub extends HotSpotInstalledCode { - - public HotSpotRuntimeStub(String name) { - super(name); - } - - public ResolvedJavaMethod getMethod() { - return null; - } - - @Override - public boolean isValid() { - return true; - } - - @Override - public void invalidate() { - } - - @Override - public String toString() { - return String.format("InstalledRuntimeStub[stub=%s, codeBlob=0x%x]", name, getAddress()); - } - - @Override - public Object executeVarargs(Object... args) throws InvalidInstalledCodeException { - throw new InternalError("Cannot call stub " + name); - } -} --- /dev/null 2016-05-04 09:43:47.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotRuntimeStub.java 2016-05-04 09:43:46.000000000 -1000 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.code.InstalledCode; +import jdk.vm.ci.code.InvalidInstalledCodeException; +import jdk.vm.ci.meta.ResolvedJavaMethod; + +/** + * Implementation of {@link InstalledCode} for code installed as a RuntimeStub. + */ +public class HotSpotRuntimeStub extends HotSpotInstalledCode { + + public HotSpotRuntimeStub(String name) { + super(name); + } + + public ResolvedJavaMethod getMethod() { + return null; + } + + @Override + public boolean isValid() { + return true; + } + + @Override + public void invalidate() { + } + + @Override + public String toString() { + return String.format("InstalledRuntimeStub[stub=%s, codeBlob=0x%x]", name, getAddress()); + } + + @Override + public Object executeVarargs(Object... args) throws InvalidInstalledCodeException { + throw new InternalError("Cannot call stub " + name); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSentinelConstant.java 2016-05-04 09:43:47.000000000 -1000 +++ /dev/null 2016-05-04 09:43:47.000000000 -1000 @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.LIRKind; -import jdk.vm.ci.meta.VMConstant; -import jdk.vm.ci.meta.Value; - -public final class HotSpotSentinelConstant extends Value implements JavaConstant, VMConstant { - - private final JavaKind javaKind; - - public HotSpotSentinelConstant(LIRKind lirKind, JavaKind javaKind) { - super(lirKind); - this.javaKind = javaKind; - } - - public JavaKind getJavaKind() { - return javaKind; - } - - @Override - public boolean isNull() { - return true; - } - - @Override - public boolean isDefaultForKind() { - return true; - } - - @Override - public Object asBoxedPrimitive() { - throw new IllegalArgumentException(); - } - - @Override - public int asInt() { - throw new IllegalArgumentException(); - } - - @Override - public boolean asBoolean() { - throw new IllegalArgumentException(); - } - - @Override - public long asLong() { - throw new IllegalArgumentException(); - } - - @Override - public float asFloat() { - throw new IllegalArgumentException(); - } - - @Override - public double asDouble() { - throw new IllegalArgumentException(); - } - - @Override - public String toString() { - return JavaConstant.toString(this); - } - - @Override - public String toValueString() { - return "sentinel"; - } - - @Override - public int hashCode() { - return 13; - } - - @Override - public boolean equals(Object o) { - return o instanceof HotSpotSentinelConstant; - } -} --- /dev/null 2016-05-04 09:43:47.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSentinelConstant.java 2016-05-04 09:43:47.000000000 -1000 @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.LIRKind; +import jdk.vm.ci.meta.VMConstant; +import jdk.vm.ci.meta.Value; + +public final class HotSpotSentinelConstant extends Value implements JavaConstant, VMConstant { + + private final JavaKind javaKind; + + public HotSpotSentinelConstant(LIRKind lirKind, JavaKind javaKind) { + super(lirKind); + this.javaKind = javaKind; + } + + public JavaKind getJavaKind() { + return javaKind; + } + + @Override + public boolean isNull() { + return true; + } + + @Override + public boolean isDefaultForKind() { + return true; + } + + @Override + public Object asBoxedPrimitive() { + throw new IllegalArgumentException(); + } + + @Override + public int asInt() { + throw new IllegalArgumentException(); + } + + @Override + public boolean asBoolean() { + throw new IllegalArgumentException(); + } + + @Override + public long asLong() { + throw new IllegalArgumentException(); + } + + @Override + public float asFloat() { + throw new IllegalArgumentException(); + } + + @Override + public double asDouble() { + throw new IllegalArgumentException(); + } + + @Override + public String toString() { + return JavaConstant.toString(this); + } + + @Override + public String toValueString() { + return "sentinel"; + } + + @Override + public int hashCode() { + return 13; + } + + @Override + public boolean equals(Object o) { + return o instanceof HotSpotSentinelConstant; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSignature.java 2016-05-04 09:43:48.000000000 -1000 +++ /dev/null 2016-05-04 09:43:48.000000000 -1000 @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.ArrayList; -import java.util.List; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.Signature; - -/** - * Represents a method signature. - */ -public class HotSpotSignature implements Signature { - - private final List parameters = new ArrayList<>(); - private final String returnType; - private final String originalString; - private ResolvedJavaType[] parameterTypes; - private ResolvedJavaType returnTypeCache; - private final HotSpotJVMCIRuntimeProvider runtime; - - public HotSpotSignature(HotSpotJVMCIRuntimeProvider runtime, String signature) { - this.runtime = runtime; - assert signature.length() > 0; - this.originalString = signature; - - if (signature.charAt(0) == '(') { - int cur = 1; - while (cur < signature.length() && signature.charAt(cur) != ')') { - int nextCur = parseSignature(signature, cur); - parameters.add(signature.substring(cur, nextCur)); - cur = nextCur; - } - - cur++; - int nextCur = parseSignature(signature, cur); - returnType = signature.substring(cur, nextCur); - assert nextCur == signature.length(); - } else { - returnType = null; - } - } - - public HotSpotSignature(HotSpotJVMCIRuntimeProvider runtime, ResolvedJavaType returnType, ResolvedJavaType... parameterTypes) { - this.runtime = runtime; - this.parameterTypes = parameterTypes.clone(); - this.returnTypeCache = returnType; - this.returnType = returnType.getName(); - StringBuilder sb = new StringBuilder("("); - for (JavaType type : parameterTypes) { - parameters.add(type.getName()); - sb.append(type.getName()); - } - sb.append(")").append(returnType.getName()); - this.originalString = sb.toString(); - assert new HotSpotSignature(runtime, originalString).equals(this); - } - - private static int parseSignature(String signature, int start) { - int cur = start; - char first; - do { - first = signature.charAt(cur++); - } while (first == '['); - - switch (first) { - case 'L': - while (signature.charAt(cur) != ';') { - cur++; - } - cur++; - break; - case 'V': - case 'I': - case 'B': - case 'C': - case 'D': - case 'F': - case 'J': - case 'S': - case 'Z': - break; - default: - throw new JVMCIError("Invalid character at index %d in signature: %s", cur, signature); - } - return cur; - } - - @Override - public int getParameterCount(boolean withReceiver) { - return parameters.size() + (withReceiver ? 1 : 0); - } - - @Override - public JavaKind getParameterKind(int index) { - return JavaKind.fromTypeString(parameters.get(index)); - } - - private static boolean checkValidCache(ResolvedJavaType type, ResolvedJavaType accessingClass) { - assert accessingClass != null; - if (type == null) { - return false; - } else if (type instanceof HotSpotResolvedObjectTypeImpl) { - return ((HotSpotResolvedObjectTypeImpl) type).isDefinitelyResolvedWithRespectTo(accessingClass); - } - return true; - } - - private static JavaType getUnresolvedOrPrimitiveType(HotSpotJVMCIRuntimeProvider runtime, String name) { - if (name.length() == 1) { - JavaKind kind = JavaKind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); - return runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType(kind.toJavaClass()); - } - return HotSpotUnresolvedJavaType.create(runtime, name); - } - - @Override - public JavaType getParameterType(int index, ResolvedJavaType accessingClass) { - if (accessingClass == null) { - // Caller doesn't care about resolution context so return an unresolved - // or primitive type (primitive type resolution is context free) - return getUnresolvedOrPrimitiveType(runtime, parameters.get(index)); - } - if (parameterTypes == null) { - parameterTypes = new ResolvedJavaType[parameters.size()]; - } - - ResolvedJavaType type = parameterTypes[index]; - if (!checkValidCache(type, accessingClass)) { - JavaType result = runtime.lookupType(parameters.get(index), (HotSpotResolvedObjectType) accessingClass, false); - if (result instanceof ResolvedJavaType) { - type = (ResolvedJavaType) result; - parameterTypes[index] = type; - } else { - return result; - } - } - return type; - } - - @Override - public String toMethodDescriptor() { - assert originalString.equals(Signature.super.toMethodDescriptor()); - return originalString; - } - - @Override - public JavaKind getReturnKind() { - return JavaKind.fromTypeString(returnType); - } - - @Override - public JavaType getReturnType(ResolvedJavaType accessingClass) { - if (accessingClass == null) { - // Caller doesn't care about resolution context so return an unresolved - // or primitive type (primitive type resolution is context free) - return getUnresolvedOrPrimitiveType(runtime, returnType); - } - if (!checkValidCache(returnTypeCache, accessingClass)) { - JavaType result = runtime.lookupType(returnType, (HotSpotResolvedObjectType) accessingClass, false); - if (result instanceof ResolvedJavaType) { - returnTypeCache = (ResolvedJavaType) result; - } else { - return result; - } - } - return returnTypeCache; - } - - @Override - public String toString() { - return "HotSpotSignature<" + originalString + ">"; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof HotSpotSignature) { - HotSpotSignature other = (HotSpotSignature) obj; - if (other.originalString.equals(originalString)) { - assert other.parameters.equals(parameters); - assert other.returnType.equals(returnType); - return true; - } - } - return false; - } - - @Override - public int hashCode() { - return originalString.hashCode(); - } -} --- /dev/null 2016-05-04 09:43:48.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSignature.java 2016-05-04 09:43:47.000000000 -1000 @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import java.util.ArrayList; +import java.util.List; + +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.ResolvedJavaType; +import jdk.vm.ci.meta.Signature; + +/** + * Represents a method signature. + */ +public class HotSpotSignature implements Signature { + + private final List parameters = new ArrayList<>(); + private final String returnType; + private final String originalString; + private ResolvedJavaType[] parameterTypes; + private ResolvedJavaType returnTypeCache; + private final HotSpotJVMCIRuntimeProvider runtime; + + public HotSpotSignature(HotSpotJVMCIRuntimeProvider runtime, String signature) { + this.runtime = runtime; + assert signature.length() > 0; + this.originalString = signature; + + if (signature.charAt(0) == '(') { + int cur = 1; + while (cur < signature.length() && signature.charAt(cur) != ')') { + int nextCur = parseSignature(signature, cur); + parameters.add(signature.substring(cur, nextCur)); + cur = nextCur; + } + + cur++; + int nextCur = parseSignature(signature, cur); + returnType = signature.substring(cur, nextCur); + assert nextCur == signature.length(); + } else { + returnType = null; + } + } + + public HotSpotSignature(HotSpotJVMCIRuntimeProvider runtime, ResolvedJavaType returnType, ResolvedJavaType... parameterTypes) { + this.runtime = runtime; + this.parameterTypes = parameterTypes.clone(); + this.returnTypeCache = returnType; + this.returnType = returnType.getName(); + StringBuilder sb = new StringBuilder("("); + for (JavaType type : parameterTypes) { + parameters.add(type.getName()); + sb.append(type.getName()); + } + sb.append(")").append(returnType.getName()); + this.originalString = sb.toString(); + assert new HotSpotSignature(runtime, originalString).equals(this); + } + + private static int parseSignature(String signature, int start) { + int cur = start; + char first; + do { + first = signature.charAt(cur++); + } while (first == '['); + + switch (first) { + case 'L': + while (signature.charAt(cur) != ';') { + cur++; + } + cur++; + break; + case 'V': + case 'I': + case 'B': + case 'C': + case 'D': + case 'F': + case 'J': + case 'S': + case 'Z': + break; + default: + throw new JVMCIError("Invalid character at index %d in signature: %s", cur, signature); + } + return cur; + } + + @Override + public int getParameterCount(boolean withReceiver) { + return parameters.size() + (withReceiver ? 1 : 0); + } + + @Override + public JavaKind getParameterKind(int index) { + return JavaKind.fromTypeString(parameters.get(index)); + } + + private static boolean checkValidCache(ResolvedJavaType type, ResolvedJavaType accessingClass) { + assert accessingClass != null; + if (type == null) { + return false; + } else if (type instanceof HotSpotResolvedObjectTypeImpl) { + return ((HotSpotResolvedObjectTypeImpl) type).isDefinitelyResolvedWithRespectTo(accessingClass); + } + return true; + } + + private static JavaType getUnresolvedOrPrimitiveType(HotSpotJVMCIRuntimeProvider runtime, String name) { + if (name.length() == 1) { + JavaKind kind = JavaKind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); + return runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType(kind.toJavaClass()); + } + return HotSpotUnresolvedJavaType.create(runtime, name); + } + + @Override + public JavaType getParameterType(int index, ResolvedJavaType accessingClass) { + if (accessingClass == null) { + // Caller doesn't care about resolution context so return an unresolved + // or primitive type (primitive type resolution is context free) + return getUnresolvedOrPrimitiveType(runtime, parameters.get(index)); + } + if (parameterTypes == null) { + parameterTypes = new ResolvedJavaType[parameters.size()]; + } + + ResolvedJavaType type = parameterTypes[index]; + if (!checkValidCache(type, accessingClass)) { + JavaType result = runtime.lookupType(parameters.get(index), (HotSpotResolvedObjectType) accessingClass, false); + if (result instanceof ResolvedJavaType) { + type = (ResolvedJavaType) result; + parameterTypes[index] = type; + } else { + return result; + } + } + return type; + } + + @Override + public String toMethodDescriptor() { + assert originalString.equals(Signature.super.toMethodDescriptor()); + return originalString; + } + + @Override + public JavaKind getReturnKind() { + return JavaKind.fromTypeString(returnType); + } + + @Override + public JavaType getReturnType(ResolvedJavaType accessingClass) { + if (accessingClass == null) { + // Caller doesn't care about resolution context so return an unresolved + // or primitive type (primitive type resolution is context free) + return getUnresolvedOrPrimitiveType(runtime, returnType); + } + if (!checkValidCache(returnTypeCache, accessingClass)) { + JavaType result = runtime.lookupType(returnType, (HotSpotResolvedObjectType) accessingClass, false); + if (result instanceof ResolvedJavaType) { + returnTypeCache = (ResolvedJavaType) result; + } else { + return result; + } + } + return returnTypeCache; + } + + @Override + public String toString() { + return "HotSpotSignature<" + originalString + ">"; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof HotSpotSignature) { + HotSpotSignature other = (HotSpotSignature) obj; + if (other.originalString.equals(originalString)) { + assert other.parameters.equals(parameters); + assert other.returnType.equals(returnType); + return true; + } + } + return false; + } + + @Override + public int hashCode() { + return originalString.hashCode(); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java 2016-05-04 09:43:48.000000000 -1000 +++ /dev/null 2016-05-04 09:43:48.000000000 -1000 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ConcurrentLinkedQueue; - -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.SpeculationLog; - -public class HotSpotSpeculationLog implements SpeculationLog { - - /** Written by the C++ code that performs deoptimization. */ - private volatile Object lastFailed; - - /** All speculations that have been a deoptimization reason. */ - private Set failedSpeculations; - - /** Strong references to all reasons embedded in the current nmethod. */ - private volatile Collection speculations; - - @Override - public synchronized void collectFailedSpeculations() { - if (lastFailed != null) { - if (failedSpeculations == null) { - failedSpeculations = new HashSet<>(2); - } - failedSpeculations.add((SpeculationReason) lastFailed); - lastFailed = null; - speculations = null; - } - } - - @Override - public boolean maySpeculate(SpeculationReason reason) { - if (failedSpeculations != null && failedSpeculations.contains(reason)) { - return false; - } - return true; - } - - @Override - public JavaConstant speculate(SpeculationReason reason) { - assert maySpeculate(reason); - - /* - * Objects referenced from nmethods are weak references. We need a strong reference to the - * reason objects that are embedded in nmethods, so we add them to the speculations - * collection. - */ - if (speculations == null) { - synchronized (this) { - if (speculations == null) { - speculations = new ConcurrentLinkedQueue<>(); - } - } - } - speculations.add(reason); - - return HotSpotObjectConstantImpl.forObject(reason); - } - - @Override - public synchronized boolean hasSpeculations() { - return speculations != null && !speculations.isEmpty(); - } -} --- /dev/null 2016-05-04 09:43:48.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java 2016-05-04 09:43:48.000000000 -1000 @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.ConcurrentLinkedQueue; + +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.SpeculationLog; + +public class HotSpotSpeculationLog implements SpeculationLog { + + /** Written by the C++ code that performs deoptimization. */ + private volatile Object lastFailed; + + /** All speculations that have been a deoptimization reason. */ + private Set failedSpeculations; + + /** Strong references to all reasons embedded in the current nmethod. */ + private volatile Collection speculations; + + @Override + public synchronized void collectFailedSpeculations() { + if (lastFailed != null) { + if (failedSpeculations == null) { + failedSpeculations = new HashSet<>(2); + } + failedSpeculations.add((SpeculationReason) lastFailed); + lastFailed = null; + speculations = null; + } + } + + @Override + public boolean maySpeculate(SpeculationReason reason) { + if (failedSpeculations != null && failedSpeculations.contains(reason)) { + return false; + } + return true; + } + + @Override + public JavaConstant speculate(SpeculationReason reason) { + assert maySpeculate(reason); + + /* + * Objects referenced from nmethods are weak references. We need a strong reference to the + * reason objects that are embedded in nmethods, so we add them to the speculations + * collection. + */ + if (speculations == null) { + synchronized (this) { + if (speculations == null) { + speculations = new ConcurrentLinkedQueue<>(); + } + } + } + speculations.add(reason); + + return HotSpotObjectConstantImpl.forObject(reason); + } + + @Override + public synchronized boolean hasSpeculations() { + return speculations != null && !speculations.isEmpty(); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotStackFrameReference.java 2016-05-04 09:43:49.000000000 -1000 +++ /dev/null 2016-05-04 09:43:49.000000000 -1000 @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.Arrays; - -import jdk.vm.ci.code.stack.InspectedFrame; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -public class HotSpotStackFrameReference implements InspectedFrame { - - private CompilerToVM compilerToVM; - - // information used to find the stack frame - private long stackPointer; - private int frameNumber; - - // information about the stack frame's contents - private int bci; - private HotSpotResolvedJavaMethod method; - private Object[] locals; - private boolean[] localIsVirtual; - - public long getStackPointer() { - return stackPointer; - } - - public int getFrameNumber() { - return frameNumber; - } - - @Override - public Object getLocal(int index) { - return locals[index]; - } - - @Override - public boolean isVirtual(int index) { - return localIsVirtual == null ? false : localIsVirtual[index]; - } - - @Override - public void materializeVirtualObjects(boolean invalidateCode) { - compilerToVM.materializeVirtualObjects(this, invalidateCode); - } - - @Override - public int getBytecodeIndex() { - return bci; - } - - @Override - public ResolvedJavaMethod getMethod() { - return method; - } - - @Override - public boolean isMethod(ResolvedJavaMethod otherMethod) { - return method.equals(otherMethod); - } - - @Override - public boolean hasVirtualObjects() { - return localIsVirtual != null; - } - - @Override - public String toString() { - return "HotSpotStackFrameReference [stackPointer=" + stackPointer + ", frameNumber=" + frameNumber + ", bci=" + bci + ", method=" + getMethod() + ", locals=" + Arrays.toString(locals) + - ", localIsVirtual=" + Arrays.toString(localIsVirtual) + "]"; - } -} --- /dev/null 2016-05-04 09:43:49.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotStackFrameReference.java 2016-05-04 09:43:48.000000000 -1000 @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import java.util.Arrays; + +import jdk.vm.ci.code.stack.InspectedFrame; +import jdk.vm.ci.meta.ResolvedJavaMethod; + +public class HotSpotStackFrameReference implements InspectedFrame { + + private CompilerToVM compilerToVM; + + // information used to find the stack frame + private long stackPointer; + private int frameNumber; + + // information about the stack frame's contents + private int bci; + private HotSpotResolvedJavaMethod method; + private Object[] locals; + private boolean[] localIsVirtual; + + public long getStackPointer() { + return stackPointer; + } + + public int getFrameNumber() { + return frameNumber; + } + + @Override + public Object getLocal(int index) { + return locals[index]; + } + + @Override + public boolean isVirtual(int index) { + return localIsVirtual == null ? false : localIsVirtual[index]; + } + + @Override + public void materializeVirtualObjects(boolean invalidateCode) { + compilerToVM.materializeVirtualObjects(this, invalidateCode); + } + + @Override + public int getBytecodeIndex() { + return bci; + } + + @Override + public ResolvedJavaMethod getMethod() { + return method; + } + + @Override + public boolean isMethod(ResolvedJavaMethod otherMethod) { + return method.equals(otherMethod); + } + + @Override + public boolean hasVirtualObjects() { + return localIsVirtual != null; + } + + @Override + public String toString() { + return "HotSpotStackFrameReference [stackPointer=" + stackPointer + ", frameNumber=" + frameNumber + ", bci=" + bci + ", method=" + getMethod() + ", locals=" + Arrays.toString(locals) + + ", localIsVirtual=" + Arrays.toString(localIsVirtual) + "]"; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotStackIntrospection.java 2016-05-04 09:43:49.000000000 -1000 +++ /dev/null 2016-05-04 09:43:49.000000000 -1000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.stack.InspectedFrameVisitor; -import jdk.vm.ci.code.stack.StackIntrospection; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -public class HotSpotStackIntrospection implements StackIntrospection { - - protected final HotSpotJVMCIRuntimeProvider runtime; - - public HotSpotStackIntrospection(HotSpotJVMCIRuntimeProvider runtime) { - this.runtime = runtime; - } - - @Override - public T iterateFrames(ResolvedJavaMethod[] initialMethods, ResolvedJavaMethod[] matchingMethods, int initialSkip, InspectedFrameVisitor visitor) { - CompilerToVM compilerToVM = runtime.getCompilerToVM(); - HotSpotStackFrameReference current = compilerToVM.getNextStackFrame(null, initialMethods, initialSkip); - while (current != null) { - T result = visitor.visitFrame(current); - if (result != null) { - return result; - } - current = compilerToVM.getNextStackFrame(current, matchingMethods, 0); - } - return null; - } -} --- /dev/null 2016-05-04 09:43:49.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotStackIntrospection.java 2016-05-04 09:43:49.000000000 -1000 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.code.stack.InspectedFrameVisitor; +import jdk.vm.ci.code.stack.StackIntrospection; +import jdk.vm.ci.meta.ResolvedJavaMethod; + +public class HotSpotStackIntrospection implements StackIntrospection { + + protected final HotSpotJVMCIRuntimeProvider runtime; + + public HotSpotStackIntrospection(HotSpotJVMCIRuntimeProvider runtime) { + this.runtime = runtime; + } + + @Override + public T iterateFrames(ResolvedJavaMethod[] initialMethods, ResolvedJavaMethod[] matchingMethods, int initialSkip, InspectedFrameVisitor visitor) { + CompilerToVM compilerToVM = runtime.getCompilerToVM(); + HotSpotStackFrameReference current = compilerToVM.getNextStackFrame(null, initialMethods, initialSkip); + while (current != null) { + T result = visitor.visitFrame(current); + if (result != null) { + return result; + } + current = compilerToVM.getNextStackFrame(current, matchingMethods, 0); + } + return null; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSymbol.java 2016-05-04 09:43:50.000000000 -1000 +++ /dev/null 2016-05-04 09:43:50.000000000 -1000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.Constant; - -/** - * Class to access the C++ {@code vmSymbols} table. - */ -public final class HotSpotSymbol implements MetaspaceWrapperObject { - - private final String symbol; - private final long pointer; - - HotSpotSymbol(String symbol, long pointer) { - this.symbol = symbol; - this.pointer = pointer; - } - - public String getSymbol() { - return symbol; - } - - public Constant asConstant() { - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(this, false); - } - - @Override - public long getMetaspacePointer() { - return pointer; - } - - @Override - public String toString() { - return "Symbol<" + symbol + ">"; - } -} --- /dev/null 2016-05-04 09:43:50.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSymbol.java 2016-05-04 09:43:49.000000000 -1000 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.Constant; + +/** + * Class to access the C++ {@code vmSymbols} table. + */ +public final class HotSpotSymbol implements MetaspaceWrapperObject { + + private final String symbol; + private final long pointer; + + HotSpotSymbol(String symbol, long pointer) { + this.symbol = symbol; + this.pointer = pointer; + } + + public String getSymbol() { + return symbol; + } + + public Constant asConstant() { + return HotSpotMetaspaceConstantImpl.forMetaspaceObject(this, false); + } + + @Override + public long getMetaspacePointer() { + return pointer; + } + + @Override + public String toString() { + return "Symbol<" + symbol + ">"; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotUnresolvedField.java 2016-05-04 09:43:50.000000000 -1000 +++ /dev/null 2016-05-04 09:43:50.000000000 -1000 @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.JavaField; -import jdk.vm.ci.meta.JavaType; - -/** - * A implementation of {@link JavaField} for an unresolved field. - */ -class HotSpotUnresolvedField implements JavaField { - - private final String name; - private final JavaType holder; - private final JavaType type; - - HotSpotUnresolvedField(JavaType holder, String name, JavaType type) { - this.name = name; - this.type = type; - this.holder = holder; - } - - public String getName() { - return name; - } - - public JavaType getType() { - return type; - } - - public JavaType getDeclaringClass() { - return holder; - } - - @Override - public int hashCode() { - return super.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || !(obj instanceof HotSpotUnresolvedField)) { - return false; - } - HotSpotUnresolvedField that = (HotSpotUnresolvedField) obj; - return this.holder.equals(that.holder) && this.name.equals(that.name) && this.type.equals(that.type); - } - - /** - * Converts this compiler interface field to a string. - */ - @Override - public String toString() { - return format("HotSpotField<%H.%n %t, unresolved>"); - } -} --- /dev/null 2016-05-04 09:43:50.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotUnresolvedField.java 2016-05-04 09:43:50.000000000 -1000 @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.JavaField; +import jdk.vm.ci.meta.JavaType; + +/** + * A implementation of {@link JavaField} for an unresolved field. + */ +class HotSpotUnresolvedField implements JavaField { + + private final String name; + private final JavaType holder; + private final JavaType type; + + HotSpotUnresolvedField(JavaType holder, String name, JavaType type) { + this.name = name; + this.type = type; + this.holder = holder; + } + + public String getName() { + return name; + } + + public JavaType getType() { + return type; + } + + public JavaType getDeclaringClass() { + return holder; + } + + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || !(obj instanceof HotSpotUnresolvedField)) { + return false; + } + HotSpotUnresolvedField that = (HotSpotUnresolvedField) obj; + return this.holder.equals(that.holder) && this.name.equals(that.name) && this.type.equals(that.type); + } + + /** + * Converts this compiler interface field to a string. + */ + @Override + public String toString() { + return format("HotSpotField<%H.%n %t, unresolved>"); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotUnresolvedJavaType.java 2016-05-04 09:43:51.000000000 -1000 +++ /dev/null 2016-05-04 09:43:51.000000000 -1000 @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Implementation of {@link JavaType} for unresolved HotSpot classes. - */ -final class HotSpotUnresolvedJavaType extends HotSpotJavaType { - - private final HotSpotJVMCIRuntimeProvider runtime; - - private HotSpotUnresolvedJavaType(String name, HotSpotJVMCIRuntimeProvider runtime) { - super(name); - assert name.charAt(0) == '[' || name.charAt(name.length() - 1) == ';' : name; - this.runtime = runtime; - } - - /** - * Creates an unresolved type for a valid {@link JavaType#getName() type name}. - */ - static HotSpotUnresolvedJavaType create(HotSpotJVMCIRuntimeProvider runtime, String name) { - return new HotSpotUnresolvedJavaType(name, runtime); - } - - @Override - public JavaType getComponentType() { - assert getName().charAt(0) == '[' : "no array class" + getName(); - return new HotSpotUnresolvedJavaType(getName().substring(1), runtime); - } - - @Override - public JavaType getArrayClass() { - return new HotSpotUnresolvedJavaType('[' + getName(), runtime); - } - - @Override - public JavaKind getJavaKind() { - return JavaKind.Object; - } - - @Override - public int hashCode() { - return getName().hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || !(obj instanceof HotSpotUnresolvedJavaType)) { - return false; - } - HotSpotUnresolvedJavaType that = (HotSpotUnresolvedJavaType) obj; - return this.getName().equals(that.getName()); - } - - @Override - public String toString() { - return "HotSpotType<" + getName() + ", unresolved>"; - } - - @Override - public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { - return (ResolvedJavaType) runtime.lookupType(getName(), (HotSpotResolvedObjectType) accessingClass, true); - } - - /** - * Try to find a loaded version of this class. - * - * @param accessingClass - * @return the resolved class or null. - */ - ResolvedJavaType reresolve(HotSpotResolvedObjectType accessingClass) { - JavaType type = runtime.lookupType(getName(), accessingClass, false); - if (type instanceof ResolvedJavaType) { - return (ResolvedJavaType) type; - } - return null; - } -} --- /dev/null 2016-05-04 09:43:51.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotUnresolvedJavaType.java 2016-05-04 09:43:50.000000000 -1000 @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.JavaType; +import jdk.vm.ci.meta.ResolvedJavaType; + +/** + * Implementation of {@link JavaType} for unresolved HotSpot classes. + */ +final class HotSpotUnresolvedJavaType extends HotSpotJavaType { + + private final HotSpotJVMCIRuntimeProvider runtime; + + private HotSpotUnresolvedJavaType(String name, HotSpotJVMCIRuntimeProvider runtime) { + super(name); + assert name.charAt(0) == '[' || name.charAt(name.length() - 1) == ';' : name; + this.runtime = runtime; + } + + /** + * Creates an unresolved type for a valid {@link JavaType#getName() type name}. + */ + static HotSpotUnresolvedJavaType create(HotSpotJVMCIRuntimeProvider runtime, String name) { + return new HotSpotUnresolvedJavaType(name, runtime); + } + + @Override + public JavaType getComponentType() { + assert getName().charAt(0) == '[' : "no array class" + getName(); + return new HotSpotUnresolvedJavaType(getName().substring(1), runtime); + } + + @Override + public JavaType getArrayClass() { + return new HotSpotUnresolvedJavaType('[' + getName(), runtime); + } + + @Override + public JavaKind getJavaKind() { + return JavaKind.Object; + } + + @Override + public int hashCode() { + return getName().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || !(obj instanceof HotSpotUnresolvedJavaType)) { + return false; + } + HotSpotUnresolvedJavaType that = (HotSpotUnresolvedJavaType) obj; + return this.getName().equals(that.getName()); + } + + @Override + public String toString() { + return "HotSpotType<" + getName() + ", unresolved>"; + } + + @Override + public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { + return (ResolvedJavaType) runtime.lookupType(getName(), (HotSpotResolvedObjectType) accessingClass, true); + } + + /** + * Try to find a loaded version of this class. + * + * @param accessingClass + * @return the resolved class or null. + */ + ResolvedJavaType reresolve(HotSpotResolvedObjectType accessingClass) { + JavaType type = runtime.lookupType(getName(), accessingClass, false); + if (type instanceof ResolvedJavaType) { + return (ResolvedJavaType) type; + } + return null; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java 2016-05-04 09:43:51.000000000 -1000 +++ /dev/null 2016-05-04 09:43:51.000000000 -1000 @@ -1,1763 +0,0 @@ -/* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.common.UnsafeUtil.readCString; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.HashMap; -import java.util.Iterator; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMAddress; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMConstant; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMData; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag; -import jdk.vm.ci.hotspotvmconfig.HotSpotVMType; -import jdk.internal.misc.Unsafe; - -//JaCoCo Exclude - -/** - * Used to access native configuration details. - * - * All non-static, public fields in this class are so that they can be compiled as constants. - */ -public class HotSpotVMConfig { - - /** - * Gets the configuration associated with the singleton {@link HotSpotJVMCIRuntime}. - */ - public static HotSpotVMConfig config() { - return runtime().getConfig(); - } - - /** - * Maximum allowed size of allocated area for a frame. - */ - public final int maxFrameSize = 16 * 1024; - - public HotSpotVMConfig(CompilerToVM compilerToVm) { - // Get raw pointer to the array that contains all gHotSpotVM values. - final long gHotSpotVMData = compilerToVm.initializeConfiguration(this); - assert gHotSpotVMData != 0; - - // Make FindBugs happy. - jvmciHotSpotVMStructs = 0; - jvmciHotSpotVMTypes = 0; - jvmciHotSpotVMIntConstants = 0; - jvmciHotSpotVMLongConstants = 0; - jvmciHotSpotVMAddresses = 0; - - // Initialize the gHotSpotVM fields. - for (Field f : HotSpotVMConfig.class.getDeclaredFields()) { - if (f.isAnnotationPresent(HotSpotVMData.class)) { - HotSpotVMData annotation = f.getAnnotation(HotSpotVMData.class); - final int index = annotation.index(); - final long value = UNSAFE.getAddress(gHotSpotVMData + Unsafe.ADDRESS_SIZE * index); - try { - f.setLong(this, value); - } catch (IllegalAccessException e) { - throw new JVMCIError("index " + index, e); - } - } - } - - // Quick sanity check. - assert jvmciHotSpotVMStructs != 0; - assert jvmciHotSpotVMTypes != 0; - assert jvmciHotSpotVMIntConstants != 0; - assert jvmciHotSpotVMLongConstants != 0; - assert jvmciHotSpotVMAddresses != 0; - - initialize(); - - oopEncoding = new CompressEncoding(narrowOopBase, narrowOopShift, logMinObjAlignment()); - klassEncoding = new CompressEncoding(narrowKlassBase, narrowKlassShift, logKlassAlignment); - - assert check(); - assert HotSpotVMConfigVerifier.check(); - } - - @Override - public String toString() { - return getClass().getSimpleName(); - } - - /** - * Initialize fields by reading their values from vmStructs. - */ - private void initialize() { - // Fill the VM fields hash map. - HashMap vmFields = new HashMap<>(); - for (VMFields.Field e : new VMFields(jvmciHotSpotVMStructs)) { - vmFields.put(e.getName(), e); - } - - // Fill the VM types hash map. - HashMap vmTypes = new HashMap<>(); - for (VMTypes.Type e : new VMTypes(jvmciHotSpotVMTypes)) { - vmTypes.put(e.getTypeName(), e); - } - - // Fill the VM constants hash map. - HashMap vmConstants = new HashMap<>(); - for (AbstractConstant e : new VMIntConstants(jvmciHotSpotVMIntConstants)) { - vmConstants.put(e.getName(), e); - } - for (AbstractConstant e : new VMLongConstants(jvmciHotSpotVMLongConstants)) { - vmConstants.put(e.getName(), e); - } - - // Fill the VM addresses hash map. - HashMap vmAddresses = new HashMap<>(); - for (VMAddresses.Address e : new VMAddresses(jvmciHotSpotVMAddresses)) { - vmAddresses.put(e.getName(), e); - } - - // Fill the flags hash map. - HashMap flags = new HashMap<>(); - for (Flags.Flag e : new Flags(vmFields, vmTypes)) { - flags.put(e.getName(), e); - } - - String osName = getHostOSName(); - String osArch = getHostArchitectureName(); - - for (Field f : HotSpotVMConfig.class.getDeclaredFields()) { - if (f.isAnnotationPresent(HotSpotVMField.class)) { - HotSpotVMField annotation = f.getAnnotation(HotSpotVMField.class); - String name = annotation.name(); - String type = annotation.type(); - VMFields.Field entry = vmFields.get(name); - if (entry == null) { - if (!isRequired(osArch, annotation.archs())) { - continue; - } - throw new JVMCIError(f.getName() + ": expected VM field not found: " + name); - } - - // Make sure the native type is still the type we expect. - if (!type.isEmpty()) { - if (!type.equals(entry.getTypeString())) { - throw new JVMCIError(f.getName() + ": compiler expects type " + type + " but VM field " + name + " is of type " + entry.getTypeString()); - } - } - - switch (annotation.get()) { - case OFFSET: - setField(f, entry.getOffset()); - break; - case ADDRESS: - setField(f, entry.getAddress()); - break; - case VALUE: - setField(f, entry.getValue()); - break; - default: - throw new JVMCIError(f.getName() + ": unknown kind: " + annotation.get()); - } - } else if (f.isAnnotationPresent(HotSpotVMType.class)) { - HotSpotVMType annotation = f.getAnnotation(HotSpotVMType.class); - String name = annotation.name(); - VMTypes.Type entry = vmTypes.get(name); - if (entry == null) { - throw new JVMCIError(f.getName() + ": expected VM type not found: " + name); - } - - switch (annotation.get()) { - case SIZE: - setField(f, entry.getSize()); - break; - default: - throw new JVMCIError(f.getName() + ": unknown kind: " + annotation.get()); - } - } else if (f.isAnnotationPresent(HotSpotVMConstant.class)) { - HotSpotVMConstant annotation = f.getAnnotation(HotSpotVMConstant.class); - String name = annotation.name(); - AbstractConstant entry = vmConstants.get(name); - if (entry == null) { - if (!isRequired(osArch, annotation.archs())) { - continue; - } - throw new JVMCIError(f.getName() + ": expected VM constant not found: " + name); - } - setField(f, entry.getValue()); - } else if (f.isAnnotationPresent(HotSpotVMAddress.class)) { - HotSpotVMAddress annotation = f.getAnnotation(HotSpotVMAddress.class); - String name = annotation.name(); - VMAddresses.Address entry = vmAddresses.get(name); - if (entry == null) { - if (!isRequired(osName, annotation.os())) { - continue; - } - throw new JVMCIError(f.getName() + ": expected VM address not found: " + name); - } - setField(f, entry.getValue()); - } else if (f.isAnnotationPresent(HotSpotVMFlag.class)) { - HotSpotVMFlag annotation = f.getAnnotation(HotSpotVMFlag.class); - String name = annotation.name(); - Flags.Flag entry = flags.get(name); - if (entry == null) { - if (annotation.optional() || !isRequired(osArch, annotation.archs())) { - continue; - } - throw new JVMCIError(f.getName() + ": expected VM flag not found: " + name); - - } - setField(f, entry.getValue()); - } - } - } - - private final CompressEncoding oopEncoding; - private final CompressEncoding klassEncoding; - - public CompressEncoding getOopEncoding() { - return oopEncoding; - } - - public CompressEncoding getKlassEncoding() { - return klassEncoding; - } - - private void setField(Field field, Object value) { - try { - Class fieldType = field.getType(); - if (fieldType == boolean.class) { - if (value instanceof String) { - field.setBoolean(this, Boolean.valueOf((String) value)); - } else if (value instanceof Boolean) { - field.setBoolean(this, (boolean) value); - } else if (value instanceof Long) { - field.setBoolean(this, ((long) value) != 0); - } else { - throw new JVMCIError(value.getClass().getSimpleName()); - } - } else if (fieldType == byte.class) { - if (value instanceof Long) { - field.setByte(this, (byte) (long) value); - } else { - throw new JVMCIError(value.getClass().getSimpleName()); - } - } else if (fieldType == int.class) { - if (value instanceof Integer) { - field.setInt(this, (int) value); - } else if (value instanceof Long) { - field.setInt(this, (int) (long) value); - } else { - throw new JVMCIError(value.getClass().getSimpleName()); - } - } else if (fieldType == long.class) { - field.setLong(this, (long) value); - } else { - throw new JVMCIError(field.toString()); - } - } catch (IllegalAccessException e) { - throw new JVMCIError("%s: %s", field, e); - } - } - - /** - * Gets the host operating system name. - */ - private static String getHostOSName() { - String osName = System.getProperty("os.name"); - switch (osName) { - case "Linux": - osName = "linux"; - break; - case "SunOS": - osName = "solaris"; - break; - case "Mac OS X": - osName = "bsd"; - break; - default: - // Of course Windows is different... - if (osName.startsWith("Windows")) { - osName = "windows"; - } else { - throw new JVMCIError("Unexpected OS name: " + osName); - } - } - return osName; - } - - /** - * Gets the host architecture name for the purpose of finding the corresponding - * {@linkplain HotSpotJVMCIBackendFactory backend}. - */ - public String getHostArchitectureName() { - String arch = System.getProperty("os.arch"); - switch (arch) { - case "x86_64": - arch = "amd64"; - break; - case "sparcv9": - arch = "sparc"; - break; - } - return arch; - } - - /** - * Determines if the current specification is included in a given set of specifications. - * - * @param current - * @param specification specifies a set of specifications, e.g. architectures or operating - * systems. A zero length value implies all. - */ - private static boolean isRequired(String current, String[] specification) { - if (specification.length == 0) { - return true; - } - for (String arch : specification) { - if (arch.equals(current)) { - return true; - } - } - return false; - } - - /** - * VMStructEntry (see {@code vmStructs.hpp}). - */ - @HotSpotVMData(index = 0) @Stable private long jvmciHotSpotVMStructs; - @HotSpotVMData(index = 1) @Stable private long jvmciHotSpotVMStructEntryTypeNameOffset; - @HotSpotVMData(index = 2) @Stable private long jvmciHotSpotVMStructEntryFieldNameOffset; - @HotSpotVMData(index = 3) @Stable private long jvmciHotSpotVMStructEntryTypeStringOffset; - @HotSpotVMData(index = 4) @Stable private long jvmciHotSpotVMStructEntryIsStaticOffset; - @HotSpotVMData(index = 5) @Stable private long jvmciHotSpotVMStructEntryOffsetOffset; - @HotSpotVMData(index = 6) @Stable private long jvmciHotSpotVMStructEntryAddressOffset; - @HotSpotVMData(index = 7) @Stable private long jvmciHotSpotVMStructEntryArrayStride; - - final class VMFields implements Iterable { - - private final long address; - - VMFields(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Field current() { - return new Field(address + jvmciHotSpotVMStructEntryArrayStride * index); - } - - /** - * The last entry is identified by a NULL fieldName. - */ - public boolean hasNext() { - Field entry = current(); - return entry.getFieldName() != null; - } - - public Field next() { - Field entry = current(); - index++; - return entry; - } - }; - } - - final class Field { - - private final long entryAddress; - - Field(long address) { - this.entryAddress = address; - } - - public String getTypeName() { - long typeNameAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMStructEntryTypeNameOffset); - return readCString(UNSAFE, typeNameAddress); - } - - public String getFieldName() { - long fieldNameAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMStructEntryFieldNameOffset); - return readCString(UNSAFE, fieldNameAddress); - } - - public String getTypeString() { - long typeStringAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMStructEntryTypeStringOffset); - return readCString(UNSAFE, typeStringAddress); - } - - public boolean isStatic() { - return UNSAFE.getInt(entryAddress + jvmciHotSpotVMStructEntryIsStaticOffset) != 0; - } - - public long getOffset() { - return UNSAFE.getLong(entryAddress + jvmciHotSpotVMStructEntryOffsetOffset); - } - - public long getAddress() { - return UNSAFE.getAddress(entryAddress + jvmciHotSpotVMStructEntryAddressOffset); - } - - public String getName() { - String typeName = getTypeName(); - String fieldName = getFieldName(); - return typeName + "::" + fieldName; - } - - public long getValue() { - String type = getTypeString(); - switch (type) { - case "bool": - return UNSAFE.getByte(getAddress()); - case "int": - return UNSAFE.getInt(getAddress()); - case "uint64_t": - return UNSAFE.getLong(getAddress()); - case "address": - case "intptr_t": - case "uintptr_t": - case "size_t": - return UNSAFE.getAddress(getAddress()); - default: - // All foo* types are addresses. - if (type.endsWith("*")) { - return UNSAFE.getAddress(getAddress()); - } - throw new JVMCIError(type); - } - } - - @Override - public String toString() { - return String.format("Field[typeName=%s, fieldName=%s, typeString=%s, isStatic=%b, offset=%d, address=0x%x]", getTypeName(), getFieldName(), getTypeString(), isStatic(), getOffset(), - getAddress()); - } - } - } - - /** - * VMTypeEntry (see vmStructs.hpp). - */ - @HotSpotVMData(index = 8) @Stable private long jvmciHotSpotVMTypes; - @HotSpotVMData(index = 9) @Stable private long jvmciHotSpotVMTypeEntryTypeNameOffset; - @HotSpotVMData(index = 10) @Stable private long jvmciHotSpotVMTypeEntrySuperclassNameOffset; - @HotSpotVMData(index = 11) @Stable private long jvmciHotSpotVMTypeEntryIsOopTypeOffset; - @HotSpotVMData(index = 12) @Stable private long jvmciHotSpotVMTypeEntryIsIntegerTypeOffset; - @HotSpotVMData(index = 13) @Stable private long jvmciHotSpotVMTypeEntryIsUnsignedOffset; - @HotSpotVMData(index = 14) @Stable private long jvmciHotSpotVMTypeEntrySizeOffset; - @HotSpotVMData(index = 15) @Stable private long jvmciHotSpotVMTypeEntryArrayStride; - - final class VMTypes implements Iterable { - - private final long address; - - VMTypes(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Type current() { - return new Type(address + jvmciHotSpotVMTypeEntryArrayStride * index); - } - - /** - * The last entry is identified by a NULL type name. - */ - public boolean hasNext() { - Type entry = current(); - return entry.getTypeName() != null; - } - - public Type next() { - Type entry = current(); - index++; - return entry; - } - }; - } - - final class Type { - - private final long entryAddress; - - Type(long address) { - this.entryAddress = address; - } - - public String getTypeName() { - long typeNameAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMTypeEntryTypeNameOffset); - return readCString(UNSAFE, typeNameAddress); - } - - public String getSuperclassName() { - long superclassNameAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMTypeEntrySuperclassNameOffset); - return readCString(UNSAFE, superclassNameAddress); - } - - public boolean isOopType() { - return UNSAFE.getInt(entryAddress + jvmciHotSpotVMTypeEntryIsOopTypeOffset) != 0; - } - - public boolean isIntegerType() { - return UNSAFE.getInt(entryAddress + jvmciHotSpotVMTypeEntryIsIntegerTypeOffset) != 0; - } - - public boolean isUnsigned() { - return UNSAFE.getInt(entryAddress + jvmciHotSpotVMTypeEntryIsUnsignedOffset) != 0; - } - - public long getSize() { - return UNSAFE.getLong(entryAddress + jvmciHotSpotVMTypeEntrySizeOffset); - } - - @Override - public String toString() { - return String.format("Type[typeName=%s, superclassName=%s, isOopType=%b, isIntegerType=%b, isUnsigned=%b, size=%d]", getTypeName(), getSuperclassName(), isOopType(), isIntegerType(), - isUnsigned(), getSize()); - } - } - } - - public abstract class AbstractConstant { - - protected final long address; - protected final long nameOffset; - protected final long valueOffset; - - AbstractConstant(long address, long nameOffset, long valueOffset) { - this.address = address; - this.nameOffset = nameOffset; - this.valueOffset = valueOffset; - } - - public String getName() { - long nameAddress = UNSAFE.getAddress(address + nameOffset); - return readCString(UNSAFE, nameAddress); - } - - public abstract long getValue(); - } - - /** - * VMIntConstantEntry (see vmStructs.hpp). - */ - @HotSpotVMData(index = 16) @Stable private long jvmciHotSpotVMIntConstants; - @HotSpotVMData(index = 17) @Stable private long jvmciHotSpotVMIntConstantEntryNameOffset; - @HotSpotVMData(index = 18) @Stable private long jvmciHotSpotVMIntConstantEntryValueOffset; - @HotSpotVMData(index = 19) @Stable private long jvmciHotSpotVMIntConstantEntryArrayStride; - - final class VMIntConstants implements Iterable { - - private final long address; - - VMIntConstants(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Constant current() { - return new Constant(address + jvmciHotSpotVMIntConstantEntryArrayStride * index); - } - - /** - * The last entry is identified by a NULL name. - */ - public boolean hasNext() { - Constant entry = current(); - return entry.getName() != null; - } - - public Constant next() { - Constant entry = current(); - index++; - return entry; - } - }; - } - - final class Constant extends AbstractConstant { - - Constant(long address) { - super(address, jvmciHotSpotVMIntConstantEntryNameOffset, jvmciHotSpotVMIntConstantEntryValueOffset); - } - - @Override - public long getValue() { - return UNSAFE.getInt(address + valueOffset); - } - - @Override - public String toString() { - return String.format("IntConstant[name=%s, value=%d (0x%x)]", getName(), getValue(), getValue()); - } - } - } - - /** - * VMLongConstantEntry (see vmStructs.hpp). - */ - @HotSpotVMData(index = 20) @Stable private long jvmciHotSpotVMLongConstants; - @HotSpotVMData(index = 21) @Stable private long jvmciHotSpotVMLongConstantEntryNameOffset; - @HotSpotVMData(index = 22) @Stable private long jvmciHotSpotVMLongConstantEntryValueOffset; - @HotSpotVMData(index = 23) @Stable private long jvmciHotSpotVMLongConstantEntryArrayStride; - - final class VMLongConstants implements Iterable { - - private final long address; - - VMLongConstants(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Constant currentEntry() { - return new Constant(address + jvmciHotSpotVMLongConstantEntryArrayStride * index); - } - - /** - * The last entry is identified by a NULL name. - */ - public boolean hasNext() { - Constant entry = currentEntry(); - return entry.getName() != null; - } - - public Constant next() { - Constant entry = currentEntry(); - index++; - return entry; - } - }; - } - - final class Constant extends AbstractConstant { - - Constant(long address) { - super(address, jvmciHotSpotVMLongConstantEntryNameOffset, jvmciHotSpotVMLongConstantEntryValueOffset); - } - - @Override - public long getValue() { - return UNSAFE.getLong(address + valueOffset); - } - - @Override - public String toString() { - return String.format("LongConstant[name=%s, value=%d (0x%x)]", getName(), getValue(), getValue()); - } - } - } - - /** - * VMAddressEntry (see vmStructs.hpp). - */ - @HotSpotVMData(index = 24) @Stable private long jvmciHotSpotVMAddresses; - @HotSpotVMData(index = 25) @Stable private long jvmciHotSpotVMAddressEntryNameOffset; - @HotSpotVMData(index = 26) @Stable private long jvmciHotSpotVMAddressEntryValueOffset; - @HotSpotVMData(index = 27) @Stable private long jvmciHotSpotVMAddressEntryArrayStride; - - final class VMAddresses implements Iterable { - - private final long address; - - VMAddresses(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Address currentEntry() { - return new Address(address + jvmciHotSpotVMAddressEntryArrayStride * index); - } - - /** - * The last entry is identified by a NULL name. - */ - public boolean hasNext() { - Address entry = currentEntry(); - return entry.getName() != null; - } - - public Address next() { - Address entry = currentEntry(); - index++; - return entry; - } - }; - } - - final class Address extends AbstractConstant { - - Address(long address) { - super(address, jvmciHotSpotVMAddressEntryNameOffset, jvmciHotSpotVMAddressEntryValueOffset); - } - - @Override - public long getValue() { - return UNSAFE.getLong(address + valueOffset); - } - - @Override - public String toString() { - return String.format("Address[name=%s, value=%d (0x%x)]", getName(), getValue(), getValue()); - } - } - } - - final class Flags implements Iterable { - - private final long address; - private final long entrySize; - private final long typeOffset; - private final long nameOffset; - private final long addrOffset; - - Flags(HashMap vmStructs, HashMap vmTypes) { - address = vmStructs.get("Flag::flags").getValue(); - entrySize = vmTypes.get("Flag").getSize(); - typeOffset = vmStructs.get("Flag::_type").getOffset(); - nameOffset = vmStructs.get("Flag::_name").getOffset(); - addrOffset = vmStructs.get("Flag::_addr").getOffset(); - - assert vmTypes.get("bool").getSize() == Byte.BYTES; - assert vmTypes.get("intx").getSize() == Long.BYTES; - assert vmTypes.get("uintx").getSize() == Long.BYTES; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Flag current() { - return new Flag(address + entrySize * index); - } - - /** - * The last entry is identified by a NULL name. - */ - public boolean hasNext() { - Flag entry = current(); - return entry.getName() != null; - } - - public Flag next() { - Flag entry = current(); - index++; - return entry; - } - }; - } - - final class Flag { - - private final long entryAddress; - - Flag(long address) { - this.entryAddress = address; - } - - public String getType() { - long typeAddress = UNSAFE.getAddress(entryAddress + typeOffset); - return readCString(UNSAFE, typeAddress); - } - - public String getName() { - long nameAddress = UNSAFE.getAddress(entryAddress + nameOffset); - return readCString(UNSAFE, nameAddress); - } - - public long getAddr() { - return UNSAFE.getAddress(entryAddress + addrOffset); - } - - public Object getValue() { - switch (getType()) { - case "bool": - return Boolean.valueOf(UNSAFE.getByte(getAddr()) != 0); - case "intx": - case "uintx": - case "uint64_t": - return Long.valueOf(UNSAFE.getLong(getAddr())); - case "double": - return Double.valueOf(UNSAFE.getDouble(getAddr())); - case "ccstr": - case "ccstrlist": - return readCString(UNSAFE, getAddr()); - default: - throw new JVMCIError(getType()); - } - } - - @Override - public String toString() { - return String.format("Flag[type=%s, name=%s, value=%s]", getType(), getName(), getValue()); - } - } - } - - @HotSpotVMConstant(name = "ASSERT") @Stable public boolean cAssertions; - public final boolean windowsOs = System.getProperty("os.name", "").startsWith("Windows"); - public final boolean linuxOs = System.getProperty("os.name", "").startsWith("Linux"); - - @HotSpotVMFlag(name = "CodeEntryAlignment") @Stable public int codeEntryAlignment; - @HotSpotVMFlag(name = "VerifyOops") @Stable public boolean verifyOops; - @HotSpotVMFlag(name = "CITime") @Stable public boolean ciTime; - @HotSpotVMFlag(name = "CITimeEach") @Stable public boolean ciTimeEach; - @HotSpotVMFlag(name = "CompileTheWorldStartAt", optional = true) @Stable public int compileTheWorldStartAt; - @HotSpotVMFlag(name = "CompileTheWorldStopAt", optional = true) @Stable public int compileTheWorldStopAt; - @HotSpotVMFlag(name = "DontCompileHugeMethods") @Stable public boolean dontCompileHugeMethods; - @HotSpotVMFlag(name = "HugeMethodLimit") @Stable public int hugeMethodLimit; - @HotSpotVMFlag(name = "PrintInlining") @Stable public boolean printInlining; - @HotSpotVMFlag(name = "Inline") @Stable public boolean inline; - @HotSpotVMFlag(name = "JVMCIUseFastLocking") @Stable public boolean useFastLocking; - @HotSpotVMFlag(name = "ForceUnreachable") @Stable public boolean forceUnreachable; - @HotSpotVMFlag(name = "CodeCacheSegmentSize") @Stable public int codeSegmentSize; - @HotSpotVMFlag(name = "FoldStableValues") @Stable public boolean foldStableValues; - - @HotSpotVMFlag(name = "UseTLAB") @Stable public boolean useTLAB; - @HotSpotVMFlag(name = "UseBiasedLocking") @Stable public boolean useBiasedLocking; - @HotSpotVMFlag(name = "UsePopCountInstruction") @Stable public boolean usePopCountInstruction; - @HotSpotVMFlag(name = "UseCountLeadingZerosInstruction", archs = {"amd64"}) @Stable public boolean useCountLeadingZerosInstruction; - @HotSpotVMFlag(name = "UseCountTrailingZerosInstruction", archs = {"amd64"}) @Stable public boolean useCountTrailingZerosInstruction; - @HotSpotVMFlag(name = "UseAESIntrinsics") @Stable public boolean useAESIntrinsics; - @HotSpotVMFlag(name = "UseCRC32Intrinsics") @Stable public boolean useCRC32Intrinsics; - @HotSpotVMFlag(name = "UseG1GC") @Stable public boolean useG1GC; - @HotSpotVMFlag(name = "UseConcMarkSweepGC") @Stable public boolean useCMSGC; - - @HotSpotVMFlag(name = "AllocatePrefetchStyle") @Stable public int allocatePrefetchStyle; - @HotSpotVMFlag(name = "AllocatePrefetchInstr") @Stable public int allocatePrefetchInstr; - @HotSpotVMFlag(name = "AllocatePrefetchLines") @Stable public int allocatePrefetchLines; - @HotSpotVMFlag(name = "AllocateInstancePrefetchLines") @Stable public int allocateInstancePrefetchLines; - @HotSpotVMFlag(name = "AllocatePrefetchStepSize") @Stable public int allocatePrefetchStepSize; - @HotSpotVMFlag(name = "AllocatePrefetchDistance") @Stable public int allocatePrefetchDistance; - - @HotSpotVMFlag(name = "FlightRecorder", optional = true) @Stable public boolean flightRecorder; - - @HotSpotVMField(name = "CompilerToVM::Data::Universe_collectedHeap", type = "CollectedHeap*", get = HotSpotVMField.Type.VALUE) @Stable private long universeCollectedHeap; - @HotSpotVMField(name = "CollectedHeap::_total_collections", type = "unsigned int", get = HotSpotVMField.Type.OFFSET) @Stable private int collectedHeapTotalCollectionsOffset; - - public long gcTotalCollectionsAddress() { - return universeCollectedHeap + collectedHeapTotalCollectionsOffset; - } - - @HotSpotVMFlag(name = "ReduceInitialCardMarks") @Stable public boolean useDeferredInitBarriers; - - // Compressed Oops related values. - @HotSpotVMFlag(name = "UseCompressedOops") @Stable public boolean useCompressedOops; - @HotSpotVMFlag(name = "UseCompressedClassPointers") @Stable public boolean useCompressedClassPointers; - - @HotSpotVMField(name = "CompilerToVM::Data::Universe_narrow_oop_base", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long narrowOopBase; - @HotSpotVMField(name = "CompilerToVM::Data::Universe_narrow_oop_shift", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int narrowOopShift; - @HotSpotVMFlag(name = "ObjectAlignmentInBytes") @Stable public int objectAlignment; - - public final int minObjAlignment() { - return objectAlignment / heapWordSize; - } - - public final int logMinObjAlignment() { - return (int) (Math.log(objectAlignment) / Math.log(2)); - } - - @HotSpotVMType(name = "narrowKlass", get = HotSpotVMType.Type.SIZE) @Stable public int narrowKlassSize; - @HotSpotVMField(name = "CompilerToVM::Data::Universe_narrow_klass_base", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long narrowKlassBase; - @HotSpotVMField(name = "CompilerToVM::Data::Universe_narrow_klass_shift", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int narrowKlassShift; - @HotSpotVMConstant(name = "LogKlassAlignmentInBytes") @Stable public int logKlassAlignment; - - // CPU capabilities - @HotSpotVMFlag(name = "UseSSE") @Stable public int useSSE; - @HotSpotVMFlag(name = "UseAVX", archs = {"amd64"}) @Stable public int useAVX; - - @HotSpotVMField(name = "Abstract_VM_Version::_features", type = "uint64_t", get = HotSpotVMField.Type.VALUE) @Stable public long vmVersionFeatures; - - // AMD64 specific values - @HotSpotVMConstant(name = "VM_Version::CPU_CX8", archs = {"amd64"}) @Stable public long amd64CX8; - @HotSpotVMConstant(name = "VM_Version::CPU_CMOV", archs = {"amd64"}) @Stable public long amd64CMOV; - @HotSpotVMConstant(name = "VM_Version::CPU_FXSR", archs = {"amd64"}) @Stable public long amd64FXSR; - @HotSpotVMConstant(name = "VM_Version::CPU_HT", archs = {"amd64"}) @Stable public long amd64HT; - @HotSpotVMConstant(name = "VM_Version::CPU_MMX", archs = {"amd64"}) @Stable public long amd64MMX; - @HotSpotVMConstant(name = "VM_Version::CPU_3DNOW_PREFETCH", archs = {"amd64"}) @Stable public long amd643DNOWPREFETCH; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE", archs = {"amd64"}) @Stable public long amd64SSE; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE2", archs = {"amd64"}) @Stable public long amd64SSE2; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE3", archs = {"amd64"}) @Stable public long amd64SSE3; - @HotSpotVMConstant(name = "VM_Version::CPU_SSSE3", archs = {"amd64"}) @Stable public long amd64SSSE3; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE4A", archs = {"amd64"}) @Stable public long amd64SSE4A; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE4_1", archs = {"amd64"}) @Stable public long amd64SSE41; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE4_2", archs = {"amd64"}) @Stable public long amd64SSE42; - @HotSpotVMConstant(name = "VM_Version::CPU_POPCNT", archs = {"amd64"}) @Stable public long amd64POPCNT; - @HotSpotVMConstant(name = "VM_Version::CPU_LZCNT", archs = {"amd64"}) @Stable public long amd64LZCNT; - @HotSpotVMConstant(name = "VM_Version::CPU_TSC", archs = {"amd64"}) @Stable public long amd64TSC; - @HotSpotVMConstant(name = "VM_Version::CPU_TSCINV", archs = {"amd64"}) @Stable public long amd64TSCINV; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX", archs = {"amd64"}) @Stable public long amd64AVX; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX2", archs = {"amd64"}) @Stable public long amd64AVX2; - @HotSpotVMConstant(name = "VM_Version::CPU_AES", archs = {"amd64"}) @Stable public long amd64AES; - @HotSpotVMConstant(name = "VM_Version::CPU_ERMS", archs = {"amd64"}) @Stable public long amd64ERMS; - @HotSpotVMConstant(name = "VM_Version::CPU_CLMUL", archs = {"amd64"}) @Stable public long amd64CLMUL; - @HotSpotVMConstant(name = "VM_Version::CPU_BMI1", archs = {"amd64"}) @Stable public long amd64BMI1; - @HotSpotVMConstant(name = "VM_Version::CPU_BMI2", archs = {"amd64"}) @Stable public long amd64BMI2; - @HotSpotVMConstant(name = "VM_Version::CPU_RTM", archs = {"amd64"}) @Stable public long amd64RTM; - @HotSpotVMConstant(name = "VM_Version::CPU_ADX", archs = {"amd64"}) @Stable public long amd64ADX; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512F", archs = {"amd64"}) @Stable public long amd64AVX512F; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512DQ", archs = {"amd64"}) @Stable public long amd64AVX512DQ; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512PF", archs = {"amd64"}) @Stable public long amd64AVX512PF; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512ER", archs = {"amd64"}) @Stable public long amd64AVX512ER; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512CD", archs = {"amd64"}) @Stable public long amd64AVX512CD; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512BW", archs = {"amd64"}) @Stable public long amd64AVX512BW; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX512VL", archs = {"amd64"}) @Stable public long amd64AVX512VL; - @HotSpotVMConstant(name = "VM_Version::CPU_SHA", archs = {"amd64"}) @Stable public long amd64SHA; - - // SPARC specific values - @HotSpotVMConstant(name = "VM_Version::vis3_instructions_m", archs = {"sparc"}) @Stable public int sparcVis3Instructions; - @HotSpotVMConstant(name = "VM_Version::vis2_instructions_m", archs = {"sparc"}) @Stable public int sparcVis2Instructions; - @HotSpotVMConstant(name = "VM_Version::vis1_instructions_m", archs = {"sparc"}) @Stable public int sparcVis1Instructions; - @HotSpotVMConstant(name = "VM_Version::cbcond_instructions_m", archs = {"sparc"}) @Stable public int sparcCbcondInstructions; - @HotSpotVMConstant(name = "VM_Version::v8_instructions_m", archs = {"sparc"}) @Stable public int sparcV8Instructions; - @HotSpotVMConstant(name = "VM_Version::hardware_mul32_m", archs = {"sparc"}) @Stable public int sparcHardwareMul32; - @HotSpotVMConstant(name = "VM_Version::hardware_div32_m", archs = {"sparc"}) @Stable public int sparcHardwareDiv32; - @HotSpotVMConstant(name = "VM_Version::hardware_fsmuld_m", archs = {"sparc"}) @Stable public int sparcHardwareFsmuld; - @HotSpotVMConstant(name = "VM_Version::hardware_popc_m", archs = {"sparc"}) @Stable public int sparcHardwarePopc; - @HotSpotVMConstant(name = "VM_Version::v9_instructions_m", archs = {"sparc"}) @Stable public int sparcV9Instructions; - @HotSpotVMConstant(name = "VM_Version::sun4v_m", archs = {"sparc"}) @Stable public int sparcSun4v; - @HotSpotVMConstant(name = "VM_Version::blk_init_instructions_m", archs = {"sparc"}) @Stable public int sparcBlkInitInstructions; - @HotSpotVMConstant(name = "VM_Version::fmaf_instructions_m", archs = {"sparc"}) @Stable public int sparcFmafInstructions; - @HotSpotVMConstant(name = "VM_Version::fmau_instructions_m", archs = {"sparc"}) @Stable public int sparcFmauInstructions; - @HotSpotVMConstant(name = "VM_Version::sparc64_family_m", archs = {"sparc"}) @Stable public int sparcSparc64Family; - @HotSpotVMConstant(name = "VM_Version::M_family_m", archs = {"sparc"}) @Stable public int sparcMFamily; - @HotSpotVMConstant(name = "VM_Version::T_family_m", archs = {"sparc"}) @Stable public int sparcTFamily; - @HotSpotVMConstant(name = "VM_Version::T1_model_m", archs = {"sparc"}) @Stable public int sparcT1Model; - @HotSpotVMConstant(name = "VM_Version::sparc5_instructions_m", archs = {"sparc"}) @Stable public int sparcSparc5Instructions; - @HotSpotVMConstant(name = "VM_Version::aes_instructions_m", archs = {"sparc"}) @Stable public int sparcAesInstructions; - @HotSpotVMConstant(name = "VM_Version::sha1_instruction_m", archs = {"sparc"}) @Stable public int sparcSha1Instruction; - @HotSpotVMConstant(name = "VM_Version::sha256_instruction_m", archs = {"sparc"}) @Stable public int sparcSha256Instruction; - @HotSpotVMConstant(name = "VM_Version::sha512_instruction_m", archs = {"sparc"}) @Stable public int sparcSha512Instruction; - - @HotSpotVMFlag(name = "UseBlockZeroing", archs = {"sparc"}) @Stable public boolean useBlockZeroing; - @HotSpotVMFlag(name = "BlockZeroingLowLimit", archs = {"sparc"}) @Stable public int blockZeroingLowLimit; - - @HotSpotVMFlag(name = "StackShadowPages") @Stable public int stackShadowPages; - @HotSpotVMFlag(name = "StackReservedPages") @Stable public int stackReservedPages; - @HotSpotVMFlag(name = "UseStackBanging") @Stable public boolean useStackBanging; - @HotSpotVMConstant(name = "STACK_BIAS") @Stable public int stackBias; - @HotSpotVMField(name = "CompilerToVM::Data::vm_page_size", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int vmPageSize; - - // offsets, ... - @HotSpotVMField(name = "oopDesc::_mark", type = "markOop", get = HotSpotVMField.Type.OFFSET) @Stable public int markOffset; - @HotSpotVMField(name = "oopDesc::_metadata._klass", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int hubOffset; - - @HotSpotVMField(name = "Klass::_prototype_header", type = "markOop", get = HotSpotVMField.Type.OFFSET) @Stable public int prototypeMarkWordOffset; - @HotSpotVMField(name = "Klass::_subklass", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int subklassOffset; - @HotSpotVMField(name = "Klass::_next_sibling", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int nextSiblingOffset; - @HotSpotVMField(name = "Klass::_super_check_offset", type = "juint", get = HotSpotVMField.Type.OFFSET) @Stable public int superCheckOffsetOffset; - @HotSpotVMField(name = "Klass::_secondary_super_cache", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int secondarySuperCacheOffset; - @HotSpotVMField(name = "Klass::_secondary_supers", type = "Array*", get = HotSpotVMField.Type.OFFSET) @Stable public int secondarySupersOffset; - - /** - * The offset of the _java_mirror field (of type {@link Class}) in a Klass. - */ - @HotSpotVMField(name = "Klass::_java_mirror", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int classMirrorOffset; - - @HotSpotVMField(name = "Klass::_super", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int klassSuperKlassOffset; - @HotSpotVMField(name = "Klass::_modifier_flags", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int klassModifierFlagsOffset; - @HotSpotVMField(name = "Klass::_access_flags", type = "AccessFlags", get = HotSpotVMField.Type.OFFSET) @Stable public int klassAccessFlagsOffset; - @HotSpotVMField(name = "Klass::_layout_helper", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int klassLayoutHelperOffset; - @HotSpotVMField(name = "Klass::_name", type = "Symbol*", get = HotSpotVMField.Type.OFFSET) @Stable public int klassNameOffset; - - @HotSpotVMConstant(name = "Klass::_lh_neutral_value") @Stable public int klassLayoutHelperNeutralValue; - @HotSpotVMConstant(name = "Klass::_lh_instance_slow_path_bit") @Stable public int klassLayoutHelperInstanceSlowPathBit; - @HotSpotVMConstant(name = "Klass::_lh_log2_element_size_shift") @Stable public int layoutHelperLog2ElementSizeShift; - @HotSpotVMConstant(name = "Klass::_lh_log2_element_size_mask") @Stable public int layoutHelperLog2ElementSizeMask; - @HotSpotVMConstant(name = "Klass::_lh_element_type_shift") @Stable public int layoutHelperElementTypeShift; - @HotSpotVMConstant(name = "Klass::_lh_element_type_mask") @Stable public int layoutHelperElementTypeMask; - @HotSpotVMConstant(name = "Klass::_lh_header_size_shift") @Stable public int layoutHelperHeaderSizeShift; - @HotSpotVMConstant(name = "Klass::_lh_header_size_mask") @Stable public int layoutHelperHeaderSizeMask; - @HotSpotVMConstant(name = "Klass::_lh_array_tag_shift") @Stable public int layoutHelperArrayTagShift; - @HotSpotVMConstant(name = "Klass::_lh_array_tag_type_value") @Stable public int layoutHelperArrayTagTypeValue; - @HotSpotVMConstant(name = "Klass::_lh_array_tag_obj_value") @Stable public int layoutHelperArrayTagObjectValue; - - /** - * This filters out the bit that differentiates a type array from an object array. - */ - public int layoutHelperElementTypePrimitiveInPlace() { - return (layoutHelperArrayTagTypeValue & ~layoutHelperArrayTagObjectValue) << layoutHelperArrayTagShift; - } - - /** - * Bit pattern in the klass layout helper that can be used to identify arrays. - */ - public final int arrayKlassLayoutHelperIdentifier = 0x80000000; - - @HotSpotVMType(name = "vtableEntry", get = HotSpotVMType.Type.SIZE) @Stable public int vtableEntrySize; - @HotSpotVMField(name = "vtableEntry::_method", type = "Method*", get = HotSpotVMField.Type.OFFSET) @Stable public int vtableEntryMethodOffset; - - @HotSpotVMType(name = "InstanceKlass", get = HotSpotVMType.Type.SIZE) @Stable public int instanceKlassSize; - @HotSpotVMField(name = "InstanceKlass::_source_file_name_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassSourceFileNameIndexOffset; - @HotSpotVMField(name = "InstanceKlass::_init_state", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassInitStateOffset; - @HotSpotVMField(name = "InstanceKlass::_constants", type = "ConstantPool*", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassConstantsOffset; - @HotSpotVMField(name = "InstanceKlass::_fields", type = "Array*", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassFieldsOffset; - @HotSpotVMField(name = "CompilerToVM::Data::Klass_vtable_start_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int klassVtableStartOffset; - @HotSpotVMField(name = "CompilerToVM::Data::Klass_vtable_length_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int klassVtableLengthOffset; - - @HotSpotVMConstant(name = "InstanceKlass::linked") @Stable public int instanceKlassStateLinked; - @HotSpotVMConstant(name = "InstanceKlass::fully_initialized") @Stable public int instanceKlassStateFullyInitialized; - - @HotSpotVMType(name = "arrayOopDesc", get = HotSpotVMType.Type.SIZE) @Stable public int arrayOopDescSize; - - /** - * The offset of the array length word in an array object's header. - * - * See {@code arrayOopDesc::length_offset_in_bytes()}. - */ - public final int arrayOopDescLengthOffset() { - return useCompressedClassPointers ? hubOffset + narrowKlassSize : arrayOopDescSize; - } - - @HotSpotVMField(name = "Array::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayU1LengthOffset; - @HotSpotVMField(name = "Array::_data", type = "", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayU1DataOffset; - @HotSpotVMField(name = "Array::_data", type = "", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayU2DataOffset; - @HotSpotVMField(name = "Array::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int metaspaceArrayLengthOffset; - @HotSpotVMField(name = "Array::_data[0]", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int metaspaceArrayBaseOffset; - - @HotSpotVMField(name = "ObjArrayKlass::_element_klass", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayClassElementOffset; - - @HotSpotVMConstant(name = "FieldInfo::access_flags_offset") @Stable public int fieldInfoAccessFlagsOffset; - @HotSpotVMConstant(name = "FieldInfo::name_index_offset") @Stable public int fieldInfoNameIndexOffset; - @HotSpotVMConstant(name = "FieldInfo::signature_index_offset") @Stable public int fieldInfoSignatureIndexOffset; - @HotSpotVMConstant(name = "FieldInfo::initval_index_offset") @Stable public int fieldInfoInitvalIndexOffset; - @HotSpotVMConstant(name = "FieldInfo::low_packed_offset") @Stable public int fieldInfoLowPackedOffset; - @HotSpotVMConstant(name = "FieldInfo::high_packed_offset") @Stable public int fieldInfoHighPackedOffset; - @HotSpotVMConstant(name = "FieldInfo::field_slots") @Stable public int fieldInfoFieldSlots; - - @HotSpotVMConstant(name = "FIELDINFO_TAG_SIZE") @Stable public int fieldInfoTagSize; - - @HotSpotVMConstant(name = "JVM_ACC_MONITOR_MATCH") @Stable public int jvmAccMonitorMatch; - @HotSpotVMConstant(name = "JVM_ACC_HAS_MONITOR_BYTECODES") @Stable public int jvmAccHasMonitorBytecodes; - @HotSpotVMConstant(name = "JVM_ACC_HAS_FINALIZER") @Stable public int jvmAccHasFinalizer; - @HotSpotVMConstant(name = "JVM_ACC_FIELD_INTERNAL") @Stable public int jvmAccFieldInternal; - @HotSpotVMConstant(name = "JVM_ACC_FIELD_STABLE") @Stable public int jvmAccFieldStable; - @HotSpotVMConstant(name = "JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE") @Stable public int jvmAccFieldHasGenericSignature; - @HotSpotVMConstant(name = "JVM_ACC_WRITTEN_FLAGS") @Stable public int jvmAccWrittenFlags; - @HotSpotVMConstant(name = "JVM_ACC_IS_CLONEABLE_FAST") @Stable public int jvmAccIsCloneableFast; - - // Modifier.SYNTHETIC is not public so we get it via vmStructs. - @HotSpotVMConstant(name = "JVM_ACC_SYNTHETIC") @Stable public int jvmAccSynthetic; - - /** - * @see HotSpotResolvedObjectTypeImpl#createField - */ - @HotSpotVMConstant(name = "JVM_RECOGNIZED_FIELD_MODIFIERS") @Stable public int recognizedFieldModifiers; - - @HotSpotVMField(name = "Thread::_tlab", type = "ThreadLocalAllocBuffer", get = HotSpotVMField.Type.OFFSET) @Stable public int threadTlabOffset; - - @HotSpotVMField(name = "JavaThread::_anchor", type = "JavaFrameAnchor", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadAnchorOffset; - @HotSpotVMField(name = "JavaThread::_threadObj", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadObjectOffset; - @HotSpotVMField(name = "JavaThread::_osthread", type = "OSThread*", get = HotSpotVMField.Type.OFFSET) @Stable public int osThreadOffset; - @HotSpotVMField(name = "JavaThread::_dirty_card_queue", type = "DirtyCardQueue", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadDirtyCardQueueOffset; - @HotSpotVMField(name = "JavaThread::_is_method_handle_return", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int threadIsMethodHandleReturnOffset; - @HotSpotVMField(name = "JavaThread::_satb_mark_queue", type = "SATBMarkQueue", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadSatbMarkQueueOffset; - @HotSpotVMField(name = "JavaThread::_vm_result", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadObjectResultOffset; - @HotSpotVMField(name = "JavaThread::_jvmci_counters", type = "jlong*", get = HotSpotVMField.Type.OFFSET) @Stable public int jvmciCountersThreadOffset; - @HotSpotVMField(name = "JavaThread::_reserved_stack_activation", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadReservedStackActivationOffset; - - /** - * An invalid value for {@link #rtldDefault}. - */ - public static final long INVALID_RTLD_DEFAULT_HANDLE = 0xDEADFACE; - - /** - * Address of the library lookup routine. The C signature of this routine is: - * - *
-     *     void* (const char *filename, char *ebuf, int ebuflen)
-     * 
- */ - @HotSpotVMAddress(name = "os::dll_load") @Stable public long dllLoad; - - /** - * Address of the library lookup routine. The C signature of this routine is: - * - *
-     *     void* (void* handle, const char* name)
-     * 
- */ - @HotSpotVMAddress(name = "os::dll_lookup") @Stable public long dllLookup; - - /** - * A pseudo-handle which when used as the first argument to {@link #dllLookup} means lookup will - * return the first occurrence of the desired symbol using the default library search order. If - * this field is {@value #INVALID_RTLD_DEFAULT_HANDLE}, then this capability is not supported on - * the current platform. - */ - @HotSpotVMAddress(name = "RTLD_DEFAULT", os = {"bsd", "linux"}) @Stable public long rtldDefault = INVALID_RTLD_DEFAULT_HANDLE; - - /** - * This field is used to pass exception objects into and out of the runtime system during - * exception handling for compiled code. - */ - @HotSpotVMField(name = "JavaThread::_exception_oop", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadExceptionOopOffset; - @HotSpotVMField(name = "JavaThread::_exception_pc", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int threadExceptionPcOffset; - @HotSpotVMField(name = "ThreadShadow::_pending_exception", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingExceptionOffset; - - @HotSpotVMField(name = "JavaThread::_pending_deoptimization", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingDeoptimizationOffset; - @HotSpotVMField(name = "JavaThread::_pending_failed_speculation", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingFailedSpeculationOffset; - @HotSpotVMField(name = "JavaThread::_pending_transfer_to_interpreter", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingTransferToInterpreterOffset; - - @HotSpotVMField(name = "JavaFrameAnchor::_last_Java_sp", type = "intptr_t*", get = HotSpotVMField.Type.OFFSET) @Stable private int javaFrameAnchorLastJavaSpOffset; - @HotSpotVMField(name = "JavaFrameAnchor::_last_Java_pc", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable private int javaFrameAnchorLastJavaPcOffset; - @HotSpotVMField(name = "JavaFrameAnchor::_last_Java_fp", type = "intptr_t*", get = HotSpotVMField.Type.OFFSET, archs = {"aarch64, amd64"}) @Stable private int javaFrameAnchorLastJavaFpOffset; - @HotSpotVMField(name = "JavaFrameAnchor::_flags", type = "int", get = HotSpotVMField.Type.OFFSET, archs = {"sparc"}) @Stable private int javaFrameAnchorFlagsOffset; - - public int threadLastJavaSpOffset() { - return javaThreadAnchorOffset + javaFrameAnchorLastJavaSpOffset; - } - - public int threadLastJavaPcOffset() { - return javaThreadAnchorOffset + javaFrameAnchorLastJavaPcOffset; - } - - public int threadLastJavaFpOffset() { - assert getHostArchitectureName().equals("aarch64") || getHostArchitectureName().equals("amd64"); - return javaThreadAnchorOffset + javaFrameAnchorLastJavaFpOffset; - } - - /** - * This value is only valid on SPARC. - */ - public int threadJavaFrameAnchorFlagsOffset() { - // TODO add an assert for SPARC - return javaThreadAnchorOffset + javaFrameAnchorFlagsOffset; - } - - // These are only valid on AMD64. - @HotSpotVMConstant(name = "frame::arg_reg_save_area_bytes", archs = {"amd64"}) @Stable public int runtimeCallStackSize; - @HotSpotVMConstant(name = "frame::interpreter_frame_sender_sp_offset", archs = {"amd64"}) @Stable public int frameInterpreterFrameSenderSpOffset; - @HotSpotVMConstant(name = "frame::interpreter_frame_last_sp_offset", archs = {"amd64"}) @Stable public int frameInterpreterFrameLastSpOffset; - - @HotSpotVMConstant(name = "dirtyCardQueueBufferOffset") @Stable private int dirtyCardQueueBufferOffset; - @HotSpotVMConstant(name = "dirtyCardQueueIndexOffset") @Stable private int dirtyCardQueueIndexOffset; - - @HotSpotVMConstant(name = "satbMarkQueueBufferOffset") @Stable private int satbMarkQueueBufferOffset; - @HotSpotVMConstant(name = "satbMarkQueueIndexOffset") @Stable private int satbMarkQueueIndexOffset; - @HotSpotVMConstant(name = "satbMarkQueueActiveOffset") @Stable private int satbMarkQueueActiveOffset; - - @HotSpotVMField(name = "OSThread::_interrupted", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int osThreadInterruptedOffset; - - @HotSpotVMConstant(name = "markOopDesc::hash_shift") @Stable public long markOopDescHashShift; - - @HotSpotVMConstant(name = "markOopDesc::biased_lock_mask_in_place") @Stable public int biasedLockMaskInPlace; - @HotSpotVMConstant(name = "markOopDesc::age_mask_in_place") @Stable public int ageMaskInPlace; - @HotSpotVMConstant(name = "markOopDesc::epoch_mask_in_place") @Stable public int epochMaskInPlace; - @HotSpotVMConstant(name = "markOopDesc::hash_mask") @Stable public long markOopDescHashMask; - @HotSpotVMConstant(name = "markOopDesc::hash_mask_in_place") @Stable public long markOopDescHashMaskInPlace; - - @HotSpotVMConstant(name = "markOopDesc::unlocked_value") @Stable public int unlockedMask; - @HotSpotVMConstant(name = "markOopDesc::biased_lock_pattern") @Stable public int biasedLockPattern; - - @HotSpotVMConstant(name = "markOopDesc::no_hash_in_place") @Stable public int markWordNoHashInPlace; - @HotSpotVMConstant(name = "markOopDesc::no_lock_in_place") @Stable public int markWordNoLockInPlace; - - /** - * See {@code markOopDesc::prototype()}. - */ - public long arrayPrototypeMarkWord() { - return markWordNoHashInPlace | markWordNoLockInPlace; - } - - /** - * See {@code markOopDesc::copy_set_hash()}. - */ - public long tlabIntArrayMarkWord() { - long tmp = arrayPrototypeMarkWord() & (~markOopDescHashMaskInPlace); - tmp |= ((0x2 & markOopDescHashMask) << markOopDescHashShift); - return tmp; - } - - /** - * Mark word right shift to get identity hash code. - */ - @HotSpotVMConstant(name = "markOopDesc::hash_shift") @Stable public int identityHashCodeShift; - - /** - * Identity hash code value when uninitialized. - */ - @HotSpotVMConstant(name = "markOopDesc::no_hash") @Stable public int uninitializedIdentityHashCodeValue; - - @HotSpotVMField(name = "Method::_access_flags", type = "AccessFlags", get = HotSpotVMField.Type.OFFSET) @Stable public int methodAccessFlagsOffset; - @HotSpotVMField(name = "Method::_constMethod", type = "ConstMethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodConstMethodOffset; - @HotSpotVMField(name = "Method::_intrinsic_id", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int methodIntrinsicIdOffset; - @HotSpotVMField(name = "Method::_flags", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int methodFlagsOffset; - @HotSpotVMField(name = "Method::_vtable_index", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodVtableIndexOffset; - - @HotSpotVMField(name = "Method::_method_counters", type = "MethodCounters*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCountersOffset; - @HotSpotVMField(name = "Method::_method_data", type = "MethodData*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOffset; - @HotSpotVMField(name = "Method::_from_compiled_entry", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCompiledEntryOffset; - @HotSpotVMField(name = "Method::_code", type = "CompiledMethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCodeOffset; - - @HotSpotVMConstant(name = "Method::_jfr_towrite") @Stable public int methodFlagsJfrTowrite; - @HotSpotVMConstant(name = "Method::_caller_sensitive") @Stable public int methodFlagsCallerSensitive; - @HotSpotVMConstant(name = "Method::_force_inline") @Stable public int methodFlagsForceInline; - @HotSpotVMConstant(name = "Method::_dont_inline") @Stable public int methodFlagsDontInline; - @HotSpotVMConstant(name = "Method::_hidden") @Stable public int methodFlagsHidden; - @HotSpotVMConstant(name = "Method::_reserved_stack_access") @Stable public int methodFlagsReservedStackAccess; - @HotSpotVMConstant(name = "Method::nonvirtual_vtable_index") @Stable public int nonvirtualVtableIndex; - @HotSpotVMConstant(name = "Method::invalid_vtable_index") @Stable public int invalidVtableIndex; - - @HotSpotVMField(name = "MethodCounters::_invocation_counter", type = "InvocationCounter", get = HotSpotVMField.Type.OFFSET) @Stable public int invocationCounterOffset; - @HotSpotVMField(name = "MethodCounters::_backedge_counter", type = "InvocationCounter", get = HotSpotVMField.Type.OFFSET) @Stable public int backedgeCounterOffset; - @HotSpotVMConstant(name = "InvocationCounter::count_increment") @Stable public int invocationCounterIncrement; - @HotSpotVMConstant(name = "InvocationCounter::count_shift") @Stable public int invocationCounterShift; - - @HotSpotVMField(name = "MethodData::_size", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataSize; - @HotSpotVMField(name = "MethodData::_data_size", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataDataSize; - @HotSpotVMField(name = "MethodData::_data[0]", type = "intptr_t", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopDataOffset; - @HotSpotVMField(name = "MethodData::_trap_hist._array[0]", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopTrapHistoryOffset; - @HotSpotVMField(name = "MethodData::_jvmci_ir_size", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataIRSizeOffset; - - @HotSpotVMField(name = "nmethod::_verified_entry_point", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int nmethodEntryOffset; - @HotSpotVMField(name = "nmethod::_comp_level", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int nmethodCompLevelOffset; - - @HotSpotVMConstant(name = "CompLevel_full_optimization") @Stable public int compilationLevelFullOptimization; - - @HotSpotVMConstant(name = "InvocationEntryBci") @Stable public int invocationEntryBci; - - @HotSpotVMField(name = "JVMCIEnv::_task", type = "CompileTask*", get = HotSpotVMField.Type.OFFSET) @Stable public int jvmciEnvTaskOffset; - @HotSpotVMField(name = "JVMCIEnv::_jvmti_can_hotswap_or_post_breakpoint", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int jvmciEnvJvmtiCanHotswapOrPostBreakpointOffset; - @HotSpotVMField(name = "CompileTask::_num_inlined_bytecodes", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int compileTaskNumInlinedBytecodesOffset; - - @HotSpotVMField(name = "CompilerToVM::Data::Method_extra_stack_entries", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int extraStackEntries; - - @HotSpotVMField(name = "ConstMethod::_constants", type = "ConstantPool*", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodConstantsOffset; - @HotSpotVMField(name = "ConstMethod::_flags", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodFlagsOffset; - @HotSpotVMField(name = "ConstMethod::_code_size", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodCodeSizeOffset; - @HotSpotVMField(name = "ConstMethod::_name_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodNameIndexOffset; - @HotSpotVMField(name = "ConstMethod::_signature_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodSignatureIndexOffset; - @HotSpotVMField(name = "ConstMethod::_max_stack", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodMaxStackOffset; - @HotSpotVMField(name = "ConstMethod::_max_locals", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int methodMaxLocalsOffset; - - @HotSpotVMConstant(name = "ConstMethod::_has_linenumber_table") @Stable public int constMethodHasLineNumberTable; - @HotSpotVMConstant(name = "ConstMethod::_has_localvariable_table") @Stable public int constMethodHasLocalVariableTable; - @HotSpotVMConstant(name = "ConstMethod::_has_exception_table") @Stable public int constMethodHasExceptionTable; - - @HotSpotVMType(name = "ExceptionTableElement", get = HotSpotVMType.Type.SIZE) @Stable public int exceptionTableElementSize; - @HotSpotVMField(name = "ExceptionTableElement::start_pc", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int exceptionTableElementStartPcOffset; - @HotSpotVMField(name = "ExceptionTableElement::end_pc", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int exceptionTableElementEndPcOffset; - @HotSpotVMField(name = "ExceptionTableElement::handler_pc", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int exceptionTableElementHandlerPcOffset; - @HotSpotVMField(name = "ExceptionTableElement::catch_type_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int exceptionTableElementCatchTypeIndexOffset; - - @HotSpotVMType(name = "LocalVariableTableElement", get = HotSpotVMType.Type.SIZE) @Stable public int localVariableTableElementSize; - @HotSpotVMField(name = "LocalVariableTableElement::start_bci", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementStartBciOffset; - @HotSpotVMField(name = "LocalVariableTableElement::length", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementLengthOffset; - @HotSpotVMField(name = "LocalVariableTableElement::name_cp_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementNameCpIndexOffset; - @HotSpotVMField(name = "LocalVariableTableElement::descriptor_cp_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementDescriptorCpIndexOffset; - @HotSpotVMField(name = "LocalVariableTableElement::signature_cp_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementSignatureCpIndexOffset; - @HotSpotVMField(name = "LocalVariableTableElement::slot", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementSlotOffset; - - @HotSpotVMType(name = "ConstantPool", get = HotSpotVMType.Type.SIZE) @Stable public int constantPoolSize; - @HotSpotVMField(name = "ConstantPool::_tags", type = "Array*", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolTagsOffset; - @HotSpotVMField(name = "ConstantPool::_pool_holder", type = "InstanceKlass*", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolHolderOffset; - @HotSpotVMField(name = "ConstantPool::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolLengthOffset; - - @HotSpotVMConstant(name = "ConstantPool::CPCACHE_INDEX_TAG") @Stable public int constantPoolCpCacheIndexTag; - - @HotSpotVMConstant(name = "JVM_CONSTANT_Utf8") @Stable public int jvmConstantUtf8; - @HotSpotVMConstant(name = "JVM_CONSTANT_Integer") @Stable public int jvmConstantInteger; - @HotSpotVMConstant(name = "JVM_CONSTANT_Long") @Stable public int jvmConstantLong; - @HotSpotVMConstant(name = "JVM_CONSTANT_Float") @Stable public int jvmConstantFloat; - @HotSpotVMConstant(name = "JVM_CONSTANT_Double") @Stable public int jvmConstantDouble; - @HotSpotVMConstant(name = "JVM_CONSTANT_Class") @Stable public int jvmConstantClass; - @HotSpotVMConstant(name = "JVM_CONSTANT_UnresolvedClass") @Stable public int jvmConstantUnresolvedClass; - @HotSpotVMConstant(name = "JVM_CONSTANT_UnresolvedClassInError") @Stable public int jvmConstantUnresolvedClassInError; - @HotSpotVMConstant(name = "JVM_CONSTANT_String") @Stable public int jvmConstantString; - @HotSpotVMConstant(name = "JVM_CONSTANT_Fieldref") @Stable public int jvmConstantFieldref; - @HotSpotVMConstant(name = "JVM_CONSTANT_Methodref") @Stable public int jvmConstantMethodref; - @HotSpotVMConstant(name = "JVM_CONSTANT_InterfaceMethodref") @Stable public int jvmConstantInterfaceMethodref; - @HotSpotVMConstant(name = "JVM_CONSTANT_NameAndType") @Stable public int jvmConstantNameAndType; - @HotSpotVMConstant(name = "JVM_CONSTANT_MethodHandle") @Stable public int jvmConstantMethodHandle; - @HotSpotVMConstant(name = "JVM_CONSTANT_MethodHandleInError") @Stable public int jvmConstantMethodHandleInError; - @HotSpotVMConstant(name = "JVM_CONSTANT_MethodType") @Stable public int jvmConstantMethodType; - @HotSpotVMConstant(name = "JVM_CONSTANT_MethodTypeInError") @Stable public int jvmConstantMethodTypeInError; - @HotSpotVMConstant(name = "JVM_CONSTANT_InvokeDynamic") @Stable public int jvmConstantInvokeDynamic; - - @HotSpotVMConstant(name = "JVM_CONSTANT_ExternalMax") @Stable public int jvmConstantExternalMax; - @HotSpotVMConstant(name = "JVM_CONSTANT_InternalMin") @Stable public int jvmConstantInternalMin; - @HotSpotVMConstant(name = "JVM_CONSTANT_InternalMax") @Stable public int jvmConstantInternalMax; - - @HotSpotVMConstant(name = "HeapWordSize") @Stable public int heapWordSize; - - @HotSpotVMType(name = "Symbol*", get = HotSpotVMType.Type.SIZE) @Stable public int symbolPointerSize; - - @HotSpotVMField(name = "vmSymbols::_symbols[0]", type = "Symbol*", get = HotSpotVMField.Type.ADDRESS) @Stable public long vmSymbolsSymbols; - @HotSpotVMConstant(name = "vmSymbols::FIRST_SID") @Stable public int vmSymbolsFirstSID; - @HotSpotVMConstant(name = "vmSymbols::SID_LIMIT") @Stable public int vmSymbolsSIDLimit; - - /** - * Bit pattern that represents a non-oop. Neither the high bits nor the low bits of this value - * are allowed to look like (respectively) the high or low bits of a real oop. - */ - @HotSpotVMField(name = "CompilerToVM::Data::Universe_non_oop_bits", type = "void*", get = HotSpotVMField.Type.VALUE) @Stable public long nonOopBits; - - @HotSpotVMField(name = "StubRoutines::_verify_oop_count", type = "jint", get = HotSpotVMField.Type.ADDRESS) @Stable public long verifyOopCounterAddress; - @HotSpotVMField(name = "CompilerToVM::Data::Universe_verify_oop_mask", type = "uintptr_t", get = HotSpotVMField.Type.VALUE) @Stable public long verifyOopMask; - @HotSpotVMField(name = "CompilerToVM::Data::Universe_verify_oop_bits", type = "uintptr_t", get = HotSpotVMField.Type.VALUE) @Stable public long verifyOopBits; - @HotSpotVMField(name = "CompilerToVM::Data::Universe_base_vtable_size", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int universeBaseVtableSize; - - public final int baseVtableLength() { - return universeBaseVtableSize / vtableEntrySize; - } - - @HotSpotVMField(name = "HeapRegion::LogOfHRGrainBytes", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int logOfHRGrainBytes; - - @HotSpotVMConstant(name = "CardTableModRefBS::dirty_card") @Stable public byte dirtyCardValue; - @HotSpotVMConstant(name = "G1SATBCardTableModRefBS::g1_young_gen") @Stable public byte g1YoungCardValue; - - @HotSpotVMField(name = "CompilerToVM::Data::cardtable_start_address", type = "jbyte*", get = HotSpotVMField.Type.VALUE) @Stable private long cardtableStartAddress; - @HotSpotVMField(name = "CompilerToVM::Data::cardtable_shift", type = "int", get = HotSpotVMField.Type.VALUE) @Stable private int cardtableShift; - - public long cardtableStartAddress() { - return cardtableStartAddress; - } - - public int cardtableShift() { - return cardtableShift; - } - - @HotSpotVMField(name = "os::_polling_page", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long safepointPollingAddress; - - // G1 Collector Related Values. - - public int g1CardQueueIndexOffset() { - return javaThreadDirtyCardQueueOffset + dirtyCardQueueIndexOffset; - } - - public int g1CardQueueBufferOffset() { - return javaThreadDirtyCardQueueOffset + dirtyCardQueueBufferOffset; - } - - public int g1SATBQueueMarkingOffset() { - return javaThreadSatbMarkQueueOffset + satbMarkQueueActiveOffset; - } - - public int g1SATBQueueIndexOffset() { - return javaThreadSatbMarkQueueOffset + satbMarkQueueIndexOffset; - } - - public int g1SATBQueueBufferOffset() { - return javaThreadSatbMarkQueueOffset + satbMarkQueueBufferOffset; - } - - @HotSpotVMField(name = "java_lang_Class::_klass_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int klassOffset; - @HotSpotVMField(name = "java_lang_Class::_array_klass_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int arrayKlassOffset; - - @HotSpotVMType(name = "BasicLock", get = HotSpotVMType.Type.SIZE) @Stable public int basicLockSize; - @HotSpotVMField(name = "BasicLock::_displaced_header", type = "markOop", get = HotSpotVMField.Type.OFFSET) @Stable public int basicLockDisplacedHeaderOffset; - - @HotSpotVMField(name = "Thread::_allocated_bytes", type = "jlong", get = HotSpotVMField.Type.OFFSET) @Stable public int threadAllocatedBytesOffset; - - @HotSpotVMFlag(name = "TLABWasteIncrement") @Stable public int tlabRefillWasteIncrement; - - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_start", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferStartOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_end", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferEndOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_top", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferTopOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_pf_top", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferPfTopOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_slow_allocations", type = "unsigned", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferSlowAllocationsOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_fast_refill_waste", type = "unsigned", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferFastRefillWasteOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_number_of_refills", type = "unsigned", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferNumberOfRefillsOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_refill_waste_limit", type = "size_t", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferRefillWasteLimitOffset; - @HotSpotVMField(name = "ThreadLocalAllocBuffer::_desired_size", type = "size_t", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferDesiredSizeOffset; - - public int tlabSlowAllocationsOffset() { - return threadTlabOffset + threadLocalAllocBufferSlowAllocationsOffset; - } - - public int tlabFastRefillWasteOffset() { - return threadTlabOffset + threadLocalAllocBufferFastRefillWasteOffset; - } - - public int tlabNumberOfRefillsOffset() { - return threadTlabOffset + threadLocalAllocBufferNumberOfRefillsOffset; - } - - public int tlabRefillWasteLimitOffset() { - return threadTlabOffset + threadLocalAllocBufferRefillWasteLimitOffset; - } - - public int threadTlabSizeOffset() { - return threadTlabOffset + threadLocalAllocBufferDesiredSizeOffset; - } - - public int threadTlabStartOffset() { - return threadTlabOffset + threadLocalAllocBufferStartOffset; - } - - public int threadTlabEndOffset() { - return threadTlabOffset + threadLocalAllocBufferEndOffset; - } - - public int threadTlabTopOffset() { - return threadTlabOffset + threadLocalAllocBufferTopOffset; - } - - public int threadTlabPfTopOffset() { - return threadTlabOffset + threadLocalAllocBufferPfTopOffset; - } - - @HotSpotVMField(name = "CompilerToVM::Data::ThreadLocalAllocBuffer_alignment_reserve", type = "size_t", get = HotSpotVMField.Type.VALUE) @Stable public int tlabAlignmentReserve; - - @HotSpotVMFlag(name = "TLABStats") @Stable public boolean tlabStats; - - // FIXME This is only temporary until the GC code is changed. - @HotSpotVMField(name = "CompilerToVM::Data::_supports_inline_contig_alloc", type = "bool", get = HotSpotVMField.Type.VALUE) @Stable public boolean inlineContiguousAllocationSupported; - @HotSpotVMField(name = "CompilerToVM::Data::_heap_end_addr", type = "HeapWord**", get = HotSpotVMField.Type.VALUE) @Stable public long heapEndAddress; - @HotSpotVMField(name = "CompilerToVM::Data::_heap_top_addr", type = "HeapWord**", get = HotSpotVMField.Type.VALUE) @Stable public long heapTopAddress; - - /** - * The DataLayout header size is the same as the cell size. - */ - @HotSpotVMConstant(name = "DataLayout::cell_size") @Stable public int dataLayoutHeaderSize; - @HotSpotVMField(name = "DataLayout::_header._struct._tag", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutTagOffset; - @HotSpotVMField(name = "DataLayout::_header._struct._flags", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutFlagsOffset; - @HotSpotVMField(name = "DataLayout::_header._struct._bci", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutBCIOffset; - @HotSpotVMField(name = "DataLayout::_cells[0]", type = "intptr_t", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutCellsOffset; - @HotSpotVMConstant(name = "DataLayout::cell_size") @Stable public int dataLayoutCellSize; - - @HotSpotVMConstant(name = "DataLayout::no_tag") @Stable public int dataLayoutNoTag; - @HotSpotVMConstant(name = "DataLayout::bit_data_tag") @Stable public int dataLayoutBitDataTag; - @HotSpotVMConstant(name = "DataLayout::counter_data_tag") @Stable public int dataLayoutCounterDataTag; - @HotSpotVMConstant(name = "DataLayout::jump_data_tag") @Stable public int dataLayoutJumpDataTag; - @HotSpotVMConstant(name = "DataLayout::receiver_type_data_tag") @Stable public int dataLayoutReceiverTypeDataTag; - @HotSpotVMConstant(name = "DataLayout::virtual_call_data_tag") @Stable public int dataLayoutVirtualCallDataTag; - @HotSpotVMConstant(name = "DataLayout::ret_data_tag") @Stable public int dataLayoutRetDataTag; - @HotSpotVMConstant(name = "DataLayout::branch_data_tag") @Stable public int dataLayoutBranchDataTag; - @HotSpotVMConstant(name = "DataLayout::multi_branch_data_tag") @Stable public int dataLayoutMultiBranchDataTag; - @HotSpotVMConstant(name = "DataLayout::arg_info_data_tag") @Stable public int dataLayoutArgInfoDataTag; - @HotSpotVMConstant(name = "DataLayout::call_type_data_tag") @Stable public int dataLayoutCallTypeDataTag; - @HotSpotVMConstant(name = "DataLayout::virtual_call_type_data_tag") @Stable public int dataLayoutVirtualCallTypeDataTag; - @HotSpotVMConstant(name = "DataLayout::parameters_type_data_tag") @Stable public int dataLayoutParametersTypeDataTag; - @HotSpotVMConstant(name = "DataLayout::speculative_trap_data_tag") @Stable public int dataLayoutSpeculativeTrapDataTag; - - @HotSpotVMFlag(name = "BciProfileWidth") @Stable public int bciProfileWidth; - @HotSpotVMFlag(name = "TypeProfileWidth") @Stable public int typeProfileWidth; - @HotSpotVMFlag(name = "MethodProfileWidth") @Stable public int methodProfileWidth; - - @HotSpotVMField(name = "CompilerToVM::Data::SharedRuntime_ic_miss_stub", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long inlineCacheMissStub; - @HotSpotVMField(name = "CompilerToVM::Data::SharedRuntime_handle_wrong_method_stub", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long handleWrongMethodStub; - - @HotSpotVMField(name = "CompilerToVM::Data::SharedRuntime_deopt_blob_unpack", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long handleDeoptStub; - @HotSpotVMField(name = "CompilerToVM::Data::SharedRuntime_deopt_blob_uncommon_trap", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long uncommonTrapStub; - - @HotSpotVMField(name = "CodeCache::_low_bound", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long codeCacheLowBound; - @HotSpotVMField(name = "CodeCache::_high_bound", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long codeCacheHighBound; - - @HotSpotVMField(name = "StubRoutines::_aescrypt_encryptBlock", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long aescryptEncryptBlockStub; - @HotSpotVMField(name = "StubRoutines::_aescrypt_decryptBlock", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long aescryptDecryptBlockStub; - @HotSpotVMField(name = "StubRoutines::_cipherBlockChaining_encryptAESCrypt", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long cipherBlockChainingEncryptAESCryptStub; - @HotSpotVMField(name = "StubRoutines::_cipherBlockChaining_decryptAESCrypt", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long cipherBlockChainingDecryptAESCryptStub; - @HotSpotVMField(name = "StubRoutines::_updateBytesCRC32", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long updateBytesCRC32Stub; - @HotSpotVMField(name = "StubRoutines::_crc_table_adr", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long crcTableAddress; - - @HotSpotVMField(name = "StubRoutines::_throw_delayed_StackOverflowError_entry", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long throwDelayedStackOverflowErrorEntry; - - @HotSpotVMField(name = "StubRoutines::_jbyte_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jbyteArraycopy; - @HotSpotVMField(name = "StubRoutines::_jshort_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jshortArraycopy; - @HotSpotVMField(name = "StubRoutines::_jint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jintArraycopy; - @HotSpotVMField(name = "StubRoutines::_jlong_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jlongArraycopy; - @HotSpotVMField(name = "StubRoutines::_oop_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopArraycopy; - @HotSpotVMField(name = "StubRoutines::_oop_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopArraycopyUninit; - @HotSpotVMField(name = "StubRoutines::_jbyte_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jbyteDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_jshort_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jshortDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_jint_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jintDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_jlong_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jlongDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_oop_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_oop_disjoint_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopDisjointArraycopyUninit; - @HotSpotVMField(name = "StubRoutines::_arrayof_jbyte_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jbyteAlignedArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_jshort_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jshortAlignedArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_jint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jintAlignedArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_jlong_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jlongAlignedArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_oop_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopAlignedArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_oop_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopAlignedArraycopyUninit; - @HotSpotVMField(name = "StubRoutines::_arrayof_jbyte_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jbyteAlignedDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_jshort_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jshortAlignedDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_jint_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jintAlignedDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_jlong_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jlongAlignedDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_oop_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopAlignedDisjointArraycopy; - @HotSpotVMField(name = "StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopAlignedDisjointArraycopyUninit; - @HotSpotVMField(name = "StubRoutines::_checkcast_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long checkcastArraycopy; - @HotSpotVMField(name = "StubRoutines::_checkcast_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long checkcastArraycopyUninit; - @HotSpotVMField(name = "StubRoutines::_unsafe_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long unsafeArraycopy; - @HotSpotVMField(name = "StubRoutines::_generic_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long genericArraycopy; - - @HotSpotVMAddress(name = "JVMCIRuntime::new_instance") @Stable public long newInstanceAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::new_array") @Stable public long newArrayAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::new_multi_array") @Stable public long newMultiArrayAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::dynamic_new_array") @Stable public long dynamicNewArrayAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::dynamic_new_instance") @Stable public long dynamicNewInstanceAddress; - - @HotSpotVMAddress(name = "JVMCIRuntime::thread_is_interrupted") @Stable public long threadIsInterruptedAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::vm_message") @Stable public long vmMessageAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::identity_hash_code") @Stable public long identityHashCodeAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::exception_handler_for_pc") @Stable public long exceptionHandlerForPcAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::monitorenter") @Stable public long monitorenterAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::monitorexit") @Stable public long monitorexitAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::throw_and_post_jvmti_exception") @Stable public long throwAndPostJvmtiExceptionAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::throw_klass_external_name_exception") @Stable public long throwKlassExternalNameExceptionAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::throw_class_cast_exception") @Stable public long throwClassCastExceptionAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::log_primitive") @Stable public long logPrimitiveAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::log_object") @Stable public long logObjectAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::log_printf") @Stable public long logPrintfAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::vm_error") @Stable public long vmErrorAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::load_and_clear_exception") @Stable public long loadAndClearExceptionAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::write_barrier_pre") @Stable public long writeBarrierPreAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::write_barrier_post") @Stable public long writeBarrierPostAddress; - @HotSpotVMAddress(name = "JVMCIRuntime::validate_object") @Stable public long validateObject; - - @HotSpotVMAddress(name = "JVMCIRuntime::test_deoptimize_call_int") @Stable public long testDeoptimizeCallInt; - - @HotSpotVMAddress(name = "SharedRuntime::register_finalizer") @Stable public long registerFinalizerAddress; - @HotSpotVMAddress(name = "SharedRuntime::exception_handler_for_return_address") @Stable public long exceptionHandlerForReturnAddressAddress; - @HotSpotVMAddress(name = "SharedRuntime::OSR_migration_end") @Stable public long osrMigrationEndAddress; - @HotSpotVMAddress(name = "SharedRuntime::enable_stack_reserved_zone") @Stable public long enableStackReservedZoneAddress; - - @HotSpotVMAddress(name = "os::javaTimeMillis") @Stable public long javaTimeMillisAddress; - @HotSpotVMAddress(name = "os::javaTimeNanos") @Stable public long javaTimeNanosAddress; - @HotSpotVMAddress(name = "SharedRuntime::dsin") @Stable public long arithmeticSinAddress; - @HotSpotVMAddress(name = "SharedRuntime::dcos") @Stable public long arithmeticCosAddress; - @HotSpotVMAddress(name = "SharedRuntime::dtan") @Stable public long arithmeticTanAddress; - @HotSpotVMAddress(name = "SharedRuntime::dexp") @Stable public long arithmeticExpAddress; - @HotSpotVMAddress(name = "SharedRuntime::dlog") @Stable public long arithmeticLogAddress; - @HotSpotVMAddress(name = "SharedRuntime::dlog10") @Stable public long arithmeticLog10Address; - @HotSpotVMAddress(name = "SharedRuntime::dpow") @Stable public long arithmeticPowAddress; - - @HotSpotVMFlag(name = "JVMCICounterSize") @Stable public int jvmciCountersSize; - - @HotSpotVMAddress(name = "Deoptimization::fetch_unroll_info") @Stable public long deoptimizationFetchUnrollInfo; - @HotSpotVMAddress(name = "Deoptimization::uncommon_trap") @Stable public long deoptimizationUncommonTrap; - @HotSpotVMAddress(name = "Deoptimization::unpack_frames") @Stable public long deoptimizationUnpackFrames; - - @HotSpotVMConstant(name = "Deoptimization::Reason_none") @Stable public int deoptReasonNone; - @HotSpotVMConstant(name = "Deoptimization::Reason_null_check") @Stable public int deoptReasonNullCheck; - @HotSpotVMConstant(name = "Deoptimization::Reason_range_check") @Stable public int deoptReasonRangeCheck; - @HotSpotVMConstant(name = "Deoptimization::Reason_class_check") @Stable public int deoptReasonClassCheck; - @HotSpotVMConstant(name = "Deoptimization::Reason_array_check") @Stable public int deoptReasonArrayCheck; - @HotSpotVMConstant(name = "Deoptimization::Reason_unreached0") @Stable public int deoptReasonUnreached0; - @HotSpotVMConstant(name = "Deoptimization::Reason_type_checked_inlining") @Stable public int deoptReasonTypeCheckInlining; - @HotSpotVMConstant(name = "Deoptimization::Reason_optimized_type_check") @Stable public int deoptReasonOptimizedTypeCheck; - @HotSpotVMConstant(name = "Deoptimization::Reason_not_compiled_exception_handler") @Stable public int deoptReasonNotCompiledExceptionHandler; - @HotSpotVMConstant(name = "Deoptimization::Reason_unresolved") @Stable public int deoptReasonUnresolved; - @HotSpotVMConstant(name = "Deoptimization::Reason_jsr_mismatch") @Stable public int deoptReasonJsrMismatch; - @HotSpotVMConstant(name = "Deoptimization::Reason_div0_check") @Stable public int deoptReasonDiv0Check; - @HotSpotVMConstant(name = "Deoptimization::Reason_constraint") @Stable public int deoptReasonConstraint; - @HotSpotVMConstant(name = "Deoptimization::Reason_loop_limit_check") @Stable public int deoptReasonLoopLimitCheck; - @HotSpotVMConstant(name = "Deoptimization::Reason_aliasing") @Stable public int deoptReasonAliasing; - @HotSpotVMConstant(name = "Deoptimization::Reason_transfer_to_interpreter") @Stable public int deoptReasonTransferToInterpreter; - @HotSpotVMConstant(name = "Deoptimization::Reason_LIMIT") @Stable public int deoptReasonOSROffset; - - @HotSpotVMConstant(name = "Deoptimization::Action_none") @Stable public int deoptActionNone; - @HotSpotVMConstant(name = "Deoptimization::Action_maybe_recompile") @Stable public int deoptActionMaybeRecompile; - @HotSpotVMConstant(name = "Deoptimization::Action_reinterpret") @Stable public int deoptActionReinterpret; - @HotSpotVMConstant(name = "Deoptimization::Action_make_not_entrant") @Stable public int deoptActionMakeNotEntrant; - @HotSpotVMConstant(name = "Deoptimization::Action_make_not_compilable") @Stable public int deoptActionMakeNotCompilable; - - @HotSpotVMConstant(name = "Deoptimization::_action_bits") @Stable public int deoptimizationActionBits; - @HotSpotVMConstant(name = "Deoptimization::_reason_bits") @Stable public int deoptimizationReasonBits; - @HotSpotVMConstant(name = "Deoptimization::_debug_id_bits") @Stable public int deoptimizationDebugIdBits; - @HotSpotVMConstant(name = "Deoptimization::_action_shift") @Stable public int deoptimizationActionShift; - @HotSpotVMConstant(name = "Deoptimization::_reason_shift") @Stable public int deoptimizationReasonShift; - @HotSpotVMConstant(name = "Deoptimization::_debug_id_shift") @Stable public int deoptimizationDebugIdShift; - - @HotSpotVMConstant(name = "Deoptimization::Unpack_deopt") @Stable public int deoptimizationUnpackDeopt; - @HotSpotVMConstant(name = "Deoptimization::Unpack_exception") @Stable public int deoptimizationUnpackException; - @HotSpotVMConstant(name = "Deoptimization::Unpack_uncommon_trap") @Stable public int deoptimizationUnpackUncommonTrap; - @HotSpotVMConstant(name = "Deoptimization::Unpack_reexecute") @Stable public int deoptimizationUnpackReexecute; - - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_size_of_deoptimized_frame", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockSizeOfDeoptimizedFrameOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_caller_adjustment", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockCallerAdjustmentOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_number_of_frames", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockNumberOfFramesOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_total_frame_sizes", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockTotalFrameSizesOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_unpack_kind", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockUnpackKindOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_frame_sizes", type = "intptr_t*", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockFrameSizesOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_frame_pcs", type = "address*", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockFramePcsOffset; - @HotSpotVMField(name = "Deoptimization::UnrollBlock::_initial_info", type = "intptr_t", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockInitialInfoOffset; - - @HotSpotVMConstant(name = "vmIntrinsics::_invokeBasic") @Stable public int vmIntrinsicInvokeBasic; - @HotSpotVMConstant(name = "vmIntrinsics::_linkToVirtual") @Stable public int vmIntrinsicLinkToVirtual; - @HotSpotVMConstant(name = "vmIntrinsics::_linkToStatic") @Stable public int vmIntrinsicLinkToStatic; - @HotSpotVMConstant(name = "vmIntrinsics::_linkToSpecial") @Stable public int vmIntrinsicLinkToSpecial; - @HotSpotVMConstant(name = "vmIntrinsics::_linkToInterface") @Stable public int vmIntrinsicLinkToInterface; - - @HotSpotVMConstant(name = "JVMCIEnv::ok") @Stable public int codeInstallResultOk; - @HotSpotVMConstant(name = "JVMCIEnv::dependencies_failed") @Stable public int codeInstallResultDependenciesFailed; - @HotSpotVMConstant(name = "JVMCIEnv::dependencies_invalid") @Stable public int codeInstallResultDependenciesInvalid; - @HotSpotVMConstant(name = "JVMCIEnv::cache_full") @Stable public int codeInstallResultCacheFull; - @HotSpotVMConstant(name = "JVMCIEnv::code_too_large") @Stable public int codeInstallResultCodeTooLarge; - - public String getCodeInstallResultDescription(int codeInstallResult) { - if (codeInstallResult == codeInstallResultOk) { - return "ok"; - } - if (codeInstallResult == codeInstallResultDependenciesFailed) { - return "dependencies failed"; - } - if (codeInstallResult == codeInstallResultDependenciesInvalid) { - return "dependencies invalid"; - } - if (codeInstallResult == codeInstallResultCacheFull) { - return "code cache is full"; - } - if (codeInstallResult == codeInstallResultCodeTooLarge) { - return "code is too large"; - } - assert false : codeInstallResult; - return "unknown"; - } - - // Checkstyle: stop - @HotSpotVMConstant(name = "CodeInstaller::VERIFIED_ENTRY") @Stable public int MARKID_VERIFIED_ENTRY; - @HotSpotVMConstant(name = "CodeInstaller::UNVERIFIED_ENTRY") @Stable public int MARKID_UNVERIFIED_ENTRY; - @HotSpotVMConstant(name = "CodeInstaller::OSR_ENTRY") @Stable public int MARKID_OSR_ENTRY; - @HotSpotVMConstant(name = "CodeInstaller::EXCEPTION_HANDLER_ENTRY") @Stable public int MARKID_EXCEPTION_HANDLER_ENTRY; - @HotSpotVMConstant(name = "CodeInstaller::DEOPT_HANDLER_ENTRY") @Stable public int MARKID_DEOPT_HANDLER_ENTRY; - @HotSpotVMConstant(name = "CodeInstaller::INVOKEINTERFACE") @Stable public int MARKID_INVOKEINTERFACE; - @HotSpotVMConstant(name = "CodeInstaller::INVOKEVIRTUAL") @Stable public int MARKID_INVOKEVIRTUAL; - @HotSpotVMConstant(name = "CodeInstaller::INVOKESTATIC") @Stable public int MARKID_INVOKESTATIC; - @HotSpotVMConstant(name = "CodeInstaller::INVOKESPECIAL") @Stable public int MARKID_INVOKESPECIAL; - @HotSpotVMConstant(name = "CodeInstaller::INLINE_INVOKE") @Stable public int MARKID_INLINE_INVOKE; - @HotSpotVMConstant(name = "CodeInstaller::POLL_NEAR") @Stable public int MARKID_POLL_NEAR; - @HotSpotVMConstant(name = "CodeInstaller::POLL_RETURN_NEAR") @Stable public int MARKID_POLL_RETURN_NEAR; - @HotSpotVMConstant(name = "CodeInstaller::POLL_FAR") @Stable public int MARKID_POLL_FAR; - @HotSpotVMConstant(name = "CodeInstaller::POLL_RETURN_FAR") @Stable public int MARKID_POLL_RETURN_FAR; - @HotSpotVMConstant(name = "CodeInstaller::CARD_TABLE_SHIFT") @Stable public int MARKID_CARD_TABLE_SHIFT; - @HotSpotVMConstant(name = "CodeInstaller::CARD_TABLE_ADDRESS") @Stable public int MARKID_CARD_TABLE_ADDRESS; - @HotSpotVMConstant(name = "CodeInstaller::HEAP_TOP_ADDRESS") @Stable public int MARKID_HEAP_TOP_ADDRESS; - @HotSpotVMConstant(name = "CodeInstaller::HEAP_END_ADDRESS") @Stable public int MARKID_HEAP_END_ADDRESS; - @HotSpotVMConstant(name = "CodeInstaller::NARROW_KLASS_BASE_ADDRESS") @Stable public int MARKID_NARROW_KLASS_BASE_ADDRESS; - @HotSpotVMConstant(name = "CodeInstaller::CRC_TABLE_ADDRESS") @Stable public int MARKID_CRC_TABLE_ADDRESS; - @HotSpotVMConstant(name = "CodeInstaller::INVOKE_INVALID") @Stable public int MARKID_INVOKE_INVALID; - - @HotSpotVMConstant(name = "BitData::exception_seen_flag") @Stable public int bitDataExceptionSeenFlag; - @HotSpotVMConstant(name = "BitData::null_seen_flag") @Stable public int bitDataNullSeenFlag; - @HotSpotVMConstant(name = "CounterData::count_off") @Stable public int methodDataCountOffset; - @HotSpotVMConstant(name = "JumpData::taken_off_set") @Stable public int jumpDataTakenOffset; - @HotSpotVMConstant(name = "JumpData::displacement_off_set") @Stable public int jumpDataDisplacementOffset; - @HotSpotVMConstant(name = "ReceiverTypeData::nonprofiled_count_off_set") @Stable public int receiverTypeDataNonprofiledCountOffset; - @HotSpotVMConstant(name = "ReceiverTypeData::receiver_type_row_cell_count") @Stable public int receiverTypeDataReceiverTypeRowCellCount; - @HotSpotVMConstant(name = "ReceiverTypeData::receiver0_offset") @Stable public int receiverTypeDataReceiver0Offset; - @HotSpotVMConstant(name = "ReceiverTypeData::count0_offset") @Stable public int receiverTypeDataCount0Offset; - @HotSpotVMConstant(name = "BranchData::not_taken_off_set") @Stable public int branchDataNotTakenOffset; - @HotSpotVMConstant(name = "ArrayData::array_len_off_set") @Stable public int arrayDataArrayLenOffset; - @HotSpotVMConstant(name = "ArrayData::array_start_off_set") @Stable public int arrayDataArrayStartOffset; - @HotSpotVMConstant(name = "MultiBranchData::per_case_cell_count") @Stable public int multiBranchDataPerCaseCellCount; - - // Checkstyle: resume - - private boolean check() { - for (Field f : getClass().getDeclaredFields()) { - int modifiers = f.getModifiers(); - if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers)) { - assert Modifier.isFinal(modifiers) || f.getAnnotation(Stable.class) != null : "field should either be final or @Stable: " + f; - } - } - - assert codeEntryAlignment > 0 : codeEntryAlignment; - assert (layoutHelperArrayTagObjectValue & (1 << (Integer.SIZE - 1))) != 0 : "object array must have first bit set"; - assert (layoutHelperArrayTagTypeValue & (1 << (Integer.SIZE - 1))) != 0 : "type array must have first bit set"; - - return true; - } - - /** - * A compact representation of the different encoding strategies for Objects and metadata. - */ - public static class CompressEncoding { - public final long base; - public final int shift; - public final int alignment; - - CompressEncoding(long base, int shift, int alignment) { - this.base = base; - this.shift = shift; - this.alignment = alignment; - } - - public int compress(long ptr) { - if (ptr == 0L) { - return 0; - } else { - return (int) ((ptr - base) >>> shift); - } - } - - public long uncompress(int ptr) { - if (ptr == 0) { - return 0L; - } else { - return ((ptr & 0xFFFFFFFFL) << shift) + base; - } - } - - @Override - public String toString() { - return "base: " + base + " shift: " + shift + " alignment: " + alignment; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + alignment; - result = prime * result + (int) (base ^ (base >>> 32)); - result = prime * result + shift; - return result; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof CompressEncoding) { - CompressEncoding other = (CompressEncoding) obj; - return alignment == other.alignment && base == other.base && shift == other.shift; - } else { - return false; - } - } - } - -} --- /dev/null 2016-05-04 09:43:51.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java 2016-05-04 09:43:51.000000000 -1000 @@ -0,0 +1,1763 @@ +/* + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.common.UnsafeUtil.readCString; +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; +import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.HashMap; +import java.util.Iterator; + +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.hotspotvmconfig.HotSpotVMAddress; +import jdk.vm.ci.hotspotvmconfig.HotSpotVMConstant; +import jdk.vm.ci.hotspotvmconfig.HotSpotVMData; +import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; +import jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag; +import jdk.vm.ci.hotspotvmconfig.HotSpotVMType; +import jdk.internal.misc.Unsafe; + +//JaCoCo Exclude + +/** + * Used to access native configuration details. + * + * All non-static, public fields in this class are so that they can be compiled as constants. + */ +public class HotSpotVMConfig { + + /** + * Gets the configuration associated with the singleton {@link HotSpotJVMCIRuntime}. + */ + public static HotSpotVMConfig config() { + return runtime().getConfig(); + } + + /** + * Maximum allowed size of allocated area for a frame. + */ + public final int maxFrameSize = 16 * 1024; + + public HotSpotVMConfig(CompilerToVM compilerToVm) { + // Get raw pointer to the array that contains all gHotSpotVM values. + final long gHotSpotVMData = compilerToVm.initializeConfiguration(this); + assert gHotSpotVMData != 0; + + // Make FindBugs happy. + jvmciHotSpotVMStructs = 0; + jvmciHotSpotVMTypes = 0; + jvmciHotSpotVMIntConstants = 0; + jvmciHotSpotVMLongConstants = 0; + jvmciHotSpotVMAddresses = 0; + + // Initialize the gHotSpotVM fields. + for (Field f : HotSpotVMConfig.class.getDeclaredFields()) { + if (f.isAnnotationPresent(HotSpotVMData.class)) { + HotSpotVMData annotation = f.getAnnotation(HotSpotVMData.class); + final int index = annotation.index(); + final long value = UNSAFE.getAddress(gHotSpotVMData + Unsafe.ADDRESS_SIZE * index); + try { + f.setLong(this, value); + } catch (IllegalAccessException e) { + throw new JVMCIError("index " + index, e); + } + } + } + + // Quick sanity check. + assert jvmciHotSpotVMStructs != 0; + assert jvmciHotSpotVMTypes != 0; + assert jvmciHotSpotVMIntConstants != 0; + assert jvmciHotSpotVMLongConstants != 0; + assert jvmciHotSpotVMAddresses != 0; + + initialize(); + + oopEncoding = new CompressEncoding(narrowOopBase, narrowOopShift, logMinObjAlignment()); + klassEncoding = new CompressEncoding(narrowKlassBase, narrowKlassShift, logKlassAlignment); + + assert check(); + assert HotSpotVMConfigVerifier.check(); + } + + @Override + public String toString() { + return getClass().getSimpleName(); + } + + /** + * Initialize fields by reading their values from vmStructs. + */ + private void initialize() { + // Fill the VM fields hash map. + HashMap vmFields = new HashMap<>(); + for (VMFields.Field e : new VMFields(jvmciHotSpotVMStructs)) { + vmFields.put(e.getName(), e); + } + + // Fill the VM types hash map. + HashMap vmTypes = new HashMap<>(); + for (VMTypes.Type e : new VMTypes(jvmciHotSpotVMTypes)) { + vmTypes.put(e.getTypeName(), e); + } + + // Fill the VM constants hash map. + HashMap vmConstants = new HashMap<>(); + for (AbstractConstant e : new VMIntConstants(jvmciHotSpotVMIntConstants)) { + vmConstants.put(e.getName(), e); + } + for (AbstractConstant e : new VMLongConstants(jvmciHotSpotVMLongConstants)) { + vmConstants.put(e.getName(), e); + } + + // Fill the VM addresses hash map. + HashMap vmAddresses = new HashMap<>(); + for (VMAddresses.Address e : new VMAddresses(jvmciHotSpotVMAddresses)) { + vmAddresses.put(e.getName(), e); + } + + // Fill the flags hash map. + HashMap flags = new HashMap<>(); + for (Flags.Flag e : new Flags(vmFields, vmTypes)) { + flags.put(e.getName(), e); + } + + String osName = getHostOSName(); + String osArch = getHostArchitectureName(); + + for (Field f : HotSpotVMConfig.class.getDeclaredFields()) { + if (f.isAnnotationPresent(HotSpotVMField.class)) { + HotSpotVMField annotation = f.getAnnotation(HotSpotVMField.class); + String name = annotation.name(); + String type = annotation.type(); + VMFields.Field entry = vmFields.get(name); + if (entry == null) { + if (!isRequired(osArch, annotation.archs())) { + continue; + } + throw new JVMCIError(f.getName() + ": expected VM field not found: " + name); + } + + // Make sure the native type is still the type we expect. + if (!type.isEmpty()) { + if (!type.equals(entry.getTypeString())) { + throw new JVMCIError(f.getName() + ": compiler expects type " + type + " but VM field " + name + " is of type " + entry.getTypeString()); + } + } + + switch (annotation.get()) { + case OFFSET: + setField(f, entry.getOffset()); + break; + case ADDRESS: + setField(f, entry.getAddress()); + break; + case VALUE: + setField(f, entry.getValue()); + break; + default: + throw new JVMCIError(f.getName() + ": unknown kind: " + annotation.get()); + } + } else if (f.isAnnotationPresent(HotSpotVMType.class)) { + HotSpotVMType annotation = f.getAnnotation(HotSpotVMType.class); + String name = annotation.name(); + VMTypes.Type entry = vmTypes.get(name); + if (entry == null) { + throw new JVMCIError(f.getName() + ": expected VM type not found: " + name); + } + + switch (annotation.get()) { + case SIZE: + setField(f, entry.getSize()); + break; + default: + throw new JVMCIError(f.getName() + ": unknown kind: " + annotation.get()); + } + } else if (f.isAnnotationPresent(HotSpotVMConstant.class)) { + HotSpotVMConstant annotation = f.getAnnotation(HotSpotVMConstant.class); + String name = annotation.name(); + AbstractConstant entry = vmConstants.get(name); + if (entry == null) { + if (!isRequired(osArch, annotation.archs())) { + continue; + } + throw new JVMCIError(f.getName() + ": expected VM constant not found: " + name); + } + setField(f, entry.getValue()); + } else if (f.isAnnotationPresent(HotSpotVMAddress.class)) { + HotSpotVMAddress annotation = f.getAnnotation(HotSpotVMAddress.class); + String name = annotation.name(); + VMAddresses.Address entry = vmAddresses.get(name); + if (entry == null) { + if (!isRequired(osName, annotation.os())) { + continue; + } + throw new JVMCIError(f.getName() + ": expected VM address not found: " + name); + } + setField(f, entry.getValue()); + } else if (f.isAnnotationPresent(HotSpotVMFlag.class)) { + HotSpotVMFlag annotation = f.getAnnotation(HotSpotVMFlag.class); + String name = annotation.name(); + Flags.Flag entry = flags.get(name); + if (entry == null) { + if (annotation.optional() || !isRequired(osArch, annotation.archs())) { + continue; + } + throw new JVMCIError(f.getName() + ": expected VM flag not found: " + name); + + } + setField(f, entry.getValue()); + } + } + } + + private final CompressEncoding oopEncoding; + private final CompressEncoding klassEncoding; + + public CompressEncoding getOopEncoding() { + return oopEncoding; + } + + public CompressEncoding getKlassEncoding() { + return klassEncoding; + } + + private void setField(Field field, Object value) { + try { + Class fieldType = field.getType(); + if (fieldType == boolean.class) { + if (value instanceof String) { + field.setBoolean(this, Boolean.valueOf((String) value)); + } else if (value instanceof Boolean) { + field.setBoolean(this, (boolean) value); + } else if (value instanceof Long) { + field.setBoolean(this, ((long) value) != 0); + } else { + throw new JVMCIError(value.getClass().getSimpleName()); + } + } else if (fieldType == byte.class) { + if (value instanceof Long) { + field.setByte(this, (byte) (long) value); + } else { + throw new JVMCIError(value.getClass().getSimpleName()); + } + } else if (fieldType == int.class) { + if (value instanceof Integer) { + field.setInt(this, (int) value); + } else if (value instanceof Long) { + field.setInt(this, (int) (long) value); + } else { + throw new JVMCIError(value.getClass().getSimpleName()); + } + } else if (fieldType == long.class) { + field.setLong(this, (long) value); + } else { + throw new JVMCIError(field.toString()); + } + } catch (IllegalAccessException e) { + throw new JVMCIError("%s: %s", field, e); + } + } + + /** + * Gets the host operating system name. + */ + private static String getHostOSName() { + String osName = System.getProperty("os.name"); + switch (osName) { + case "Linux": + osName = "linux"; + break; + case "SunOS": + osName = "solaris"; + break; + case "Mac OS X": + osName = "bsd"; + break; + default: + // Of course Windows is different... + if (osName.startsWith("Windows")) { + osName = "windows"; + } else { + throw new JVMCIError("Unexpected OS name: " + osName); + } + } + return osName; + } + + /** + * Gets the host architecture name for the purpose of finding the corresponding + * {@linkplain HotSpotJVMCIBackendFactory backend}. + */ + public String getHostArchitectureName() { + String arch = System.getProperty("os.arch"); + switch (arch) { + case "x86_64": + arch = "amd64"; + break; + case "sparcv9": + arch = "sparc"; + break; + } + return arch; + } + + /** + * Determines if the current specification is included in a given set of specifications. + * + * @param current + * @param specification specifies a set of specifications, e.g. architectures or operating + * systems. A zero length value implies all. + */ + private static boolean isRequired(String current, String[] specification) { + if (specification.length == 0) { + return true; + } + for (String arch : specification) { + if (arch.equals(current)) { + return true; + } + } + return false; + } + + /** + * VMStructEntry (see {@code vmStructs.hpp}). + */ + @HotSpotVMData(index = 0) @Stable private long jvmciHotSpotVMStructs; + @HotSpotVMData(index = 1) @Stable private long jvmciHotSpotVMStructEntryTypeNameOffset; + @HotSpotVMData(index = 2) @Stable private long jvmciHotSpotVMStructEntryFieldNameOffset; + @HotSpotVMData(index = 3) @Stable private long jvmciHotSpotVMStructEntryTypeStringOffset; + @HotSpotVMData(index = 4) @Stable private long jvmciHotSpotVMStructEntryIsStaticOffset; + @HotSpotVMData(index = 5) @Stable private long jvmciHotSpotVMStructEntryOffsetOffset; + @HotSpotVMData(index = 6) @Stable private long jvmciHotSpotVMStructEntryAddressOffset; + @HotSpotVMData(index = 7) @Stable private long jvmciHotSpotVMStructEntryArrayStride; + + final class VMFields implements Iterable { + + private final long address; + + VMFields(long address) { + this.address = address; + } + + public Iterator iterator() { + return new Iterator() { + + private int index = 0; + + private Field current() { + return new Field(address + jvmciHotSpotVMStructEntryArrayStride * index); + } + + /** + * The last entry is identified by a NULL fieldName. + */ + public boolean hasNext() { + Field entry = current(); + return entry.getFieldName() != null; + } + + public Field next() { + Field entry = current(); + index++; + return entry; + } + }; + } + + final class Field { + + private final long entryAddress; + + Field(long address) { + this.entryAddress = address; + } + + public String getTypeName() { + long typeNameAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMStructEntryTypeNameOffset); + return readCString(UNSAFE, typeNameAddress); + } + + public String getFieldName() { + long fieldNameAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMStructEntryFieldNameOffset); + return readCString(UNSAFE, fieldNameAddress); + } + + public String getTypeString() { + long typeStringAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMStructEntryTypeStringOffset); + return readCString(UNSAFE, typeStringAddress); + } + + public boolean isStatic() { + return UNSAFE.getInt(entryAddress + jvmciHotSpotVMStructEntryIsStaticOffset) != 0; + } + + public long getOffset() { + return UNSAFE.getLong(entryAddress + jvmciHotSpotVMStructEntryOffsetOffset); + } + + public long getAddress() { + return UNSAFE.getAddress(entryAddress + jvmciHotSpotVMStructEntryAddressOffset); + } + + public String getName() { + String typeName = getTypeName(); + String fieldName = getFieldName(); + return typeName + "::" + fieldName; + } + + public long getValue() { + String type = getTypeString(); + switch (type) { + case "bool": + return UNSAFE.getByte(getAddress()); + case "int": + return UNSAFE.getInt(getAddress()); + case "uint64_t": + return UNSAFE.getLong(getAddress()); + case "address": + case "intptr_t": + case "uintptr_t": + case "size_t": + return UNSAFE.getAddress(getAddress()); + default: + // All foo* types are addresses. + if (type.endsWith("*")) { + return UNSAFE.getAddress(getAddress()); + } + throw new JVMCIError(type); + } + } + + @Override + public String toString() { + return String.format("Field[typeName=%s, fieldName=%s, typeString=%s, isStatic=%b, offset=%d, address=0x%x]", getTypeName(), getFieldName(), getTypeString(), isStatic(), getOffset(), + getAddress()); + } + } + } + + /** + * VMTypeEntry (see vmStructs.hpp). + */ + @HotSpotVMData(index = 8) @Stable private long jvmciHotSpotVMTypes; + @HotSpotVMData(index = 9) @Stable private long jvmciHotSpotVMTypeEntryTypeNameOffset; + @HotSpotVMData(index = 10) @Stable private long jvmciHotSpotVMTypeEntrySuperclassNameOffset; + @HotSpotVMData(index = 11) @Stable private long jvmciHotSpotVMTypeEntryIsOopTypeOffset; + @HotSpotVMData(index = 12) @Stable private long jvmciHotSpotVMTypeEntryIsIntegerTypeOffset; + @HotSpotVMData(index = 13) @Stable private long jvmciHotSpotVMTypeEntryIsUnsignedOffset; + @HotSpotVMData(index = 14) @Stable private long jvmciHotSpotVMTypeEntrySizeOffset; + @HotSpotVMData(index = 15) @Stable private long jvmciHotSpotVMTypeEntryArrayStride; + + final class VMTypes implements Iterable { + + private final long address; + + VMTypes(long address) { + this.address = address; + } + + public Iterator iterator() { + return new Iterator() { + + private int index = 0; + + private Type current() { + return new Type(address + jvmciHotSpotVMTypeEntryArrayStride * index); + } + + /** + * The last entry is identified by a NULL type name. + */ + public boolean hasNext() { + Type entry = current(); + return entry.getTypeName() != null; + } + + public Type next() { + Type entry = current(); + index++; + return entry; + } + }; + } + + final class Type { + + private final long entryAddress; + + Type(long address) { + this.entryAddress = address; + } + + public String getTypeName() { + long typeNameAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMTypeEntryTypeNameOffset); + return readCString(UNSAFE, typeNameAddress); + } + + public String getSuperclassName() { + long superclassNameAddress = UNSAFE.getAddress(entryAddress + jvmciHotSpotVMTypeEntrySuperclassNameOffset); + return readCString(UNSAFE, superclassNameAddress); + } + + public boolean isOopType() { + return UNSAFE.getInt(entryAddress + jvmciHotSpotVMTypeEntryIsOopTypeOffset) != 0; + } + + public boolean isIntegerType() { + return UNSAFE.getInt(entryAddress + jvmciHotSpotVMTypeEntryIsIntegerTypeOffset) != 0; + } + + public boolean isUnsigned() { + return UNSAFE.getInt(entryAddress + jvmciHotSpotVMTypeEntryIsUnsignedOffset) != 0; + } + + public long getSize() { + return UNSAFE.getLong(entryAddress + jvmciHotSpotVMTypeEntrySizeOffset); + } + + @Override + public String toString() { + return String.format("Type[typeName=%s, superclassName=%s, isOopType=%b, isIntegerType=%b, isUnsigned=%b, size=%d]", getTypeName(), getSuperclassName(), isOopType(), isIntegerType(), + isUnsigned(), getSize()); + } + } + } + + public abstract class AbstractConstant { + + protected final long address; + protected final long nameOffset; + protected final long valueOffset; + + AbstractConstant(long address, long nameOffset, long valueOffset) { + this.address = address; + this.nameOffset = nameOffset; + this.valueOffset = valueOffset; + } + + public String getName() { + long nameAddress = UNSAFE.getAddress(address + nameOffset); + return readCString(UNSAFE, nameAddress); + } + + public abstract long getValue(); + } + + /** + * VMIntConstantEntry (see vmStructs.hpp). + */ + @HotSpotVMData(index = 16) @Stable private long jvmciHotSpotVMIntConstants; + @HotSpotVMData(index = 17) @Stable private long jvmciHotSpotVMIntConstantEntryNameOffset; + @HotSpotVMData(index = 18) @Stable private long jvmciHotSpotVMIntConstantEntryValueOffset; + @HotSpotVMData(index = 19) @Stable private long jvmciHotSpotVMIntConstantEntryArrayStride; + + final class VMIntConstants implements Iterable { + + private final long address; + + VMIntConstants(long address) { + this.address = address; + } + + public Iterator iterator() { + return new Iterator() { + + private int index = 0; + + private Constant current() { + return new Constant(address + jvmciHotSpotVMIntConstantEntryArrayStride * index); + } + + /** + * The last entry is identified by a NULL name. + */ + public boolean hasNext() { + Constant entry = current(); + return entry.getName() != null; + } + + public Constant next() { + Constant entry = current(); + index++; + return entry; + } + }; + } + + final class Constant extends AbstractConstant { + + Constant(long address) { + super(address, jvmciHotSpotVMIntConstantEntryNameOffset, jvmciHotSpotVMIntConstantEntryValueOffset); + } + + @Override + public long getValue() { + return UNSAFE.getInt(address + valueOffset); + } + + @Override + public String toString() { + return String.format("IntConstant[name=%s, value=%d (0x%x)]", getName(), getValue(), getValue()); + } + } + } + + /** + * VMLongConstantEntry (see vmStructs.hpp). + */ + @HotSpotVMData(index = 20) @Stable private long jvmciHotSpotVMLongConstants; + @HotSpotVMData(index = 21) @Stable private long jvmciHotSpotVMLongConstantEntryNameOffset; + @HotSpotVMData(index = 22) @Stable private long jvmciHotSpotVMLongConstantEntryValueOffset; + @HotSpotVMData(index = 23) @Stable private long jvmciHotSpotVMLongConstantEntryArrayStride; + + final class VMLongConstants implements Iterable { + + private final long address; + + VMLongConstants(long address) { + this.address = address; + } + + public Iterator iterator() { + return new Iterator() { + + private int index = 0; + + private Constant currentEntry() { + return new Constant(address + jvmciHotSpotVMLongConstantEntryArrayStride * index); + } + + /** + * The last entry is identified by a NULL name. + */ + public boolean hasNext() { + Constant entry = currentEntry(); + return entry.getName() != null; + } + + public Constant next() { + Constant entry = currentEntry(); + index++; + return entry; + } + }; + } + + final class Constant extends AbstractConstant { + + Constant(long address) { + super(address, jvmciHotSpotVMLongConstantEntryNameOffset, jvmciHotSpotVMLongConstantEntryValueOffset); + } + + @Override + public long getValue() { + return UNSAFE.getLong(address + valueOffset); + } + + @Override + public String toString() { + return String.format("LongConstant[name=%s, value=%d (0x%x)]", getName(), getValue(), getValue()); + } + } + } + + /** + * VMAddressEntry (see vmStructs.hpp). + */ + @HotSpotVMData(index = 24) @Stable private long jvmciHotSpotVMAddresses; + @HotSpotVMData(index = 25) @Stable private long jvmciHotSpotVMAddressEntryNameOffset; + @HotSpotVMData(index = 26) @Stable private long jvmciHotSpotVMAddressEntryValueOffset; + @HotSpotVMData(index = 27) @Stable private long jvmciHotSpotVMAddressEntryArrayStride; + + final class VMAddresses implements Iterable { + + private final long address; + + VMAddresses(long address) { + this.address = address; + } + + public Iterator iterator() { + return new Iterator() { + + private int index = 0; + + private Address currentEntry() { + return new Address(address + jvmciHotSpotVMAddressEntryArrayStride * index); + } + + /** + * The last entry is identified by a NULL name. + */ + public boolean hasNext() { + Address entry = currentEntry(); + return entry.getName() != null; + } + + public Address next() { + Address entry = currentEntry(); + index++; + return entry; + } + }; + } + + final class Address extends AbstractConstant { + + Address(long address) { + super(address, jvmciHotSpotVMAddressEntryNameOffset, jvmciHotSpotVMAddressEntryValueOffset); + } + + @Override + public long getValue() { + return UNSAFE.getLong(address + valueOffset); + } + + @Override + public String toString() { + return String.format("Address[name=%s, value=%d (0x%x)]", getName(), getValue(), getValue()); + } + } + } + + final class Flags implements Iterable { + + private final long address; + private final long entrySize; + private final long typeOffset; + private final long nameOffset; + private final long addrOffset; + + Flags(HashMap vmStructs, HashMap vmTypes) { + address = vmStructs.get("Flag::flags").getValue(); + entrySize = vmTypes.get("Flag").getSize(); + typeOffset = vmStructs.get("Flag::_type").getOffset(); + nameOffset = vmStructs.get("Flag::_name").getOffset(); + addrOffset = vmStructs.get("Flag::_addr").getOffset(); + + assert vmTypes.get("bool").getSize() == Byte.BYTES; + assert vmTypes.get("intx").getSize() == Long.BYTES; + assert vmTypes.get("uintx").getSize() == Long.BYTES; + } + + public Iterator iterator() { + return new Iterator() { + + private int index = 0; + + private Flag current() { + return new Flag(address + entrySize * index); + } + + /** + * The last entry is identified by a NULL name. + */ + public boolean hasNext() { + Flag entry = current(); + return entry.getName() != null; + } + + public Flag next() { + Flag entry = current(); + index++; + return entry; + } + }; + } + + final class Flag { + + private final long entryAddress; + + Flag(long address) { + this.entryAddress = address; + } + + public String getType() { + long typeAddress = UNSAFE.getAddress(entryAddress + typeOffset); + return readCString(UNSAFE, typeAddress); + } + + public String getName() { + long nameAddress = UNSAFE.getAddress(entryAddress + nameOffset); + return readCString(UNSAFE, nameAddress); + } + + public long getAddr() { + return UNSAFE.getAddress(entryAddress + addrOffset); + } + + public Object getValue() { + switch (getType()) { + case "bool": + return Boolean.valueOf(UNSAFE.getByte(getAddr()) != 0); + case "intx": + case "uintx": + case "uint64_t": + return Long.valueOf(UNSAFE.getLong(getAddr())); + case "double": + return Double.valueOf(UNSAFE.getDouble(getAddr())); + case "ccstr": + case "ccstrlist": + return readCString(UNSAFE, getAddr()); + default: + throw new JVMCIError(getType()); + } + } + + @Override + public String toString() { + return String.format("Flag[type=%s, name=%s, value=%s]", getType(), getName(), getValue()); + } + } + } + + @HotSpotVMConstant(name = "ASSERT") @Stable public boolean cAssertions; + public final boolean windowsOs = System.getProperty("os.name", "").startsWith("Windows"); + public final boolean linuxOs = System.getProperty("os.name", "").startsWith("Linux"); + + @HotSpotVMFlag(name = "CodeEntryAlignment") @Stable public int codeEntryAlignment; + @HotSpotVMFlag(name = "VerifyOops") @Stable public boolean verifyOops; + @HotSpotVMFlag(name = "CITime") @Stable public boolean ciTime; + @HotSpotVMFlag(name = "CITimeEach") @Stable public boolean ciTimeEach; + @HotSpotVMFlag(name = "CompileTheWorldStartAt", optional = true) @Stable public int compileTheWorldStartAt; + @HotSpotVMFlag(name = "CompileTheWorldStopAt", optional = true) @Stable public int compileTheWorldStopAt; + @HotSpotVMFlag(name = "DontCompileHugeMethods") @Stable public boolean dontCompileHugeMethods; + @HotSpotVMFlag(name = "HugeMethodLimit") @Stable public int hugeMethodLimit; + @HotSpotVMFlag(name = "PrintInlining") @Stable public boolean printInlining; + @HotSpotVMFlag(name = "Inline") @Stable public boolean inline; + @HotSpotVMFlag(name = "JVMCIUseFastLocking") @Stable public boolean useFastLocking; + @HotSpotVMFlag(name = "ForceUnreachable") @Stable public boolean forceUnreachable; + @HotSpotVMFlag(name = "CodeCacheSegmentSize") @Stable public int codeSegmentSize; + @HotSpotVMFlag(name = "FoldStableValues") @Stable public boolean foldStableValues; + + @HotSpotVMFlag(name = "UseTLAB") @Stable public boolean useTLAB; + @HotSpotVMFlag(name = "UseBiasedLocking") @Stable public boolean useBiasedLocking; + @HotSpotVMFlag(name = "UsePopCountInstruction") @Stable public boolean usePopCountInstruction; + @HotSpotVMFlag(name = "UseCountLeadingZerosInstruction", archs = {"amd64"}) @Stable public boolean useCountLeadingZerosInstruction; + @HotSpotVMFlag(name = "UseCountTrailingZerosInstruction", archs = {"amd64"}) @Stable public boolean useCountTrailingZerosInstruction; + @HotSpotVMFlag(name = "UseAESIntrinsics") @Stable public boolean useAESIntrinsics; + @HotSpotVMFlag(name = "UseCRC32Intrinsics") @Stable public boolean useCRC32Intrinsics; + @HotSpotVMFlag(name = "UseG1GC") @Stable public boolean useG1GC; + @HotSpotVMFlag(name = "UseConcMarkSweepGC") @Stable public boolean useCMSGC; + + @HotSpotVMFlag(name = "AllocatePrefetchStyle") @Stable public int allocatePrefetchStyle; + @HotSpotVMFlag(name = "AllocatePrefetchInstr") @Stable public int allocatePrefetchInstr; + @HotSpotVMFlag(name = "AllocatePrefetchLines") @Stable public int allocatePrefetchLines; + @HotSpotVMFlag(name = "AllocateInstancePrefetchLines") @Stable public int allocateInstancePrefetchLines; + @HotSpotVMFlag(name = "AllocatePrefetchStepSize") @Stable public int allocatePrefetchStepSize; + @HotSpotVMFlag(name = "AllocatePrefetchDistance") @Stable public int allocatePrefetchDistance; + + @HotSpotVMFlag(name = "FlightRecorder", optional = true) @Stable public boolean flightRecorder; + + @HotSpotVMField(name = "CompilerToVM::Data::Universe_collectedHeap", type = "CollectedHeap*", get = HotSpotVMField.Type.VALUE) @Stable private long universeCollectedHeap; + @HotSpotVMField(name = "CollectedHeap::_total_collections", type = "unsigned int", get = HotSpotVMField.Type.OFFSET) @Stable private int collectedHeapTotalCollectionsOffset; + + public long gcTotalCollectionsAddress() { + return universeCollectedHeap + collectedHeapTotalCollectionsOffset; + } + + @HotSpotVMFlag(name = "ReduceInitialCardMarks") @Stable public boolean useDeferredInitBarriers; + + // Compressed Oops related values. + @HotSpotVMFlag(name = "UseCompressedOops") @Stable public boolean useCompressedOops; + @HotSpotVMFlag(name = "UseCompressedClassPointers") @Stable public boolean useCompressedClassPointers; + + @HotSpotVMField(name = "CompilerToVM::Data::Universe_narrow_oop_base", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long narrowOopBase; + @HotSpotVMField(name = "CompilerToVM::Data::Universe_narrow_oop_shift", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int narrowOopShift; + @HotSpotVMFlag(name = "ObjectAlignmentInBytes") @Stable public int objectAlignment; + + public final int minObjAlignment() { + return objectAlignment / heapWordSize; + } + + public final int logMinObjAlignment() { + return (int) (Math.log(objectAlignment) / Math.log(2)); + } + + @HotSpotVMType(name = "narrowKlass", get = HotSpotVMType.Type.SIZE) @Stable public int narrowKlassSize; + @HotSpotVMField(name = "CompilerToVM::Data::Universe_narrow_klass_base", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long narrowKlassBase; + @HotSpotVMField(name = "CompilerToVM::Data::Universe_narrow_klass_shift", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int narrowKlassShift; + @HotSpotVMConstant(name = "LogKlassAlignmentInBytes") @Stable public int logKlassAlignment; + + // CPU capabilities + @HotSpotVMFlag(name = "UseSSE") @Stable public int useSSE; + @HotSpotVMFlag(name = "UseAVX", archs = {"amd64"}) @Stable public int useAVX; + + @HotSpotVMField(name = "Abstract_VM_Version::_features", type = "uint64_t", get = HotSpotVMField.Type.VALUE) @Stable public long vmVersionFeatures; + + // AMD64 specific values + @HotSpotVMConstant(name = "VM_Version::CPU_CX8", archs = {"amd64"}) @Stable public long amd64CX8; + @HotSpotVMConstant(name = "VM_Version::CPU_CMOV", archs = {"amd64"}) @Stable public long amd64CMOV; + @HotSpotVMConstant(name = "VM_Version::CPU_FXSR", archs = {"amd64"}) @Stable public long amd64FXSR; + @HotSpotVMConstant(name = "VM_Version::CPU_HT", archs = {"amd64"}) @Stable public long amd64HT; + @HotSpotVMConstant(name = "VM_Version::CPU_MMX", archs = {"amd64"}) @Stable public long amd64MMX; + @HotSpotVMConstant(name = "VM_Version::CPU_3DNOW_PREFETCH", archs = {"amd64"}) @Stable public long amd643DNOWPREFETCH; + @HotSpotVMConstant(name = "VM_Version::CPU_SSE", archs = {"amd64"}) @Stable public long amd64SSE; + @HotSpotVMConstant(name = "VM_Version::CPU_SSE2", archs = {"amd64"}) @Stable public long amd64SSE2; + @HotSpotVMConstant(name = "VM_Version::CPU_SSE3", archs = {"amd64"}) @Stable public long amd64SSE3; + @HotSpotVMConstant(name = "VM_Version::CPU_SSSE3", archs = {"amd64"}) @Stable public long amd64SSSE3; + @HotSpotVMConstant(name = "VM_Version::CPU_SSE4A", archs = {"amd64"}) @Stable public long amd64SSE4A; + @HotSpotVMConstant(name = "VM_Version::CPU_SSE4_1", archs = {"amd64"}) @Stable public long amd64SSE41; + @HotSpotVMConstant(name = "VM_Version::CPU_SSE4_2", archs = {"amd64"}) @Stable public long amd64SSE42; + @HotSpotVMConstant(name = "VM_Version::CPU_POPCNT", archs = {"amd64"}) @Stable public long amd64POPCNT; + @HotSpotVMConstant(name = "VM_Version::CPU_LZCNT", archs = {"amd64"}) @Stable public long amd64LZCNT; + @HotSpotVMConstant(name = "VM_Version::CPU_TSC", archs = {"amd64"}) @Stable public long amd64TSC; + @HotSpotVMConstant(name = "VM_Version::CPU_TSCINV", archs = {"amd64"}) @Stable public long amd64TSCINV; + @HotSpotVMConstant(name = "VM_Version::CPU_AVX", archs = {"amd64"}) @Stable public long amd64AVX; + @HotSpotVMConstant(name = "VM_Version::CPU_AVX2", archs = {"amd64"}) @Stable public long amd64AVX2; + @HotSpotVMConstant(name = "VM_Version::CPU_AES", archs = {"amd64"}) @Stable public long amd64AES; + @HotSpotVMConstant(name = "VM_Version::CPU_ERMS", archs = {"amd64"}) @Stable public long amd64ERMS; + @HotSpotVMConstant(name = "VM_Version::CPU_CLMUL", archs = {"amd64"}) @Stable public long amd64CLMUL; + @HotSpotVMConstant(name = "VM_Version::CPU_BMI1", archs = {"amd64"}) @Stable public long amd64BMI1; + @HotSpotVMConstant(name = "VM_Version::CPU_BMI2", archs = {"amd64"}) @Stable public long amd64BMI2; + @HotSpotVMConstant(name = "VM_Version::CPU_RTM", archs = {"amd64"}) @Stable public long amd64RTM; + @HotSpotVMConstant(name = "VM_Version::CPU_ADX", archs = {"amd64"}) @Stable public long amd64ADX; + @HotSpotVMConstant(name = "VM_Version::CPU_AVX512F", archs = {"amd64"}) @Stable public long amd64AVX512F; + @HotSpotVMConstant(name = "VM_Version::CPU_AVX512DQ", archs = {"amd64"}) @Stable public long amd64AVX512DQ; + @HotSpotVMConstant(name = "VM_Version::CPU_AVX512PF", archs = {"amd64"}) @Stable public long amd64AVX512PF; + @HotSpotVMConstant(name = "VM_Version::CPU_AVX512ER", archs = {"amd64"}) @Stable public long amd64AVX512ER; + @HotSpotVMConstant(name = "VM_Version::CPU_AVX512CD", archs = {"amd64"}) @Stable public long amd64AVX512CD; + @HotSpotVMConstant(name = "VM_Version::CPU_AVX512BW", archs = {"amd64"}) @Stable public long amd64AVX512BW; + @HotSpotVMConstant(name = "VM_Version::CPU_AVX512VL", archs = {"amd64"}) @Stable public long amd64AVX512VL; + @HotSpotVMConstant(name = "VM_Version::CPU_SHA", archs = {"amd64"}) @Stable public long amd64SHA; + + // SPARC specific values + @HotSpotVMConstant(name = "VM_Version::vis3_instructions_m", archs = {"sparc"}) @Stable public int sparcVis3Instructions; + @HotSpotVMConstant(name = "VM_Version::vis2_instructions_m", archs = {"sparc"}) @Stable public int sparcVis2Instructions; + @HotSpotVMConstant(name = "VM_Version::vis1_instructions_m", archs = {"sparc"}) @Stable public int sparcVis1Instructions; + @HotSpotVMConstant(name = "VM_Version::cbcond_instructions_m", archs = {"sparc"}) @Stable public int sparcCbcondInstructions; + @HotSpotVMConstant(name = "VM_Version::v8_instructions_m", archs = {"sparc"}) @Stable public int sparcV8Instructions; + @HotSpotVMConstant(name = "VM_Version::hardware_mul32_m", archs = {"sparc"}) @Stable public int sparcHardwareMul32; + @HotSpotVMConstant(name = "VM_Version::hardware_div32_m", archs = {"sparc"}) @Stable public int sparcHardwareDiv32; + @HotSpotVMConstant(name = "VM_Version::hardware_fsmuld_m", archs = {"sparc"}) @Stable public int sparcHardwareFsmuld; + @HotSpotVMConstant(name = "VM_Version::hardware_popc_m", archs = {"sparc"}) @Stable public int sparcHardwarePopc; + @HotSpotVMConstant(name = "VM_Version::v9_instructions_m", archs = {"sparc"}) @Stable public int sparcV9Instructions; + @HotSpotVMConstant(name = "VM_Version::sun4v_m", archs = {"sparc"}) @Stable public int sparcSun4v; + @HotSpotVMConstant(name = "VM_Version::blk_init_instructions_m", archs = {"sparc"}) @Stable public int sparcBlkInitInstructions; + @HotSpotVMConstant(name = "VM_Version::fmaf_instructions_m", archs = {"sparc"}) @Stable public int sparcFmafInstructions; + @HotSpotVMConstant(name = "VM_Version::fmau_instructions_m", archs = {"sparc"}) @Stable public int sparcFmauInstructions; + @HotSpotVMConstant(name = "VM_Version::sparc64_family_m", archs = {"sparc"}) @Stable public int sparcSparc64Family; + @HotSpotVMConstant(name = "VM_Version::M_family_m", archs = {"sparc"}) @Stable public int sparcMFamily; + @HotSpotVMConstant(name = "VM_Version::T_family_m", archs = {"sparc"}) @Stable public int sparcTFamily; + @HotSpotVMConstant(name = "VM_Version::T1_model_m", archs = {"sparc"}) @Stable public int sparcT1Model; + @HotSpotVMConstant(name = "VM_Version::sparc5_instructions_m", archs = {"sparc"}) @Stable public int sparcSparc5Instructions; + @HotSpotVMConstant(name = "VM_Version::aes_instructions_m", archs = {"sparc"}) @Stable public int sparcAesInstructions; + @HotSpotVMConstant(name = "VM_Version::sha1_instruction_m", archs = {"sparc"}) @Stable public int sparcSha1Instruction; + @HotSpotVMConstant(name = "VM_Version::sha256_instruction_m", archs = {"sparc"}) @Stable public int sparcSha256Instruction; + @HotSpotVMConstant(name = "VM_Version::sha512_instruction_m", archs = {"sparc"}) @Stable public int sparcSha512Instruction; + + @HotSpotVMFlag(name = "UseBlockZeroing", archs = {"sparc"}) @Stable public boolean useBlockZeroing; + @HotSpotVMFlag(name = "BlockZeroingLowLimit", archs = {"sparc"}) @Stable public int blockZeroingLowLimit; + + @HotSpotVMFlag(name = "StackShadowPages") @Stable public int stackShadowPages; + @HotSpotVMFlag(name = "StackReservedPages") @Stable public int stackReservedPages; + @HotSpotVMFlag(name = "UseStackBanging") @Stable public boolean useStackBanging; + @HotSpotVMConstant(name = "STACK_BIAS") @Stable public int stackBias; + @HotSpotVMField(name = "CompilerToVM::Data::vm_page_size", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int vmPageSize; + + // offsets, ... + @HotSpotVMField(name = "oopDesc::_mark", type = "markOop", get = HotSpotVMField.Type.OFFSET) @Stable public int markOffset; + @HotSpotVMField(name = "oopDesc::_metadata._klass", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int hubOffset; + + @HotSpotVMField(name = "Klass::_prototype_header", type = "markOop", get = HotSpotVMField.Type.OFFSET) @Stable public int prototypeMarkWordOffset; + @HotSpotVMField(name = "Klass::_subklass", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int subklassOffset; + @HotSpotVMField(name = "Klass::_next_sibling", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int nextSiblingOffset; + @HotSpotVMField(name = "Klass::_super_check_offset", type = "juint", get = HotSpotVMField.Type.OFFSET) @Stable public int superCheckOffsetOffset; + @HotSpotVMField(name = "Klass::_secondary_super_cache", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int secondarySuperCacheOffset; + @HotSpotVMField(name = "Klass::_secondary_supers", type = "Array*", get = HotSpotVMField.Type.OFFSET) @Stable public int secondarySupersOffset; + + /** + * The offset of the _java_mirror field (of type {@link Class}) in a Klass. + */ + @HotSpotVMField(name = "Klass::_java_mirror", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int classMirrorOffset; + + @HotSpotVMField(name = "Klass::_super", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int klassSuperKlassOffset; + @HotSpotVMField(name = "Klass::_modifier_flags", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int klassModifierFlagsOffset; + @HotSpotVMField(name = "Klass::_access_flags", type = "AccessFlags", get = HotSpotVMField.Type.OFFSET) @Stable public int klassAccessFlagsOffset; + @HotSpotVMField(name = "Klass::_layout_helper", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int klassLayoutHelperOffset; + @HotSpotVMField(name = "Klass::_name", type = "Symbol*", get = HotSpotVMField.Type.OFFSET) @Stable public int klassNameOffset; + + @HotSpotVMConstant(name = "Klass::_lh_neutral_value") @Stable public int klassLayoutHelperNeutralValue; + @HotSpotVMConstant(name = "Klass::_lh_instance_slow_path_bit") @Stable public int klassLayoutHelperInstanceSlowPathBit; + @HotSpotVMConstant(name = "Klass::_lh_log2_element_size_shift") @Stable public int layoutHelperLog2ElementSizeShift; + @HotSpotVMConstant(name = "Klass::_lh_log2_element_size_mask") @Stable public int layoutHelperLog2ElementSizeMask; + @HotSpotVMConstant(name = "Klass::_lh_element_type_shift") @Stable public int layoutHelperElementTypeShift; + @HotSpotVMConstant(name = "Klass::_lh_element_type_mask") @Stable public int layoutHelperElementTypeMask; + @HotSpotVMConstant(name = "Klass::_lh_header_size_shift") @Stable public int layoutHelperHeaderSizeShift; + @HotSpotVMConstant(name = "Klass::_lh_header_size_mask") @Stable public int layoutHelperHeaderSizeMask; + @HotSpotVMConstant(name = "Klass::_lh_array_tag_shift") @Stable public int layoutHelperArrayTagShift; + @HotSpotVMConstant(name = "Klass::_lh_array_tag_type_value") @Stable public int layoutHelperArrayTagTypeValue; + @HotSpotVMConstant(name = "Klass::_lh_array_tag_obj_value") @Stable public int layoutHelperArrayTagObjectValue; + + /** + * This filters out the bit that differentiates a type array from an object array. + */ + public int layoutHelperElementTypePrimitiveInPlace() { + return (layoutHelperArrayTagTypeValue & ~layoutHelperArrayTagObjectValue) << layoutHelperArrayTagShift; + } + + /** + * Bit pattern in the klass layout helper that can be used to identify arrays. + */ + public final int arrayKlassLayoutHelperIdentifier = 0x80000000; + + @HotSpotVMType(name = "vtableEntry", get = HotSpotVMType.Type.SIZE) @Stable public int vtableEntrySize; + @HotSpotVMField(name = "vtableEntry::_method", type = "Method*", get = HotSpotVMField.Type.OFFSET) @Stable public int vtableEntryMethodOffset; + + @HotSpotVMType(name = "InstanceKlass", get = HotSpotVMType.Type.SIZE) @Stable public int instanceKlassSize; + @HotSpotVMField(name = "InstanceKlass::_source_file_name_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassSourceFileNameIndexOffset; + @HotSpotVMField(name = "InstanceKlass::_init_state", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassInitStateOffset; + @HotSpotVMField(name = "InstanceKlass::_constants", type = "ConstantPool*", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassConstantsOffset; + @HotSpotVMField(name = "InstanceKlass::_fields", type = "Array*", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassFieldsOffset; + @HotSpotVMField(name = "CompilerToVM::Data::Klass_vtable_start_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int klassVtableStartOffset; + @HotSpotVMField(name = "CompilerToVM::Data::Klass_vtable_length_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int klassVtableLengthOffset; + + @HotSpotVMConstant(name = "InstanceKlass::linked") @Stable public int instanceKlassStateLinked; + @HotSpotVMConstant(name = "InstanceKlass::fully_initialized") @Stable public int instanceKlassStateFullyInitialized; + + @HotSpotVMType(name = "arrayOopDesc", get = HotSpotVMType.Type.SIZE) @Stable public int arrayOopDescSize; + + /** + * The offset of the array length word in an array object's header. + * + * See {@code arrayOopDesc::length_offset_in_bytes()}. + */ + public final int arrayOopDescLengthOffset() { + return useCompressedClassPointers ? hubOffset + narrowKlassSize : arrayOopDescSize; + } + + @HotSpotVMField(name = "Array::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayU1LengthOffset; + @HotSpotVMField(name = "Array::_data", type = "", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayU1DataOffset; + @HotSpotVMField(name = "Array::_data", type = "", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayU2DataOffset; + @HotSpotVMField(name = "Array::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int metaspaceArrayLengthOffset; + @HotSpotVMField(name = "Array::_data[0]", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int metaspaceArrayBaseOffset; + + @HotSpotVMField(name = "ObjArrayKlass::_element_klass", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayClassElementOffset; + + @HotSpotVMConstant(name = "FieldInfo::access_flags_offset") @Stable public int fieldInfoAccessFlagsOffset; + @HotSpotVMConstant(name = "FieldInfo::name_index_offset") @Stable public int fieldInfoNameIndexOffset; + @HotSpotVMConstant(name = "FieldInfo::signature_index_offset") @Stable public int fieldInfoSignatureIndexOffset; + @HotSpotVMConstant(name = "FieldInfo::initval_index_offset") @Stable public int fieldInfoInitvalIndexOffset; + @HotSpotVMConstant(name = "FieldInfo::low_packed_offset") @Stable public int fieldInfoLowPackedOffset; + @HotSpotVMConstant(name = "FieldInfo::high_packed_offset") @Stable public int fieldInfoHighPackedOffset; + @HotSpotVMConstant(name = "FieldInfo::field_slots") @Stable public int fieldInfoFieldSlots; + + @HotSpotVMConstant(name = "FIELDINFO_TAG_SIZE") @Stable public int fieldInfoTagSize; + + @HotSpotVMConstant(name = "JVM_ACC_MONITOR_MATCH") @Stable public int jvmAccMonitorMatch; + @HotSpotVMConstant(name = "JVM_ACC_HAS_MONITOR_BYTECODES") @Stable public int jvmAccHasMonitorBytecodes; + @HotSpotVMConstant(name = "JVM_ACC_HAS_FINALIZER") @Stable public int jvmAccHasFinalizer; + @HotSpotVMConstant(name = "JVM_ACC_FIELD_INTERNAL") @Stable public int jvmAccFieldInternal; + @HotSpotVMConstant(name = "JVM_ACC_FIELD_STABLE") @Stable public int jvmAccFieldStable; + @HotSpotVMConstant(name = "JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE") @Stable public int jvmAccFieldHasGenericSignature; + @HotSpotVMConstant(name = "JVM_ACC_WRITTEN_FLAGS") @Stable public int jvmAccWrittenFlags; + @HotSpotVMConstant(name = "JVM_ACC_IS_CLONEABLE_FAST") @Stable public int jvmAccIsCloneableFast; + + // Modifier.SYNTHETIC is not public so we get it via vmStructs. + @HotSpotVMConstant(name = "JVM_ACC_SYNTHETIC") @Stable public int jvmAccSynthetic; + + /** + * @see HotSpotResolvedObjectTypeImpl#createField + */ + @HotSpotVMConstant(name = "JVM_RECOGNIZED_FIELD_MODIFIERS") @Stable public int recognizedFieldModifiers; + + @HotSpotVMField(name = "Thread::_tlab", type = "ThreadLocalAllocBuffer", get = HotSpotVMField.Type.OFFSET) @Stable public int threadTlabOffset; + + @HotSpotVMField(name = "JavaThread::_anchor", type = "JavaFrameAnchor", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadAnchorOffset; + @HotSpotVMField(name = "JavaThread::_threadObj", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadObjectOffset; + @HotSpotVMField(name = "JavaThread::_osthread", type = "OSThread*", get = HotSpotVMField.Type.OFFSET) @Stable public int osThreadOffset; + @HotSpotVMField(name = "JavaThread::_dirty_card_queue", type = "DirtyCardQueue", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadDirtyCardQueueOffset; + @HotSpotVMField(name = "JavaThread::_is_method_handle_return", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int threadIsMethodHandleReturnOffset; + @HotSpotVMField(name = "JavaThread::_satb_mark_queue", type = "SATBMarkQueue", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadSatbMarkQueueOffset; + @HotSpotVMField(name = "JavaThread::_vm_result", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadObjectResultOffset; + @HotSpotVMField(name = "JavaThread::_jvmci_counters", type = "jlong*", get = HotSpotVMField.Type.OFFSET) @Stable public int jvmciCountersThreadOffset; + @HotSpotVMField(name = "JavaThread::_reserved_stack_activation", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadReservedStackActivationOffset; + + /** + * An invalid value for {@link #rtldDefault}. + */ + public static final long INVALID_RTLD_DEFAULT_HANDLE = 0xDEADFACE; + + /** + * Address of the library lookup routine. The C signature of this routine is: + * + *
+     *     void* (const char *filename, char *ebuf, int ebuflen)
+     * 
+ */ + @HotSpotVMAddress(name = "os::dll_load") @Stable public long dllLoad; + + /** + * Address of the library lookup routine. The C signature of this routine is: + * + *
+     *     void* (void* handle, const char* name)
+     * 
+ */ + @HotSpotVMAddress(name = "os::dll_lookup") @Stable public long dllLookup; + + /** + * A pseudo-handle which when used as the first argument to {@link #dllLookup} means lookup will + * return the first occurrence of the desired symbol using the default library search order. If + * this field is {@value #INVALID_RTLD_DEFAULT_HANDLE}, then this capability is not supported on + * the current platform. + */ + @HotSpotVMAddress(name = "RTLD_DEFAULT", os = {"bsd", "linux"}) @Stable public long rtldDefault = INVALID_RTLD_DEFAULT_HANDLE; + + /** + * This field is used to pass exception objects into and out of the runtime system during + * exception handling for compiled code. + */ + @HotSpotVMField(name = "JavaThread::_exception_oop", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadExceptionOopOffset; + @HotSpotVMField(name = "JavaThread::_exception_pc", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int threadExceptionPcOffset; + @HotSpotVMField(name = "ThreadShadow::_pending_exception", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingExceptionOffset; + + @HotSpotVMField(name = "JavaThread::_pending_deoptimization", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingDeoptimizationOffset; + @HotSpotVMField(name = "JavaThread::_pending_failed_speculation", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingFailedSpeculationOffset; + @HotSpotVMField(name = "JavaThread::_pending_transfer_to_interpreter", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingTransferToInterpreterOffset; + + @HotSpotVMField(name = "JavaFrameAnchor::_last_Java_sp", type = "intptr_t*", get = HotSpotVMField.Type.OFFSET) @Stable private int javaFrameAnchorLastJavaSpOffset; + @HotSpotVMField(name = "JavaFrameAnchor::_last_Java_pc", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable private int javaFrameAnchorLastJavaPcOffset; + @HotSpotVMField(name = "JavaFrameAnchor::_last_Java_fp", type = "intptr_t*", get = HotSpotVMField.Type.OFFSET, archs = {"aarch64, amd64"}) @Stable private int javaFrameAnchorLastJavaFpOffset; + @HotSpotVMField(name = "JavaFrameAnchor::_flags", type = "int", get = HotSpotVMField.Type.OFFSET, archs = {"sparc"}) @Stable private int javaFrameAnchorFlagsOffset; + + public int threadLastJavaSpOffset() { + return javaThreadAnchorOffset + javaFrameAnchorLastJavaSpOffset; + } + + public int threadLastJavaPcOffset() { + return javaThreadAnchorOffset + javaFrameAnchorLastJavaPcOffset; + } + + public int threadLastJavaFpOffset() { + assert getHostArchitectureName().equals("aarch64") || getHostArchitectureName().equals("amd64"); + return javaThreadAnchorOffset + javaFrameAnchorLastJavaFpOffset; + } + + /** + * This value is only valid on SPARC. + */ + public int threadJavaFrameAnchorFlagsOffset() { + // TODO add an assert for SPARC + return javaThreadAnchorOffset + javaFrameAnchorFlagsOffset; + } + + // These are only valid on AMD64. + @HotSpotVMConstant(name = "frame::arg_reg_save_area_bytes", archs = {"amd64"}) @Stable public int runtimeCallStackSize; + @HotSpotVMConstant(name = "frame::interpreter_frame_sender_sp_offset", archs = {"amd64"}) @Stable public int frameInterpreterFrameSenderSpOffset; + @HotSpotVMConstant(name = "frame::interpreter_frame_last_sp_offset", archs = {"amd64"}) @Stable public int frameInterpreterFrameLastSpOffset; + + @HotSpotVMConstant(name = "dirtyCardQueueBufferOffset") @Stable private int dirtyCardQueueBufferOffset; + @HotSpotVMConstant(name = "dirtyCardQueueIndexOffset") @Stable private int dirtyCardQueueIndexOffset; + + @HotSpotVMConstant(name = "satbMarkQueueBufferOffset") @Stable private int satbMarkQueueBufferOffset; + @HotSpotVMConstant(name = "satbMarkQueueIndexOffset") @Stable private int satbMarkQueueIndexOffset; + @HotSpotVMConstant(name = "satbMarkQueueActiveOffset") @Stable private int satbMarkQueueActiveOffset; + + @HotSpotVMField(name = "OSThread::_interrupted", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int osThreadInterruptedOffset; + + @HotSpotVMConstant(name = "markOopDesc::hash_shift") @Stable public long markOopDescHashShift; + + @HotSpotVMConstant(name = "markOopDesc::biased_lock_mask_in_place") @Stable public int biasedLockMaskInPlace; + @HotSpotVMConstant(name = "markOopDesc::age_mask_in_place") @Stable public int ageMaskInPlace; + @HotSpotVMConstant(name = "markOopDesc::epoch_mask_in_place") @Stable public int epochMaskInPlace; + @HotSpotVMConstant(name = "markOopDesc::hash_mask") @Stable public long markOopDescHashMask; + @HotSpotVMConstant(name = "markOopDesc::hash_mask_in_place") @Stable public long markOopDescHashMaskInPlace; + + @HotSpotVMConstant(name = "markOopDesc::unlocked_value") @Stable public int unlockedMask; + @HotSpotVMConstant(name = "markOopDesc::biased_lock_pattern") @Stable public int biasedLockPattern; + + @HotSpotVMConstant(name = "markOopDesc::no_hash_in_place") @Stable public int markWordNoHashInPlace; + @HotSpotVMConstant(name = "markOopDesc::no_lock_in_place") @Stable public int markWordNoLockInPlace; + + /** + * See {@code markOopDesc::prototype()}. + */ + public long arrayPrototypeMarkWord() { + return markWordNoHashInPlace | markWordNoLockInPlace; + } + + /** + * See {@code markOopDesc::copy_set_hash()}. + */ + public long tlabIntArrayMarkWord() { + long tmp = arrayPrototypeMarkWord() & (~markOopDescHashMaskInPlace); + tmp |= ((0x2 & markOopDescHashMask) << markOopDescHashShift); + return tmp; + } + + /** + * Mark word right shift to get identity hash code. + */ + @HotSpotVMConstant(name = "markOopDesc::hash_shift") @Stable public int identityHashCodeShift; + + /** + * Identity hash code value when uninitialized. + */ + @HotSpotVMConstant(name = "markOopDesc::no_hash") @Stable public int uninitializedIdentityHashCodeValue; + + @HotSpotVMField(name = "Method::_access_flags", type = "AccessFlags", get = HotSpotVMField.Type.OFFSET) @Stable public int methodAccessFlagsOffset; + @HotSpotVMField(name = "Method::_constMethod", type = "ConstMethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodConstMethodOffset; + @HotSpotVMField(name = "Method::_intrinsic_id", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int methodIntrinsicIdOffset; + @HotSpotVMField(name = "Method::_flags", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int methodFlagsOffset; + @HotSpotVMField(name = "Method::_vtable_index", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodVtableIndexOffset; + + @HotSpotVMField(name = "Method::_method_counters", type = "MethodCounters*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCountersOffset; + @HotSpotVMField(name = "Method::_method_data", type = "MethodData*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOffset; + @HotSpotVMField(name = "Method::_from_compiled_entry", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCompiledEntryOffset; + @HotSpotVMField(name = "Method::_code", type = "CompiledMethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCodeOffset; + + @HotSpotVMConstant(name = "Method::_jfr_towrite") @Stable public int methodFlagsJfrTowrite; + @HotSpotVMConstant(name = "Method::_caller_sensitive") @Stable public int methodFlagsCallerSensitive; + @HotSpotVMConstant(name = "Method::_force_inline") @Stable public int methodFlagsForceInline; + @HotSpotVMConstant(name = "Method::_dont_inline") @Stable public int methodFlagsDontInline; + @HotSpotVMConstant(name = "Method::_hidden") @Stable public int methodFlagsHidden; + @HotSpotVMConstant(name = "Method::_reserved_stack_access") @Stable public int methodFlagsReservedStackAccess; + @HotSpotVMConstant(name = "Method::nonvirtual_vtable_index") @Stable public int nonvirtualVtableIndex; + @HotSpotVMConstant(name = "Method::invalid_vtable_index") @Stable public int invalidVtableIndex; + + @HotSpotVMField(name = "MethodCounters::_invocation_counter", type = "InvocationCounter", get = HotSpotVMField.Type.OFFSET) @Stable public int invocationCounterOffset; + @HotSpotVMField(name = "MethodCounters::_backedge_counter", type = "InvocationCounter", get = HotSpotVMField.Type.OFFSET) @Stable public int backedgeCounterOffset; + @HotSpotVMConstant(name = "InvocationCounter::count_increment") @Stable public int invocationCounterIncrement; + @HotSpotVMConstant(name = "InvocationCounter::count_shift") @Stable public int invocationCounterShift; + + @HotSpotVMField(name = "MethodData::_size", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataSize; + @HotSpotVMField(name = "MethodData::_data_size", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataDataSize; + @HotSpotVMField(name = "MethodData::_data[0]", type = "intptr_t", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopDataOffset; + @HotSpotVMField(name = "MethodData::_trap_hist._array[0]", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopTrapHistoryOffset; + @HotSpotVMField(name = "MethodData::_jvmci_ir_size", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataIRSizeOffset; + + @HotSpotVMField(name = "nmethod::_verified_entry_point", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int nmethodEntryOffset; + @HotSpotVMField(name = "nmethod::_comp_level", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int nmethodCompLevelOffset; + + @HotSpotVMConstant(name = "CompLevel_full_optimization") @Stable public int compilationLevelFullOptimization; + + @HotSpotVMConstant(name = "InvocationEntryBci") @Stable public int invocationEntryBci; + + @HotSpotVMField(name = "JVMCIEnv::_task", type = "CompileTask*", get = HotSpotVMField.Type.OFFSET) @Stable public int jvmciEnvTaskOffset; + @HotSpotVMField(name = "JVMCIEnv::_jvmti_can_hotswap_or_post_breakpoint", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int jvmciEnvJvmtiCanHotswapOrPostBreakpointOffset; + @HotSpotVMField(name = "CompileTask::_num_inlined_bytecodes", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int compileTaskNumInlinedBytecodesOffset; + + @HotSpotVMField(name = "CompilerToVM::Data::Method_extra_stack_entries", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int extraStackEntries; + + @HotSpotVMField(name = "ConstMethod::_constants", type = "ConstantPool*", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodConstantsOffset; + @HotSpotVMField(name = "ConstMethod::_flags", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodFlagsOffset; + @HotSpotVMField(name = "ConstMethod::_code_size", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodCodeSizeOffset; + @HotSpotVMField(name = "ConstMethod::_name_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodNameIndexOffset; + @HotSpotVMField(name = "ConstMethod::_signature_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodSignatureIndexOffset; + @HotSpotVMField(name = "ConstMethod::_max_stack", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodMaxStackOffset; + @HotSpotVMField(name = "ConstMethod::_max_locals", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int methodMaxLocalsOffset; + + @HotSpotVMConstant(name = "ConstMethod::_has_linenumber_table") @Stable public int constMethodHasLineNumberTable; + @HotSpotVMConstant(name = "ConstMethod::_has_localvariable_table") @Stable public int constMethodHasLocalVariableTable; + @HotSpotVMConstant(name = "ConstMethod::_has_exception_table") @Stable public int constMethodHasExceptionTable; + + @HotSpotVMType(name = "ExceptionTableElement", get = HotSpotVMType.Type.SIZE) @Stable public int exceptionTableElementSize; + @HotSpotVMField(name = "ExceptionTableElement::start_pc", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int exceptionTableElementStartPcOffset; + @HotSpotVMField(name = "ExceptionTableElement::end_pc", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int exceptionTableElementEndPcOffset; + @HotSpotVMField(name = "ExceptionTableElement::handler_pc", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int exceptionTableElementHandlerPcOffset; + @HotSpotVMField(name = "ExceptionTableElement::catch_type_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int exceptionTableElementCatchTypeIndexOffset; + + @HotSpotVMType(name = "LocalVariableTableElement", get = HotSpotVMType.Type.SIZE) @Stable public int localVariableTableElementSize; + @HotSpotVMField(name = "LocalVariableTableElement::start_bci", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementStartBciOffset; + @HotSpotVMField(name = "LocalVariableTableElement::length", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementLengthOffset; + @HotSpotVMField(name = "LocalVariableTableElement::name_cp_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementNameCpIndexOffset; + @HotSpotVMField(name = "LocalVariableTableElement::descriptor_cp_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementDescriptorCpIndexOffset; + @HotSpotVMField(name = "LocalVariableTableElement::signature_cp_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementSignatureCpIndexOffset; + @HotSpotVMField(name = "LocalVariableTableElement::slot", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int localVariableTableElementSlotOffset; + + @HotSpotVMType(name = "ConstantPool", get = HotSpotVMType.Type.SIZE) @Stable public int constantPoolSize; + @HotSpotVMField(name = "ConstantPool::_tags", type = "Array*", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolTagsOffset; + @HotSpotVMField(name = "ConstantPool::_pool_holder", type = "InstanceKlass*", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolHolderOffset; + @HotSpotVMField(name = "ConstantPool::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int constantPoolLengthOffset; + + @HotSpotVMConstant(name = "ConstantPool::CPCACHE_INDEX_TAG") @Stable public int constantPoolCpCacheIndexTag; + + @HotSpotVMConstant(name = "JVM_CONSTANT_Utf8") @Stable public int jvmConstantUtf8; + @HotSpotVMConstant(name = "JVM_CONSTANT_Integer") @Stable public int jvmConstantInteger; + @HotSpotVMConstant(name = "JVM_CONSTANT_Long") @Stable public int jvmConstantLong; + @HotSpotVMConstant(name = "JVM_CONSTANT_Float") @Stable public int jvmConstantFloat; + @HotSpotVMConstant(name = "JVM_CONSTANT_Double") @Stable public int jvmConstantDouble; + @HotSpotVMConstant(name = "JVM_CONSTANT_Class") @Stable public int jvmConstantClass; + @HotSpotVMConstant(name = "JVM_CONSTANT_UnresolvedClass") @Stable public int jvmConstantUnresolvedClass; + @HotSpotVMConstant(name = "JVM_CONSTANT_UnresolvedClassInError") @Stable public int jvmConstantUnresolvedClassInError; + @HotSpotVMConstant(name = "JVM_CONSTANT_String") @Stable public int jvmConstantString; + @HotSpotVMConstant(name = "JVM_CONSTANT_Fieldref") @Stable public int jvmConstantFieldref; + @HotSpotVMConstant(name = "JVM_CONSTANT_Methodref") @Stable public int jvmConstantMethodref; + @HotSpotVMConstant(name = "JVM_CONSTANT_InterfaceMethodref") @Stable public int jvmConstantInterfaceMethodref; + @HotSpotVMConstant(name = "JVM_CONSTANT_NameAndType") @Stable public int jvmConstantNameAndType; + @HotSpotVMConstant(name = "JVM_CONSTANT_MethodHandle") @Stable public int jvmConstantMethodHandle; + @HotSpotVMConstant(name = "JVM_CONSTANT_MethodHandleInError") @Stable public int jvmConstantMethodHandleInError; + @HotSpotVMConstant(name = "JVM_CONSTANT_MethodType") @Stable public int jvmConstantMethodType; + @HotSpotVMConstant(name = "JVM_CONSTANT_MethodTypeInError") @Stable public int jvmConstantMethodTypeInError; + @HotSpotVMConstant(name = "JVM_CONSTANT_InvokeDynamic") @Stable public int jvmConstantInvokeDynamic; + + @HotSpotVMConstant(name = "JVM_CONSTANT_ExternalMax") @Stable public int jvmConstantExternalMax; + @HotSpotVMConstant(name = "JVM_CONSTANT_InternalMin") @Stable public int jvmConstantInternalMin; + @HotSpotVMConstant(name = "JVM_CONSTANT_InternalMax") @Stable public int jvmConstantInternalMax; + + @HotSpotVMConstant(name = "HeapWordSize") @Stable public int heapWordSize; + + @HotSpotVMType(name = "Symbol*", get = HotSpotVMType.Type.SIZE) @Stable public int symbolPointerSize; + + @HotSpotVMField(name = "vmSymbols::_symbols[0]", type = "Symbol*", get = HotSpotVMField.Type.ADDRESS) @Stable public long vmSymbolsSymbols; + @HotSpotVMConstant(name = "vmSymbols::FIRST_SID") @Stable public int vmSymbolsFirstSID; + @HotSpotVMConstant(name = "vmSymbols::SID_LIMIT") @Stable public int vmSymbolsSIDLimit; + + /** + * Bit pattern that represents a non-oop. Neither the high bits nor the low bits of this value + * are allowed to look like (respectively) the high or low bits of a real oop. + */ + @HotSpotVMField(name = "CompilerToVM::Data::Universe_non_oop_bits", type = "void*", get = HotSpotVMField.Type.VALUE) @Stable public long nonOopBits; + + @HotSpotVMField(name = "StubRoutines::_verify_oop_count", type = "jint", get = HotSpotVMField.Type.ADDRESS) @Stable public long verifyOopCounterAddress; + @HotSpotVMField(name = "CompilerToVM::Data::Universe_verify_oop_mask", type = "uintptr_t", get = HotSpotVMField.Type.VALUE) @Stable public long verifyOopMask; + @HotSpotVMField(name = "CompilerToVM::Data::Universe_verify_oop_bits", type = "uintptr_t", get = HotSpotVMField.Type.VALUE) @Stable public long verifyOopBits; + @HotSpotVMField(name = "CompilerToVM::Data::Universe_base_vtable_size", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int universeBaseVtableSize; + + public final int baseVtableLength() { + return universeBaseVtableSize / vtableEntrySize; + } + + @HotSpotVMField(name = "HeapRegion::LogOfHRGrainBytes", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int logOfHRGrainBytes; + + @HotSpotVMConstant(name = "CardTableModRefBS::dirty_card") @Stable public byte dirtyCardValue; + @HotSpotVMConstant(name = "G1SATBCardTableModRefBS::g1_young_gen") @Stable public byte g1YoungCardValue; + + @HotSpotVMField(name = "CompilerToVM::Data::cardtable_start_address", type = "jbyte*", get = HotSpotVMField.Type.VALUE) @Stable private long cardtableStartAddress; + @HotSpotVMField(name = "CompilerToVM::Data::cardtable_shift", type = "int", get = HotSpotVMField.Type.VALUE) @Stable private int cardtableShift; + + public long cardtableStartAddress() { + return cardtableStartAddress; + } + + public int cardtableShift() { + return cardtableShift; + } + + @HotSpotVMField(name = "os::_polling_page", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long safepointPollingAddress; + + // G1 Collector Related Values. + + public int g1CardQueueIndexOffset() { + return javaThreadDirtyCardQueueOffset + dirtyCardQueueIndexOffset; + } + + public int g1CardQueueBufferOffset() { + return javaThreadDirtyCardQueueOffset + dirtyCardQueueBufferOffset; + } + + public int g1SATBQueueMarkingOffset() { + return javaThreadSatbMarkQueueOffset + satbMarkQueueActiveOffset; + } + + public int g1SATBQueueIndexOffset() { + return javaThreadSatbMarkQueueOffset + satbMarkQueueIndexOffset; + } + + public int g1SATBQueueBufferOffset() { + return javaThreadSatbMarkQueueOffset + satbMarkQueueBufferOffset; + } + + @HotSpotVMField(name = "java_lang_Class::_klass_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int klassOffset; + @HotSpotVMField(name = "java_lang_Class::_array_klass_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int arrayKlassOffset; + + @HotSpotVMType(name = "BasicLock", get = HotSpotVMType.Type.SIZE) @Stable public int basicLockSize; + @HotSpotVMField(name = "BasicLock::_displaced_header", type = "markOop", get = HotSpotVMField.Type.OFFSET) @Stable public int basicLockDisplacedHeaderOffset; + + @HotSpotVMField(name = "Thread::_allocated_bytes", type = "jlong", get = HotSpotVMField.Type.OFFSET) @Stable public int threadAllocatedBytesOffset; + + @HotSpotVMFlag(name = "TLABWasteIncrement") @Stable public int tlabRefillWasteIncrement; + + @HotSpotVMField(name = "ThreadLocalAllocBuffer::_start", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferStartOffset; + @HotSpotVMField(name = "ThreadLocalAllocBuffer::_end", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferEndOffset; + @HotSpotVMField(name = "ThreadLocalAllocBuffer::_top", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferTopOffset; + @HotSpotVMField(name = "ThreadLocalAllocBuffer::_pf_top", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferPfTopOffset; + @HotSpotVMField(name = "ThreadLocalAllocBuffer::_slow_allocations", type = "unsigned", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferSlowAllocationsOffset; + @HotSpotVMField(name = "ThreadLocalAllocBuffer::_fast_refill_waste", type = "unsigned", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferFastRefillWasteOffset; + @HotSpotVMField(name = "ThreadLocalAllocBuffer::_number_of_refills", type = "unsigned", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferNumberOfRefillsOffset; + @HotSpotVMField(name = "ThreadLocalAllocBuffer::_refill_waste_limit", type = "size_t", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferRefillWasteLimitOffset; + @HotSpotVMField(name = "ThreadLocalAllocBuffer::_desired_size", type = "size_t", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferDesiredSizeOffset; + + public int tlabSlowAllocationsOffset() { + return threadTlabOffset + threadLocalAllocBufferSlowAllocationsOffset; + } + + public int tlabFastRefillWasteOffset() { + return threadTlabOffset + threadLocalAllocBufferFastRefillWasteOffset; + } + + public int tlabNumberOfRefillsOffset() { + return threadTlabOffset + threadLocalAllocBufferNumberOfRefillsOffset; + } + + public int tlabRefillWasteLimitOffset() { + return threadTlabOffset + threadLocalAllocBufferRefillWasteLimitOffset; + } + + public int threadTlabSizeOffset() { + return threadTlabOffset + threadLocalAllocBufferDesiredSizeOffset; + } + + public int threadTlabStartOffset() { + return threadTlabOffset + threadLocalAllocBufferStartOffset; + } + + public int threadTlabEndOffset() { + return threadTlabOffset + threadLocalAllocBufferEndOffset; + } + + public int threadTlabTopOffset() { + return threadTlabOffset + threadLocalAllocBufferTopOffset; + } + + public int threadTlabPfTopOffset() { + return threadTlabOffset + threadLocalAllocBufferPfTopOffset; + } + + @HotSpotVMField(name = "CompilerToVM::Data::ThreadLocalAllocBuffer_alignment_reserve", type = "size_t", get = HotSpotVMField.Type.VALUE) @Stable public int tlabAlignmentReserve; + + @HotSpotVMFlag(name = "TLABStats") @Stable public boolean tlabStats; + + // FIXME This is only temporary until the GC code is changed. + @HotSpotVMField(name = "CompilerToVM::Data::_supports_inline_contig_alloc", type = "bool", get = HotSpotVMField.Type.VALUE) @Stable public boolean inlineContiguousAllocationSupported; + @HotSpotVMField(name = "CompilerToVM::Data::_heap_end_addr", type = "HeapWord**", get = HotSpotVMField.Type.VALUE) @Stable public long heapEndAddress; + @HotSpotVMField(name = "CompilerToVM::Data::_heap_top_addr", type = "HeapWord**", get = HotSpotVMField.Type.VALUE) @Stable public long heapTopAddress; + + /** + * The DataLayout header size is the same as the cell size. + */ + @HotSpotVMConstant(name = "DataLayout::cell_size") @Stable public int dataLayoutHeaderSize; + @HotSpotVMField(name = "DataLayout::_header._struct._tag", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutTagOffset; + @HotSpotVMField(name = "DataLayout::_header._struct._flags", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutFlagsOffset; + @HotSpotVMField(name = "DataLayout::_header._struct._bci", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutBCIOffset; + @HotSpotVMField(name = "DataLayout::_cells[0]", type = "intptr_t", get = HotSpotVMField.Type.OFFSET) @Stable public int dataLayoutCellsOffset; + @HotSpotVMConstant(name = "DataLayout::cell_size") @Stable public int dataLayoutCellSize; + + @HotSpotVMConstant(name = "DataLayout::no_tag") @Stable public int dataLayoutNoTag; + @HotSpotVMConstant(name = "DataLayout::bit_data_tag") @Stable public int dataLayoutBitDataTag; + @HotSpotVMConstant(name = "DataLayout::counter_data_tag") @Stable public int dataLayoutCounterDataTag; + @HotSpotVMConstant(name = "DataLayout::jump_data_tag") @Stable public int dataLayoutJumpDataTag; + @HotSpotVMConstant(name = "DataLayout::receiver_type_data_tag") @Stable public int dataLayoutReceiverTypeDataTag; + @HotSpotVMConstant(name = "DataLayout::virtual_call_data_tag") @Stable public int dataLayoutVirtualCallDataTag; + @HotSpotVMConstant(name = "DataLayout::ret_data_tag") @Stable public int dataLayoutRetDataTag; + @HotSpotVMConstant(name = "DataLayout::branch_data_tag") @Stable public int dataLayoutBranchDataTag; + @HotSpotVMConstant(name = "DataLayout::multi_branch_data_tag") @Stable public int dataLayoutMultiBranchDataTag; + @HotSpotVMConstant(name = "DataLayout::arg_info_data_tag") @Stable public int dataLayoutArgInfoDataTag; + @HotSpotVMConstant(name = "DataLayout::call_type_data_tag") @Stable public int dataLayoutCallTypeDataTag; + @HotSpotVMConstant(name = "DataLayout::virtual_call_type_data_tag") @Stable public int dataLayoutVirtualCallTypeDataTag; + @HotSpotVMConstant(name = "DataLayout::parameters_type_data_tag") @Stable public int dataLayoutParametersTypeDataTag; + @HotSpotVMConstant(name = "DataLayout::speculative_trap_data_tag") @Stable public int dataLayoutSpeculativeTrapDataTag; + + @HotSpotVMFlag(name = "BciProfileWidth") @Stable public int bciProfileWidth; + @HotSpotVMFlag(name = "TypeProfileWidth") @Stable public int typeProfileWidth; + @HotSpotVMFlag(name = "MethodProfileWidth") @Stable public int methodProfileWidth; + + @HotSpotVMField(name = "CompilerToVM::Data::SharedRuntime_ic_miss_stub", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long inlineCacheMissStub; + @HotSpotVMField(name = "CompilerToVM::Data::SharedRuntime_handle_wrong_method_stub", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long handleWrongMethodStub; + + @HotSpotVMField(name = "CompilerToVM::Data::SharedRuntime_deopt_blob_unpack", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long handleDeoptStub; + @HotSpotVMField(name = "CompilerToVM::Data::SharedRuntime_deopt_blob_uncommon_trap", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long uncommonTrapStub; + + @HotSpotVMField(name = "CodeCache::_low_bound", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long codeCacheLowBound; + @HotSpotVMField(name = "CodeCache::_high_bound", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long codeCacheHighBound; + + @HotSpotVMField(name = "StubRoutines::_aescrypt_encryptBlock", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long aescryptEncryptBlockStub; + @HotSpotVMField(name = "StubRoutines::_aescrypt_decryptBlock", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long aescryptDecryptBlockStub; + @HotSpotVMField(name = "StubRoutines::_cipherBlockChaining_encryptAESCrypt", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long cipherBlockChainingEncryptAESCryptStub; + @HotSpotVMField(name = "StubRoutines::_cipherBlockChaining_decryptAESCrypt", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long cipherBlockChainingDecryptAESCryptStub; + @HotSpotVMField(name = "StubRoutines::_updateBytesCRC32", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long updateBytesCRC32Stub; + @HotSpotVMField(name = "StubRoutines::_crc_table_adr", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long crcTableAddress; + + @HotSpotVMField(name = "StubRoutines::_throw_delayed_StackOverflowError_entry", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long throwDelayedStackOverflowErrorEntry; + + @HotSpotVMField(name = "StubRoutines::_jbyte_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jbyteArraycopy; + @HotSpotVMField(name = "StubRoutines::_jshort_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jshortArraycopy; + @HotSpotVMField(name = "StubRoutines::_jint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jintArraycopy; + @HotSpotVMField(name = "StubRoutines::_jlong_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jlongArraycopy; + @HotSpotVMField(name = "StubRoutines::_oop_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopArraycopy; + @HotSpotVMField(name = "StubRoutines::_oop_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopArraycopyUninit; + @HotSpotVMField(name = "StubRoutines::_jbyte_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jbyteDisjointArraycopy; + @HotSpotVMField(name = "StubRoutines::_jshort_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jshortDisjointArraycopy; + @HotSpotVMField(name = "StubRoutines::_jint_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jintDisjointArraycopy; + @HotSpotVMField(name = "StubRoutines::_jlong_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jlongDisjointArraycopy; + @HotSpotVMField(name = "StubRoutines::_oop_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopDisjointArraycopy; + @HotSpotVMField(name = "StubRoutines::_oop_disjoint_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopDisjointArraycopyUninit; + @HotSpotVMField(name = "StubRoutines::_arrayof_jbyte_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jbyteAlignedArraycopy; + @HotSpotVMField(name = "StubRoutines::_arrayof_jshort_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jshortAlignedArraycopy; + @HotSpotVMField(name = "StubRoutines::_arrayof_jint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jintAlignedArraycopy; + @HotSpotVMField(name = "StubRoutines::_arrayof_jlong_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jlongAlignedArraycopy; + @HotSpotVMField(name = "StubRoutines::_arrayof_oop_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopAlignedArraycopy; + @HotSpotVMField(name = "StubRoutines::_arrayof_oop_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopAlignedArraycopyUninit; + @HotSpotVMField(name = "StubRoutines::_arrayof_jbyte_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jbyteAlignedDisjointArraycopy; + @HotSpotVMField(name = "StubRoutines::_arrayof_jshort_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jshortAlignedDisjointArraycopy; + @HotSpotVMField(name = "StubRoutines::_arrayof_jint_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jintAlignedDisjointArraycopy; + @HotSpotVMField(name = "StubRoutines::_arrayof_jlong_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long jlongAlignedDisjointArraycopy; + @HotSpotVMField(name = "StubRoutines::_arrayof_oop_disjoint_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopAlignedDisjointArraycopy; + @HotSpotVMField(name = "StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long oopAlignedDisjointArraycopyUninit; + @HotSpotVMField(name = "StubRoutines::_checkcast_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long checkcastArraycopy; + @HotSpotVMField(name = "StubRoutines::_checkcast_arraycopy_uninit", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long checkcastArraycopyUninit; + @HotSpotVMField(name = "StubRoutines::_unsafe_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long unsafeArraycopy; + @HotSpotVMField(name = "StubRoutines::_generic_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long genericArraycopy; + + @HotSpotVMAddress(name = "JVMCIRuntime::new_instance") @Stable public long newInstanceAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::new_array") @Stable public long newArrayAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::new_multi_array") @Stable public long newMultiArrayAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::dynamic_new_array") @Stable public long dynamicNewArrayAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::dynamic_new_instance") @Stable public long dynamicNewInstanceAddress; + + @HotSpotVMAddress(name = "JVMCIRuntime::thread_is_interrupted") @Stable public long threadIsInterruptedAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::vm_message") @Stable public long vmMessageAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::identity_hash_code") @Stable public long identityHashCodeAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::exception_handler_for_pc") @Stable public long exceptionHandlerForPcAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::monitorenter") @Stable public long monitorenterAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::monitorexit") @Stable public long monitorexitAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::throw_and_post_jvmti_exception") @Stable public long throwAndPostJvmtiExceptionAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::throw_klass_external_name_exception") @Stable public long throwKlassExternalNameExceptionAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::throw_class_cast_exception") @Stable public long throwClassCastExceptionAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::log_primitive") @Stable public long logPrimitiveAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::log_object") @Stable public long logObjectAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::log_printf") @Stable public long logPrintfAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::vm_error") @Stable public long vmErrorAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::load_and_clear_exception") @Stable public long loadAndClearExceptionAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::write_barrier_pre") @Stable public long writeBarrierPreAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::write_barrier_post") @Stable public long writeBarrierPostAddress; + @HotSpotVMAddress(name = "JVMCIRuntime::validate_object") @Stable public long validateObject; + + @HotSpotVMAddress(name = "JVMCIRuntime::test_deoptimize_call_int") @Stable public long testDeoptimizeCallInt; + + @HotSpotVMAddress(name = "SharedRuntime::register_finalizer") @Stable public long registerFinalizerAddress; + @HotSpotVMAddress(name = "SharedRuntime::exception_handler_for_return_address") @Stable public long exceptionHandlerForReturnAddressAddress; + @HotSpotVMAddress(name = "SharedRuntime::OSR_migration_end") @Stable public long osrMigrationEndAddress; + @HotSpotVMAddress(name = "SharedRuntime::enable_stack_reserved_zone") @Stable public long enableStackReservedZoneAddress; + + @HotSpotVMAddress(name = "os::javaTimeMillis") @Stable public long javaTimeMillisAddress; + @HotSpotVMAddress(name = "os::javaTimeNanos") @Stable public long javaTimeNanosAddress; + @HotSpotVMAddress(name = "SharedRuntime::dsin") @Stable public long arithmeticSinAddress; + @HotSpotVMAddress(name = "SharedRuntime::dcos") @Stable public long arithmeticCosAddress; + @HotSpotVMAddress(name = "SharedRuntime::dtan") @Stable public long arithmeticTanAddress; + @HotSpotVMAddress(name = "SharedRuntime::dexp") @Stable public long arithmeticExpAddress; + @HotSpotVMAddress(name = "SharedRuntime::dlog") @Stable public long arithmeticLogAddress; + @HotSpotVMAddress(name = "SharedRuntime::dlog10") @Stable public long arithmeticLog10Address; + @HotSpotVMAddress(name = "SharedRuntime::dpow") @Stable public long arithmeticPowAddress; + + @HotSpotVMFlag(name = "JVMCICounterSize") @Stable public int jvmciCountersSize; + + @HotSpotVMAddress(name = "Deoptimization::fetch_unroll_info") @Stable public long deoptimizationFetchUnrollInfo; + @HotSpotVMAddress(name = "Deoptimization::uncommon_trap") @Stable public long deoptimizationUncommonTrap; + @HotSpotVMAddress(name = "Deoptimization::unpack_frames") @Stable public long deoptimizationUnpackFrames; + + @HotSpotVMConstant(name = "Deoptimization::Reason_none") @Stable public int deoptReasonNone; + @HotSpotVMConstant(name = "Deoptimization::Reason_null_check") @Stable public int deoptReasonNullCheck; + @HotSpotVMConstant(name = "Deoptimization::Reason_range_check") @Stable public int deoptReasonRangeCheck; + @HotSpotVMConstant(name = "Deoptimization::Reason_class_check") @Stable public int deoptReasonClassCheck; + @HotSpotVMConstant(name = "Deoptimization::Reason_array_check") @Stable public int deoptReasonArrayCheck; + @HotSpotVMConstant(name = "Deoptimization::Reason_unreached0") @Stable public int deoptReasonUnreached0; + @HotSpotVMConstant(name = "Deoptimization::Reason_type_checked_inlining") @Stable public int deoptReasonTypeCheckInlining; + @HotSpotVMConstant(name = "Deoptimization::Reason_optimized_type_check") @Stable public int deoptReasonOptimizedTypeCheck; + @HotSpotVMConstant(name = "Deoptimization::Reason_not_compiled_exception_handler") @Stable public int deoptReasonNotCompiledExceptionHandler; + @HotSpotVMConstant(name = "Deoptimization::Reason_unresolved") @Stable public int deoptReasonUnresolved; + @HotSpotVMConstant(name = "Deoptimization::Reason_jsr_mismatch") @Stable public int deoptReasonJsrMismatch; + @HotSpotVMConstant(name = "Deoptimization::Reason_div0_check") @Stable public int deoptReasonDiv0Check; + @HotSpotVMConstant(name = "Deoptimization::Reason_constraint") @Stable public int deoptReasonConstraint; + @HotSpotVMConstant(name = "Deoptimization::Reason_loop_limit_check") @Stable public int deoptReasonLoopLimitCheck; + @HotSpotVMConstant(name = "Deoptimization::Reason_aliasing") @Stable public int deoptReasonAliasing; + @HotSpotVMConstant(name = "Deoptimization::Reason_transfer_to_interpreter") @Stable public int deoptReasonTransferToInterpreter; + @HotSpotVMConstant(name = "Deoptimization::Reason_LIMIT") @Stable public int deoptReasonOSROffset; + + @HotSpotVMConstant(name = "Deoptimization::Action_none") @Stable public int deoptActionNone; + @HotSpotVMConstant(name = "Deoptimization::Action_maybe_recompile") @Stable public int deoptActionMaybeRecompile; + @HotSpotVMConstant(name = "Deoptimization::Action_reinterpret") @Stable public int deoptActionReinterpret; + @HotSpotVMConstant(name = "Deoptimization::Action_make_not_entrant") @Stable public int deoptActionMakeNotEntrant; + @HotSpotVMConstant(name = "Deoptimization::Action_make_not_compilable") @Stable public int deoptActionMakeNotCompilable; + + @HotSpotVMConstant(name = "Deoptimization::_action_bits") @Stable public int deoptimizationActionBits; + @HotSpotVMConstant(name = "Deoptimization::_reason_bits") @Stable public int deoptimizationReasonBits; + @HotSpotVMConstant(name = "Deoptimization::_debug_id_bits") @Stable public int deoptimizationDebugIdBits; + @HotSpotVMConstant(name = "Deoptimization::_action_shift") @Stable public int deoptimizationActionShift; + @HotSpotVMConstant(name = "Deoptimization::_reason_shift") @Stable public int deoptimizationReasonShift; + @HotSpotVMConstant(name = "Deoptimization::_debug_id_shift") @Stable public int deoptimizationDebugIdShift; + + @HotSpotVMConstant(name = "Deoptimization::Unpack_deopt") @Stable public int deoptimizationUnpackDeopt; + @HotSpotVMConstant(name = "Deoptimization::Unpack_exception") @Stable public int deoptimizationUnpackException; + @HotSpotVMConstant(name = "Deoptimization::Unpack_uncommon_trap") @Stable public int deoptimizationUnpackUncommonTrap; + @HotSpotVMConstant(name = "Deoptimization::Unpack_reexecute") @Stable public int deoptimizationUnpackReexecute; + + @HotSpotVMField(name = "Deoptimization::UnrollBlock::_size_of_deoptimized_frame", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockSizeOfDeoptimizedFrameOffset; + @HotSpotVMField(name = "Deoptimization::UnrollBlock::_caller_adjustment", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockCallerAdjustmentOffset; + @HotSpotVMField(name = "Deoptimization::UnrollBlock::_number_of_frames", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockNumberOfFramesOffset; + @HotSpotVMField(name = "Deoptimization::UnrollBlock::_total_frame_sizes", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockTotalFrameSizesOffset; + @HotSpotVMField(name = "Deoptimization::UnrollBlock::_unpack_kind", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockUnpackKindOffset; + @HotSpotVMField(name = "Deoptimization::UnrollBlock::_frame_sizes", type = "intptr_t*", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockFrameSizesOffset; + @HotSpotVMField(name = "Deoptimization::UnrollBlock::_frame_pcs", type = "address*", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockFramePcsOffset; + @HotSpotVMField(name = "Deoptimization::UnrollBlock::_initial_info", type = "intptr_t", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockInitialInfoOffset; + + @HotSpotVMConstant(name = "vmIntrinsics::_invokeBasic") @Stable public int vmIntrinsicInvokeBasic; + @HotSpotVMConstant(name = "vmIntrinsics::_linkToVirtual") @Stable public int vmIntrinsicLinkToVirtual; + @HotSpotVMConstant(name = "vmIntrinsics::_linkToStatic") @Stable public int vmIntrinsicLinkToStatic; + @HotSpotVMConstant(name = "vmIntrinsics::_linkToSpecial") @Stable public int vmIntrinsicLinkToSpecial; + @HotSpotVMConstant(name = "vmIntrinsics::_linkToInterface") @Stable public int vmIntrinsicLinkToInterface; + + @HotSpotVMConstant(name = "JVMCIEnv::ok") @Stable public int codeInstallResultOk; + @HotSpotVMConstant(name = "JVMCIEnv::dependencies_failed") @Stable public int codeInstallResultDependenciesFailed; + @HotSpotVMConstant(name = "JVMCIEnv::dependencies_invalid") @Stable public int codeInstallResultDependenciesInvalid; + @HotSpotVMConstant(name = "JVMCIEnv::cache_full") @Stable public int codeInstallResultCacheFull; + @HotSpotVMConstant(name = "JVMCIEnv::code_too_large") @Stable public int codeInstallResultCodeTooLarge; + + public String getCodeInstallResultDescription(int codeInstallResult) { + if (codeInstallResult == codeInstallResultOk) { + return "ok"; + } + if (codeInstallResult == codeInstallResultDependenciesFailed) { + return "dependencies failed"; + } + if (codeInstallResult == codeInstallResultDependenciesInvalid) { + return "dependencies invalid"; + } + if (codeInstallResult == codeInstallResultCacheFull) { + return "code cache is full"; + } + if (codeInstallResult == codeInstallResultCodeTooLarge) { + return "code is too large"; + } + assert false : codeInstallResult; + return "unknown"; + } + + // Checkstyle: stop + @HotSpotVMConstant(name = "CodeInstaller::VERIFIED_ENTRY") @Stable public int MARKID_VERIFIED_ENTRY; + @HotSpotVMConstant(name = "CodeInstaller::UNVERIFIED_ENTRY") @Stable public int MARKID_UNVERIFIED_ENTRY; + @HotSpotVMConstant(name = "CodeInstaller::OSR_ENTRY") @Stable public int MARKID_OSR_ENTRY; + @HotSpotVMConstant(name = "CodeInstaller::EXCEPTION_HANDLER_ENTRY") @Stable public int MARKID_EXCEPTION_HANDLER_ENTRY; + @HotSpotVMConstant(name = "CodeInstaller::DEOPT_HANDLER_ENTRY") @Stable public int MARKID_DEOPT_HANDLER_ENTRY; + @HotSpotVMConstant(name = "CodeInstaller::INVOKEINTERFACE") @Stable public int MARKID_INVOKEINTERFACE; + @HotSpotVMConstant(name = "CodeInstaller::INVOKEVIRTUAL") @Stable public int MARKID_INVOKEVIRTUAL; + @HotSpotVMConstant(name = "CodeInstaller::INVOKESTATIC") @Stable public int MARKID_INVOKESTATIC; + @HotSpotVMConstant(name = "CodeInstaller::INVOKESPECIAL") @Stable public int MARKID_INVOKESPECIAL; + @HotSpotVMConstant(name = "CodeInstaller::INLINE_INVOKE") @Stable public int MARKID_INLINE_INVOKE; + @HotSpotVMConstant(name = "CodeInstaller::POLL_NEAR") @Stable public int MARKID_POLL_NEAR; + @HotSpotVMConstant(name = "CodeInstaller::POLL_RETURN_NEAR") @Stable public int MARKID_POLL_RETURN_NEAR; + @HotSpotVMConstant(name = "CodeInstaller::POLL_FAR") @Stable public int MARKID_POLL_FAR; + @HotSpotVMConstant(name = "CodeInstaller::POLL_RETURN_FAR") @Stable public int MARKID_POLL_RETURN_FAR; + @HotSpotVMConstant(name = "CodeInstaller::CARD_TABLE_SHIFT") @Stable public int MARKID_CARD_TABLE_SHIFT; + @HotSpotVMConstant(name = "CodeInstaller::CARD_TABLE_ADDRESS") @Stable public int MARKID_CARD_TABLE_ADDRESS; + @HotSpotVMConstant(name = "CodeInstaller::HEAP_TOP_ADDRESS") @Stable public int MARKID_HEAP_TOP_ADDRESS; + @HotSpotVMConstant(name = "CodeInstaller::HEAP_END_ADDRESS") @Stable public int MARKID_HEAP_END_ADDRESS; + @HotSpotVMConstant(name = "CodeInstaller::NARROW_KLASS_BASE_ADDRESS") @Stable public int MARKID_NARROW_KLASS_BASE_ADDRESS; + @HotSpotVMConstant(name = "CodeInstaller::CRC_TABLE_ADDRESS") @Stable public int MARKID_CRC_TABLE_ADDRESS; + @HotSpotVMConstant(name = "CodeInstaller::INVOKE_INVALID") @Stable public int MARKID_INVOKE_INVALID; + + @HotSpotVMConstant(name = "BitData::exception_seen_flag") @Stable public int bitDataExceptionSeenFlag; + @HotSpotVMConstant(name = "BitData::null_seen_flag") @Stable public int bitDataNullSeenFlag; + @HotSpotVMConstant(name = "CounterData::count_off") @Stable public int methodDataCountOffset; + @HotSpotVMConstant(name = "JumpData::taken_off_set") @Stable public int jumpDataTakenOffset; + @HotSpotVMConstant(name = "JumpData::displacement_off_set") @Stable public int jumpDataDisplacementOffset; + @HotSpotVMConstant(name = "ReceiverTypeData::nonprofiled_count_off_set") @Stable public int receiverTypeDataNonprofiledCountOffset; + @HotSpotVMConstant(name = "ReceiverTypeData::receiver_type_row_cell_count") @Stable public int receiverTypeDataReceiverTypeRowCellCount; + @HotSpotVMConstant(name = "ReceiverTypeData::receiver0_offset") @Stable public int receiverTypeDataReceiver0Offset; + @HotSpotVMConstant(name = "ReceiverTypeData::count0_offset") @Stable public int receiverTypeDataCount0Offset; + @HotSpotVMConstant(name = "BranchData::not_taken_off_set") @Stable public int branchDataNotTakenOffset; + @HotSpotVMConstant(name = "ArrayData::array_len_off_set") @Stable public int arrayDataArrayLenOffset; + @HotSpotVMConstant(name = "ArrayData::array_start_off_set") @Stable public int arrayDataArrayStartOffset; + @HotSpotVMConstant(name = "MultiBranchData::per_case_cell_count") @Stable public int multiBranchDataPerCaseCellCount; + + // Checkstyle: resume + + private boolean check() { + for (Field f : getClass().getDeclaredFields()) { + int modifiers = f.getModifiers(); + if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers)) { + assert Modifier.isFinal(modifiers) || f.getAnnotation(Stable.class) != null : "field should either be final or @Stable: " + f; + } + } + + assert codeEntryAlignment > 0 : codeEntryAlignment; + assert (layoutHelperArrayTagObjectValue & (1 << (Integer.SIZE - 1))) != 0 : "object array must have first bit set"; + assert (layoutHelperArrayTagTypeValue & (1 << (Integer.SIZE - 1))) != 0 : "type array must have first bit set"; + + return true; + } + + /** + * A compact representation of the different encoding strategies for Objects and metadata. + */ + public static class CompressEncoding { + public final long base; + public final int shift; + public final int alignment; + + CompressEncoding(long base, int shift, int alignment) { + this.base = base; + this.shift = shift; + this.alignment = alignment; + } + + public int compress(long ptr) { + if (ptr == 0L) { + return 0; + } else { + return (int) ((ptr - base) >>> shift); + } + } + + public long uncompress(int ptr) { + if (ptr == 0) { + return 0L; + } else { + return ((ptr & 0xFFFFFFFFL) << shift) + base; + } + } + + @Override + public String toString() { + return "base: " + base + " shift: " + shift + " alignment: " + alignment; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + alignment; + result = prime * result + (int) (base ^ (base >>> 32)); + result = prime * result + shift; + return result; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof CompressEncoding) { + CompressEncoding other = (CompressEncoding) obj; + return alignment == other.alignment && base == other.base && shift == other.shift; + } else { + return false; + } + } + } + +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java 2016-05-04 09:43:52.000000000 -1000 +++ /dev/null 2016-05-04 09:43:52.000000000 -1000 @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static java.lang.String.format; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.Objects; - -import jdk.vm.ci.common.JVMCIError; -import jdk.internal.org.objectweb.asm.ClassReader; -import jdk.internal.org.objectweb.asm.ClassVisitor; -import jdk.internal.org.objectweb.asm.Label; -import jdk.internal.org.objectweb.asm.MethodVisitor; -import jdk.internal.org.objectweb.asm.Opcodes; -import jdk.internal.org.objectweb.asm.Type; -import jdk.internal.misc.Unsafe; - -/** - * A {@link ClassVisitor} that verifies {@link HotSpotVMConfig} does not access {@link Unsafe} from - * any of its non-static, non-constructor methods. This ensures that a deserialized - * {@link HotSpotVMConfig} object does not perform any unsafe reads on addresses that are only valid - * in the context in which the object was serialized. Note that this does not catch cases where a - * client uses an address stored in a {@link HotSpotVMConfig} field. - */ -final class HotSpotVMConfigVerifier extends ClassVisitor { - - public static boolean check() { - Class cls = HotSpotVMConfig.class; - String classFilePath = "/" + cls.getName().replace('.', '/') + ".class"; - try { - InputStream classfile = cls.getResourceAsStream(classFilePath); - ClassReader cr = new ClassReader(Objects.requireNonNull(classfile, "Could not find class file for " + cls.getName())); - ClassVisitor cv = new HotSpotVMConfigVerifier(); - cr.accept(cv, 0); - return true; - } catch (IOException e) { - throw new JVMCIError(e); - } - } - - /** - * Source file context for error reporting. - */ - String sourceFile = null; - - /** - * Line number for error reporting. - */ - int lineNo = -1; - - private static Class resolve(String name) { - try { - return Class.forName(name.replace('/', '.')); - } catch (ClassNotFoundException e) { - throw new JVMCIError(e); - } - } - - HotSpotVMConfigVerifier() { - super(Opcodes.ASM5); - } - - @Override - public void visitSource(String source, String debug) { - this.sourceFile = source; - } - - void verify(boolean condition, String message) { - if (!condition) { - error(message); - } - } - - void error(String message) { - String errorMessage = format("%s:%d: %s is not allowed in the context of compilation replay. The unsafe access should be moved into the %s constructor and the result cached in a field", - sourceFile, lineNo, message, HotSpotVMConfig.class.getSimpleName()); - throw new JVMCIError(errorMessage); - - } - - @Override - public MethodVisitor visitMethod(int access, String name, String d, String signature, String[] exceptions) { - if (!Modifier.isStatic(access) && Modifier.isPublic(access) && !name.equals("")) { - return new MethodVisitor(Opcodes.ASM5) { - - @Override - public void visitLineNumber(int line, Label start) { - lineNo = line; - } - - private Executable resolveMethod(String owner, String methodName, String methodDesc) { - Class declaringClass = resolve(owner); - while (declaringClass != null) { - if (methodName.equals("")) { - for (Constructor c : declaringClass.getDeclaredConstructors()) { - if (methodDesc.equals(Type.getConstructorDescriptor(c))) { - return c; - } - } - } else { - Type[] argumentTypes = Type.getArgumentTypes(methodDesc); - for (Method m : declaringClass.getDeclaredMethods()) { - if (m.getName().equals(methodName)) { - if (Arrays.equals(argumentTypes, Type.getArgumentTypes(m))) { - if (Type.getReturnType(methodDesc).equals(Type.getReturnType(m))) { - return m; - } - } - } - } - } - declaringClass = declaringClass.getSuperclass(); - } - throw new NoSuchMethodError(owner + "." + methodName + methodDesc); - } - - /** - * Checks whether a given method is allowed to be called. - */ - private boolean checkInvokeTarget(Executable method) { - if (method.getDeclaringClass().equals(Unsafe.class)) { - return false; - } - return true; - } - - @Override - public void visitMethodInsn(int opcode, String owner, String methodName, String methodDesc, boolean itf) { - Executable callee = resolveMethod(owner, methodName, methodDesc); - verify(checkInvokeTarget(callee), "invocation of " + callee); - } - }; - } else { - return null; - } - } -} --- /dev/null 2016-05-04 09:43:52.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java 2016-05-04 09:43:51.000000000 -1000 @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static java.lang.String.format; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.Executable; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.Objects; + +import jdk.vm.ci.common.JVMCIError; +import jdk.internal.org.objectweb.asm.ClassReader; +import jdk.internal.org.objectweb.asm.ClassVisitor; +import jdk.internal.org.objectweb.asm.Label; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; +import jdk.internal.misc.Unsafe; + +/** + * A {@link ClassVisitor} that verifies {@link HotSpotVMConfig} does not access {@link Unsafe} from + * any of its non-static, non-constructor methods. This ensures that a deserialized + * {@link HotSpotVMConfig} object does not perform any unsafe reads on addresses that are only valid + * in the context in which the object was serialized. Note that this does not catch cases where a + * client uses an address stored in a {@link HotSpotVMConfig} field. + */ +final class HotSpotVMConfigVerifier extends ClassVisitor { + + public static boolean check() { + Class cls = HotSpotVMConfig.class; + String classFilePath = "/" + cls.getName().replace('.', '/') + ".class"; + try { + InputStream classfile = cls.getResourceAsStream(classFilePath); + ClassReader cr = new ClassReader(Objects.requireNonNull(classfile, "Could not find class file for " + cls.getName())); + ClassVisitor cv = new HotSpotVMConfigVerifier(); + cr.accept(cv, 0); + return true; + } catch (IOException e) { + throw new JVMCIError(e); + } + } + + /** + * Source file context for error reporting. + */ + String sourceFile = null; + + /** + * Line number for error reporting. + */ + int lineNo = -1; + + private static Class resolve(String name) { + try { + return Class.forName(name.replace('/', '.')); + } catch (ClassNotFoundException e) { + throw new JVMCIError(e); + } + } + + HotSpotVMConfigVerifier() { + super(Opcodes.ASM5); + } + + @Override + public void visitSource(String source, String debug) { + this.sourceFile = source; + } + + void verify(boolean condition, String message) { + if (!condition) { + error(message); + } + } + + void error(String message) { + String errorMessage = format("%s:%d: %s is not allowed in the context of compilation replay. The unsafe access should be moved into the %s constructor and the result cached in a field", + sourceFile, lineNo, message, HotSpotVMConfig.class.getSimpleName()); + throw new JVMCIError(errorMessage); + + } + + @Override + public MethodVisitor visitMethod(int access, String name, String d, String signature, String[] exceptions) { + if (!Modifier.isStatic(access) && Modifier.isPublic(access) && !name.equals("")) { + return new MethodVisitor(Opcodes.ASM5) { + + @Override + public void visitLineNumber(int line, Label start) { + lineNo = line; + } + + private Executable resolveMethod(String owner, String methodName, String methodDesc) { + Class declaringClass = resolve(owner); + while (declaringClass != null) { + if (methodName.equals("")) { + for (Constructor c : declaringClass.getDeclaredConstructors()) { + if (methodDesc.equals(Type.getConstructorDescriptor(c))) { + return c; + } + } + } else { + Type[] argumentTypes = Type.getArgumentTypes(methodDesc); + for (Method m : declaringClass.getDeclaredMethods()) { + if (m.getName().equals(methodName)) { + if (Arrays.equals(argumentTypes, Type.getArgumentTypes(m))) { + if (Type.getReturnType(methodDesc).equals(Type.getReturnType(m))) { + return m; + } + } + } + } + } + declaringClass = declaringClass.getSuperclass(); + } + throw new NoSuchMethodError(owner + "." + methodName + methodDesc); + } + + /** + * Checks whether a given method is allowed to be called. + */ + private boolean checkInvokeTarget(Executable method) { + if (method.getDeclaringClass().equals(Unsafe.class)) { + return false; + } + return true; + } + + @Override + public void visitMethodInsn(int opcode, String owner, String methodName, String methodDesc, boolean itf) { + Executable callee = resolveMethod(owner, methodName, methodDesc); + verify(checkInvokeTarget(callee), "invocation of " + callee); + } + }; + } else { + return null; + } + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMEventListener.java 2016-05-04 09:43:52.000000000 -1000 +++ /dev/null 2016-05-04 09:43:52.000000000 -1000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.CompiledCode; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.meta.JVMCIMetaAccessContext; -import jdk.vm.ci.meta.ResolvedJavaType; - -public interface HotSpotVMEventListener { - - /** - * Notifies this client that the VM is shutting down. - */ - default void notifyShutdown() { - } - - /** - * Notify on successful install into the code cache. - * - * @param hotSpotCodeCacheProvider - * @param installedCode - * @param compiledCode - */ - default void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) { - } - - /** - * Create a custom {@link JVMCIMetaAccessContext} to be used for managing the lifetime of loaded - * metadata. It a custom one isn't created then the default implementation will be a single - * context with globally shared instances of {@link ResolvedJavaType} that are never released. - * - * @param hotSpotJVMCIRuntime - * @return a custom context or null - */ - default JVMCIMetaAccessContext createMetaAccessContext(HotSpotJVMCIRuntime hotSpotJVMCIRuntime) { - return null; - } -} --- /dev/null 2016-05-04 09:43:52.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMEventListener.java 2016-05-04 09:43:52.000000000 -1000 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.code.CompiledCode; +import jdk.vm.ci.code.InstalledCode; +import jdk.vm.ci.meta.JVMCIMetaAccessContext; +import jdk.vm.ci.meta.ResolvedJavaType; + +public interface HotSpotVMEventListener { + + /** + * Notifies this client that the VM is shutting down. + */ + default void notifyShutdown() { + } + + /** + * Notify on successful install into the code cache. + * + * @param hotSpotCodeCacheProvider + * @param installedCode + * @param compiledCode + */ + default void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) { + } + + /** + * Create a custom {@link JVMCIMetaAccessContext} to be used for managing the lifetime of loaded + * metadata. It a custom one isn't created then the default implementation will be a single + * context with globally shared instances of {@link ResolvedJavaType} that are never released. + * + * @param hotSpotJVMCIRuntime + * @return a custom context or null + */ + default JVMCIMetaAccessContext createMetaAccessContext(HotSpotJVMCIRuntime hotSpotJVMCIRuntime) { + return null; + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVmSymbols.java 2016-05-04 09:43:53.000000000 -1000 +++ /dev/null 2016-05-04 09:43:53.000000000 -1000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; -import jdk.internal.misc.Unsafe; - -/** - * Class to access the C++ {@code vmSymbols} table. - */ -final class HotSpotVmSymbols { - - /** - * Returns the symbol in the {@code vmSymbols} table at position {@code index} as {@link String} - * . - * - * @param index position in the symbol table - * @return the symbol at position id - */ - static String symbolAt(int index) { - HotSpotJVMCIRuntimeProvider runtime = runtime(); - HotSpotVMConfig config = runtime.getConfig(); - assert config.vmSymbolsFirstSID <= index && index < config.vmSymbolsSIDLimit : "index " + index + " is out of bounds"; - assert config.symbolPointerSize == Unsafe.ADDRESS_SIZE : "the following address read is broken"; - return runtime.getCompilerToVM().getSymbol(UNSAFE.getAddress(config.vmSymbolsSymbols + index * config.symbolPointerSize)); - } -} --- /dev/null 2016-05-04 09:43:53.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVmSymbols.java 2016-05-04 09:43:52.000000000 -1000 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; +import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; +import jdk.internal.misc.Unsafe; + +/** + * Class to access the C++ {@code vmSymbols} table. + */ +final class HotSpotVmSymbols { + + /** + * Returns the symbol in the {@code vmSymbols} table at position {@code index} as {@link String} + * . + * + * @param index position in the symbol table + * @return the symbol at position id + */ + static String symbolAt(int index) { + HotSpotJVMCIRuntimeProvider runtime = runtime(); + HotSpotVMConfig config = runtime.getConfig(); + assert config.vmSymbolsFirstSID <= index && index < config.vmSymbolsSIDLimit : "index " + index + " is out of bounds"; + assert config.symbolPointerSize == Unsafe.ADDRESS_SIZE : "the following address read is broken"; + return runtime.getCompilerToVM().getSymbol(UNSAFE.getAddress(config.vmSymbolsSymbols + index * config.symbolPointerSize)); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/MetaspaceWrapperObject.java 2016-05-04 09:43:53.000000000 -1000 +++ /dev/null 2016-05-04 09:43:53.000000000 -1000 @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -/** - * A tag interface indicating that this type is a wrapper around a HotSpot metaspace object. - * - * It would preferable if this were the base class containing the pointer but that would require - * mixins since most of the wrapper types have complex supertype hierarchies. - */ -interface MetaspaceWrapperObject { - - long getMetaspacePointer(); -} --- /dev/null 2016-05-04 09:43:53.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/MetaspaceWrapperObject.java 2016-05-04 09:43:53.000000000 -1000 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +/** + * A tag interface indicating that this type is a wrapper around a HotSpot metaspace object. + * + * It would preferable if this were the base class containing the pointer but that would require + * mixins since most of the wrapper types have complex supertype hierarchies. + */ +interface MetaspaceWrapperObject { + + long getMetaspacePointer(); +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/Stable.java 2016-05-04 09:43:54.000000000 -1000 +++ /dev/null 2016-05-04 09:43:54.000000000 -1000 @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This annotation functions as an alias for the jdk.internal.vm.annotation.Stable annotation within JVMCI - * code. It is specially recognized during class file parsing in the same way as that annotation. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Stable { -} --- /dev/null 2016-05-04 09:43:54.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/Stable.java 2016-05-04 09:43:53.000000000 -1000 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.vm.ci.hotspot; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * This annotation functions as an alias for the jdk.internal.vm.annotation.Stable annotation within JVMCI + * code. It is specially recognized during class file parsing in the same way as that annotation. + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Stable { +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java 2016-05-04 09:43:54.000000000 -1000 +++ /dev/null 2016-05-04 09:43:54.000000000 -1000 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.lang.reflect.Field; - -import jdk.internal.misc.Unsafe; - -/** - * Package private access to the {@link Unsafe} capability. - */ -class UnsafeAccess { - - static final Unsafe UNSAFE = initUnsafe(); - - private static Unsafe initUnsafe() { - try { - // Fast path when we are trusted. - return Unsafe.getUnsafe(); - } catch (SecurityException se) { - // Slow path when we are not trusted. - try { - Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); - theUnsafe.setAccessible(true); - return (Unsafe) theUnsafe.get(Unsafe.class); - } catch (Exception e) { - throw new RuntimeException("exception while trying to get Unsafe", e); - } - } - } -} --- /dev/null 2016-05-04 09:43:54.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java 2016-05-04 09:43:54.000000000 -1000 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot; + +import java.lang.reflect.Field; + +import jdk.internal.misc.Unsafe; + +/** + * Package private access to the {@link Unsafe} capability. + */ +class UnsafeAccess { + + static final Unsafe UNSAFE = initUnsafe(); + + private static Unsafe initUnsafe() { + try { + // Fast path when we are trusted. + return Unsafe.getUnsafe(); + } catch (SecurityException se) { + // Slow path when we are not trusted. + try { + Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); + theUnsafe.setAccessible(true); + return (Unsafe) theUnsafe.get(Unsafe.class); + } catch (Exception e) { + throw new RuntimeException("exception while trying to get Unsafe", e); + } + } + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/events/EmptyEventProvider.java 2016-05-04 09:43:55.000000000 -1000 +++ /dev/null 2016-05-04 09:43:55.000000000 -1000 @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.events; - -import jdk.vm.ci.common.JVMCIError; - -/** - * An empty implementation for {@link EventProvider}. This implementation is used when no logging is - * requested. - */ -public final class EmptyEventProvider implements EventProvider { - - public CompilationEvent newCompilationEvent() { - return new EmptyCompilationEvent(); - } - - public static class EmptyCompilationEvent implements CompilationEvent { - public void commit() { - throw JVMCIError.shouldNotReachHere(); - } - - public boolean shouldWrite() { - // Events of this class should never been written. - return false; - } - - public void begin() { - } - - public void end() { - } - - public void setMethod(String method) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setCompileId(int compileId) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setCompileLevel(int compileLevel) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setSucceeded(boolean succeeded) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setIsOsr(boolean isOsr) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setCodeSize(int codeSize) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setInlinedBytes(int inlinedBytes) { - throw JVMCIError.shouldNotReachHere(); - } - } - - public CompilerFailureEvent newCompilerFailureEvent() { - return new EmptyCompilerFailureEvent(); - } - - public static class EmptyCompilerFailureEvent implements CompilerFailureEvent { - public void commit() { - throw JVMCIError.shouldNotReachHere(); - } - - public boolean shouldWrite() { - // Events of this class should never been written. - return false; - } - - public void setCompileId(int compileId) { - throw JVMCIError.shouldNotReachHere(); - } - - public void setMessage(String message) { - throw JVMCIError.shouldNotReachHere(); - } - } - -} --- /dev/null 2016-05-04 09:43:55.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/events/EmptyEventProvider.java 2016-05-04 09:43:54.000000000 -1000 @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot.events; + +import jdk.vm.ci.common.JVMCIError; + +/** + * An empty implementation for {@link EventProvider}. This implementation is used when no logging is + * requested. + */ +public final class EmptyEventProvider implements EventProvider { + + public CompilationEvent newCompilationEvent() { + return new EmptyCompilationEvent(); + } + + public static class EmptyCompilationEvent implements CompilationEvent { + public void commit() { + throw JVMCIError.shouldNotReachHere(); + } + + public boolean shouldWrite() { + // Events of this class should never been written. + return false; + } + + public void begin() { + } + + public void end() { + } + + public void setMethod(String method) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setCompileId(int compileId) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setCompileLevel(int compileLevel) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setSucceeded(boolean succeeded) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setIsOsr(boolean isOsr) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setCodeSize(int codeSize) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setInlinedBytes(int inlinedBytes) { + throw JVMCIError.shouldNotReachHere(); + } + } + + public CompilerFailureEvent newCompilerFailureEvent() { + return new EmptyCompilerFailureEvent(); + } + + public static class EmptyCompilerFailureEvent implements CompilerFailureEvent { + public void commit() { + throw JVMCIError.shouldNotReachHere(); + } + + public boolean shouldWrite() { + // Events of this class should never been written. + return false; + } + + public void setCompileId(int compileId) { + throw JVMCIError.shouldNotReachHere(); + } + + public void setMessage(String message) { + throw JVMCIError.shouldNotReachHere(); + } + } + +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/events/EventProvider.java 2016-05-04 09:43:55.000000000 -1000 +++ /dev/null 2016-05-04 09:43:55.000000000 -1000 @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.events; - -/** - * A provider that provides a specific implementation for events that can be logged in the compiler. - */ -public interface EventProvider { - - /** - * An instant event is an event that is not considered to have taken any time. - */ - interface InstantEvent { - /** - * Commits the event. - */ - void commit(); - - /** - * Determines if this particular event instance would be committed to the data stream right - * now if application called {@link #commit()}. This in turn depends on whether the event is - * enabled and possible other factors. - * - * @return if this event would be committed on a call to {@link #commit()}. - */ - boolean shouldWrite(); - } - - /** - * Timed events describe an operation that somehow consumes time. - */ - interface TimedEvent extends InstantEvent { - /** - * Starts the timing for this event. - */ - void begin(); - - /** - * Ends the timing period for this event. - */ - void end(); - } - - /** - * Creates a new {@link CompilationEvent}. - * - * @return a compilation event - */ - CompilationEvent newCompilationEvent(); - - /** - * A compilation event. - */ - interface CompilationEvent extends TimedEvent { - void setMethod(String method); - - void setCompileId(int compileId); - - void setCompileLevel(int compileLevel); - - void setSucceeded(boolean succeeded); - - void setIsOsr(boolean isOsr); - - void setCodeSize(int codeSize); - - void setInlinedBytes(int inlinedBytes); - } - - /** - * Creates a new {@link CompilerFailureEvent}. - * - * @return a compiler failure event - */ - CompilerFailureEvent newCompilerFailureEvent(); - - /** - * A compiler failure event. - */ - interface CompilerFailureEvent extends InstantEvent { - void setCompileId(int compileId); - - void setMessage(String message); - } -} --- /dev/null 2016-05-04 09:43:55.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/events/EventProvider.java 2016-05-04 09:43:55.000000000 -1000 @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspot.events; + +/** + * A provider that provides a specific implementation for events that can be logged in the compiler. + */ +public interface EventProvider { + + /** + * An instant event is an event that is not considered to have taken any time. + */ + interface InstantEvent { + /** + * Commits the event. + */ + void commit(); + + /** + * Determines if this particular event instance would be committed to the data stream right + * now if application called {@link #commit()}. This in turn depends on whether the event is + * enabled and possible other factors. + * + * @return if this event would be committed on a call to {@link #commit()}. + */ + boolean shouldWrite(); + } + + /** + * Timed events describe an operation that somehow consumes time. + */ + interface TimedEvent extends InstantEvent { + /** + * Starts the timing for this event. + */ + void begin(); + + /** + * Ends the timing period for this event. + */ + void end(); + } + + /** + * Creates a new {@link CompilationEvent}. + * + * @return a compilation event + */ + CompilationEvent newCompilationEvent(); + + /** + * A compilation event. + */ + interface CompilationEvent extends TimedEvent { + void setMethod(String method); + + void setCompileId(int compileId); + + void setCompileLevel(int compileLevel); + + void setSucceeded(boolean succeeded); + + void setIsOsr(boolean isOsr); + + void setCodeSize(int codeSize); + + void setInlinedBytes(int inlinedBytes); + } + + /** + * Creates a new {@link CompilerFailureEvent}. + * + * @return a compiler failure event + */ + CompilerFailureEvent newCompilerFailureEvent(); + + /** + * A compiler failure event. + */ + interface CompilerFailureEvent extends InstantEvent { + void setCompileId(int compileId); + + void setMessage(String message); + } +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/logging/package-info.java 2016-05-04 09:43:55.000000000 -1000 +++ /dev/null 2016-05-04 09:43:55.000000000 -1000 @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -/** - * Logging framework for the HotSpot CRI implementation. - */ -package jdk.vm.ci.hotspot.logging; - --- /dev/null 2016-05-04 09:43:55.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/logging/package-info.java 2016-05-04 09:43:55.000000000 -1000 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/** + * Logging framework for the HotSpot CRI implementation. + */ +package jdk.vm.ci.hotspot.logging; + --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMAddress.java 2016-05-04 09:43:56.000000000 -1000 +++ /dev/null 2016-05-04 09:43:56.000000000 -1000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspotvmconfig; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Refers to a C++ address in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMAddress { - - /** - * Returns the name of the symbol this address is referring to. - * - * @return name of symbol of this address - */ - String name(); - - /** - * List of architectures where this constant is required. Names are derived from - * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is - * required on all architectures. - */ - @SuppressWarnings("javadoc") - String[] archs() default {}; - - /** - * List of operating systems where this constant is required. Names are derived from - * {@link HotSpotVMConfig#getHostOSName()}. An empty list implies that the constant is required - * on all operating systems. - */ - @SuppressWarnings("javadoc") - String[] os() default {}; - -} --- /dev/null 2016-05-04 09:43:56.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMAddress.java 2016-05-04 09:43:56.000000000 -1000 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspotvmconfig; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Refers to a C++ address in the VM. + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface HotSpotVMAddress { + + /** + * Returns the name of the symbol this address is referring to. + * + * @return name of symbol of this address + */ + String name(); + + /** + * List of architectures where this constant is required. Names are derived from + * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is + * required on all architectures. + */ + @SuppressWarnings("javadoc") + String[] archs() default {}; + + /** + * List of operating systems where this constant is required. Names are derived from + * {@link HotSpotVMConfig#getHostOSName()}. An empty list implies that the constant is required + * on all operating systems. + */ + @SuppressWarnings("javadoc") + String[] os() default {}; + +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMConstant.java 2016-05-04 09:43:56.000000000 -1000 +++ /dev/null 2016-05-04 09:43:56.000000000 -1000 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspotvmconfig; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Refers to a C++ constant in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMConstant { - - /** - * Returns the name of the constant. - * - * @return name of constant - */ - String name(); - - /** - * List of architectures where this constant is required. Names are derived from - * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is - * required on all architectures. - */ - @SuppressWarnings("javadoc") - String[] archs() default {}; -} --- /dev/null 2016-05-04 09:43:56.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMConstant.java 2016-05-04 09:43:56.000000000 -1000 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspotvmconfig; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Refers to a C++ constant in the VM. + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface HotSpotVMConstant { + + /** + * Returns the name of the constant. + * + * @return name of constant + */ + String name(); + + /** + * List of architectures where this constant is required. Names are derived from + * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is + * required on all architectures. + */ + @SuppressWarnings("javadoc") + String[] archs() default {}; +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMData.java 2016-05-04 09:43:57.000000000 -1000 +++ /dev/null 2016-05-04 09:43:57.000000000 -1000 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspotvmconfig; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Refers to a entry in {@code gHotSpotVMData}. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMData { - - /** - * Returns the array index of this field. - * - * @return array index of field - */ - int index(); - -} --- /dev/null 2016-05-04 09:43:57.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMData.java 2016-05-04 09:43:57.000000000 -1000 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspotvmconfig; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Refers to a entry in {@code gHotSpotVMData}. + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface HotSpotVMData { + + /** + * Returns the array index of this field. + * + * @return array index of field + */ + int index(); + +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMField.java 2016-05-04 09:43:57.000000000 -1000 +++ /dev/null 2016-05-04 09:43:57.000000000 -1000 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspotvmconfig; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Refers to a C++ field in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMField { - - /** - * Types of information this annotation can return. - */ - enum Type { - /** - * Returns the offset of this field within the type. Only valid for instance fields. - */ - OFFSET, - - /** - * Returns the absolute address of this field. Only valid for static fields. - */ - ADDRESS, - - /** - * Returns the value of this field. Only valid for static fields. - */ - VALUE; - } - - /** - * Specifies what type of information to return. - * - * @see Type - */ - Type get(); - - /** - * Returns the type name containing this field. - * - * @return name of containing type - */ - String type(); - - /** - * Returns the name of this field. - * - * @return name of field - */ - String name(); - - /** - * List of architectures where this constant is required. Names are derived from - * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is - * required on all architectures. - */ - @SuppressWarnings("javadoc") - String[] archs() default {}; -} --- /dev/null 2016-05-04 09:43:57.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMField.java 2016-05-04 09:43:57.000000000 -1000 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspotvmconfig; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Refers to a C++ field in the VM. + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface HotSpotVMField { + + /** + * Types of information this annotation can return. + */ + enum Type { + /** + * Returns the offset of this field within the type. Only valid for instance fields. + */ + OFFSET, + + /** + * Returns the absolute address of this field. Only valid for static fields. + */ + ADDRESS, + + /** + * Returns the value of this field. Only valid for static fields. + */ + VALUE; + } + + /** + * Specifies what type of information to return. + * + * @see Type + */ + Type get(); + + /** + * Returns the type name containing this field. + * + * @return name of containing type + */ + String type(); + + /** + * Returns the name of this field. + * + * @return name of field + */ + String name(); + + /** + * List of architectures where this constant is required. Names are derived from + * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is + * required on all architectures. + */ + @SuppressWarnings("javadoc") + String[] archs() default {}; +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMFlag.java 2016-05-04 09:43:58.000000000 -1000 +++ /dev/null 2016-05-04 09:43:58.000000000 -1000 @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspotvmconfig; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Refers to a C++ flag in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMFlag { - - /** - * Returns the name of this flag. - * - * @return name of flag. - */ - String name(); - - /** - * List of architectures where this constant is required. Names are derived from - * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is - * required on all architectures. - */ - @SuppressWarnings("javadoc") - String[] archs() default {}; - - boolean optional() default false; -} --- /dev/null 2016-05-04 09:43:58.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMFlag.java 2016-05-04 09:43:58.000000000 -1000 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspotvmconfig; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Refers to a C++ flag in the VM. + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface HotSpotVMFlag { + + /** + * Returns the name of this flag. + * + * @return name of flag. + */ + String name(); + + /** + * List of architectures where this constant is required. Names are derived from + * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is + * required on all architectures. + */ + @SuppressWarnings("javadoc") + String[] archs() default {}; + + boolean optional() default false; +} --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMType.java 2016-05-04 09:43:58.000000000 -1000 +++ /dev/null 2016-05-04 09:43:58.000000000 -1000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspotvmconfig; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Refers to a C++ type in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMType { - - /** - * Types of information this annotation can return. - */ - enum Type { - /** - * Returns the size of the type (C++ {@code sizeof()}). - */ - SIZE; - } - - /** - * Specifies what type of information to return. - * - * @see Type - */ - Type get(); - - /** - * Returns the name of the type. - * - * @return name of type - */ - String name(); -} --- /dev/null 2016-05-04 09:43:58.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/jdk.vm.ci.hotspotvmconfig/src/jdk/vm/ci/hotspotvmconfig/HotSpotVMType.java 2016-05-04 09:43:58.000000000 -1000 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.vm.ci.hotspotvmconfig; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Refers to a C++ type in the VM. + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface HotSpotVMType { + + /** + * Types of information this annotation can return. + */ + enum Type { + /** + * Returns the size of the type (C++ {@code sizeof()}). + */ + SIZE; + } + + /** + * Specifies what type of information to return. + * + * @see Type + */ + Type get(); + + /** + * Returns the name of the type. + * + * @return name of type + */ + String name(); +} --- /dev/null 2016-05-04 09:43:59.000000000 -1000 +++ new/src/jdk.vm.ci.hotspot/share/classes/module-info.java 2016-05-04 09:43:58.000000000 -1000 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +module jdk.vm.ci.hotspot { + requires jdk.vm.ci; + + uses jdk.vm.ci.hotspot.HotSpotVMEventListener; + uses jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; + + provides jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory with jdk.vm.ci.hotspot.aarch64.AArch64HotSpotJVMCIBackendFactory; + provides jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory with jdk.vm.ci.hotspot.amd64.AMD64HotSpotJVMCIBackendFactory; + provides jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory with jdk.vm.ci.hotspot.sparc.SPARCHotSpotJVMCIBackendFactory; +} --- old/test/compiler/jvmci/common/patches/jdk.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java 2016-05-04 09:43:59.000000000 -1000 +++ /dev/null 2016-05-04 09:43:59.000000000 -1000 @@ -1,305 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.code.InvalidInstalledCodeException; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.meta.ConstantPool; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.SpeculationLog; - -/** - * A simple "proxy" class to get test access to CompilerToVM package-private methods - */ -public class CompilerToVMHelper { - public static final CompilerToVM CTVM = new CompilerToVM(); - - public static byte[] getBytecode(HotSpotResolvedJavaMethod method) { - return CTVM.getBytecode((HotSpotResolvedJavaMethodImpl)method); - } - - public static int getExceptionTableLength(HotSpotResolvedJavaMethod method) { - return CTVM.getExceptionTableLength((HotSpotResolvedJavaMethodImpl)method); - } - - public static long getExceptionTableStart(HotSpotResolvedJavaMethod method) { - return CTVM.getExceptionTableStart((HotSpotResolvedJavaMethodImpl)method); - } - - public static boolean canInlineMethod(HotSpotResolvedJavaMethod method) { - return CTVM.canInlineMethod((HotSpotResolvedJavaMethodImpl)method); - } - - public static boolean shouldInlineMethod(HotSpotResolvedJavaMethod method) { - return CTVM.shouldInlineMethod((HotSpotResolvedJavaMethodImpl)method); - } - - public static HotSpotResolvedJavaMethod findUniqueConcreteMethod( - HotSpotResolvedObjectType actualHolderType, - HotSpotResolvedJavaMethod method) { - return CTVM.findUniqueConcreteMethod((HotSpotResolvedObjectTypeImpl) actualHolderType, (HotSpotResolvedJavaMethodImpl)method); - } - - public static HotSpotResolvedObjectType getImplementor(HotSpotResolvedObjectType type) { - return CTVM.getImplementor((HotSpotResolvedObjectTypeImpl) type); - } - - public static boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethod method) { - return CTVM.methodIsIgnoredBySecurityStackWalk((HotSpotResolvedJavaMethodImpl)method); - } - - public static HotSpotResolvedObjectType lookupType(String name, - Class accessingClass, boolean resolve) { - return CTVM.lookupType(name, accessingClass, resolve); - } - - public static Object resolveConstantInPool(ConstantPool constantPool, int cpi) { - return CTVM.resolveConstantInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static Object resolvePossiblyCachedConstantInPool(ConstantPool constantPool, int cpi) { - return CTVM.resolvePossiblyCachedConstantInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static int lookupNameAndTypeRefIndexInPool(ConstantPool constantPool, int cpi) { - return CTVM.lookupNameAndTypeRefIndexInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static String lookupNameInPool(ConstantPool constantPool, int cpi) { - return CTVM.lookupNameInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static String lookupSignatureInPool(ConstantPool constantPool, int cpi) { - return CTVM.lookupSignatureInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static int lookupKlassRefIndexInPool(ConstantPool constantPool, int cpi) { - return CTVM.lookupKlassRefIndexInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static Object lookupKlassInPool(ConstantPool constantPool, int cpi) { - return CTVM.lookupKlassInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static HotSpotResolvedJavaMethod lookupMethodInPool( - ConstantPool constantPool, int cpi, byte opcode) { - return CTVM.lookupMethodInPool((HotSpotConstantPool) constantPool, cpi, opcode); - } - - public static void resolveInvokeDynamicInPool( - ConstantPool constantPool, int cpi) { - CTVM.resolveInvokeDynamicInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static void resolveInvokeHandleInPool( - ConstantPool constantPool, int cpi) { - CTVM.resolveInvokeHandleInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static HotSpotResolvedObjectType resolveTypeInPool( - ConstantPool constantPool, int cpi) { - return CTVM.resolveTypeInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static HotSpotResolvedObjectType resolveFieldInPool( - ConstantPool constantPool, int cpi, byte opcode, long[] info) { - return CTVM.resolveFieldInPool((HotSpotConstantPool) constantPool, cpi, opcode, info); - } - - public static int constantPoolRemapInstructionOperandFromCache( - ConstantPool constantPool, int cpci) { - return CTVM.constantPoolRemapInstructionOperandFromCache((HotSpotConstantPool) constantPool, cpci); - } - - public static Object lookupAppendixInPool( - ConstantPool constantPool, int cpi) { - return CTVM.lookupAppendixInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static int installCode(TargetDescription target, - HotSpotCompiledCode compiledCode, InstalledCode code, HotSpotSpeculationLog speculationLog) { - return CTVM.installCode(target, compiledCode, code, speculationLog); - } - - public static int getMetadata(TargetDescription target, - HotSpotCompiledCode compiledCode, HotSpotMetaData metaData) { - return CTVM.getMetadata(target, compiledCode, metaData); - } - - public static void resetCompilationStatistics() { - CTVM.resetCompilationStatistics(); - } - - public static long initializeConfiguration(HotSpotVMConfig config) { - return CTVM.initializeConfiguration(config); - } - - public static HotSpotResolvedJavaMethod resolveMethod( - HotSpotResolvedObjectType exactReceiver, - HotSpotResolvedJavaMethod method, - HotSpotResolvedObjectType caller) { - return CTVM.resolveMethod((HotSpotResolvedObjectTypeImpl) exactReceiver, (HotSpotResolvedJavaMethodImpl) method, (HotSpotResolvedObjectTypeImpl) caller); - } - - public static HotSpotResolvedJavaMethod getClassInitializer( - HotSpotResolvedObjectType type) { - return CTVM.getClassInitializer((HotSpotResolvedObjectTypeImpl) type); - } - - public static boolean hasFinalizableSubclass(HotSpotResolvedObjectType type) { - return CTVM.hasFinalizableSubclass((HotSpotResolvedObjectTypeImpl) type); - } - - public static HotSpotResolvedJavaMethodImpl getResolvedJavaMethodAtSlot( - Class holder, int slot) { - return CTVM.getResolvedJavaMethodAtSlot(holder, slot); - } - - public static long getMaxCallTargetOffset(long address) { - return CTVM.getMaxCallTargetOffset(address); - } - - public static String disassembleCodeBlob(InstalledCode codeBlob) { - return CTVM.disassembleCodeBlob(codeBlob); - } - - public static StackTraceElement getStackTraceElement( - HotSpotResolvedJavaMethod method, int bci) { - return CTVM.getStackTraceElement((HotSpotResolvedJavaMethodImpl)method, bci); - } - - public static Object executeInstalledCode(Object[] args, - InstalledCode installedCode) throws InvalidInstalledCodeException { - return CTVM.executeInstalledCode(args, installedCode); - } - - public static long[] getLineNumberTable(HotSpotResolvedJavaMethod method) { - return CTVM.getLineNumberTable((HotSpotResolvedJavaMethodImpl)method); - } - - public static int getLocalVariableTableLength(HotSpotResolvedJavaMethod method) { - return CTVM.getLocalVariableTableLength((HotSpotResolvedJavaMethodImpl)method); - } - - public static long getLocalVariableTableStart(HotSpotResolvedJavaMethod method) { - return CTVM.getLocalVariableTableStart((HotSpotResolvedJavaMethodImpl)method); - } - - public static Object readUncompressedOop(long address) { - return CTVM.readUncompressedOop(address); - } - - public static void doNotInlineOrCompile(HotSpotResolvedJavaMethod method) { - CTVM.doNotInlineOrCompile((HotSpotResolvedJavaMethodImpl)method); - } - - public static void reprofile(HotSpotResolvedJavaMethod method) { - CTVM.reprofile((HotSpotResolvedJavaMethodImpl)method); - } - - public static void invalidateInstalledCode(InstalledCode installedCode) { - CTVM.invalidateInstalledCode(installedCode); - } - - public static long[] collectCounters() { - return CTVM.collectCounters(); - } - - public static boolean isMature(long metaspaceMethodData) { - return CTVM.isMature(metaspaceMethodData); - } - - public static int allocateCompileId(HotSpotResolvedJavaMethod method, - int entryBCI) { - return CTVM.allocateCompileId((HotSpotResolvedJavaMethodImpl) method, entryBCI); - } - - public static boolean hasCompiledCodeForOSR( - HotSpotResolvedJavaMethod method, int entryBCI, int level) { - return CTVM.hasCompiledCodeForOSR((HotSpotResolvedJavaMethodImpl) method, entryBCI, level); - } - - public static String getSymbol(long metaspaceSymbol) { - return CTVM.getSymbol(metaspaceSymbol); - } - - public static HotSpotStackFrameReference getNextStackFrame( - HotSpotStackFrameReference frame, - ResolvedJavaMethod[] methods, int initialSkip) { - return CTVM.getNextStackFrame(frame, methods, initialSkip); - } - - public static void materializeVirtualObjects( - HotSpotStackFrameReference stackFrame, boolean invalidate) { - CTVM.materializeVirtualObjects(stackFrame, invalidate); - } - - public static int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectType type, - HotSpotResolvedJavaMethod method) { - return CTVM.getVtableIndexForInterfaceMethod((HotSpotResolvedObjectTypeImpl) type, (HotSpotResolvedJavaMethodImpl) method); - } - - public static boolean shouldDebugNonSafepoints() { - return CTVM.shouldDebugNonSafepoints(); - } - - public static void writeDebugOutput(byte[] bytes, int offset, int length) { - CTVM.writeDebugOutput(bytes, offset, length); - } - - public static void flushDebugOutput() { - CTVM.flushDebugOutput(); - } - - public static HotSpotResolvedJavaMethod getResolvedJavaMethod(Object base, - long displacement) { - return CTVM.getResolvedJavaMethod(base, displacement); - } - - public static HotSpotConstantPool getConstantPool(Object base, long displacement) { - return CTVM.getConstantPool(base, displacement); - } - - public static HotSpotResolvedObjectType getResolvedJavaType(Object base, - long displacement, boolean compressed) { - return CTVM.getResolvedJavaType(base, displacement, compressed); - } - - public static long getMetaspacePointer(Object o) { - return ((MetaspaceWrapperObject) o).getMetaspacePointer(); - } - - public static Class CompilerToVMClass() { - return CompilerToVM.class; - } - - public static Class HotSpotConstantPoolClass() { - return HotSpotConstantPool.class; - } - - public static Class getMirror(HotSpotResolvedObjectType type) { - return ((HotSpotResolvedJavaType) type).mirror(); - } -} --- /dev/null 2016-05-04 09:43:59.000000000 -1000 +++ new/test/compiler/jvmci/common/patches/jdk.vm.ci.hotspot/jdk/vm/ci/hotspot/CompilerToVMHelper.java 2016-05-04 09:43:59.000000000 -1000 @@ -0,0 +1,305 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.code.InstalledCode; +import jdk.vm.ci.code.InvalidInstalledCodeException; +import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.meta.ConstantPool; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.SpeculationLog; + +/** + * A simple "proxy" class to get test access to CompilerToVM package-private methods + */ +public class CompilerToVMHelper { + public static final CompilerToVM CTVM = new CompilerToVM(); + + public static byte[] getBytecode(HotSpotResolvedJavaMethod method) { + return CTVM.getBytecode((HotSpotResolvedJavaMethodImpl)method); + } + + public static int getExceptionTableLength(HotSpotResolvedJavaMethod method) { + return CTVM.getExceptionTableLength((HotSpotResolvedJavaMethodImpl)method); + } + + public static long getExceptionTableStart(HotSpotResolvedJavaMethod method) { + return CTVM.getExceptionTableStart((HotSpotResolvedJavaMethodImpl)method); + } + + public static boolean canInlineMethod(HotSpotResolvedJavaMethod method) { + return CTVM.canInlineMethod((HotSpotResolvedJavaMethodImpl)method); + } + + public static boolean shouldInlineMethod(HotSpotResolvedJavaMethod method) { + return CTVM.shouldInlineMethod((HotSpotResolvedJavaMethodImpl)method); + } + + public static HotSpotResolvedJavaMethod findUniqueConcreteMethod( + HotSpotResolvedObjectType actualHolderType, + HotSpotResolvedJavaMethod method) { + return CTVM.findUniqueConcreteMethod((HotSpotResolvedObjectTypeImpl) actualHolderType, (HotSpotResolvedJavaMethodImpl)method); + } + + public static HotSpotResolvedObjectType getImplementor(HotSpotResolvedObjectType type) { + return CTVM.getImplementor((HotSpotResolvedObjectTypeImpl) type); + } + + public static boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethod method) { + return CTVM.methodIsIgnoredBySecurityStackWalk((HotSpotResolvedJavaMethodImpl)method); + } + + public static HotSpotResolvedObjectType lookupType(String name, + Class accessingClass, boolean resolve) { + return CTVM.lookupType(name, accessingClass, resolve); + } + + public static Object resolveConstantInPool(ConstantPool constantPool, int cpi) { + return CTVM.resolveConstantInPool((HotSpotConstantPool) constantPool, cpi); + } + + public static Object resolvePossiblyCachedConstantInPool(ConstantPool constantPool, int cpi) { + return CTVM.resolvePossiblyCachedConstantInPool((HotSpotConstantPool) constantPool, cpi); + } + + public static int lookupNameAndTypeRefIndexInPool(ConstantPool constantPool, int cpi) { + return CTVM.lookupNameAndTypeRefIndexInPool((HotSpotConstantPool) constantPool, cpi); + } + + public static String lookupNameInPool(ConstantPool constantPool, int cpi) { + return CTVM.lookupNameInPool((HotSpotConstantPool) constantPool, cpi); + } + + public static String lookupSignatureInPool(ConstantPool constantPool, int cpi) { + return CTVM.lookupSignatureInPool((HotSpotConstantPool) constantPool, cpi); + } + + public static int lookupKlassRefIndexInPool(ConstantPool constantPool, int cpi) { + return CTVM.lookupKlassRefIndexInPool((HotSpotConstantPool) constantPool, cpi); + } + + public static Object lookupKlassInPool(ConstantPool constantPool, int cpi) { + return CTVM.lookupKlassInPool((HotSpotConstantPool) constantPool, cpi); + } + + public static HotSpotResolvedJavaMethod lookupMethodInPool( + ConstantPool constantPool, int cpi, byte opcode) { + return CTVM.lookupMethodInPool((HotSpotConstantPool) constantPool, cpi, opcode); + } + + public static void resolveInvokeDynamicInPool( + ConstantPool constantPool, int cpi) { + CTVM.resolveInvokeDynamicInPool((HotSpotConstantPool) constantPool, cpi); + } + + public static void resolveInvokeHandleInPool( + ConstantPool constantPool, int cpi) { + CTVM.resolveInvokeHandleInPool((HotSpotConstantPool) constantPool, cpi); + } + + public static HotSpotResolvedObjectType resolveTypeInPool( + ConstantPool constantPool, int cpi) { + return CTVM.resolveTypeInPool((HotSpotConstantPool) constantPool, cpi); + } + + public static HotSpotResolvedObjectType resolveFieldInPool( + ConstantPool constantPool, int cpi, byte opcode, long[] info) { + return CTVM.resolveFieldInPool((HotSpotConstantPool) constantPool, cpi, opcode, info); + } + + public static int constantPoolRemapInstructionOperandFromCache( + ConstantPool constantPool, int cpci) { + return CTVM.constantPoolRemapInstructionOperandFromCache((HotSpotConstantPool) constantPool, cpci); + } + + public static Object lookupAppendixInPool( + ConstantPool constantPool, int cpi) { + return CTVM.lookupAppendixInPool((HotSpotConstantPool) constantPool, cpi); + } + + public static int installCode(TargetDescription target, + HotSpotCompiledCode compiledCode, InstalledCode code, HotSpotSpeculationLog speculationLog) { + return CTVM.installCode(target, compiledCode, code, speculationLog); + } + + public static int getMetadata(TargetDescription target, + HotSpotCompiledCode compiledCode, HotSpotMetaData metaData) { + return CTVM.getMetadata(target, compiledCode, metaData); + } + + public static void resetCompilationStatistics() { + CTVM.resetCompilationStatistics(); + } + + public static long initializeConfiguration(HotSpotVMConfig config) { + return CTVM.initializeConfiguration(config); + } + + public static HotSpotResolvedJavaMethod resolveMethod( + HotSpotResolvedObjectType exactReceiver, + HotSpotResolvedJavaMethod method, + HotSpotResolvedObjectType caller) { + return CTVM.resolveMethod((HotSpotResolvedObjectTypeImpl) exactReceiver, (HotSpotResolvedJavaMethodImpl) method, (HotSpotResolvedObjectTypeImpl) caller); + } + + public static HotSpotResolvedJavaMethod getClassInitializer( + HotSpotResolvedObjectType type) { + return CTVM.getClassInitializer((HotSpotResolvedObjectTypeImpl) type); + } + + public static boolean hasFinalizableSubclass(HotSpotResolvedObjectType type) { + return CTVM.hasFinalizableSubclass((HotSpotResolvedObjectTypeImpl) type); + } + + public static HotSpotResolvedJavaMethodImpl getResolvedJavaMethodAtSlot( + Class holder, int slot) { + return CTVM.getResolvedJavaMethodAtSlot(holder, slot); + } + + public static long getMaxCallTargetOffset(long address) { + return CTVM.getMaxCallTargetOffset(address); + } + + public static String disassembleCodeBlob(InstalledCode codeBlob) { + return CTVM.disassembleCodeBlob(codeBlob); + } + + public static StackTraceElement getStackTraceElement( + HotSpotResolvedJavaMethod method, int bci) { + return CTVM.getStackTraceElement((HotSpotResolvedJavaMethodImpl)method, bci); + } + + public static Object executeInstalledCode(Object[] args, + InstalledCode installedCode) throws InvalidInstalledCodeException { + return CTVM.executeInstalledCode(args, installedCode); + } + + public static long[] getLineNumberTable(HotSpotResolvedJavaMethod method) { + return CTVM.getLineNumberTable((HotSpotResolvedJavaMethodImpl)method); + } + + public static int getLocalVariableTableLength(HotSpotResolvedJavaMethod method) { + return CTVM.getLocalVariableTableLength((HotSpotResolvedJavaMethodImpl)method); + } + + public static long getLocalVariableTableStart(HotSpotResolvedJavaMethod method) { + return CTVM.getLocalVariableTableStart((HotSpotResolvedJavaMethodImpl)method); + } + + public static Object readUncompressedOop(long address) { + return CTVM.readUncompressedOop(address); + } + + public static void doNotInlineOrCompile(HotSpotResolvedJavaMethod method) { + CTVM.doNotInlineOrCompile((HotSpotResolvedJavaMethodImpl)method); + } + + public static void reprofile(HotSpotResolvedJavaMethod method) { + CTVM.reprofile((HotSpotResolvedJavaMethodImpl)method); + } + + public static void invalidateInstalledCode(InstalledCode installedCode) { + CTVM.invalidateInstalledCode(installedCode); + } + + public static long[] collectCounters() { + return CTVM.collectCounters(); + } + + public static boolean isMature(long metaspaceMethodData) { + return CTVM.isMature(metaspaceMethodData); + } + + public static int allocateCompileId(HotSpotResolvedJavaMethod method, + int entryBCI) { + return CTVM.allocateCompileId((HotSpotResolvedJavaMethodImpl) method, entryBCI); + } + + public static boolean hasCompiledCodeForOSR( + HotSpotResolvedJavaMethod method, int entryBCI, int level) { + return CTVM.hasCompiledCodeForOSR((HotSpotResolvedJavaMethodImpl) method, entryBCI, level); + } + + public static String getSymbol(long metaspaceSymbol) { + return CTVM.getSymbol(metaspaceSymbol); + } + + public static HotSpotStackFrameReference getNextStackFrame( + HotSpotStackFrameReference frame, + ResolvedJavaMethod[] methods, int initialSkip) { + return CTVM.getNextStackFrame(frame, methods, initialSkip); + } + + public static void materializeVirtualObjects( + HotSpotStackFrameReference stackFrame, boolean invalidate) { + CTVM.materializeVirtualObjects(stackFrame, invalidate); + } + + public static int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectType type, + HotSpotResolvedJavaMethod method) { + return CTVM.getVtableIndexForInterfaceMethod((HotSpotResolvedObjectTypeImpl) type, (HotSpotResolvedJavaMethodImpl) method); + } + + public static boolean shouldDebugNonSafepoints() { + return CTVM.shouldDebugNonSafepoints(); + } + + public static void writeDebugOutput(byte[] bytes, int offset, int length) { + CTVM.writeDebugOutput(bytes, offset, length); + } + + public static void flushDebugOutput() { + CTVM.flushDebugOutput(); + } + + public static HotSpotResolvedJavaMethod getResolvedJavaMethod(Object base, + long displacement) { + return CTVM.getResolvedJavaMethod(base, displacement); + } + + public static HotSpotConstantPool getConstantPool(Object base, long displacement) { + return CTVM.getConstantPool(base, displacement); + } + + public static HotSpotResolvedObjectType getResolvedJavaType(Object base, + long displacement, boolean compressed) { + return CTVM.getResolvedJavaType(base, displacement, compressed); + } + + public static long getMetaspacePointer(Object o) { + return ((MetaspaceWrapperObject) o).getMetaspacePointer(); + } + + public static Class CompilerToVMClass() { + return CompilerToVM.class; + } + + public static Class HotSpotConstantPoolClass() { + return HotSpotConstantPool.class; + } + + public static Class getMirror(HotSpotResolvedObjectType type) { + return ((HotSpotResolvedJavaType) type).mirror(); + } +} --- old/test/compiler/jvmci/common/patches/jdk.vm.ci/jdk/vm/ci/hotspot/MetaAccessWrapper.java 2016-05-04 09:44:00.000000000 -1000 +++ /dev/null 2016-05-04 09:44:00.000000000 -1000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.JVMCIMetaAccessContext; -import jdk.vm.ci.meta.ResolvedJavaType; - -/* - * A JVMCIMetaAccessContext wrapper class to mark context - * being provided/returned - */ -public class MetaAccessWrapper implements JVMCIMetaAccessContext { - private static final HotSpotJVMCIMetaAccessContext CONTEXT - = new HotSpotJVMCIMetaAccessContext(); - @Override - public ResolvedJavaType fromClass(Class clazz) { - return CONTEXT.fromClass(clazz); - } -} --- /dev/null 2016-05-04 09:44:00.000000000 -1000 +++ new/test/compiler/jvmci/common/patches/jdk.vm.ci.hotspot/jdk/vm/ci/hotspot/MetaAccessWrapper.java 2016-05-04 09:43:59.000000000 -1000 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.meta.JVMCIMetaAccessContext; +import jdk.vm.ci.meta.ResolvedJavaType; + +/* + * A JVMCIMetaAccessContext wrapper class to mark context + * being provided/returned + */ +public class MetaAccessWrapper implements JVMCIMetaAccessContext { + private static final HotSpotJVMCIMetaAccessContext CONTEXT + = new HotSpotJVMCIMetaAccessContext(); + @Override + public ResolvedJavaType fromClass(Class clazz) { + return CONTEXT.fromClass(clazz); + } +} --- old/test/compiler/jvmci/common/patches/jdk.vm.ci/jdk/vm/ci/hotspot/PublicMetaspaceWrapperObject.java 2016-05-04 09:44:00.000000000 -1000 +++ /dev/null 2016-05-04 09:44:00.000000000 -1000 @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot; - -/** - * A public available version of MetaspaceWrapperObject interface. - */ -public interface PublicMetaspaceWrapperObject extends MetaspaceWrapperObject { } --- /dev/null 2016-05-04 09:44:00.000000000 -1000 +++ new/test/compiler/jvmci/common/patches/jdk.vm.ci.hotspot/jdk/vm/ci/hotspot/PublicMetaspaceWrapperObject.java 2016-05-04 09:44:00.000000000 -1000 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.vm.ci.hotspot; + +/** + * A public available version of MetaspaceWrapperObject interface. + */ +public interface PublicMetaspaceWrapperObject extends MetaspaceWrapperObject { }