# HG changeset patch # User Doug Simon # Date 1432070167 -7200 # Node ID 1da7aef31a08653ea26a95f49c94d7d62439f860 # Parent b3f1d8b2303759cf8a49a814f1f3b040d217e917 created com.oracle.graal.hotspot.jvmci package and moved classes destined for future JVMCI module into it (JBS:GRAAL-53) diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/DataPatchInConstantsTest.java --- a/graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/DataPatchInConstantsTest.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/DataPatchInConstantsTest.java Tue May 19 23:16:07 2015 +0200 @@ -34,6 +34,7 @@ import com.oracle.graal.asm.amd64.*; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.nodes.CompressionNode.CompressionOp; import com.oracle.graal.hotspot.nodes.type.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizationStub.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizationStub.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizationStub.java Tue May 19 23:16:07 2015 +0200 @@ -26,6 +26,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.stubs.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Tue May 19 23:16:07 2015 +0200 @@ -39,6 +39,7 @@ import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Tue May 19 23:16:07 2015 +0200 @@ -33,6 +33,7 @@ import com.oracle.graal.api.runtime.*; import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.word.*; import com.oracle.graal.phases.util.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBinaryConsumer.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBinaryConsumer.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBinaryConsumer.java Tue May 19 23:16:07 2015 +0200 @@ -27,7 +27,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.AMD64Assembler.AMD64MIOp; import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.amd64.*; import com.oracle.graal.lir.asm.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBytecodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBytecodeLIRBuilder.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBytecodeLIRBuilder.java Tue May 19 23:16:07 2015 +0200 @@ -28,7 +28,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.hotspot.amd64.AMD64HotSpotLIRGenerator.SaveRbp; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.StandardOp.NoOp; import com.oracle.graal.lir.gen.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCardTableAddressOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCardTableAddressOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCardTableAddressOp.java Tue May 19 23:16:07 2015 +0200 @@ -26,6 +26,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.amd64.*; import com.oracle.graal.lir.asm.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCardTableShiftOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCardTableShiftOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCardTableShiftOp.java Tue May 19 23:16:07 2015 +0200 @@ -26,6 +26,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.amd64.*; import com.oracle.graal.lir.asm.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCounterOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCounterOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCounterOp.java Tue May 19 23:16:07 2015 +0200 @@ -30,6 +30,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java Tue May 19 23:16:07 2015 +0200 @@ -37,6 +37,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; public class AMD64HotSpotForeignCallsProvider extends HotSpotHostForeignCallsProvider { diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Tue May 19 23:16:07 2015 +0200 @@ -40,8 +40,9 @@ import com.oracle.graal.compiler.common.spi.*; import com.oracle.graal.debug.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; import com.oracle.graal.hotspot.debug.*; +import com.oracle.graal.hotspot.jvmci.*; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLoweringProvider.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLoweringProvider.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLoweringProvider.java Tue May 19 23:16:07 2015 +0200 @@ -26,6 +26,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Tue May 19 23:16:07 2015 +0200 @@ -32,8 +32,8 @@ import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; import com.oracle.graal.compiler.common.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.MoveOp; import com.oracle.graal.lir.amd64.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Tue May 19 23:16:07 2015 +0200 @@ -41,7 +41,7 @@ import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.amd64.AMD64HotSpotLIRGenerator.SaveRbp; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.lir.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotPushInterpreterFrameOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotPushInterpreterFrameOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotPushInterpreterFrameOp.java Tue May 19 23:16:07 2015 +0200 @@ -29,7 +29,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.amd64.*; import com.oracle.graal.lir.asm.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Tue May 19 23:16:07 2015 +0200 @@ -32,7 +32,7 @@ import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; public class AMD64HotSpotRegisterConfig implements RegisterConfig { diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotReturnOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotReturnOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotReturnOp.java Tue May 19 23:16:07 2015 +0200 @@ -27,7 +27,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.BlockEndOp; import com.oracle.graal.lir.asm.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java Tue May 19 23:16:07 2015 +0200 @@ -29,7 +29,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.amd64.*; import com.oracle.graal.lir.asm.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java Tue May 19 23:16:07 2015 +0200 @@ -24,7 +24,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.amd64.AMD64Call.DirectCallOp; import com.oracle.graal.lir.asm.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java Tue May 19 23:16:07 2015 +0200 @@ -25,7 +25,7 @@ import com.oracle.graal.amd64.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.amd64.AMD64Call.DirectCallOp; import com.oracle.graal.lir.asm.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64IndirectCallOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64IndirectCallOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64IndirectCallOp.java Tue May 19 23:16:07 2015 +0200 @@ -29,7 +29,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.amd64.*; import com.oracle.graal.lir.amd64.AMD64Call.IndirectCallOp; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64UncommonTrapStub.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64UncommonTrapStub.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64UncommonTrapStub.java Tue May 19 23:16:07 2015 +0200 @@ -26,6 +26,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.stubs.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/GenGraalRuntimeInlineHpp.java --- a/graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/GenGraalRuntimeInlineHpp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/GenGraalRuntimeInlineHpp.java Tue May 19 23:16:07 2015 +0200 @@ -136,7 +136,7 @@ out.printf(" if (strncmp(name, \"PrintFlags\", %d) == 0) {%n", len); out.println(" if (value == '+') {"); out.println(" if (check_only) {"); - out.println(" TempNewSymbol name = SymbolTable::new_symbol(\"Lcom/oracle/graal/hotspot/HotSpotOptions;\", CHECK_(true));"); + out.println(" TempNewSymbol name = SymbolTable::new_symbol(\"Lcom/oracle/graal/hotspot/jvmci/HotSpotOptions;\", CHECK_(true));"); out.println(" hotSpotOptionsClass = SystemDictionary::resolve_or_fail(name, true, CHECK_(true));"); out.println(" }"); out.println(" set_option_helper(hotSpotOptionsClass, name, name_len, Handle(), '?', Handle(), 0L);"); @@ -186,7 +186,7 @@ @SuppressWarnings("unchecked") static SortedMap getOptions() throws Exception { - Field field = Class.forName("com.oracle.graal.hotspot.HotSpotOptionsLoader").getDeclaredField("options"); + Field field = Class.forName("com.oracle.graal.hotspot.jvmci.HotSpotOptionsLoader").getDeclaredField("options"); field.setAccessible(true); SortedMap options = (SortedMap) field.get(null); diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Tue May 19 23:16:07 2015 +0200 @@ -42,6 +42,7 @@ import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Tue May 19 23:16:07 2015 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.api.runtime.*; import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.word.*; import com.oracle.graal.nodes.spi.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCounterOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCounterOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCounterOp.java Tue May 19 23:16:07 2015 +0200 @@ -32,6 +32,7 @@ import com.oracle.graal.asm.sparc.SPARCMacroAssembler.ScratchRegister; import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotForeignCallsProvider.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotForeignCallsProvider.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotForeignCallsProvider.java Tue May 19 23:16:07 2015 +0200 @@ -35,6 +35,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; public class SPARCHotSpotForeignCallsProvider extends HotSpotHostForeignCallsProvider { diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Tue May 19 23:16:07 2015 +0200 @@ -36,8 +36,9 @@ import com.oracle.graal.compiler.common.spi.*; import com.oracle.graal.compiler.sparc.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; import com.oracle.graal.hotspot.debug.*; +import com.oracle.graal.hotspot.jvmci.*; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotMove.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotMove.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotMove.java Tue May 19 23:16:07 2015 +0200 @@ -37,8 +37,8 @@ import com.oracle.graal.asm.sparc.SPARCMacroAssembler.ScratchRegister; import com.oracle.graal.compiler.common.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.MoveOp; import com.oracle.graal.lir.asm.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java Tue May 19 23:16:07 2015 +0200 @@ -33,7 +33,7 @@ import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.gen.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java Tue May 19 23:16:07 2015 +0200 @@ -31,7 +31,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.framemap.*; import com.oracle.graal.sparc.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotReturnOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotReturnOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotReturnOp.java Tue May 19 23:16:07 2015 +0200 @@ -26,7 +26,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.sparc.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.sparc.SPARCControlFlow.ReturnOp; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java Tue May 19 23:16:07 2015 +0200 @@ -28,7 +28,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.sparc.*; import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.gen.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectStaticCallOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectStaticCallOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectStaticCallOp.java Tue May 19 23:16:07 2015 +0200 @@ -24,7 +24,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.sparc.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.sparc.SPARCCall.DirectCallOp; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java Tue May 19 23:16:07 2015 +0200 @@ -28,7 +28,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.sparc.*; import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.sparc.SPARCCall.DirectCallOp; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java Tue May 19 23:16:07 2015 +0200 @@ -29,7 +29,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.sparc.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.sparc.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Tue May 19 23:16:07 2015 +0200 @@ -36,7 +36,7 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.graph.iterators.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.phases.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java Tue May 19 23:16:07 2015 +0200 @@ -30,7 +30,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.test.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; /** * The following tests perform object/array equality and assignments in various ways. The selected diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/DataPatchTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/DataPatchTest.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/DataPatchTest.java Tue May 19 23:16:07 2015 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.compiler.test.*; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.nodes.CompressionNode.CompressionOp; import com.oracle.graal.nodeinfo.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java Tue May 19 23:16:07 2015 +0200 @@ -36,7 +36,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graphbuilderconf.*; import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.java.*; import com.oracle.graal.nodes.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java Tue May 19 23:16:07 2015 +0200 @@ -27,7 +27,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.test.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; public class HotSpotNmethodTest extends GraalCompilerTest { diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotResolvedJavaFieldTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotResolvedJavaFieldTest.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotResolvedJavaFieldTest.java Tue May 19 23:16:07 2015 +0200 @@ -22,14 +22,14 @@ */ package com.oracle.graal.hotspot.test; -import static com.oracle.graal.hotspot.meta.HotSpotResolvedObjectTypeImpl.*; +import static com.oracle.graal.hotspot.jvmci.HotSpotResolvedObjectTypeImpl.*; import java.lang.reflect.*; import org.junit.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; /** * Tests {@link HotSpotResolvedJavaField} functionality. diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotResolvedObjectTypeTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotResolvedObjectTypeTest.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotResolvedObjectTypeTest.java Tue May 19 23:16:07 2015 +0200 @@ -24,7 +24,7 @@ import org.junit.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; /** * Tests {@link HotSpotResolvedJavaMethod} functionality. diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java Tue May 19 23:16:07 2015 +0200 @@ -29,7 +29,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.test.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Tue May 19 23:16:07 2015 +0200 @@ -33,7 +33,7 @@ import com.oracle.graal.debug.internal.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.CompileTheWorld.Config; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions; import com.oracle.graal.printer.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Tue May 19 23:16:07 2015 +0200 @@ -35,7 +35,7 @@ import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.phases.*; import com.oracle.graal.hotspot.replacements.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Tue May 19 23:16:07 2015 +0200 @@ -32,6 +32,7 @@ import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.debug.internal.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.phases.*; import com.oracle.graal.hotspot.replacements.arraycopy.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java Tue May 19 23:16:07 2015 +0200 @@ -31,6 +31,7 @@ import java.util.*; import java.util.concurrent.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.sun.management.ThreadMXBean; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Tue May 19 23:16:07 2015 +0200 @@ -43,10 +43,10 @@ import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.debug.internal.*; -import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.events.*; import com.oracle.graal.hotspot.events.EventProvider.CompilationEvent; import com.oracle.graal.hotspot.events.EventProvider.CompilerFailureEvent; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.phases.*; import com.oracle.graal.lir.asm.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Tue May 19 23:16:07 2015 +0200 @@ -43,7 +43,7 @@ import com.oracle.graal.compiler.common.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.internal.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.options.*; import com.oracle.graal.options.OptionUtils.OptionConsumer; import com.oracle.graal.options.OptionValue.OverrideScope; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java Tue May 19 23:16:07 2015 +0200 @@ -31,6 +31,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.compiler.target.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.replacements.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledCode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledCode.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot; - -import java.nio.*; -import java.util.*; -import java.util.stream.*; -import java.util.stream.Stream.Builder; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CompilationResult.CodeAnnotation; -import com.oracle.graal.api.code.CompilationResult.CodeComment; -import com.oracle.graal.api.code.CompilationResult.DataPatch; -import com.oracle.graal.api.code.CompilationResult.ExceptionHandler; -import com.oracle.graal.api.code.CompilationResult.Infopoint; -import com.oracle.graal.api.code.CompilationResult.JumpTable; -import com.oracle.graal.api.code.CompilationResult.Mark; -import com.oracle.graal.api.code.CompilationResult.Site; - -/** - * A {@link CompilationResult} with additional HotSpot-specific information required for installing - * the code in HotSpot's code cache. - */ -public abstract class HotSpotCompiledCode { - - public final CompilationResult comp; - - public final Site[] sites; - public final ExceptionHandler[] exceptionHandlers; - public final Comment[] comments; - - public final byte[] dataSection; - public final int dataSectionAlignment; - public final DataPatch[] dataSectionPatches; - - 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(CompilationResult compResult) { - this.comp = compResult; - sites = getSortedSites(compResult); - if (compResult.getExceptionHandlers().isEmpty()) { - exceptionHandlers = null; - } else { - exceptionHandlers = compResult.getExceptionHandlers().toArray(new ExceptionHandler[compResult.getExceptionHandlers().size()]); - } - List annotations = compResult.getAnnotations(); - comments = new Comment[annotations.size()]; - if (!annotations.isEmpty()) { - for (int i = 0; i < comments.length; i++) { - CodeAnnotation annotation = annotations.get(i); - String text; - if (annotation instanceof CodeComment) { - CodeComment codeComment = (CodeComment) annotation; - text = codeComment.value; - } else if (annotation instanceof JumpTable) { - JumpTable jumpTable = (JumpTable) annotation; - text = "JumpTable [" + jumpTable.low + " .. " + jumpTable.high + "]"; - } else { - text = annotation.toString(); - } - comments[i] = new Comment(annotation.position, text); - } - } - assert validateFrames(); - - DataSection data = compResult.getDataSection(); - data.finalizeLayout(); - dataSection = new byte[data.getSectionSize()]; - - ByteBuffer buffer = ByteBuffer.wrap(dataSection).order(ByteOrder.nativeOrder()); - Builder patchBuilder = Stream.builder(); - data.buildDataSection(buffer, patchBuilder); - - dataSectionAlignment = data.getSectionAlignment(); - dataSectionPatches = patchBuilder.build().toArray(len -> new DataPatch[len]); - } - - /** - * Ensure that all the frames passed into HotSpot 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(false); - } - } - } - return true; - } - - static class SiteComparator implements Comparator { - - public int compare(Site s1, Site s2) { - if (s1.pcOffset == s2.pcOffset && (s1 instanceof Mark ^ s2 instanceof Mark)) { - return s1 instanceof Mark ? -1 : 1; - } - return s1.pcOffset - s2.pcOffset; - } - } - - private static Site[] getSortedSites(CompilationResult target) { - List[] lists = new List[]{target.getInfopoints(), target.getDataPatches(), target.getMarks()}; - int count = 0; - for (List list : lists) { - count += list.size(); - } - Site[] result = new Site[count]; - int pos = 0; - for (List list : lists) { - for (Object elem : list) { - result[pos++] = (Site) elem; - } - } - Arrays.sort(result, new SiteComparator()); - return result; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledNmethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledNmethod.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.hotspot.meta.*; - -import edu.umd.cs.findbugs.annotations.*; - -/** - * {@link HotSpotCompiledCode} destined for installation as an nmethod. - */ -public final class HotSpotCompiledNmethod extends HotSpotCompiledCode { - - public final HotSpotResolvedJavaMethod method; - public final int entryBCI; - public final int id; - public final long graalEnv; - - /** - * 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("UWF_UNWRITTEN_FIELD") private String installationFailureMessage; - - public HotSpotCompiledNmethod(HotSpotResolvedJavaMethod method, CompilationResult compResult) { - this(method, compResult, 0L); - } - - public HotSpotCompiledNmethod(HotSpotResolvedJavaMethod method, CompilationResult compResult, long graalEnv) { - super(compResult); - this.method = method; - this.entryBCI = compResult.getEntryBCI(); - this.id = compResult.getId(); - this.graalEnv = graalEnv; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[" + id + ":" + method.format("%H.%n(%p)%r@") + entryBCI + "]"; - } - - public String getInstallationFailureMessage() { - return installationFailureMessage; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub.java Tue May 19 23:16:07 2015 +0200 @@ -29,19 +29,15 @@ import com.oracle.graal.api.code.CompilationResult.ConstantReference; import com.oracle.graal.api.code.CompilationResult.DataPatch; import com.oracle.graal.api.code.CompilationResult.Infopoint; -import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.hotspot.stubs.*; +import com.oracle.graal.hotspot.jvmci.*; /** * {@link HotSpotCompiledCode} destined for installation as a RuntimeStub. */ public final class HotSpotCompiledRuntimeStub extends HotSpotCompiledCode { - public final String stubName; - - public HotSpotCompiledRuntimeStub(Stub stub, CompilationResult compResult) { + public HotSpotCompiledRuntimeStub(CompilationResult compResult) { super(compResult); - this.stubName = stub.toString(); assert checkStubInvariants(compResult); } @@ -83,6 +79,6 @@ @Override public String toString() { - return stubName != null ? stubName : super.toString(); + return String.valueOf(comp.getName()); } } diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCounterOp.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCounterOp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCounterOp.java Tue May 19 23:16:07 2015 +0200 @@ -31,6 +31,7 @@ import com.oracle.graal.asm.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.hotspot.debug.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.lir.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkageImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkageImpl.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkageImpl.java Tue May 19 23:16:07 2015 +0200 @@ -31,6 +31,7 @@ import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.target.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.word.*; @@ -38,17 +39,7 @@ /** * The details required to link a HotSpot runtime or stub call. */ -public class HotSpotForeignCallLinkageImpl implements HotSpotForeignCallLinkage, HotSpotProxified { - - /** - * The descriptor of the call. - */ - private final ForeignCallDescriptor descriptor; - - /** - * The entry point address of this call's target. - */ - private long address; +public class HotSpotForeignCallLinkageImpl extends HotSpotForeignCallTarget implements HotSpotForeignCallLinkage, HotSpotProxified { /** * Non-null (eventually) iff this is a call to a compiled {@linkplain Stub stub}. @@ -134,10 +125,10 @@ public HotSpotForeignCallLinkageImpl(ForeignCallDescriptor descriptor, long address, RegisterEffect effect, Transition transition, CallingConvention outgoingCallingConvention, CallingConvention incomingCallingConvention, boolean reexecutable, LocationIdentity... killedLocations) { + super(descriptor, address); this.address = address; this.effect = effect; this.transition = transition; - this.descriptor = descriptor; this.outgoingCallingConvention = outgoingCallingConvention; this.incomingCallingConvention = incomingCallingConvention; this.reexecutable = reexecutable; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Tue May 19 23:16:07 2015 +0200 @@ -45,9 +45,9 @@ import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.CompileTheWorld.Config; -import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.debug.*; import com.oracle.graal.hotspot.events.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.logging.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.options.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeProvider.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeProvider.java Tue May 19 23:16:07 2015 +0200 @@ -26,7 +26,7 @@ import com.oracle.graal.api.code.stack.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.runtime.*; -import com.oracle.graal.hotspot.bridge.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.runtime.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java Tue May 19 23:16:07 2015 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.api.runtime.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.nodes.spi.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLIRGenerator.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLIRGenerator.java Tue May 19 23:16:07 2015 +0200 @@ -25,7 +25,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.lir.StandardOp.SaveRegistersOp; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +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 com.oracle.graal.hotspot; - -import static com.oracle.graal.compiler.GraalDebugConfig.*; -import static com.oracle.graal.hotspot.HotSpotOptionsLoader.*; -import static java.lang.Double.*; - -import com.oracle.graal.api.runtime.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.options.*; -import com.oracle.graal.options.OptionUtils.OptionConsumer; - -//JaCoCo Exclude - -/** - * Sets Graal options from the HotSpot command line. Such options are distinguished by the - * {@link #GRAAL_OPTION_PREFIX} prefix. - */ -public class HotSpotOptions { - - private static final String GRAAL_OPTION_PREFIX = "-G:"; - - /** - * Parses the Graal specific options specified to HotSpot (e.g., on the command line). - */ - private static native void parseVMOptions(); - - static { - parseVMOptions(); - - assert !Debug.Initialization.isDebugInitialized() : "The class " + Debug.class.getName() + " must not be initialized before the Graal runtime has been initialized. " + - "This can be fixed by placing a call to " + Graal.class.getName() + ".runtime() on the path that triggers initialization of " + Debug.class.getName(); - if (areDebugScopePatternsEnabled()) { - System.setProperty(Debug.Initialization.INITIALIZER_PROPERTY_NAME, "true"); - } - if ("".equals(Meter.getValue())) { - System.setProperty(Debug.ENABLE_UNSCOPED_METRICS_PROPERTY_NAME, "true"); - } - if ("".equals(Time.getValue())) { - System.setProperty(Debug.ENABLE_UNSCOPED_TIMERS_PROPERTY_NAME, "true"); - } - if ("".equals(TrackMemUse.getValue())) { - System.setProperty(Debug.ENABLE_UNSCOPED_MEM_USE_TRACKERS_PROPERTY_NAME, "true"); - } - } - - /** - * Ensures {@link HotSpotOptions} is initialized. - */ - public static void initialize() { - } - - /** - * Helper for the VM code called by {@link #parseVMOptions()}. - * - * @param name the name of a parsed option - * @param option the object encapsulating the option - * @param spec specification of boolean option value, type of option value or action to take - */ - static void setOption(String name, OptionValue option, char spec, String stringValue, long primitiveValue) { - switch (spec) { - case '+': - option.setValue(Boolean.TRUE); - break; - case '-': - option.setValue(Boolean.FALSE); - break; - case '?': - OptionUtils.printFlags(options, GRAAL_OPTION_PREFIX); - break; - case ' ': - OptionUtils.printNoMatchMessage(options, name, GRAAL_OPTION_PREFIX); - break; - case 'i': - option.setValue((int) primitiveValue); - break; - case 'f': - option.setValue((float) longBitsToDouble(primitiveValue)); - break; - case 'd': - option.setValue(longBitsToDouble(primitiveValue)); - break; - case 's': - option.setValue(stringValue); - break; - } - } - - /** - * Parses a given option value specification. - * - * @param option the specification of an option and its value - * @param setter the object to notify of the parsed option and value. If null, the - * {@link OptionValue#setValue(Object)} method of the specified option is called - * instead. - */ - public static boolean parseOption(String option, OptionConsumer setter) { - return OptionUtils.parseOption(options, option, GRAAL_OPTION_PREFIX, setter); - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptionsLoader.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptionsLoader.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +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 com.oracle.graal.hotspot; - -import java.util.*; - -import com.oracle.graal.api.runtime.*; -import com.oracle.graal.options.*; - -/** - * Helper class for separating loading of options from option initialization at runtime. - */ -class HotSpotOptionsLoader { - static final SortedMap options = new TreeMap<>(); - - /** - * Initializes {@link #options} from {@link Options} services. - */ - static { - for (Options opts : Services.load(Options.class)) { - for (OptionDescriptor desc : opts) { - if (isHotSpotOption(desc)) { - String name = desc.getName(); - OptionDescriptor existing = options.put(name, desc); - assert existing == null : "Option named \"" + name + "\" has multiple definitions: " + existing.getLocation() + " and " + desc.getLocation(); - } - } - } - } - - /** - * Determines if a given option is a HotSpot command line option. - */ - private static boolean isHotSpotOption(OptionDescriptor desc) { - return desc.getClass().getName().startsWith("com.oracle.graal"); - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotProxified.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotProxified.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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 com.oracle.graal.hotspot; - -/** - * Marker interface for classes whose values are proxied during replay compilation capture. - */ -public interface HotSpotProxified { -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReferenceMap.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReferenceMap.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,509 +0,0 @@ -/* - * Copyright (c) 2009, 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 com.oracle.graal.hotspot; - -import java.util.*; - -import com.oracle.graal.api.code.CodeUtil.RefMapFormatter; -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; - -public final class HotSpotReferenceMap extends ReferenceMap { - - static final int OOP64 = 0b1010; - static final int OOP32 = 0b01; - static final int NARROW_LOW = OOP32; - static final int NARROW_HIGH = OOP32 << 2; - static final int NARROW_BOTH = NARROW_LOW | NARROW_HIGH; - - private enum MapEntry { - NoReference(0), - WideOop(OOP64), - NarrowOopLowerHalf(NARROW_LOW), - NarrowOopUpperHalf(NARROW_HIGH), - TwoNarrowOops(NARROW_BOTH), - Illegal(-1); - - MapEntry(int pattern) { - this.pattern = pattern; - } - - final int pattern; - - /** - * Create enum values from OopMap. - *

- * These bits can have the following values (MSB first): - * - *

-         * 0000 - contains no references
-         * 1010 - contains a wide oop
-         * 0001 - contains a narrow oop in the lower half
-         * 0101 - contains a narrow oop in the upper half
-         * 0101 - contains two narrow oops
-         * 
- * - * @see HotSpotReferenceMap#registerRefMap - * @see HotSpotReferenceMap#frameRefMap - */ - static MapEntry getFromBits(int idx, HotSpotOopMap set) { - int n = set.get(idx); - switch (n) { - case 0: - return NoReference; - case OOP64: - return WideOop; - case NARROW_LOW: - return NarrowOopLowerHalf; - case NARROW_HIGH: - return NarrowOopUpperHalf; - case NARROW_BOTH: - return TwoNarrowOops; - default: - return Illegal; - } - } - - String toBitString() { - int bits = toBit(this); - if (bits == -1) { - return "---"; - } - return String.format("%3s", Integer.toBinaryString(bits)).replace(' ', '0'); - } - - static int toBit(MapEntry type) { - return type.pattern; - } - } - - /** - * A specialized bit set that represents both wide and narrow oops in an efficient manner. The - * map consists of 4 bit entries that represent 8 bytes of memory. - * - */ - class HotSpotOopMap implements Cloneable { - - /** - * Each entry is 4 bits long and covers 8 bytes of memory. - */ - private static final int BITS_PER_ENTRY = 4; - private static final int BITS_PER_ELEMENT = 64; - - public HotSpotOopMap(int i) { - words = new long[(i * BITS_PER_ENTRY + BITS_PER_ELEMENT) / BITS_PER_ELEMENT]; - } - - public HotSpotOopMap(HotSpotOopMap other) { - words = other.words.clone(); - } - - private long[] words; - - private int get(int i) { - return getEntry(i); - } - - public void or(HotSpotOopMap src) { - if (words.length < src.words.length) { - long[] newWords = new long[src.words.length]; - System.arraycopy(src.words, 0, newWords, 0, src.words.length); - for (int i = 0; i < words.length; i++) { - newWords[i] |= words[i]; - } - words = newWords; - } else { - for (int i = 0; i < src.words.length; i++) { - words[i] |= src.words[i]; - } - } - } - - private void setOop(int regIdx) { - setEntry(regIdx, OOP64); - } - - public int size() { - return words.length * BITS_PER_ELEMENT / BITS_PER_ENTRY; - } - - @Override - public HotSpotOopMap clone() { - return new HotSpotOopMap(this); - } - - private void setNarrowOop(int offset) { - setNarrowEntry(offset, OOP32); - } - - private void setEntry(int regIdx, int value) { - assert regIdx % 2 == 0 : "must be alinged"; - int bitIndex = (regIdx >> 1) * BITS_PER_ENTRY; - int wordIndex = bitIndex / BITS_PER_ELEMENT; - int shift = bitIndex - wordIndex * BITS_PER_ELEMENT; - if (wordIndex >= words.length) { - if (value == 0) { - // Nothing to do since bits are clear - return; - } - words = Arrays.copyOf(words, wordIndex + 1); - } - assert verifyUpdate(this, this); - long orig = words[wordIndex]; - words[wordIndex] = (orig & (~(0b1111L << shift))) | ((long) value << shift); - assert get(regIdx / 2) == value; - assert verifyUpdate(this, this); - } - - private void setNarrowEntry(int offset, int value) { - int regIdx = offset >> 1; - boolean low = offset % 2 == 0; - int bitIndex = regIdx * BITS_PER_ENTRY; - int wordIndex = bitIndex / BITS_PER_ELEMENT; - int shift = bitIndex - wordIndex * BITS_PER_ELEMENT; - if (wordIndex >= words.length) { - if (value == 0) { - // Nothing to do since bits are clear - return; - } - words = Arrays.copyOf(words, wordIndex + 1); - } - long originalValue = words[wordIndex]; - int current = ((int) (originalValue >> shift)) & 0b1111; - if (current == OOP64) { - current = 0; - } - long newValue; - if (value != 0) { - newValue = current | (low ? value : (value << 2)); - } else { - newValue = current & (low ? 0b1100 : 0b0011); - } - long masked = originalValue & (~(0b1111L << shift)); - words[wordIndex] = masked | (newValue << shift); - assert verifyUpdate(this, this); - } - - private int getEntry(int regIdx) { - int bitIndex = regIdx * BITS_PER_ENTRY; - int wordIndex = bitIndex / BITS_PER_ELEMENT; - int shift = bitIndex - wordIndex * BITS_PER_ELEMENT; - return ((int) (words[wordIndex] >>> shift)) & 0b1111; - } - - @Override - public boolean equals(Object other) { - if (this == other) { - return true; - } - - if (other instanceof HotSpotOopMap) { - HotSpotOopMap otherMap = (HotSpotOopMap) other; - int limit = Math.min(words.length, otherMap.words.length); - for (int i = 0; i < limit; i++) { - if (words[i] != otherMap.words[i]) { - return false; - } - } - for (int i = limit; i < words.length; i++) { - if (words[i] != 0) { - return false; - } - } - for (int i = limit; i < otherMap.words.length; i++) { - if (otherMap.words[i] != 0) { - return false; - } - } - return true; - } - return false; - } - - @Override - public int hashCode() { - long h = 1234; - for (int i = words.length; --i >= 0;) { - h ^= words[i] * (i + 1); - } - return (int) ((h >> 32) ^ h); - } - - @Override - public String toString() { - int count = 0; - StringBuilder sb = new StringBuilder(); - sb.append("["); - for (int idx = 0; idx < size(); idx++) { - MapEntry dstType = MapEntry.getFromBits(idx, this); - if (dstType == MapEntry.NoReference) { - continue; - } - if (count > 0) { - sb.append(", "); - } - if (dstType == MapEntry.Illegal) { - int value = get(idx); - sb.append("0x"); - sb.append(Integer.toHexString(value)); - } else { - sb.append(idx); - sb.append(':'); - sb.append(dstType); - } - count++; - } - sb.append("]"); - return sb.toString(); - } - } - - /** - * Contains 3 bits per scalar register, and n*3 bits per n-word vector register (e.g., on a - * 64-bit system, a 256-bit vector register requires 12 reference map bits). - *

- * These bits can have the following values (LSB first): - * - *

-     * 000 - contains no references
-     * 100 - contains a wide oop
-     * 110 - contains a narrow oop in the lower half
-     * 101 - contains a narrow oop in the upper half
-     * 111 - contains two narrow oops
-     * 
- */ - private final HotSpotOopMap registerRefMap; - - /** - * Contains 3 bits per stack word. - *

- * These bits can have the following values (LSB first): - * - *

-     * 000 - contains no references
-     * 100 - contains a wide oop
-     * 110 - contains a narrow oop in the lower half
-     * 101 - contains a narrow oop in the upper half
-     * 111 - contains two narrow oops
-     * 
- */ - private final HotSpotOopMap frameRefMap; - - private final TargetDescription target; - - public HotSpotReferenceMap(int registerCount, int frameSlotCount, TargetDescription target) { - if (registerCount > 0) { - this.registerRefMap = new HotSpotOopMap(registerCount); - } else { - this.registerRefMap = null; - } - this.frameRefMap = new HotSpotOopMap(frameSlotCount); - this.target = target; - } - - private HotSpotReferenceMap(HotSpotReferenceMap other) { - this.registerRefMap = other.registerRefMap.clone(); - this.frameRefMap = other.frameRefMap.clone(); - this.target = other.target; - } - - @Override - public ReferenceMap clone() { - return new HotSpotReferenceMap(this); - } - - // setters - @Override - public void setRegister(int idx, LIRKind kind) { - set(registerRefMap, idx * 2, kind); - } - - @Override - public void setStackSlot(int offset, LIRKind kind) { - assert offset % bytesPerElement(kind) == 0 : "unaligned value in ReferenceMap"; - set(frameRefMap, offset / 4, kind); - } - - private void set(HotSpotOopMap refMap, int index, LIRKind kind) { - if (kind.isDerivedReference()) { - throw new InternalError("derived reference cannot be inserted in ReferenceMap"); - } - - int bytesPerElement = bytesPerElement(kind); - int length = kind.getPlatformKind().getVectorLength(); - if (bytesPerElement == 8) { - for (int i = 0; i < length; i++) { - if (kind.isReference(i)) { - refMap.setOop(index + i * 2); - } - } - } else if (bytesPerElement == 4) { - for (int i = 0; i < length; i++) { - if (kind.isReference(i)) { - refMap.setNarrowOop(index + i); - } - } - } else { - assert kind.isValue() : "unknown reference kind " + kind; - } - } - - private int bytesPerElement(LIRKind kind) { - PlatformKind platformKind = kind.getPlatformKind(); - return target.getSizeInBytes(platformKind) / platformKind.getVectorLength(); - } - - public HotSpotOopMap getFrameMap() { - return frameRefMap == null ? null : (HotSpotOopMap) frameRefMap.clone(); - } - - public HotSpotOopMap getRegisterMap() { - return registerRefMap == null ? null : (HotSpotOopMap) registerRefMap.clone(); - } - - static MapEntry[] entries(HotSpotOopMap fixedMap) { - MapEntry[] result = new MapEntry[fixedMap.size()]; - for (int idx = 0; idx < fixedMap.size(); idx++) { - MapEntry dstType = MapEntry.getFromBits(idx, fixedMap); - result[idx] = dstType; - } - return result; - } - - private static boolean verifyUpdate(HotSpotOopMap dst, HotSpotOopMap src) { - return verifyUpdate(dst, src, true); - } - - private static boolean verifyUpdate(HotSpotOopMap dst, HotSpotOopMap src, boolean doAssert) { - for (int idx = 0; idx < Math.min(src.size(), dst.size()); idx++) { - if (!verifyUpdateEntry(idx, dst, src, doAssert)) { - return false; - } - } - return true; - } - - private static boolean verifyUpdateEntry(int idx, HotSpotOopMap dst, HotSpotOopMap src, boolean doAssert) { - MapEntry dstType = MapEntry.getFromBits(idx, dst); - MapEntry srcType = MapEntry.getFromBits(idx, src); - - if (dstType == MapEntry.Illegal || srcType == MapEntry.Illegal) { - assert !doAssert : String.format("Illegal RefMap bit pattern: %s (0b%s), %s (0b%s)", dstType, dstType.toBitString(), srcType, srcType.toBitString()); - return false; - } - switch (dstType) { - case NoReference: - return true; - case WideOop: - switch (srcType) { - case NoReference: - case WideOop: - return true; - default: - assert false : String.format("Illegal RefMap combination: %s (0b%s), %s (0b%s)", dstType, dstType.toBitString(), srcType, srcType.toBitString()); - return false; - } - case TwoNarrowOops: - case NarrowOopLowerHalf: - case NarrowOopUpperHalf: - switch (srcType) { - case TwoNarrowOops: - case NarrowOopLowerHalf: - case NarrowOopUpperHalf: - case NoReference: - return true; - default: - assert false : String.format("Illegal RefMap combination: %s (0b%s), %s (0b%s)", dstType, dstType.toBitString(), srcType, srcType.toBitString()); - return false; - } - default: - return false; - } - } - - @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 (this.frameRefMap.equals(that.frameRefMap) && Objects.equals(this.registerRefMap, that.registerRefMap) && this.target.equals(that.target)) { - return true; - } - } - return false; - } - - @Override - public boolean hasRegisterRefMap() { - return registerRefMap != null && registerRefMap.size() > 0; - } - - @Override - public boolean hasFrameRefMap() { - return frameRefMap != null && frameRefMap.size() > 0; - } - - @Override - public void appendRegisterMap(StringBuilder sb, RefMapFormatter formatter) { - for (int idx = 0; idx < registerRefMap.size(); idx++) { - MapEntry dstType = MapEntry.getFromBits(idx, registerRefMap); - if (dstType != MapEntry.NoReference) { - sb.append(' ').append(formatter.formatRegister(idx)).append(':').append(dstType); - } - } - } - - @Override - public void appendFrameMap(StringBuilder sb, RefMapFormatter formatter) { - for (int idx = 0; idx < frameRefMap.size(); idx++) { - MapEntry dstType = MapEntry.getFromBits(idx, frameRefMap); - if (dstType != MapEntry.NoReference) { - sb.append(' ').append(formatter.formatStackSlot(idx)).append(':').append(dstType); - } - } - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - if (registerRefMap != null) { - sb.append("Registers = "); - sb.append(registerRefMap); - } - sb.append("Stack = "); - sb.append(frameRefMap); - return sb.toString(); - } - - public void verify() { - assert verifyUpdate(frameRefMap, frameRefMap); - assert registerRefMap == null || verifyUpdate(registerRefMap, registerRefMap); - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java Tue May 19 23:16:07 2015 +0200 @@ -27,6 +27,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.word.*; import com.oracle.graal.phases.util.*; import com.oracle.graal.replacements.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotStackFrameReference.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotStackFrameReference.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +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 com.oracle.graal.hotspot; - -import java.util.*; - -import com.oracle.graal.api.code.stack.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.bridge.*; -import com.oracle.graal.hotspot.meta.*; - -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 long metaspaceMethod; - 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 HotSpotResolvedJavaMethodImpl.fromMetaspace(metaspaceMethod); - } - - @Override - public boolean isMethod(ResolvedJavaMethod method) { - return metaspaceMethod == ((HotSpotResolvedJavaMethodImpl) method).getMetaspaceMethod(); - } - - @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) + "]"; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTargetDescription.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTargetDescription.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTargetDescription.java Tue May 19 23:16:07 2015 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.hotspot; import com.oracle.graal.api.code.*; +import com.oracle.graal.hotspot.jvmci.*; public class HotSpotTargetDescription extends TargetDescription { diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1688 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot; - -import static com.oracle.graal.compiler.common.UnsafeAccess.*; - -import java.lang.reflect.*; -import java.util.*; - -import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.bridge.*; -import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.hotspotvmconfig.*; - -//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 { - - /** - * Determines if the current architecture is included in a given architecture set specification. - * - * @param currentArch - * @param archsSpecification specifies a set of architectures. A zero length value implies all - * architectures. - */ - private static boolean isRequired(String currentArch, String[] archsSpecification) { - if (archsSpecification.length == 0) { - return true; - } - for (String arch : archsSpecification) { - if (arch.equals(currentArch)) { - return true; - } - } - return false; - } - - /** - * Maximum allowed size of allocated area for a frame. - */ - public final int maxFrameSize = 16 * 1024; - - @Override - public String toString() { - return getClass().getSimpleName(); - } - - HotSpotVMConfig(CompilerToVM compilerToVm) { - compilerToVm.initializeConfiguration(this); - assert verifyInitialization(); - - oopEncoding = new CompressEncoding(narrowOopBase, narrowOopShift, logMinObjAlignment()); - klassEncoding = new CompressEncoding(narrowKlassBase, narrowKlassShift, logKlassAlignment); - - codeCacheLowBoundary = unsafe.getAddress(codeCacheHeap + codeHeapMemoryOffset + virtualSpaceLowBoundaryOffset); - codeCacheHighBoundary = unsafe.getAddress(codeCacheHeap + codeHeapMemoryOffset + virtualSpaceHighBoundaryOffset); - - final long barrierSetAddress = unsafe.getAddress(universeCollectedHeap + collectedHeapBarrierSetOffset); - final int kind = unsafe.getInt(barrierSetAddress + barrierSetKindOffset); - if ((kind == barrierSetCardTableModRef) || (kind == barrierSetCardTableExtension) || (kind == barrierSetG1SATBCT) || (kind == barrierSetG1SATBCTLogging)) { - final long base = unsafe.getAddress(barrierSetAddress + cardTableModRefBSByteMapBaseOffset); - assert base != 0 : "unexpected byte_map_base: " + base; - cardtableStartAddress = base; - cardtableShift = cardTableModRefBSCardShift; - } else if ((kind == barrierSetModRef) || (kind == barrierSetOther)) { - // No post barriers - cardtableStartAddress = 0; - cardtableShift = 0; - } else { - cardtableStartAddress = -1; - cardtableShift = -1; - } - - inlineCacheMissStub = inlineCacheMissBlob + unsafe.getInt(inlineCacheMissBlob + codeBlobCodeOffsetOffset); - - assert check(); - assert HotSpotVMConfigVerifier.check(); - } - - /** - * Check that the initialization produces the same result as the values captured through - * vmStructs. - */ - private boolean verifyInitialization() { - /** These fields are set in {@link CompilerToVM#initializeConfiguration}. */ - assert gHotSpotVMStructs != 0; - assert gHotSpotVMTypes != 0; - assert gHotSpotVMIntConstants != 0; - assert gHotSpotVMLongConstants != 0; - - // Fill the VM fields hash map. - HashMap vmFields = new HashMap<>(); - for (VMFields.Field e : new VMFields(gHotSpotVMStructs)) { - vmFields.put(e.getName(), e); - } - - // Fill the VM types hash map. - HashMap vmTypes = new HashMap<>(); - for (VMTypes.Type e : new VMTypes(gHotSpotVMTypes)) { - vmTypes.put(e.getTypeName(), e); - } - - // Fill the VM constants hash map. - HashMap vmConstants = new HashMap<>(); - for (AbstractConstant e : new VMIntConstants(gHotSpotVMIntConstants)) { - vmConstants.put(e.getName(), e); - } - for (AbstractConstant e : new VMLongConstants(gHotSpotVMLongConstants)) { - vmConstants.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 currentArch = 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(currentArch, annotation.archs())) { - continue; - } - throw new IllegalArgumentException("field not found: " + name); - } - - // Make sure the native type is still the type we expect. - if (!type.equals("")) { - if (!type.equals(entry.getTypeString())) { - throw new IllegalArgumentException("compiler expects type " + type + " but field " + name + " is of type " + entry.getTypeString()); - } - } - - switch (annotation.get()) { - case OFFSET: - checkField(f, entry.getOffset()); - break; - case ADDRESS: - checkField(f, entry.getAddress()); - break; - case VALUE: - checkField(f, entry.getValue()); - break; - default: - throw GraalInternalError.shouldNotReachHere("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 IllegalArgumentException("type not found: " + name); - } - switch (annotation.get()) { - case SIZE: - checkField(f, entry.getSize()); - break; - default: - throw GraalInternalError.shouldNotReachHere("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(currentArch, annotation.archs())) { - continue; - } - throw new IllegalArgumentException("constant not found: " + name); - } - checkField(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(currentArch, annotation.archs())) { - continue; - } - throw new IllegalArgumentException("flag not found: " + name); - - } - checkField(f, entry.getValue()); - } - } - return true; - } - - private final CompressEncoding oopEncoding; - private final CompressEncoding klassEncoding; - - public CompressEncoding getOopEncoding() { - return oopEncoding; - } - - public CompressEncoding getKlassEncoding() { - return klassEncoding; - } - - private void checkField(Field field, Object value) { - try { - Class fieldType = field.getType(); - if (fieldType == boolean.class) { - if (value instanceof String) { - assert field.getBoolean(this) == Boolean.valueOf((String) value) : field + " " + value + " " + field.getBoolean(this); - } else if (value instanceof Boolean) { - assert field.getBoolean(this) == (boolean) value : field + " " + value + " " + field.getBoolean(this); - } else if (value instanceof Long) { - assert field.getBoolean(this) == (((long) value) != 0) : field + " " + value + " " + field.getBoolean(this); - } else { - GraalInternalError.shouldNotReachHere(value.getClass().getSimpleName()); - } - } else if (fieldType == int.class) { - if (value instanceof Integer) { - assert field.getInt(this) == (int) value : field + " " + value + " " + field.getInt(this); - } else if (value instanceof Long) { - assert field.getInt(this) == (int) (long) value : field + " " + value + " " + field.getInt(this); - } else { - GraalInternalError.shouldNotReachHere(value.getClass().getSimpleName()); - } - } else if (fieldType == long.class) { - assert field.getLong(this) == (long) value : field + " " + value + " " + field.getLong(this); - } else { - GraalInternalError.shouldNotReachHere(field.toString()); - } - } catch (IllegalAccessException e) { - throw GraalInternalError.shouldNotReachHere(field.toString() + ": " + e); - } - } - - /** - * Gets the host architecture name for the purpose of finding the corresponding - * {@linkplain HotSpotBackendFactory 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; - } - - /** - * VMStructEntry (see vmStructs.hpp). - */ - @HotSpotVMValue(expression = "gHotSpotVMStructs", get = HotSpotVMValue.Type.ADDRESS) @Stable private long gHotSpotVMStructs; - @HotSpotVMValue(expression = "gHotSpotVMStructEntryTypeNameOffset") @Stable private long gHotSpotVMStructEntryTypeNameOffset; - @HotSpotVMValue(expression = "gHotSpotVMStructEntryFieldNameOffset") @Stable private long gHotSpotVMStructEntryFieldNameOffset; - @HotSpotVMValue(expression = "gHotSpotVMStructEntryTypeStringOffset") @Stable private long gHotSpotVMStructEntryTypeStringOffset; - @HotSpotVMValue(expression = "gHotSpotVMStructEntryIsStaticOffset") @Stable private long gHotSpotVMStructEntryIsStaticOffset; - @HotSpotVMValue(expression = "gHotSpotVMStructEntryOffsetOffset") @Stable private long gHotSpotVMStructEntryOffsetOffset; - @HotSpotVMValue(expression = "gHotSpotVMStructEntryAddressOffset") @Stable private long gHotSpotVMStructEntryAddressOffset; - @HotSpotVMValue(expression = "gHotSpotVMStructEntryArrayStride") @Stable private long gHotSpotVMStructEntryArrayStride; - - class VMFields implements Iterable { - - private long address; - - public VMFields(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Field current() { - return new Field(address + gHotSpotVMStructEntryArrayStride * 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; - } - - @Override - public void remove() { - throw GraalInternalError.unimplemented(); - } - }; - } - - class Field { - - private long entryAddress; - - Field(long address) { - this.entryAddress = address; - } - - public String getTypeName() { - long typeNameAddress = unsafe.getAddress(entryAddress + gHotSpotVMStructEntryTypeNameOffset); - return readCString(typeNameAddress); - } - - public String getFieldName() { - long fieldNameAddress = unsafe.getAddress(entryAddress + gHotSpotVMStructEntryFieldNameOffset); - return readCString(fieldNameAddress); - } - - public String getTypeString() { - long typeStringAddress = unsafe.getAddress(entryAddress + gHotSpotVMStructEntryTypeStringOffset); - return readCString(typeStringAddress); - } - - public boolean isStatic() { - return unsafe.getInt(entryAddress + gHotSpotVMStructEntryIsStaticOffset) != 0; - } - - public long getOffset() { - return unsafe.getLong(entryAddress + gHotSpotVMStructEntryOffsetOffset); - } - - public long getAddress() { - return unsafe.getAddress(entryAddress + gHotSpotVMStructEntryAddressOffset); - } - - public String getName() { - String typeName = getTypeName(); - String fieldName = getFieldName(); - return typeName + "::" + fieldName; - } - - public long getValue() { - String type = getTypeString(); - switch (type) { - case "int": - return unsafe.getInt(getAddress()); - case "address": - case "intptr_t": - return unsafe.getAddress(getAddress()); - default: - // All foo* types are addresses. - if (type.endsWith("*")) { - return unsafe.getAddress(getAddress()); - } - throw GraalInternalError.shouldNotReachHere(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). - */ - @HotSpotVMValue(expression = "gHotSpotVMTypes", get = HotSpotVMValue.Type.ADDRESS) @Stable private long gHotSpotVMTypes; - @HotSpotVMValue(expression = "gHotSpotVMTypeEntryTypeNameOffset") @Stable private long gHotSpotVMTypeEntryTypeNameOffset; - @HotSpotVMValue(expression = "gHotSpotVMTypeEntrySuperclassNameOffset") @Stable private long gHotSpotVMTypeEntrySuperclassNameOffset; - @HotSpotVMValue(expression = "gHotSpotVMTypeEntryIsOopTypeOffset") @Stable private long gHotSpotVMTypeEntryIsOopTypeOffset; - @HotSpotVMValue(expression = "gHotSpotVMTypeEntryIsIntegerTypeOffset") @Stable private long gHotSpotVMTypeEntryIsIntegerTypeOffset; - @HotSpotVMValue(expression = "gHotSpotVMTypeEntryIsUnsignedOffset") @Stable private long gHotSpotVMTypeEntryIsUnsignedOffset; - @HotSpotVMValue(expression = "gHotSpotVMTypeEntrySizeOffset") @Stable private long gHotSpotVMTypeEntrySizeOffset; - @HotSpotVMValue(expression = "gHotSpotVMTypeEntryArrayStride") @Stable private long gHotSpotVMTypeEntryArrayStride; - - class VMTypes implements Iterable { - - private long address; - - public VMTypes(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Type current() { - return new Type(address + gHotSpotVMTypeEntryArrayStride * 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; - } - - @Override - public void remove() { - throw GraalInternalError.unimplemented(); - } - }; - } - - class Type { - - private long entryAddress; - - Type(long address) { - this.entryAddress = address; - } - - public String getTypeName() { - long typeNameAddress = unsafe.getAddress(entryAddress + gHotSpotVMTypeEntryTypeNameOffset); - return readCString(typeNameAddress); - } - - public String getSuperclassName() { - long superclassNameAddress = unsafe.getAddress(entryAddress + gHotSpotVMTypeEntrySuperclassNameOffset); - return readCString(superclassNameAddress); - } - - public boolean isOopType() { - return unsafe.getInt(entryAddress + gHotSpotVMTypeEntryIsOopTypeOffset) != 0; - } - - public boolean isIntegerType() { - return unsafe.getInt(entryAddress + gHotSpotVMTypeEntryIsIntegerTypeOffset) != 0; - } - - public boolean isUnsigned() { - return unsafe.getInt(entryAddress + gHotSpotVMTypeEntryIsUnsignedOffset) != 0; - } - - public long getSize() { - return unsafe.getLong(entryAddress + gHotSpotVMTypeEntrySizeOffset); - } - - @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 long address; - protected long nameOffset; - protected 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(nameAddress); - } - - public abstract long getValue(); - } - - /** - * VMIntConstantEntry (see vmStructs.hpp). - */ - @HotSpotVMValue(expression = "gHotSpotVMIntConstants", get = HotSpotVMValue.Type.ADDRESS) @Stable private long gHotSpotVMIntConstants; - @HotSpotVMValue(expression = "gHotSpotVMIntConstantEntryNameOffset") @Stable private long gHotSpotVMIntConstantEntryNameOffset; - @HotSpotVMValue(expression = "gHotSpotVMIntConstantEntryValueOffset") @Stable private long gHotSpotVMIntConstantEntryValueOffset; - @HotSpotVMValue(expression = "gHotSpotVMIntConstantEntryArrayStride") @Stable private long gHotSpotVMIntConstantEntryArrayStride; - - class VMIntConstants implements Iterable { - - private long address; - - public VMIntConstants(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Constant current() { - return new Constant(address + gHotSpotVMIntConstantEntryArrayStride * 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; - } - - @Override - public void remove() { - throw GraalInternalError.unimplemented(); - } - }; - } - - class Constant extends AbstractConstant { - - Constant(long address) { - super(address, gHotSpotVMIntConstantEntryNameOffset, gHotSpotVMIntConstantEntryValueOffset); - } - - @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). - */ - @HotSpotVMValue(expression = "gHotSpotVMLongConstants", get = HotSpotVMValue.Type.ADDRESS) @Stable private long gHotSpotVMLongConstants; - @HotSpotVMValue(expression = "gHotSpotVMLongConstantEntryNameOffset") @Stable private long gHotSpotVMLongConstantEntryNameOffset; - @HotSpotVMValue(expression = "gHotSpotVMLongConstantEntryValueOffset") @Stable private long gHotSpotVMLongConstantEntryValueOffset; - @HotSpotVMValue(expression = "gHotSpotVMLongConstantEntryArrayStride") @Stable private long gHotSpotVMLongConstantEntryArrayStride; - - class VMLongConstants implements Iterable { - - private long address; - - public VMLongConstants(long address) { - this.address = address; - } - - public Iterator iterator() { - return new Iterator() { - - private int index = 0; - - private Constant currentEntry() { - return new Constant(address + gHotSpotVMLongConstantEntryArrayStride * 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; - } - - @Override - public void remove() { - throw GraalInternalError.unimplemented(); - } - }; - } - - class Constant extends AbstractConstant { - - Constant(long address) { - super(address, gHotSpotVMLongConstantEntryNameOffset, gHotSpotVMLongConstantEntryValueOffset); - } - - @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()); - } - } - } - - class Flags implements Iterable { - - private long address; - private long entrySize; - private long typeOffset; - private long nameOffset; - private long addrOffset; - - public 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; - } - - @Override - public void remove() { - throw GraalInternalError.unimplemented(); - } - }; - } - - class Flag { - - private long entryAddress; - - Flag(long address) { - this.entryAddress = address; - } - - public String getType() { - long typeAddress = unsafe.getAddress(entryAddress + typeOffset); - return readCString(typeAddress); - } - - public String getName() { - long nameAddress = unsafe.getAddress(entryAddress + nameOffset); - return readCString(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(getAddr()); - default: - throw GraalInternalError.shouldNotReachHere(getType()); - } - } - - @Override - public String toString() { - return String.format("Flag[type=%s, name=%s, value=%s]", getType(), getName(), getValue()); - } - } - } - - // os information, register layout, code generation, ... - @HotSpotVMValue(expression = "DEBUG_ONLY(1) NOT_DEBUG(0)") @Stable public boolean cAssertions; - public final boolean windowsOs = System.getProperty("os.name", "").startsWith("Windows"); - - @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 = "GraalUseFastLocking") @Stable public boolean useFastLocking; - @HotSpotVMFlag(name = "ForceUnreachable") @Stable public boolean forceUnreachable; - - @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 = "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 = "GraalDeferredInitBarriers") @Stable public boolean useDeferredInitBarriers; - @HotSpotVMFlag(name = "GraalHProfEnabled") @Stable public boolean useHeapProfiler; - - // Compressed Oops related values. - @HotSpotVMFlag(name = "UseCompressedOops") @Stable public boolean useCompressedOops; - @HotSpotVMFlag(name = "UseCompressedClassPointers") @Stable public boolean useCompressedClassPointers; - - @HotSpotVMField(name = "Universe::_narrow_oop._base", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long narrowOopBase; - @HotSpotVMField(name = "Universe::_narrow_oop._shift", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int narrowOopShift; - @HotSpotVMFlag(name = "ObjectAlignmentInBytes") @Stable public int objectAlignment; - - public int logMinObjAlignment() { - return (int) (Math.log(objectAlignment) / Math.log(2)); - } - - @HotSpotVMField(name = "Universe::_narrow_klass._base", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long narrowKlassBase; - @HotSpotVMField(name = "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; - - // X86 specific values - @HotSpotVMField(name = "VM_Version::_cpuFeatures", type = "int", get = HotSpotVMField.Type.VALUE, archs = {"amd64"}) @Stable public int x86CPUFeatures; - @HotSpotVMConstant(name = "VM_Version::CPU_CX8", archs = {"amd64"}) @Stable public int cpuCX8; - @HotSpotVMConstant(name = "VM_Version::CPU_CMOV", archs = {"amd64"}) @Stable public int cpuCMOV; - @HotSpotVMConstant(name = "VM_Version::CPU_FXSR", archs = {"amd64"}) @Stable public int cpuFXSR; - @HotSpotVMConstant(name = "VM_Version::CPU_HT", archs = {"amd64"}) @Stable public int cpuHT; - @HotSpotVMConstant(name = "VM_Version::CPU_MMX", archs = {"amd64"}) @Stable public int cpuMMX; - @HotSpotVMConstant(name = "VM_Version::CPU_3DNOW_PREFETCH", archs = {"amd64"}) @Stable public int cpu3DNOWPREFETCH; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE", archs = {"amd64"}) @Stable public int cpuSSE; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE2", archs = {"amd64"}) @Stable public int cpuSSE2; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE3", archs = {"amd64"}) @Stable public int cpuSSE3; - @HotSpotVMConstant(name = "VM_Version::CPU_SSSE3", archs = {"amd64"}) @Stable public int cpuSSSE3; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE4A", archs = {"amd64"}) @Stable public int cpuSSE4A; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE4_1", archs = {"amd64"}) @Stable public int cpuSSE41; - @HotSpotVMConstant(name = "VM_Version::CPU_SSE4_2", archs = {"amd64"}) @Stable public int cpuSSE42; - @HotSpotVMConstant(name = "VM_Version::CPU_POPCNT", archs = {"amd64"}) @Stable public int cpuPOPCNT; - @HotSpotVMConstant(name = "VM_Version::CPU_LZCNT", archs = {"amd64"}) @Stable public int cpuLZCNT; - @HotSpotVMConstant(name = "VM_Version::CPU_TSC", archs = {"amd64"}) @Stable public int cpuTSC; - @HotSpotVMConstant(name = "VM_Version::CPU_TSCINV", archs = {"amd64"}) @Stable public int cpuTSCINV; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX", archs = {"amd64"}) @Stable public int cpuAVX; - @HotSpotVMConstant(name = "VM_Version::CPU_AVX2", archs = {"amd64"}) @Stable public int cpuAVX2; - @HotSpotVMConstant(name = "VM_Version::CPU_AES", archs = {"amd64"}) @Stable public int cpuAES; - @HotSpotVMConstant(name = "VM_Version::CPU_ERMS", archs = {"amd64"}) @Stable public int cpuERMS; - @HotSpotVMConstant(name = "VM_Version::CPU_CLMUL", archs = {"amd64"}) @Stable public int cpuCLMUL; - @HotSpotVMConstant(name = "VM_Version::CPU_BMI1", archs = {"amd64"}) @Stable public int cpuBMI1; - - // SPARC specific values - @HotSpotVMField(name = "VM_Version::_features", type = "int", get = HotSpotVMField.Type.VALUE, archs = {"sparc"}) @Stable public int sparcFeatures; - @HotSpotVMConstant(name = "VM_Version::vis3_instructions_m", archs = {"sparc"}) @Stable public int vis3Instructions; - @HotSpotVMConstant(name = "VM_Version::vis2_instructions_m", archs = {"sparc"}) @Stable public int vis2Instructions; - @HotSpotVMConstant(name = "VM_Version::vis1_instructions_m", archs = {"sparc"}) @Stable public int vis1Instructions; - @HotSpotVMConstant(name = "VM_Version::cbcond_instructions_m", archs = {"sparc"}) @Stable public int cbcondInstructions; - - // offsets, ... - @HotSpotVMFlag(name = "StackShadowPages") @Stable public int stackShadowPages; - @HotSpotVMFlag(name = "UseStackBanging") @Stable public boolean useStackBanging; - @HotSpotVMConstant(name = "STACK_BIAS") @Stable public int stackBias; - - @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; - - @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; - - @HotSpotVMField(name = "ArrayKlass::_component_mirror", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayKlassComponentMirrorOffset; - - @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; - @HotSpotVMValue(expression = "InstanceKlass::vtable_start_offset() * HeapWordSize") @Stable public int instanceKlassVtableStartOffset; - @HotSpotVMValue(expression = "InstanceKlass::vtable_length_offset() * HeapWordSize") @Stable public int instanceKlassVtableLengthOffset; - @HotSpotVMValue(expression = "Universe::base_vtable_size() / vtableEntry::size()") @Stable public int baseVtableLength; - - /** - * The offset of the array length word in an array object's header. - */ - @HotSpotVMValue(expression = "arrayOopDesc::length_offset_in_bytes()") @Stable public int arrayLengthOffset; - - @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 = "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; - - @HotSpotVMConstant(name = "InstanceKlass::linked") @Stable public int instanceKlassStateLinked; - @HotSpotVMConstant(name = "InstanceKlass::fully_initialized") @Stable public int instanceKlassStateFullyInitialized; - - @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_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; - - @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 = "ObjPtrQueue", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadSatbMarkQueueOffset; - @HotSpotVMField(name = "JavaThread::_vm_result", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadObjectResultOffset; - @HotSpotVMValue(expression = "in_bytes(JavaThread::graal_counters_offset())") @Stable public int graalCountersThreadOffset; - - /** - * 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)
-     * 
- */ - @HotSpotVMValue(expression = "os::dll_load", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dllLoad; - - /** - * Address of the library lookup routine. The C signature of this routine is: - * - *
-     *     void* (void* handle, const char* name)
-     * 
- */ - @HotSpotVMValue(expression = "os::dll_lookup", get = HotSpotVMValue.Type.ADDRESS) @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. - */ - @HotSpotVMValue(expression = "RTLD_DEFAULT", defines = {"TARGET_OS_FAMILY_bsd", "TARGET_OS_FAMILY_linux"}, get = HotSpotVMValue.Type.ADDRESS) @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. - *

- * NOTE: This is not the same as {@link #pendingExceptionOffset}. - */ - @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 = "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 = {"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; - } - - /** - * This value is only valid on AMD64. - */ - public int threadLastJavaFpOffset() { - // TODO add an assert for 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; - - @HotSpotVMField(name = "PtrQueue::_active", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int ptrQueueActiveOffset; - @HotSpotVMField(name = "PtrQueue::_buf", type = "void**", get = HotSpotVMField.Type.OFFSET) @Stable public int ptrQueueBufferOffset; - @HotSpotVMField(name = "PtrQueue::_index", type = "size_t", get = HotSpotVMField.Type.OFFSET) @Stable public int ptrQueueIndexOffset; - - @HotSpotVMField(name = "OSThread::_interrupted", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int osThreadInterruptedOffset; - - @HotSpotVMConstant(name = "markOopDesc::unlocked_value") @Stable public int unlockedMask; - @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_shift") @Stable public long markOopDescHashShift; - @HotSpotVMConstant(name = "markOopDesc::hash_mask") @Stable public long markOopDescHashMask; - @HotSpotVMConstant(name = "markOopDesc::hash_mask_in_place") @Stable public long markOopDescHashMaskInPlace; - - @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 markOopDesc::prototype(). - */ - public long arrayPrototypeMarkWord() { - return markWordNoHashInPlace | markWordNoLockInPlace; - } - - /** - * See markOopDesc::copy_set_hash(). - */ - public long tlabIntArrayMarkWord() { - long tmp = arrayPrototypeMarkWord() & (~markOopDescHashMaskInPlace); - tmp |= ((0x2 & markOopDescHashMask) << markOopDescHashShift); - return tmp; - } - - /** - * Offset of the _pending_exception field in ThreadShadow (defined in exceptions.hpp). This - * field is used to propagate exceptions through C/C++ calls. - *

- * NOTE: This is not the same as {@link #threadExceptionOopOffset}. - */ - @HotSpotVMField(name = "ThreadShadow::_pending_exception", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingExceptionOffset; - @HotSpotVMField(name = "ThreadShadow::_pending_deoptimization", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingDeoptimizationOffset; - @HotSpotVMField(name = "ThreadShadow::_pending_failed_speculation", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingFailedSpeculationOffset; - @HotSpotVMField(name = "ThreadShadow::_pending_transfer_to_interpreter", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingTransferToInterpreterOffset; - - /** - * 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 = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int methodIntrinsicIdOffset; - @HotSpotVMField(name = "Method::_flags", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int methodFlagsOffset; - @HotSpotVMField(name = "Method::_vtable_index", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodVtableIndexOffset; - - @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::nonvirtual_vtable_index") @Stable public int nonvirtualVtableIndex; - @HotSpotVMConstant(name = "Method::invalid_vtable_index") @Stable public int invalidVtableIndex; - - @HotSpotVMConstant(name = "JVM_ACC_MONITOR_MATCH") @Stable public int jvmAccMonitorMatch; - @HotSpotVMConstant(name = "JVM_ACC_HAS_MONITOR_BYTECODES") @Stable public int jvmAccHasMonitorBytecodes; - - @HotSpotVMField(name = "GraalEnv::_task", type = "CompileTask*", get = HotSpotVMField.Type.OFFSET) @Stable public int graalEnvTaskOffset; - @HotSpotVMField(name = "GraalEnv::_jvmti_can_hotswap_or_post_breakpoint", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int graalEnvJvmtiCanHotswapOrPostBreakpointOffset; - @HotSpotVMField(name = "CompileTask::_num_inlined_bytecodes", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int compileTaskNumInlinedBytecodesOffset; - - /** - * Value of Method::extra_stack_entries(). - */ - @HotSpotVMValue(expression = "Method::extra_stack_entries()") @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 = "Symbol::_length", type = "unsigned short", get = HotSpotVMField.Type.OFFSET) @Stable public int symbolLengthOffset; - @HotSpotVMField(name = "Symbol::_body[0]", type = "jbyte", get = HotSpotVMField.Type.OFFSET) @Stable public int symbolBodyOffset; - - @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; - - @HotSpotVMConstant(name = "JVM_ACC_HAS_FINALIZER") @Stable public int klassHasFinalizerFlag; - - // Modifier.SYNTHETIC is not public so we get it via vmStructs. - @HotSpotVMConstant(name = "JVM_ACC_SYNTHETIC") @Stable public int syntheticFlag; - - /** - * @see HotSpotResolvedObjectTypeImpl#createField - */ - @HotSpotVMConstant(name = "JVM_RECOGNIZED_FIELD_MODIFIERS") @Stable public int recognizedFieldModifiers; - - /** - * 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 = "Universe::_non_oop_bits", type = "intptr_t", get = HotSpotVMField.Type.VALUE) @Stable public long nonOopBits; - - @HotSpotVMField(name = "StubRoutines::_verify_oop_count", type = "jint", get = HotSpotVMField.Type.ADDRESS) @Stable public long verifyOopCounterAddress; - @HotSpotVMValue(expression = "Universe::verify_oop_mask()") @Stable public long verifyOopMask; - @HotSpotVMValue(expression = "Universe::verify_oop_bits()") @Stable public long verifyOopBits; - - @HotSpotVMField(name = "CollectedHeap::_barrier_set", type = "BarrierSet*", get = HotSpotVMField.Type.OFFSET) @Stable public int collectedHeapBarrierSetOffset; - - @HotSpotVMField(name = "HeapRegion::LogOfHRGrainBytes", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int logOfHRGrainBytes; - - @HotSpotVMField(name = "BarrierSet::_kind", type = "BarrierSet::Name", get = HotSpotVMField.Type.OFFSET) @Stable private int barrierSetKindOffset; - @HotSpotVMConstant(name = "BarrierSet::CardTableModRef") @Stable public int barrierSetCardTableModRef; - @HotSpotVMConstant(name = "BarrierSet::CardTableExtension") @Stable public int barrierSetCardTableExtension; - @HotSpotVMConstant(name = "BarrierSet::G1SATBCT") @Stable public int barrierSetG1SATBCT; - @HotSpotVMConstant(name = "BarrierSet::G1SATBCTLogging") @Stable public int barrierSetG1SATBCTLogging; - @HotSpotVMConstant(name = "BarrierSet::ModRef") @Stable public int barrierSetModRef; - @HotSpotVMConstant(name = "BarrierSet::Other") @Stable public int barrierSetOther; - - @HotSpotVMField(name = "CardTableModRefBS::byte_map_base", type = "jbyte*", get = HotSpotVMField.Type.OFFSET) @Stable private int cardTableModRefBSByteMapBaseOffset; - @HotSpotVMConstant(name = "CardTableModRefBS::card_shift") @Stable public int cardTableModRefBSCardShift; - - @HotSpotVMValue(expression = "(jbyte)CardTableModRefBS::dirty_card_val()") @Stable public byte dirtyCardValue; - @HotSpotVMValue(expression = "(jbyte)G1SATBCardTableModRefBS::g1_young_card_val()") @Stable public byte g1YoungCardValue; - - private final long cardtableStartAddress; - private final int cardtableShift; - - public long cardtableStartAddress() { - if (cardtableStartAddress == -1) { - throw GraalInternalError.shouldNotReachHere(); - } - return cardtableStartAddress; - } - - public int cardtableShift() { - if (cardtableShift == -1) { - throw GraalInternalError.shouldNotReachHere(); - } - 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 + ptrQueueIndexOffset; - } - - public int g1CardQueueBufferOffset() { - return javaThreadDirtyCardQueueOffset + ptrQueueBufferOffset; - } - - public int g1SATBQueueMarkingOffset() { - return javaThreadSatbMarkQueueOffset + ptrQueueActiveOffset; - } - - public int g1SATBQueueIndexOffset() { - return javaThreadSatbMarkQueueOffset + ptrQueueIndexOffset; - } - - public int g1SATBQueueBufferOffset() { - return javaThreadSatbMarkQueueOffset + ptrQueueBufferOffset; - } - - @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; - - @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 = "nmethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCodeOffset; - - @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::_graal_node_count", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataGraalNodeCountOffset; - - @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; - - @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; - - @HotSpotVMValue(expression = "Universe::heap()->supports_inline_contig_alloc() ? Universe::heap()->end_addr() : (HeapWord**)-1", get = HotSpotVMValue.Type.ADDRESS) @Stable public long heapEndAddress; - @HotSpotVMValue(expression = "Universe::heap()->supports_inline_contig_alloc() ? Universe::heap()->top_addr() : (HeapWord**)-1", get = HotSpotVMValue.Type.ADDRESS) @Stable public long heapTopAddress; - - @HotSpotVMField(name = "Thread::_allocated_bytes", type = "jlong", get = HotSpotVMField.Type.OFFSET) @Stable public int threadAllocatedBytesOffset; - - @HotSpotVMFlag(name = "TLABWasteIncrement") @Stable public int tlabRefillWasteIncrement; - @HotSpotVMValue(expression = "ThreadLocalAllocBuffer::alignment_reserve()") @Stable public int tlabAlignmentReserve; - - @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; - } - - @HotSpotVMFlag(name = "TLABStats") @Stable public boolean tlabStats; - @HotSpotVMValue(expression = " !CMSIncrementalMode && Universe::heap()->supports_inline_contig_alloc()") @Stable public boolean inlineContiguousAllocationSupported; - - /** - * 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 = "CodeBlob::_code_offset", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable private int codeBlobCodeOffsetOffset; - @HotSpotVMField(name = "SharedRuntime::_ic_miss_blob", type = "RuntimeStub*", get = HotSpotVMField.Type.VALUE) @Stable private long inlineCacheMissBlob; - - @HotSpotVMValue(expression = "SharedRuntime::deopt_blob()->unpack()", get = HotSpotVMValue.Type.ADDRESS) @Stable public long handleDeoptStub; - @HotSpotVMValue(expression = "SharedRuntime::deopt_blob()->uncommon_trap()", get = HotSpotVMValue.Type.ADDRESS) @Stable public long uncommonTrapStub; - - private final long inlineCacheMissStub; - - public long inlineCacheMissStub() { - return inlineCacheMissStub; - } - - @HotSpotVMField(name = "CodeCache::_heap", type = "CodeHeap*", get = HotSpotVMField.Type.VALUE) @Stable private long codeCacheHeap; - @HotSpotVMField(name = "CodeHeap::_memory", type = "VirtualSpace", get = HotSpotVMField.Type.OFFSET) @Stable private int codeHeapMemoryOffset; - @HotSpotVMField(name = "VirtualSpace::_low_boundary", type = "char*", get = HotSpotVMField.Type.OFFSET) @Stable private int virtualSpaceLowBoundaryOffset; - @HotSpotVMField(name = "VirtualSpace::_high_boundary", type = "char*", get = HotSpotVMField.Type.OFFSET) @Stable private int virtualSpaceHighBoundaryOffset; - - private final long codeCacheLowBoundary; - private final long codeCacheHighBoundary; - - /** - * @return CodeCache::_heap->_memory._low_boundary - */ - public long codeCacheLowBoundary() { - return codeCacheLowBoundary; - } - - /** - * @return CodeCache::_heap->_memory._high_boundary - */ - public long codeCacheHighBoundary() { - return codeCacheHighBoundary; - } - - @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::_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; - - @HotSpotVMValue(expression = "GraalRuntime::new_instance", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newInstanceAddress; - @HotSpotVMValue(expression = "GraalRuntime::new_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newArrayAddress; - @HotSpotVMValue(expression = "GraalRuntime::new_multi_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newMultiArrayAddress; - @HotSpotVMValue(expression = "GraalRuntime::dynamic_new_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dynamicNewArrayAddress; - @HotSpotVMValue(expression = "GraalRuntime::dynamic_new_instance", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dynamicNewInstanceAddress; - @HotSpotVMValue(expression = "GraalRuntime::thread_is_interrupted", get = HotSpotVMValue.Type.ADDRESS) @Stable public long threadIsInterruptedAddress; - @HotSpotVMValue(expression = "GraalRuntime::vm_message", signature = "(unsigned char, long, long, long, long)", get = HotSpotVMValue.Type.ADDRESS) @Stable public long vmMessageAddress; - @HotSpotVMValue(expression = "GraalRuntime::identity_hash_code", get = HotSpotVMValue.Type.ADDRESS) @Stable public long identityHashCodeAddress; - @HotSpotVMValue(expression = "GraalRuntime::exception_handler_for_pc", signature = "(JavaThread*)", get = HotSpotVMValue.Type.ADDRESS) @Stable public long exceptionHandlerForPcAddress; - @HotSpotVMValue(expression = "GraalRuntime::monitorenter", get = HotSpotVMValue.Type.ADDRESS) @Stable public long monitorenterAddress; - @HotSpotVMValue(expression = "GraalRuntime::monitorexit", get = HotSpotVMValue.Type.ADDRESS) @Stable public long monitorexitAddress; - @HotSpotVMValue(expression = "GraalRuntime::create_null_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long createNullPointerExceptionAddress; - @HotSpotVMValue(expression = "GraalRuntime::create_out_of_bounds_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long createOutOfBoundsExceptionAddress; - @HotSpotVMValue(expression = "GraalRuntime::log_primitive", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logPrimitiveAddress; - @HotSpotVMValue(expression = "GraalRuntime::log_object", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logObjectAddress; - @HotSpotVMValue(expression = "GraalRuntime::log_printf", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logPrintfAddress; - @HotSpotVMValue(expression = "GraalRuntime::vm_error", get = HotSpotVMValue.Type.ADDRESS) @Stable public long vmErrorAddress; - @HotSpotVMValue(expression = "GraalRuntime::load_and_clear_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long loadAndClearExceptionAddress; - @HotSpotVMValue(expression = "GraalRuntime::write_barrier_pre", get = HotSpotVMValue.Type.ADDRESS) @Stable public long writeBarrierPreAddress; - @HotSpotVMValue(expression = "GraalRuntime::write_barrier_post", get = HotSpotVMValue.Type.ADDRESS) @Stable public long writeBarrierPostAddress; - @HotSpotVMValue(expression = "GraalRuntime::validate_object", get = HotSpotVMValue.Type.ADDRESS) @Stable public long validateObject; - - @HotSpotVMValue(expression = "GraalRuntime::test_deoptimize_call_int", get = HotSpotVMValue.Type.ADDRESS) @Stable public long testDeoptimizeCallInt; - - @HotSpotVMValue(expression = "SharedRuntime::register_finalizer", get = HotSpotVMValue.Type.ADDRESS) @Stable public long registerFinalizerAddress; - @HotSpotVMValue(expression = "SharedRuntime::exception_handler_for_return_address", get = HotSpotVMValue.Type.ADDRESS) @Stable public long exceptionHandlerForReturnAddressAddress; - @HotSpotVMValue(expression = "SharedRuntime::OSR_migration_end", get = HotSpotVMValue.Type.ADDRESS) @Stable public long osrMigrationEndAddress; - - @HotSpotVMValue(expression = "os::javaTimeMillis", get = HotSpotVMValue.Type.ADDRESS) @Stable public long javaTimeMillisAddress; - @HotSpotVMValue(expression = "os::javaTimeNanos", get = HotSpotVMValue.Type.ADDRESS) @Stable public long javaTimeNanosAddress; - @HotSpotVMValue(expression = "SharedRuntime::dsin", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticSinAddress; - @HotSpotVMValue(expression = "SharedRuntime::dcos", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticCosAddress; - @HotSpotVMValue(expression = "SharedRuntime::dtan", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticTanAddress; - @HotSpotVMValue(expression = "SharedRuntime::dexp", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticExpAddress; - @HotSpotVMValue(expression = "SharedRuntime::dlog", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticLogAddress; - @HotSpotVMValue(expression = "SharedRuntime::dlog10", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticLog10Address; - @HotSpotVMValue(expression = "SharedRuntime::dpow", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticPowAddress; - - @HotSpotVMValue(expression = "(jint) GraalCounterSize") @Stable public int graalCountersSize; - - @HotSpotVMValue(expression = "Deoptimization::fetch_unroll_info", signature = "(JavaThread*)", get = HotSpotVMValue.Type.ADDRESS) @Stable public long deoptimizationFetchUnrollInfo; - @HotSpotVMValue(expression = "Deoptimization::uncommon_trap", get = HotSpotVMValue.Type.ADDRESS) @Stable public long deoptimizationUncommonTrap; - @HotSpotVMValue(expression = "Deoptimization::unpack_frames", signature = "(JavaThread*, int)", get = HotSpotVMValue.Type.ADDRESS) @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::_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 = "GraalEnv::ok") @Stable public int codeInstallResultOk; - @HotSpotVMConstant(name = "GraalEnv::dependencies_failed") @Stable public int codeInstallResultDependenciesFailed; - @HotSpotVMConstant(name = "GraalEnv::dependencies_invalid") @Stable public int codeInstallResultDependenciesInvalid; - @HotSpotVMConstant(name = "GraalEnv::cache_full") @Stable public int codeInstallResultCacheFull; - @HotSpotVMConstant(name = "GraalEnv::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"; - } - - @HotSpotVMConstant(name = "CompilerToVM::KLASS_TAG") @Stable public int compilerToVMKlassTag; - @HotSpotVMConstant(name = "CompilerToVM::SYMBOL_TAG") @Stable public int compilerToVMSymbolTag; - - // 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::INVOKE_INVALID") @Stable public int MARKID_INVOKE_INVALID; - - // Checkstyle: resume - - public 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; - } - } - } - - /** - * Returns the name of the C/C++ symbol that is associated (via HotSpotVMValue annotation) with - * the HotSpotVMConfig object's field containing {@code value}; returns null if no field holds - * the provided address. - * - * @param value value of the field - * @return C/C++ symbol name or null - */ - public String getVMValueCSymbol(long value) { - for (Field f : HotSpotVMConfig.class.getDeclaredFields()) { - if (f.isAnnotationPresent(HotSpotVMValue.class)) { - HotSpotVMValue annotation = f.getAnnotation(HotSpotVMValue.class); - - if (annotation.get() == HotSpotVMValue.Type.ADDRESS) { - try { - if (value == f.getLong(this)) { - return (annotation.expression() + annotation.signature()); - } - } catch (IllegalArgumentException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } catch (IllegalAccessException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - } - } - return null; - } - - /** - * Returns the name of the C/C++ symbol that is associated (via HotSpotVMField annotation) with - * the HotSpotVMConfig object's field containing {@code value}; returns null if no field holds - * the provided address. - * - * @param value value of the field - * @return C/C++ symbol name or null - */ - public String getVMFieldCSymbol(long value) { - for (Field f : HotSpotVMConfig.class.getDeclaredFields()) { - if (f.isAnnotationPresent(HotSpotVMField.class)) { - HotSpotVMField annotation = f.getAnnotation(HotSpotVMField.class); - - if (annotation.get() == HotSpotVMField.Type.VALUE) { - try { - if (value == f.getLong(this)) { - return (annotation.name()); - } - } catch (IllegalArgumentException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } catch (IllegalAccessException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - } - } - return null; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfigVerifier.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfigVerifier.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,156 +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 com.oracle.graal.hotspot; - -import static java.lang.String.*; - -import java.io.*; -import java.lang.reflect.*; -import java.util.*; - -import com.oracle.graal.compiler.common.*; - -import jdk.internal.org.objectweb.asm.*; -import jdk.internal.org.objectweb.asm.Type; -import sun.misc.*; - -/** - * 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 GraalInternalError(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 InternalError(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 InternalError(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; - } - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVmSymbols.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVmSymbols.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVmSymbols.java Tue May 19 23:16:07 2015 +0200 @@ -24,6 +24,9 @@ import static com.oracle.graal.compiler.common.UnsafeAccess.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + +import com.oracle.graal.hotspot.jvmci.*; + import sun.misc.*; /** diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/InitTimer.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/InitTimer.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/InitTimer.java Tue May 19 23:16:07 2015 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.hotspot; import com.oracle.graal.debug.*; +import com.oracle.graal.hotspot.jvmci.*; import edu.umd.cs.findbugs.annotations.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/PrintStreamOption.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/PrintStreamOption.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/PrintStreamOption.java Tue May 19 23:16:07 2015 +0200 @@ -25,7 +25,7 @@ import java.io.*; import java.lang.management.*; -import com.oracle.graal.hotspot.bridge.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.options.*; /** diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/Stable.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/Stable.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +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 com.oracle.graal.hotspot; - -import java.lang.annotation.*; - -/** - * This annotation functions as an alias for the sun.invoke.Stable annotation within Graal 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 { -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,345 +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 com.oracle.graal.hotspot.bridge; - -import sun.misc.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.meta.*; - -import com.oracle.graal.hotspotvmconfig.*; - -/** - * Calls from Java into HotSpot. - */ -public interface CompilerToVM { - - /** - * Copies the original bytecode of a given method into a new byte array and returns it. - * - * @param metaspaceMethod the metaspace Method object - * @return a new byte array containing the original bytecode - */ - byte[] getBytecode(long metaspaceMethod); - - int exceptionTableLength(long metaspaceMethod); - - long exceptionTableStart(long metaspaceMethod); - - /** - * Determines if a given metaspace Method object has balanced monitors. - * - * @param metaspaceMethod the metaspace Method object to query - * @return true if the method has balanced monitors - */ - boolean hasBalancedMonitors(long metaspaceMethod); - - /** - * Determines if a given metaspace 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
  • - *
- * - * @param metaspaceMethod the metaspace Method object to query - * @return true if the method can be inlined - */ - boolean canInlineMethod(long metaspaceMethod); - - /** - * Determines if a given metaspace 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
  • - *
- * - * @param metaspaceMethod the metaspace Method object to query - * @return true if the method should be inlined - */ - boolean shouldInlineMethod(long metaspaceMethod); - - /** - * Used to implement {@link ResolvedJavaType#findUniqueConcreteMethod(ResolvedJavaMethod)}. - * - * @param metaspaceMethod the metaspace Method on which to based the search - * @param actualHolderMetaspaceKlass the best known type of receiver - * @return the metaspace Method result or 0 is there is no unique concrete method for - * {@code metaspaceMethod} - */ - long findUniqueConcreteMethod(long actualHolderMetaspaceKlass, long metaspaceMethod); - - /** - * Returns the implementor for the given interface class, if there is a single implementor. - * - * @param metaspaceKlass the metaspace klass to get the implementor for - * @return the implementor as metaspace klass pointer if there is a single implementor, null if - * there is no implementor, or the input metaspace klass pointer ({@code metaspaceKlass} - * ) itself if there is more than one implementor. - */ - long getKlassImplementor(long metaspaceKlass); - - /** - * Determines if a given metaspace method is ignored by security stack walks. - * - * @param metaspaceMethod the metaspace Method object - * @return true if the method is ignored - */ - boolean methodIsIgnoredBySecurityStackWalk(long metaspaceMethod); - - /** - * Converts a name to a metaspace klass. - * - * @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 a metaspace klass for {@code name} - * @throws LinkageError if {@code resolve == true} and the resolution failed - */ - long lookupType(String name, Class accessingClass, boolean resolve); - - Object resolveConstantInPool(long metaspaceConstantPool, int cpi); - - Object resolvePossiblyCachedConstantInPool(long metaspaceConstantPool, int cpi); - - int lookupNameAndTypeRefIndexInPool(long metaspaceConstantPool, int cpi); - - String lookupNameRefInPool(long metaspaceConstantPool, int cpi); - - String lookupSignatureRefInPool(long metaspaceConstantPool, int cpi); - - int lookupKlassRefIndexInPool(long metaspaceConstantPool, int cpi); - - long constantPoolKlassAt(long metaspaceConstantPool, int cpi); - - /** - * Looks up a class entry in a constant pool. - * - * @param metaspaceConstantPool metaspace constant pool pointer - * @param cpi constant pool index - * @return a metaspace Klass for a resolved method entry, a metaspace Symbol otherwise (with - * tagging) - */ - long lookupKlassInPool(long metaspaceConstantPool, int cpi); - - /** - * Looks up a method entry in a constant pool. - * - * @param metaspaceConstantPool metaspace constant pool pointer - * @param cpi constant pool index - * @return a metaspace Method for a resolved method entry, 0 otherwise - */ - long lookupMethodInPool(long metaspaceConstantPool, int cpi, byte opcode); - - /** - * Looks up a field entry in a constant pool and attempts to resolve it. The values returned in - * {@code info} are: - * - *
-     *     [(int) flags,   // only valid if field is resolved
-     *      (int) offset]  // only valid if field is resolved
-     * 
- * - * @param metaspaceConstantPool metaspace constant pool pointer - * @param cpi constant pool index - * @param info an array in which the details of the field are returned - * @return true if the field is resolved - */ - long resolveField(long metaspaceConstantPool, int cpi, byte opcode, long[] info); - - int constantPoolRemapInstructionOperandFromCache(long metaspaceConstantPool, int cpi); - - Object lookupAppendixInPool(long metaspaceConstantPool, int cpi); - - /** - * Installs the result of a compilation into the code cache. - * - * @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}. - */ - int installCode(HotSpotCompiledCode compiledCode, InstalledCode code, SpeculationLog speculationLog); - - /** - * Notifies the VM of statistics for a completed compilation. - * - * @param id the identifier of the compilation - * @param method the method compiled - * @param osr specifies if the compilation was for on-stack-replacement - * @param processedBytecodes the number of bytecodes processed during the compilation, including - * the bytecodes of all inlined methods - * @param time the amount time spent compiling {@code method} - * @param timeUnitsPerSecond the granularity of the units for the {@code time} value - * @param installedCode the nmethod installed as a result of the compilation - */ - void notifyCompilationStatistics(int id, HotSpotResolvedJavaMethod method, boolean osr, int processedBytecodes, long time, long timeUnitsPerSecond, InstalledCode installedCode); - - void resetCompilationStatistics(); - - void initializeConfiguration(HotSpotVMConfig config); - - long resolveMethod(long metaspaceKlassExactReceiver, long metaspaceMethod, long metaspaceKlassCaller); - - long getClassInitializer(long metaspaceKlass); - - boolean hasFinalizableSubclass(long metaspaceKlass); - - /** - * Gets the metaspace Method object corresponding to a given {@link Class} object and slot - * number. - * - * @param holder method holder - * @param slot slot number of the method - * @return the metaspace Method - */ - long getMetaspaceMethod(Class holder, int slot); - - long getMaxCallTargetOffset(long address); - - String disassembleCodeBlob(long codeBlob); - - StackTraceElement getStackTraceElement(long metaspaceMethod, int bci); - - Object executeCompiledMethod(Object arg1, Object arg2, Object arg3, InstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException; - - Object executeCompiledMethodVarargs(Object[] args, InstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException; - - long[] getLineNumberTable(long metaspaceMethod); - - long getLocalVariableTableStart(long metaspaceMethod); - - int getLocalVariableTableLength(long metaspaceMethod); - - String getFileName(HotSpotResolvedJavaType method); - - Class getJavaMirror(long metaspaceKlass); - - long readUnsafeKlassPointer(Object o); - - /** - * 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 - */ - Object readUncompressedOop(long address); - - void doNotInlineOrCompile(long metaspaceMethod); - - /** - * Invalidates the profiling information and restarts profiling upon the next invocation. - * - * @param metaspaceMethod the metaspace Method object - */ - void reprofile(long metaspaceMethod); - - void invalidateInstalledCode(InstalledCode hotspotInstalledCode); - - /** - * Collects the current values of all Graal benchmark counters, summed up over all threads. - */ - long[] collectCounters(); - - boolean isMature(long metaspaceMethodData); - - /** - * Generate a unique id to identify the result of the compile. - */ - int allocateCompileId(long metaspaceMethod, int entryBCI); - - /** - * Gets the names of the supported GPU architectures. - * - * @return a comma separated list of names - */ - String getGPUs(); - - /** - * - * @param metaspaceMethod the method to check - * @param entryBCI - * @param level the compilation level - * @return true if the {@code metaspaceMethod} has code for {@code level} - */ - boolean hasCompiledCodeForOSR(long metaspaceMethod, int entryBCI, int level); - - /** - * Fetch the time stamp used for printing inside hotspot. It's relative to VM start to that all - * events can be ordered. - * - * @return milliseconds since VM start - */ - long getTimeStamp(); - - /** - * Gets the value of a metaspace {@code Symbol} as a String. - * - * @param metaspaceSymbol - */ - String getSymbol(long metaspaceSymbol); - - /** - * Looks for the next Java stack frame with the given method. - * - * @param frame the starting point of the search, where {@code null} refers to the topmost frame - * @param methods the metaspace 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 - */ - HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, long[] methods, int initialSkip); - - /** - * Materialized all virtual objects within the given stack frame and update the locals within - * the given stackFrame object. - * - * @param invalidate if {@code true}, the compiled method for the stack frame will be - * invalidated. - */ - void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); - - void resolveInvokeDynamic(long metaspaceConstantPool, int index); - - int getVtableIndexForInterface(long metaspaceKlass, long metaspaceMethod); - - boolean shouldDebugNonSafepoints(); - - void writeDebugOutput(byte[] bytes, int offset, int length); - - void flushDebugOutput(); -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,207 +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 com.oracle.graal.hotspot.bridge; - -import static com.oracle.graal.hotspot.InitTimer.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.meta.*; - -/** - * Entries into the HotSpot VM from Java code. - */ -public class CompilerToVMImpl implements CompilerToVM { - - /** - * Initializes the native part of the Graal runtime. - */ - private static native void init(); - - static { - try (InitTimer t = timer("CompilerToVMImpl.init")) { - init(); - } - } - - @Override - public native int installCode(HotSpotCompiledCode compiledCode, InstalledCode code, SpeculationLog speculationLog); - - @Override - public native long getMetaspaceMethod(Class holder, int slot); - - @Override - public native byte[] getBytecode(long metaspaceMethod); - - @Override - public native int exceptionTableLength(long metaspaceMethod); - - @Override - public native long exceptionTableStart(long metaspaceMethod); - - @Override - public native boolean hasBalancedMonitors(long metaspaceMethod); - - @Override - public native long findUniqueConcreteMethod(long actualHolderMetaspaceKlass, long metaspaceMethod); - - @Override - public native long getKlassImplementor(long metaspaceKlass); - - @Override - public native long lookupType(String name, Class accessingClass, boolean eagerResolve); - - public native Object resolveConstantInPool(long metaspaceConstantPool, int cpi); - - public native Object resolvePossiblyCachedConstantInPool(long metaspaceConstantPool, int cpi); - - @Override - public native int lookupNameAndTypeRefIndexInPool(long metaspaceConstantPool, int cpi); - - @Override - public native String lookupNameRefInPool(long metaspaceConstantPool, int cpi); - - @Override - public native String lookupSignatureRefInPool(long metaspaceConstantPool, int cpi); - - @Override - public native int lookupKlassRefIndexInPool(long metaspaceConstantPool, int cpi); - - public native long constantPoolKlassAt(long metaspaceConstantPool, int cpi); - - @Override - public native long lookupKlassInPool(long metaspaceConstantPool, int cpi); - - @Override - public native long lookupMethodInPool(long metaspaceConstantPool, int cpi, byte opcode); - - @Override - public native long resolveField(long metaspaceConstantPool, int cpi, byte opcode, long[] info); - - public native int constantPoolRemapInstructionOperandFromCache(long metaspaceConstantPool, int cpi); - - @Override - public native Object lookupAppendixInPool(long metaspaceConstantPool, int cpi); - - @Override - public native void initializeConfiguration(HotSpotVMConfig config); - - @Override - public native long resolveMethod(long metaspaceKlassExactReceiver, long metaspaceMethod, long metaspaceKlassCaller); - - @Override - public native boolean hasFinalizableSubclass(long metaspaceKlass); - - public native boolean methodIsIgnoredBySecurityStackWalk(long metaspaceMethod); - - @Override - public native long getClassInitializer(long metaspaceKlass); - - @Override - public native long getMaxCallTargetOffset(long address); - - // The HotSpot disassembler seems not to be thread safe so it's better to synchronize its usage - @Override - public synchronized native String disassembleCodeBlob(long codeBlob); - - @Override - public native StackTraceElement getStackTraceElement(long metaspaceMethod, int bci); - - @Override - public native Object executeCompiledMethodVarargs(Object[] args, InstalledCode hotspotInstalledCode); - - @Override - public native long[] getLineNumberTable(long metaspaceMethod); - - @Override - public native long getLocalVariableTableStart(long metaspaceMethod); - - @Override - public native int getLocalVariableTableLength(long metaspaceMethod); - - @Override - public native String getFileName(HotSpotResolvedJavaType method); - - @Override - public native void reprofile(long metaspaceMethod); - - @Override - public native void invalidateInstalledCode(InstalledCode hotspotInstalledCode); - - @Override - public native Class getJavaMirror(long metaspaceKlass); - - @Override - public native long readUnsafeKlassPointer(Object o); - - @Override - public native Object readUncompressedOop(long address); - - @Override - public native void doNotInlineOrCompile(long metaspaceMethod); - - @Override - public Object executeCompiledMethod(Object arg1, Object arg2, Object arg3, InstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException { - return executeCompiledMethodVarargs(new Object[]{arg1, arg2, arg3}, hotspotInstalledCode); - } - - public synchronized native void notifyCompilationStatistics(int id, HotSpotResolvedJavaMethod method, boolean osr, int processedBytecodes, long time, long timeUnitsPerSecond, - InstalledCode installedCode); - - public native void resetCompilationStatistics(); - - public native long[] collectCounters(); - - public native boolean isMature(long method); - - public native int allocateCompileId(long metaspaceMethod, int entryBCI); - - public String getGPUs() { - return ""; - } - - public native boolean canInlineMethod(long metaspaceMethod); - - public native boolean shouldInlineMethod(long metaspaceMethod); - - public native boolean hasCompiledCodeForOSR(long metaspaceMethod, int entryBCI, int level); - - public native HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, long[] methods, int initialSkip); - - public native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); - - public native long getTimeStamp(); - - public native String getSymbol(long metaspaceSymbol); - - public native void resolveInvokeDynamic(long metaspaceConstantPool, int index); - - public native int getVtableIndexForInterface(long metaspaceKlass, long metaspaceMethod); - - public native boolean shouldDebugNonSafepoints(); - - public native void writeDebugOutput(byte[] bytes, int offset, int length); - - public native void flushDebugOutput(); -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java Tue May 19 23:16:07 2015 +0200 @@ -30,8 +30,7 @@ import com.oracle.graal.compiler.common.*; import com.oracle.graal.debug.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.bridge.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.replacements.*; import com.oracle.graal.nodes.debug.*; import com.oracle.graal.options.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/CompilerToVM.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/CompilerToVM.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,342 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import sun.misc.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspotvmconfig.*; + +/** + * Calls from Java into HotSpot. + */ +public interface CompilerToVM { + + /** + * Copies the original bytecode of a given method into a new byte array and returns it. + * + * @param metaspaceMethod the metaspace Method object + * @return a new byte array containing the original bytecode + */ + byte[] getBytecode(long metaspaceMethod); + + int exceptionTableLength(long metaspaceMethod); + + long exceptionTableStart(long metaspaceMethod); + + /** + * Determines if a given metaspace Method object has balanced monitors. + * + * @param metaspaceMethod the metaspace Method object to query + * @return true if the method has balanced monitors + */ + boolean hasBalancedMonitors(long metaspaceMethod); + + /** + * Determines if a given metaspace 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
  • + *
+ * + * @param metaspaceMethod the metaspace Method object to query + * @return true if the method can be inlined + */ + boolean canInlineMethod(long metaspaceMethod); + + /** + * Determines if a given metaspace 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
  • + *
+ * + * @param metaspaceMethod the metaspace Method object to query + * @return true if the method should be inlined + */ + boolean shouldInlineMethod(long metaspaceMethod); + + /** + * Used to implement {@link ResolvedJavaType#findUniqueConcreteMethod(ResolvedJavaMethod)}. + * + * @param metaspaceMethod the metaspace Method on which to based the search + * @param actualHolderMetaspaceKlass the best known type of receiver + * @return the metaspace Method result or 0 is there is no unique concrete method for + * {@code metaspaceMethod} + */ + long findUniqueConcreteMethod(long actualHolderMetaspaceKlass, long metaspaceMethod); + + /** + * Returns the implementor for the given interface class, if there is a single implementor. + * + * @param metaspaceKlass the metaspace klass to get the implementor for + * @return the implementor as metaspace klass pointer if there is a single implementor, null if + * there is no implementor, or the input metaspace klass pointer ({@code metaspaceKlass} + * ) itself if there is more than one implementor. + */ + long getKlassImplementor(long metaspaceKlass); + + /** + * Determines if a given metaspace method is ignored by security stack walks. + * + * @param metaspaceMethod the metaspace Method object + * @return true if the method is ignored + */ + boolean methodIsIgnoredBySecurityStackWalk(long metaspaceMethod); + + /** + * Converts a name to a metaspace klass. + * + * @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 a metaspace klass for {@code name} + * @throws LinkageError if {@code resolve == true} and the resolution failed + */ + long lookupType(String name, Class accessingClass, boolean resolve); + + Object resolveConstantInPool(long metaspaceConstantPool, int cpi); + + Object resolvePossiblyCachedConstantInPool(long metaspaceConstantPool, int cpi); + + int lookupNameAndTypeRefIndexInPool(long metaspaceConstantPool, int cpi); + + String lookupNameRefInPool(long metaspaceConstantPool, int cpi); + + String lookupSignatureRefInPool(long metaspaceConstantPool, int cpi); + + int lookupKlassRefIndexInPool(long metaspaceConstantPool, int cpi); + + long constantPoolKlassAt(long metaspaceConstantPool, int cpi); + + /** + * Looks up a class entry in a constant pool. + * + * @param metaspaceConstantPool metaspace constant pool pointer + * @param cpi constant pool index + * @return a metaspace Klass for a resolved method entry, a metaspace Symbol otherwise (with + * tagging) + */ + long lookupKlassInPool(long metaspaceConstantPool, int cpi); + + /** + * Looks up a method entry in a constant pool. + * + * @param metaspaceConstantPool metaspace constant pool pointer + * @param cpi constant pool index + * @return a metaspace Method for a resolved method entry, 0 otherwise + */ + long lookupMethodInPool(long metaspaceConstantPool, int cpi, byte opcode); + + /** + * Looks up a field entry in a constant pool and attempts to resolve it. The values returned in + * {@code info} are: + * + *
+     *     [(int) flags,   // only valid if field is resolved
+     *      (int) offset]  // only valid if field is resolved
+     * 
+ * + * @param metaspaceConstantPool metaspace constant pool pointer + * @param cpi constant pool index + * @param info an array in which the details of the field are returned + * @return true if the field is resolved + */ + long resolveField(long metaspaceConstantPool, int cpi, byte opcode, long[] info); + + int constantPoolRemapInstructionOperandFromCache(long metaspaceConstantPool, int cpi); + + Object lookupAppendixInPool(long metaspaceConstantPool, int cpi); + + /** + * Installs the result of a compilation into the code cache. + * + * @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}. + */ + int installCode(HotSpotCompiledCode compiledCode, InstalledCode code, SpeculationLog speculationLog); + + /** + * Notifies the VM of statistics for a completed compilation. + * + * @param id the identifier of the compilation + * @param method the method compiled + * @param osr specifies if the compilation was for on-stack-replacement + * @param processedBytecodes the number of bytecodes processed during the compilation, including + * the bytecodes of all inlined methods + * @param time the amount time spent compiling {@code method} + * @param timeUnitsPerSecond the granularity of the units for the {@code time} value + * @param installedCode the nmethod installed as a result of the compilation + */ + void notifyCompilationStatistics(int id, HotSpotResolvedJavaMethod method, boolean osr, int processedBytecodes, long time, long timeUnitsPerSecond, InstalledCode installedCode); + + void resetCompilationStatistics(); + + void initializeConfiguration(HotSpotVMConfig config); + + long resolveMethod(long metaspaceKlassExactReceiver, long metaspaceMethod, long metaspaceKlassCaller); + + long getClassInitializer(long metaspaceKlass); + + boolean hasFinalizableSubclass(long metaspaceKlass); + + /** + * Gets the metaspace Method object corresponding to a given {@link Class} object and slot + * number. + * + * @param holder method holder + * @param slot slot number of the method + * @return the metaspace Method + */ + long getMetaspaceMethod(Class holder, int slot); + + long getMaxCallTargetOffset(long address); + + String disassembleCodeBlob(long codeBlob); + + StackTraceElement getStackTraceElement(long metaspaceMethod, int bci); + + Object executeCompiledMethod(Object arg1, Object arg2, Object arg3, InstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException; + + Object executeCompiledMethodVarargs(Object[] args, InstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException; + + long[] getLineNumberTable(long metaspaceMethod); + + long getLocalVariableTableStart(long metaspaceMethod); + + int getLocalVariableTableLength(long metaspaceMethod); + + String getFileName(HotSpotResolvedJavaType method); + + Class getJavaMirror(long metaspaceKlass); + + long readUnsafeKlassPointer(Object o); + + /** + * 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 + */ + Object readUncompressedOop(long address); + + void doNotInlineOrCompile(long metaspaceMethod); + + /** + * Invalidates the profiling information and restarts profiling upon the next invocation. + * + * @param metaspaceMethod the metaspace Method object + */ + void reprofile(long metaspaceMethod); + + void invalidateInstalledCode(InstalledCode hotspotInstalledCode); + + /** + * Collects the current values of all Graal benchmark counters, summed up over all threads. + */ + long[] collectCounters(); + + boolean isMature(long metaspaceMethodData); + + /** + * Generate a unique id to identify the result of the compile. + */ + int allocateCompileId(long metaspaceMethod, int entryBCI); + + /** + * Gets the names of the supported GPU architectures. + * + * @return a comma separated list of names + */ + String getGPUs(); + + /** + * + * @param metaspaceMethod the method to check + * @param entryBCI + * @param level the compilation level + * @return true if the {@code metaspaceMethod} has code for {@code level} + */ + boolean hasCompiledCodeForOSR(long metaspaceMethod, int entryBCI, int level); + + /** + * Fetch the time stamp used for printing inside hotspot. It's relative to VM start to that all + * events can be ordered. + * + * @return milliseconds since VM start + */ + long getTimeStamp(); + + /** + * Gets the value of a metaspace {@code Symbol} as a String. + * + * @param metaspaceSymbol + */ + String getSymbol(long metaspaceSymbol); + + /** + * Looks for the next Java stack frame with the given method. + * + * @param frame the starting point of the search, where {@code null} refers to the topmost frame + * @param methods the metaspace 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 + */ + HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, long[] methods, int initialSkip); + + /** + * Materialized all virtual objects within the given stack frame and update the locals within + * the given stackFrame object. + * + * @param invalidate if {@code true}, the compiled method for the stack frame will be + * invalidated. + */ + void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); + + void resolveInvokeDynamic(long metaspaceConstantPool, int index); + + int getVtableIndexForInterface(long metaspaceKlass, long metaspaceMethod); + + boolean shouldDebugNonSafepoints(); + + void writeDebugOutput(byte[] bytes, int offset, int length); + + void flushDebugOutput(); +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/CompilerToVMImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/CompilerToVMImpl.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,206 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.hotspot.InitTimer.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.hotspot.*; + +/** + * Entries into the HotSpot VM from Java code. + */ +public class CompilerToVMImpl implements CompilerToVM { + + /** + * Initializes the native part of the Graal runtime. + */ + private static native void init(); + + static { + try (InitTimer t = timer("CompilerToVMImpl.init")) { + init(); + } + } + + @Override + public native int installCode(HotSpotCompiledCode compiledCode, InstalledCode code, SpeculationLog speculationLog); + + @Override + public native long getMetaspaceMethod(Class holder, int slot); + + @Override + public native byte[] getBytecode(long metaspaceMethod); + + @Override + public native int exceptionTableLength(long metaspaceMethod); + + @Override + public native long exceptionTableStart(long metaspaceMethod); + + @Override + public native boolean hasBalancedMonitors(long metaspaceMethod); + + @Override + public native long findUniqueConcreteMethod(long actualHolderMetaspaceKlass, long metaspaceMethod); + + @Override + public native long getKlassImplementor(long metaspaceKlass); + + @Override + public native long lookupType(String name, Class accessingClass, boolean eagerResolve); + + public native Object resolveConstantInPool(long metaspaceConstantPool, int cpi); + + public native Object resolvePossiblyCachedConstantInPool(long metaspaceConstantPool, int cpi); + + @Override + public native int lookupNameAndTypeRefIndexInPool(long metaspaceConstantPool, int cpi); + + @Override + public native String lookupNameRefInPool(long metaspaceConstantPool, int cpi); + + @Override + public native String lookupSignatureRefInPool(long metaspaceConstantPool, int cpi); + + @Override + public native int lookupKlassRefIndexInPool(long metaspaceConstantPool, int cpi); + + public native long constantPoolKlassAt(long metaspaceConstantPool, int cpi); + + @Override + public native long lookupKlassInPool(long metaspaceConstantPool, int cpi); + + @Override + public native long lookupMethodInPool(long metaspaceConstantPool, int cpi, byte opcode); + + @Override + public native long resolveField(long metaspaceConstantPool, int cpi, byte opcode, long[] info); + + public native int constantPoolRemapInstructionOperandFromCache(long metaspaceConstantPool, int cpi); + + @Override + public native Object lookupAppendixInPool(long metaspaceConstantPool, int cpi); + + @Override + public native void initializeConfiguration(HotSpotVMConfig config); + + @Override + public native long resolveMethod(long metaspaceKlassExactReceiver, long metaspaceMethod, long metaspaceKlassCaller); + + @Override + public native boolean hasFinalizableSubclass(long metaspaceKlass); + + public native boolean methodIsIgnoredBySecurityStackWalk(long metaspaceMethod); + + @Override + public native long getClassInitializer(long metaspaceKlass); + + @Override + public native long getMaxCallTargetOffset(long address); + + // The HotSpot disassembler seems not to be thread safe so it's better to synchronize its usage + @Override + public synchronized native String disassembleCodeBlob(long codeBlob); + + @Override + public native StackTraceElement getStackTraceElement(long metaspaceMethod, int bci); + + @Override + public native Object executeCompiledMethodVarargs(Object[] args, InstalledCode hotspotInstalledCode); + + @Override + public native long[] getLineNumberTable(long metaspaceMethod); + + @Override + public native long getLocalVariableTableStart(long metaspaceMethod); + + @Override + public native int getLocalVariableTableLength(long metaspaceMethod); + + @Override + public native String getFileName(HotSpotResolvedJavaType method); + + @Override + public native void reprofile(long metaspaceMethod); + + @Override + public native void invalidateInstalledCode(InstalledCode hotspotInstalledCode); + + @Override + public native Class getJavaMirror(long metaspaceKlass); + + @Override + public native long readUnsafeKlassPointer(Object o); + + @Override + public native Object readUncompressedOop(long address); + + @Override + public native void doNotInlineOrCompile(long metaspaceMethod); + + @Override + public Object executeCompiledMethod(Object arg1, Object arg2, Object arg3, InstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException { + return executeCompiledMethodVarargs(new Object[]{arg1, arg2, arg3}, hotspotInstalledCode); + } + + public synchronized native void notifyCompilationStatistics(int id, HotSpotResolvedJavaMethod method, boolean osr, int processedBytecodes, long time, long timeUnitsPerSecond, + InstalledCode installedCode); + + public native void resetCompilationStatistics(); + + public native long[] collectCounters(); + + public native boolean isMature(long method); + + public native int allocateCompileId(long metaspaceMethod, int entryBCI); + + public String getGPUs() { + return ""; + } + + public native boolean canInlineMethod(long metaspaceMethod); + + public native boolean shouldInlineMethod(long metaspaceMethod); + + public native boolean hasCompiledCodeForOSR(long metaspaceMethod, int entryBCI, int level); + + public native HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, long[] methods, int initialSkip); + + public native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); + + public native long getTimeStamp(); + + public native String getSymbol(long metaspaceSymbol); + + public native void resolveInvokeDynamic(long metaspaceConstantPool, int index); + + public native int getVtableIndexForInterface(long metaspaceKlass, long metaspaceMethod); + + public native boolean shouldDebugNonSafepoints(); + + public native void writeDebugOutput(byte[] bytes, int offset, int length); + + public native void flushDebugOutput(); +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCodeCacheProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCodeCacheProvider.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,333 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.hotspot.jvmci.HotSpotCompressedNullConstant.*; + +import java.lang.reflect.*; +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.code.CodeUtil.DefaultRefMapFormatter; +import com.oracle.graal.api.code.CodeUtil.RefMapFormatter; +import com.oracle.graal.api.code.CompilationResult.Call; +import com.oracle.graal.api.code.CompilationResult.ConstantReference; +import com.oracle.graal.api.code.CompilationResult.DataPatch; +import com.oracle.graal.api.code.CompilationResult.Infopoint; +import com.oracle.graal.api.code.CompilationResult.Mark; +import com.oracle.graal.api.code.DataSection.Data; +import com.oracle.graal.api.code.DataSection.DataBuilder; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.printer.*; + +/** + * HotSpot implementation of {@link CodeCacheProvider}. + */ +public class HotSpotCodeCacheProvider implements CodeCacheProvider { + + protected final HotSpotGraalRuntimeProvider runtime; + public final HotSpotVMConfig config; + protected final TargetDescription target; + protected final RegisterConfig regConfig; + + public HotSpotCodeCacheProvider(HotSpotGraalRuntimeProvider runtime, HotSpotVMConfig config, TargetDescription target, RegisterConfig regConfig) { + this.runtime = runtime; + this.config = config; + this.target = target; + this.regConfig = regConfig; + } + + @Override + public String disassemble(CompilationResult compResult, InstalledCode installedCode) { + byte[] code = installedCode == null ? Arrays.copyOf(compResult.getTargetCode(), compResult.getTargetCodeSize()) : installedCode.getCode(); + if (code == null) { + // Method was deoptimized/invalidated + return ""; + } + long start = installedCode == null ? 0L : installedCode.getStart(); + HexCodeFile hcf = new HexCodeFile(code, start, target.arch.getName(), target.wordSize * 8); + if (compResult != null) { + HexCodeFile.addAnnotations(hcf, compResult.getAnnotations()); + addExceptionHandlersComment(compResult, hcf); + Register fp = regConfig.getFrameRegister(); + RefMapFormatter slotFormatter = new DefaultRefMapFormatter(target.arch, target.wordSize, fp, 0); + for (Infopoint infopoint : compResult.getInfopoints()) { + if (infopoint instanceof Call) { + Call call = (Call) infopoint; + if (call.debugInfo != null) { + hcf.addComment(call.pcOffset + call.size, CodeUtil.append(new StringBuilder(100), call.debugInfo, slotFormatter).toString()); + } + addOperandComment(hcf, call.pcOffset, "{" + getTargetName(call) + "}"); + } else { + if (infopoint.debugInfo != null) { + hcf.addComment(infopoint.pcOffset, CodeUtil.append(new StringBuilder(100), infopoint.debugInfo, slotFormatter).toString()); + } + addOperandComment(hcf, infopoint.pcOffset, "{infopoint: " + infopoint.reason + "}"); + } + } + for (DataPatch site : compResult.getDataPatches()) { + hcf.addOperandComment(site.pcOffset, "{" + site.reference.toString() + "}"); + } + for (Mark mark : compResult.getMarks()) { + hcf.addComment(mark.pcOffset, getMarkIdName((int) mark.id)); + } + } + String hcfEmbeddedString = hcf.toEmbeddedString(); + return HexCodeFileDisTool.tryDisassemble(hcfEmbeddedString); + } + + /** + * Interface to the tool for disassembling an {@link HexCodeFile#toEmbeddedString() embedded} + * {@link HexCodeFile}. + */ + static class HexCodeFileDisTool { + static final Method processMethod; + static { + Method toolMethod = null; + try { + Class toolClass = Class.forName("com.oracle.max.hcfdis.HexCodeFileDis", true, ClassLoader.getSystemClassLoader()); + toolMethod = toolClass.getDeclaredMethod("processEmbeddedString", String.class); + } catch (Exception e) { + // Tool not available on the class path + } + processMethod = toolMethod; + } + + public static String tryDisassemble(String hcfEmbeddedString) { + if (processMethod != null) { + try { + return (String) processMethod.invoke(null, hcfEmbeddedString); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + // If the tool is available, for now let's be noisy when it fails + throw new GraalInternalError(e); + } + } + return hcfEmbeddedString; + } + } + + private String getMarkIdName(int markId) { + 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 String.valueOf(markId); + } + + /** + * Decodes a call target to a mnemonic if possible. + */ + private 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 String.valueOf(call.target); + } + + private static void addExceptionHandlersComment(CompilationResult compResult, HexCodeFile hcf) { + if (!compResult.getExceptionHandlers().isEmpty()) { + String nl = HexCodeFile.NEW_LINE; + StringBuilder buf = new StringBuilder("------ Exception Handlers ------").append(nl); + for (CompilationResult.ExceptionHandler e : compResult.getExceptionHandlers()) { + buf.append(" ").append(e.pcOffset).append(" -> ").append(e.handlerPos).append(nl); + hcf.addComment(e.pcOffset, "[exception -> " + e.handlerPos + "]"); + hcf.addComment(e.handlerPos, "[exception handler for " + e.pcOffset + "]"); + } + hcf.addComment(0, buf.toString()); + } + } + + private static void addOperandComment(HexCodeFile hcf, int pos, String comment) { + String oldValue = hcf.addOperandComment(pos, comment); + assert oldValue == null : "multiple comments for operand of instruction at " + pos + ": " + comment + ", " + oldValue; + } + + @Override + public RegisterConfig getRegisterConfig() { + return regConfig; + } + + @Override + public int getMinimumOutgoingSize() { + return runtime.getConfig().runtimeCallStackSize; + } + + public InstalledCode logOrDump(InstalledCode installedCode, CompilationResult compResult) { + if (Debug.isDumpEnabled()) { + Debug.dump(new Object[]{compResult, installedCode}, "After code installation"); + } + if (Debug.isLogEnabled()) { + Debug.log("%s", disassemble(installedCode)); + } + return installedCode; + } + + public InstalledCode installMethod(HotSpotResolvedJavaMethod method, CompilationResult compResult, long graalEnv, boolean isDefault) { + if (compResult.getId() == -1) { + compResult.setId(method.allocateCompileId(compResult.getEntryBCI())); + } + HotSpotInstalledCode installedCode = new HotSpotNmethod(method, compResult.getName(), isDefault); + runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(method, compResult, graalEnv), installedCode, method.getSpeculationLog()); + return logOrDump(installedCode, compResult); + } + + @Override + public InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult, SpeculationLog log, InstalledCode predefinedInstalledCode) { + HotSpotResolvedJavaMethod hotspotMethod = (HotSpotResolvedJavaMethod) method; + if (compResult.getId() == -1) { + compResult.setId(hotspotMethod.allocateCompileId(compResult.getEntryBCI())); + } + InstalledCode installedCode = predefinedInstalledCode; + if (installedCode == null) { + HotSpotInstalledCode code = new HotSpotNmethod(hotspotMethod, compResult.getName(), false); + installedCode = code; + } + HotSpotCompiledNmethod compiledCode = new HotSpotCompiledNmethod(hotspotMethod, compResult); + int result = runtime.getCompilerToVM().installCode(compiledCode, installedCode, log); + if (result != config.codeInstallResultOk) { + String msg = compiledCode.getInstallationFailureMessage(); + String resultDesc = config.getCodeInstallResultDescription(result); + 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); + } + return logOrDump(installedCode, compResult); + } + + @Override + public InstalledCode setDefaultMethod(ResolvedJavaMethod method, CompilationResult compResult) { + HotSpotResolvedJavaMethod hotspotMethod = (HotSpotResolvedJavaMethod) method; + return installMethod(hotspotMethod, compResult, 0L, true); + } + + public HotSpotNmethod addExternalMethod(ResolvedJavaMethod method, CompilationResult compResult) { + HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) method; + if (compResult.getId() == -1) { + compResult.setId(javaMethod.allocateCompileId(compResult.getEntryBCI())); + } + HotSpotNmethod code = new HotSpotNmethod(javaMethod, compResult.getName(), false, true); + HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(javaMethod, compResult); + CompilerToVM vm = runtime.getCompilerToVM(); + int result = vm.installCode(compiled, code, null); + if (result != runtime.getConfig().codeInstallResultOk) { + return null; + } + return code; + } + + public boolean needsDataPatch(JavaConstant constant) { + return constant instanceof HotSpotMetaspaceConstant; + } + + public Data createDataItem(Constant constant) { + int size; + DataBuilder builder; + if (constant instanceof VMConstant) { + VMConstant vmConstant = (VMConstant) constant; + boolean compressed; + long raw; + if (constant instanceof HotSpotObjectConstant) { + HotSpotObjectConstant c = (HotSpotObjectConstant) vmConstant; + compressed = c.isCompressed(); + raw = 0xDEADDEADDEADDEADL; + } else if (constant instanceof HotSpotMetaspaceConstant) { + HotSpotMetaspaceConstant meta = (HotSpotMetaspaceConstant) constant; + compressed = meta.isCompressed(); + raw = meta.rawValue(); + } else { + throw GraalInternalError.shouldNotReachHere(); + } + + size = target.getSizeInBytes(compressed ? Kind.Int : target.wordKind); + if (size == 4) { + builder = (buffer, patch) -> { + patch.accept(new DataPatch(buffer.position(), new ConstantReference(vmConstant))); + buffer.putInt((int) raw); + }; + } else { + assert size == 8; + builder = (buffer, patch) -> { + patch.accept(new DataPatch(buffer.position(), new ConstantReference(vmConstant))); + buffer.putLong(raw); + }; + } + } else if (JavaConstant.isNull(constant)) { + boolean compressed = COMPRESSED_NULL.equals(constant); + size = target.getSizeInBytes(compressed ? Kind.Int : target.wordKind); + builder = DataBuilder.zero(size); + } else if (constant instanceof SerializableConstant) { + SerializableConstant s = (SerializableConstant) constant; + size = s.getSerializedSize(); + builder = DataBuilder.serializable(s); + } else { + throw GraalInternalError.shouldNotReachHere(); + } + + return new Data(size, size, builder); + } + + @Override + public TargetDescription getTarget() { + return target; + } + + public String disassemble(InstalledCode code) { + if (code.isValid()) { + long codeBlob = code.getAddress(); + return runtime.getCompilerToVM().disassembleCodeBlob(codeBlob); + } + return null; + } + + public SpeculationLog createSpeculationLog() { + return new HotSpotSpeculationLog(); + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCompiledCode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCompiledCode.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import java.nio.*; +import java.util.*; +import java.util.stream.*; +import java.util.stream.Stream.Builder; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.code.CompilationResult.CodeAnnotation; +import com.oracle.graal.api.code.CompilationResult.CodeComment; +import com.oracle.graal.api.code.CompilationResult.DataPatch; +import com.oracle.graal.api.code.CompilationResult.ExceptionHandler; +import com.oracle.graal.api.code.CompilationResult.Infopoint; +import com.oracle.graal.api.code.CompilationResult.JumpTable; +import com.oracle.graal.api.code.CompilationResult.Mark; +import com.oracle.graal.api.code.CompilationResult.Site; + +/** + * A {@link CompilationResult} with additional HotSpot-specific information required for installing + * the code in HotSpot's code cache. + */ +public abstract class HotSpotCompiledCode { + + public final CompilationResult comp; + + public final Site[] sites; + public final ExceptionHandler[] exceptionHandlers; + public final Comment[] comments; + + public final byte[] dataSection; + public final int dataSectionAlignment; + public final DataPatch[] dataSectionPatches; + + 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(CompilationResult compResult) { + this.comp = compResult; + sites = getSortedSites(compResult); + if (compResult.getExceptionHandlers().isEmpty()) { + exceptionHandlers = null; + } else { + exceptionHandlers = compResult.getExceptionHandlers().toArray(new ExceptionHandler[compResult.getExceptionHandlers().size()]); + } + List annotations = compResult.getAnnotations(); + comments = new Comment[annotations.size()]; + if (!annotations.isEmpty()) { + for (int i = 0; i < comments.length; i++) { + CodeAnnotation annotation = annotations.get(i); + String text; + if (annotation instanceof CodeComment) { + CodeComment codeComment = (CodeComment) annotation; + text = codeComment.value; + } else if (annotation instanceof JumpTable) { + JumpTable jumpTable = (JumpTable) annotation; + text = "JumpTable [" + jumpTable.low + " .. " + jumpTable.high + "]"; + } else { + text = annotation.toString(); + } + comments[i] = new Comment(annotation.position, text); + } + } + assert validateFrames(); + + DataSection data = compResult.getDataSection(); + data.finalizeLayout(); + dataSection = new byte[data.getSectionSize()]; + + ByteBuffer buffer = ByteBuffer.wrap(dataSection).order(ByteOrder.nativeOrder()); + Builder patchBuilder = Stream.builder(); + data.buildDataSection(buffer, patchBuilder); + + dataSectionAlignment = data.getSectionAlignment(); + dataSectionPatches = patchBuilder.build().toArray(len -> new DataPatch[len]); + } + + /** + * Ensure that all the frames passed into HotSpot 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(false); + } + } + } + return true; + } + + static class SiteComparator implements Comparator { + + public int compare(Site s1, Site s2) { + if (s1.pcOffset == s2.pcOffset && (s1 instanceof Mark ^ s2 instanceof Mark)) { + return s1 instanceof Mark ? -1 : 1; + } + return s1.pcOffset - s2.pcOffset; + } + } + + private static Site[] getSortedSites(CompilationResult target) { + List[] lists = new List[]{target.getInfopoints(), target.getDataPatches(), target.getMarks()}; + int count = 0; + for (List list : lists) { + count += list.size(); + } + Site[] result = new Site[count]; + int pos = 0; + for (List list : lists) { + for (Object elem : list) { + result[pos++] = (Site) elem; + } + } + Arrays.sort(result, new SiteComparator()); + return result; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCompiledNmethod.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCompiledNmethod.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.code.*; + +import edu.umd.cs.findbugs.annotations.*; + +/** + * {@link HotSpotCompiledCode} destined for installation as an nmethod. + */ +public final class HotSpotCompiledNmethod extends HotSpotCompiledCode { + + public final HotSpotResolvedJavaMethod method; + public final int entryBCI; + public final int id; + public final long graalEnv; + + /** + * 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("UWF_UNWRITTEN_FIELD") private String installationFailureMessage; + + public HotSpotCompiledNmethod(HotSpotResolvedJavaMethod method, CompilationResult compResult) { + this(method, compResult, 0L); + } + + public HotSpotCompiledNmethod(HotSpotResolvedJavaMethod method, CompilationResult compResult, long graalEnv) { + super(compResult); + this.method = method; + this.entryBCI = compResult.getEntryBCI(); + this.id = compResult.getId(); + this.graalEnv = graalEnv; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "[" + id + ":" + method.format("%H.%n(%p)%r@") + entryBCI + "]"; + } + + public String getInstallationFailureMessage() { + return installationFailureMessage; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCompressedNullConstant.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCompressedNullConstant.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,102 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.meta.*; + +/** + * The compressed representation of the {@link JavaConstant#NULL_POINTER null constant}. + */ +public final class HotSpotCompressedNullConstant extends AbstractValue implements JavaConstant, HotSpotConstant { + + public static final JavaConstant COMPRESSED_NULL = new HotSpotCompressedNullConstant(); + + private HotSpotCompressedNullConstant() { + super(LIRKind.reference(Kind.Int)); + } + + @Override + public boolean isNull() { + return true; + } + + @Override + public boolean isCompressed() { + 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 "null"; + } + + @Override + public int hashCode() { + return System.identityHashCode(this); + } + + @Override + public boolean equals(Object o) { + return o instanceof HotSpotCompressedNullConstant; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstant.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstant.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,33 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.meta.*; + +/** + * Marker interface for hotspot specific constants. + */ +public interface HotSpotConstant extends Constant { + + boolean isCompressed(); +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantPool.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantPool.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,619 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.compiler.common.UnsafeAccess.*; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + +import java.lang.invoke.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.bytecode.*; +import com.oracle.graal.compiler.common.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.meta.*; + +/** + * Implementation of {@link ConstantPool} for HotSpot. + */ +public class HotSpotConstantPool implements ConstantPool, HotSpotProxified { + + /** + * 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; + + private JVM_CONSTANT(int tag) { + this.tag = tag; + } + + private static HotSpotVMConfig config() { + return runtime().getConfig(); + } + + /** + * 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 GraalInternalError.shouldNotReachHere("unknown JVM_CONSTANT tag " + tag); + } + } + + public static JVM_CONSTANT getEnum(int tag) { + return TagValueMap.get(tag); + } + } + + private static class LookupTypeCacheElement { + int lastCpi = Integer.MIN_VALUE; + JavaType javaType; + + public LookupTypeCacheElement(int lastCpi, JavaType javaType) { + super(); + this.lastCpi = lastCpi; + this.javaType = javaType; + } + } + + /** + * Reference to the C++ ConstantPool object. + */ + private final long metaspaceConstantPool; + private final Object[] cache; + private volatile LookupTypeCacheElement lastLookupType; + + public HotSpotConstantPool(long metaspaceConstantPool) { + this.metaspaceConstantPool = metaspaceConstantPool; + cache = new Object[length()]; + } + + /** + * Gets the holder for this constant pool as {@link HotSpotResolvedObjectTypeImpl}. + * + * @return holder for this constant pool + */ + private HotSpotResolvedObjectType getHolder() { + final long metaspaceKlass = unsafe.getAddress(metaspaceConstantPool + runtime().getConfig().constantPoolHolderOffset); + return HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass); + } + + /** + * 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 toConstantPoolIndex(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 " + Bytecodes.nameOf(opcode); + index = rawIndex + runtime().getConfig().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 - runtime().getConfig().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; + } + + /** + * 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 = runtime().getConfig(); + final long metaspaceConstantPoolTags = unsafe.getAddress(metaspaceConstantPool + 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(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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 runtime().getCompilerToVM().lookupNameAndTypeRefIndexInPool(metaspaceConstantPool, index); + } + + /** + * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index + * {@code index}. + * + * @param index constant pool index + * @return name as {@link String} + */ + private String getNameRefAt(int index) { + return runtime().getCompilerToVM().lookupNameRefInPool(metaspaceConstantPool, index); + } + + /** + * 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 at index + * {@code index}. + * + * @param index constant pool index + * @return signature as {@link String} + */ + private String getSignatureRefAt(int index) { + return runtime().getCompilerToVM().lookupSignatureRefInPool(metaspaceConstantPool, index); + } + + /** + * 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 runtime().getCompilerToVM().lookupKlassRefIndexInPool(metaspaceConstantPool, 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) { + assert getTagAt(index) == JVM_CONSTANT.Fieldref || getTagAt(index) == JVM_CONSTANT.MethodRef || getTagAt(index) == JVM_CONSTANT.InterfaceMethodref; + final int refIndex = unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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) { + assert getTagAt(index) == tag : "constant pool tag at index " + index + " is " + getTagAt(index) + " but expected " + tag; + } + + @Override + public int length() { + return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().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: + Object string = runtime().getCompilerToVM().resolvePossiblyCachedConstantInPool(metaspaceConstantPool, cpi); + return HotSpotObjectConstantImpl.forObject(string); + case MethodHandle: + case MethodHandleInError: + case MethodType: + case MethodTypeInError: + Object obj = runtime().getCompilerToVM().resolveConstantInPool(metaspaceConstantPool, cpi); + return HotSpotObjectConstantImpl.forObject(obj); + default: + throw GraalInternalError.shouldNotReachHere("unknown constant pool tag " + tag); + } + } + + @Override + public String lookupUtf8(int cpi) { + assertTag(cpi, JVM_CONSTANT.Utf8); + return runtime().getCompilerToVM().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 = toConstantPoolIndex(cpi, opcode); + Object result = runtime().getCompilerToVM().lookupAppendixInPool(metaspaceConstantPool, index); + if (result == null) { + return null; + } else { + return HotSpotObjectConstantImpl.forObject(result); + } + } + + /** + * Gets a {@link JavaType} corresponding a given metaspace Klass or a metaspace Symbol depending + * on the {@link HotSpotVMConfig#compilerToVMKlassTag tag}. + * + * @param metaspacePointer either a metaspace Klass or a metaspace Symbol + */ + private static JavaType getJavaType(final long metaspacePointer) { + HotSpotGraalRuntimeProvider runtime = runtime(); + HotSpotVMConfig config = runtime.getConfig(); + if ((metaspacePointer & config.compilerToVMSymbolTag) != 0) { + final long metaspaceSymbol = metaspacePointer & ~config.compilerToVMSymbolTag; + String name = runtime.getCompilerToVM().getSymbol(metaspaceSymbol); + return HotSpotUnresolvedJavaType.create(runtime(), "L" + name + ";"); + } else { + assert (metaspacePointer & config.compilerToVMKlassTag) == 0; + return HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspacePointer); + } + } + + @Override + public JavaMethod lookupMethod(int cpi, int opcode) { + if (opcode != Bytecodes.INVOKEDYNAMIC) { + Object result = cache[cpi]; + if (result != null) { + return (ResolvedJavaMethod) result; + } + } + final int index = toConstantPoolIndex(cpi, opcode); + final long metaspaceMethod = runtime().getCompilerToVM().lookupMethodInPool(metaspaceConstantPool, index, (byte) opcode); + if (metaspaceMethod != 0L) { + HotSpotResolvedJavaMethod result = HotSpotResolvedJavaMethodImpl.fromMetaspace(metaspaceMethod); + if (opcode != Bytecodes.INVOKEDYNAMIC) { + cache[cpi] = result; + } + return result; + } else { + // Get the method's name and signature. + String name = getNameRefAt(index); + HotSpotSignature signature = new HotSpotSignature(runtime(), getSignatureRefAt(index)); + if (opcode == Bytecodes.INVOKEDYNAMIC) { + HotSpotResolvedObjectType holder = HotSpotResolvedObjectTypeImpl.fromObjectClass(MethodHandle.class); + return new HotSpotMethodUnresolved(name, signature, holder); + } else { + final int klassIndex = getKlassRefIndexAt(index); + final long metaspacePointer = runtime().getCompilerToVM().lookupKlassInPool(metaspaceConstantPool, klassIndex); + JavaType holder = getJavaType(metaspacePointer); + 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 long metaspacePointer = runtime().getCompilerToVM().lookupKlassInPool(metaspaceConstantPool, cpi); + JavaType result = getJavaType(metaspacePointer); + if (result instanceof ResolvedJavaType) { + this.lastLookupType = new LookupTypeCacheElement(cpi, result); + } + return result; + } + } + + @Override + public JavaField lookupField(int cpi, int opcode) { + Object resolvedJavaField = cache[cpi]; + if (resolvedJavaField != null) { + return (ResolvedJavaField) resolvedJavaField; + } + final int index = toConstantPoolIndex(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]; + long metaspaceKlass; + try { + metaspaceKlass = runtime().getCompilerToVM().resolveField(metaspaceConstantPool, 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); + } + HotSpotResolvedObjectTypeImpl resolvedHolder = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass); + final int flags = (int) info[0]; + final long offset = info[1]; + HotSpotResolvedJavaField result = resolvedHolder.createField(name, type, offset, flags); + if (type instanceof ResolvedJavaType) { + cache[cpi] = result; + } + return result; + } else { + return new HotSpotUnresolvedField(holder, name, type); + } + } + + @Override + 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) + runtime().getConfig().constantPoolCpCacheIndexTag; + index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(metaspaceConstantPool, index); + break; + default: + index = toConstantPoolIndex(cpi, opcode); + index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(metaspaceConstantPool, index); + } + + 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 Fieldref: + case MethodRef: + case InterfaceMethodref: + index = getUncachedKlassRefIndexAt(index); + tag = getTagAt(index); + assert tag == JVM_CONSTANT.Class || tag == JVM_CONSTANT.UnresolvedClass || tag == JVM_CONSTANT.UnresolvedClassInError : tag; + // fall through + case Class: + case UnresolvedClass: + case UnresolvedClassInError: + final long metaspaceKlass = runtime().getCompilerToVM().constantPoolKlassAt(metaspaceConstantPool, index); + HotSpotResolvedObjectTypeImpl type = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass); + Class klass = type.mirror(); + if (!klass.isPrimitive() && !klass.isArray()) { + unsafe.ensureClassInitialized(klass); + } + break; + case InvokeDynamic: + if (isInvokedynamicIndex(cpi)) { + runtime().getCompilerToVM().resolveInvokeDynamic(metaspaceConstantPool, cpi); + } + break; + default: + // nothing + break; + } + } + + @Override + public String toString() { + HotSpotResolvedObjectType holder = getHolder(); + return "HotSpotConstantPool<" + holder.toJavaName() + ">"; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantReflectionProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantReflectionProvider.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,443 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.compiler.common.GraalOptions.*; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; +import static com.oracle.graal.hotspot.stubs.SnippetStub.*; + +import java.lang.reflect.*; +import java.util.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.options.*; +import com.oracle.graal.replacements.*; +import com.oracle.graal.replacements.SnippetTemplate.Arguments; + +/** + * HotSpot implementation of {@link ConstantReflectionProvider}. + */ +public class HotSpotConstantReflectionProvider implements ConstantReflectionProvider, HotSpotProxified { + private static final String SystemClassName = "Ljava/lang/System;"; + + protected final HotSpotGraalRuntimeProvider runtime; + protected final HotSpotMethodHandleAccessProvider methodHandleAccess; + protected final HotSpotMemoryAccessProviderImpl memoryAccess; + + public HotSpotConstantReflectionProvider(HotSpotGraalRuntimeProvider 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 x.equals(y); + } + } + + @Override + public Integer readArrayLength(JavaConstant array) { + if (array.getKind() != Kind.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 -1 if the offset isn't within the array or the computed index + */ + private int indexForOffset(JavaConstant array, long offset) { + if (array.getKind() != Kind.Object || array.isNull()) { + return -1; + } + Class componentType = ((HotSpotObjectConstantImpl) array).object().getClass().getComponentType(); + Kind kind = runtime.getHostProviders().getMetaAccess().lookupJavaType(componentType).getKind(); + int arraybase = runtime.getArrayBaseOffset(kind); + int scale = runtime.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.getKind() != Kind.Object || array.isNull()) { + return null; + } + Object a = ((HotSpotObjectConstantImpl) array).object(); + + if (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.getKind()) { + 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.getKind()); + } + } + + @Override + public JavaConstant boxPrimitive(JavaConstant source) { + if (!source.getKind().isPrimitive() || !isBoxCached(source)) { + return null; + } + return HotSpotObjectConstantImpl.forObject(source.asBoxedPrimitive()); + } + + @Override + public JavaConstant unboxPrimitive(JavaConstant source) { + if (!source.getKind().isObject()) { + return null; + } + if (source.isNull()) { + return null; + } + return JavaConstant.forBoxedPrimitive(((HotSpotObjectConstantImpl) source).object()); + } + + public JavaConstant forString(String 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.getHostProviders().getMetaAccess().lookupJavaType((Class) obj); + } + } + if (constant instanceof HotSpotMetaspaceConstant) { + Object obj = HotSpotMetaspaceConstantImpl.getMetaspaceObject(constant); + if (obj instanceof HotSpotResolvedObjectTypeImpl) { + return (ResolvedJavaType) obj; + } + } + return null; + } + + /** + * {@inheritDoc} + *

+ * The {@code value} field in {@link OptionValue} is considered constant if the type of + * {@code receiver} is (assignable to) {@link StableOptionValue}. + */ + public JavaConstant readConstantFieldValue(JavaField field, JavaConstant receiver) { + assert !ImmutableCode.getValue() || isCalledForSnippets() || SnippetGraphUnderConstruction.get() != null || HotSpotLoadFieldPlugin.FieldReadEnabledInImmutableCode.get() == Boolean.TRUE : receiver; + HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; + + if (hotspotField.isStatic()) { + if (hotspotField.isFinal() || hotspotField.isStable()) { + ResolvedJavaType holder = hotspotField.getDeclaringClass(); + if (holder.isInitialized() && !holder.getName().equals(SystemClassName) && isEmbeddable(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 (!value.isDefaultForKind() || assumeNonStaticFinalDefaultFieldsAsFinal(object.getClass())) { + return value; + } + } + } else if (hotspotField.isStable()) { + if (hotspotField.isInObject(object)) { + JavaConstant value = readFieldValue(field, receiver); + if (assumeDefaultStableFieldsAsFinal(object.getClass()) || !value.isDefaultForKind()) { + return value; + } + } + } else { + Class clazz = object.getClass(); + if (StableOptionValue.class.isAssignableFrom(clazz)) { + if (hotspotField.isInObject(object) && hotspotField.getName().equals("value")) { + StableOptionValue option = (StableOptionValue) object; + return HotSpotObjectConstantImpl.forObject(option.getValue()); + } + } + } + } + } + return null; + } + + public JavaConstant readFieldValue(JavaField field, JavaConstant receiver) { + HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; + if (!hotspotField.isStable()) { + return readNonStableFieldValue(field, receiver); + } else { + return readStableFieldValue(field, receiver, false); + } + } + + private JavaConstant readNonStableFieldValue(JavaField field, JavaConstant receiver) { + HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; + if (hotspotField.isStatic()) { + HotSpotResolvedJavaType holder = (HotSpotResolvedJavaType) hotspotField.getDeclaringClass(); + if (holder.isInitialized()) { + return memoryAccess.readUnsafeConstant(hotspotField.getKind(), HotSpotObjectConstantImpl.forObject(holder.mirror()), hotspotField.offset()); + } + } else { + if (receiver.isNonNull() && hotspotField.isInObject(((HotSpotObjectConstantImpl) receiver).object())) { + return memoryAccess.readUnsafeConstant(hotspotField.getKind(), receiver, hotspotField.offset()); + } + } + return null; + } + + public JavaConstant readStableFieldValue(JavaField field, JavaConstant receiver, boolean isDefaultStable) { + JavaConstant fieldValue = readNonStableFieldValue(field, receiver); + if (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; + } + + /** + * Compares two {@link StackTraceElement}s for equality, ignoring differences in + * {@linkplain StackTraceElement#getLineNumber() line number}. + */ + private static boolean equalsIgnoringLine(StackTraceElement left, StackTraceElement right) { + return left.getClassName().equals(right.getClassName()) && left.getMethodName().equals(right.getMethodName()) && left.getFileName().equals(right.getFileName()); + } + + /** + * If the compiler is configured for AOT mode, + * {@link #readConstantFieldValue(JavaField, JavaConstant)} should be only called for snippets + * or replacements. + */ + private static boolean isCalledForSnippets() { + MetaAccessProvider metaAccess = runtime().getHostProviders().getMetaAccess(); + ResolvedJavaMethod makeGraphMethod = null; + ResolvedJavaMethod initMethod = null; + try { + Class rjm = ResolvedJavaMethod.class; + makeGraphMethod = metaAccess.lookupJavaMethod(ReplacementsImpl.class.getDeclaredMethod("makeGraph", rjm, Object[].class, rjm)); + initMethod = metaAccess.lookupJavaMethod(SnippetTemplate.AbstractTemplates.class.getDeclaredMethod("template", Arguments.class)); + } catch (NoSuchMethodException | SecurityException e) { + throw new GraalInternalError(e); + } + StackTraceElement makeGraphSTE = makeGraphMethod.asStackTraceElement(0); + StackTraceElement initSTE = initMethod.asStackTraceElement(0); + + StackTraceElement[] stackTrace = new Exception().getStackTrace(); + for (StackTraceElement element : stackTrace) { + // Ignoring line numbers should not weaken this check too much while at + // the same time making it more robust against source code changes + if (equalsIgnoringLine(makeGraphSTE, element) || equalsIgnoringLine(initSTE, element)) { + return true; + } + } + return false; + } + + private static boolean assumeNonStaticFinalDefaultFieldsAsFinal(Class clazz) { + if (TrustFinalDefaultFields.getValue()) { + return true; + } + return clazz == SnippetCounter.class || clazz == NodeClass.class; + } + + /** + * Usually {@link Stable} fields are not considered constant if the value is the + * {@link JavaConstant#isDefaultForKind default value}. For some special classes we want to + * override this behavior. + */ + private static boolean assumeDefaultStableFieldsAsFinal(Class clazz) { + // HotSpotVMConfig has a lot of zero-value fields which we know are stable and want to be + // considered as constants. + if (clazz == HotSpotVMConfig.class) { + return true; + } + return false; + } + + /** + * in AOT mode, some fields should never be embedded even for snippets/replacements. + */ + private static boolean isEmbeddable(HotSpotResolvedJavaField field) { + return Embeddable.test(field); + } + + /** + * Separate out the static initialization to eliminate cycles between clinit and other locks + * that could lead to deadlock. Static code that doesn't call back into type or field machinery + * is probably ok but anything else should be made lazy. + */ + static class Embeddable { + + /** + * @return Return true if it's ok to embed the value of {@code field}. + */ + public static boolean test(HotSpotResolvedJavaField field) { + return !ImmutableCode.getValue() || !fields.contains(field); + } + + private static final List fields = new ArrayList<>(); + static { + try { + MetaAccessProvider metaAccess = runtime().getHostProviders().getMetaAccess(); + fields.add(metaAccess.lookupJavaField(Boolean.class.getDeclaredField("TRUE"))); + fields.add(metaAccess.lookupJavaField(Boolean.class.getDeclaredField("FALSE"))); + + Class characterCacheClass = Character.class.getDeclaredClasses()[0]; + assert "java.lang.Character$CharacterCache".equals(characterCacheClass.getName()); + fields.add(metaAccess.lookupJavaField(characterCacheClass.getDeclaredField("cache"))); + + Class byteCacheClass = Byte.class.getDeclaredClasses()[0]; + assert "java.lang.Byte$ByteCache".equals(byteCacheClass.getName()); + fields.add(metaAccess.lookupJavaField(byteCacheClass.getDeclaredField("cache"))); + + Class shortCacheClass = Short.class.getDeclaredClasses()[0]; + assert "java.lang.Short$ShortCache".equals(shortCacheClass.getName()); + fields.add(metaAccess.lookupJavaField(shortCacheClass.getDeclaredField("cache"))); + + Class integerCacheClass = Integer.class.getDeclaredClasses()[0]; + assert "java.lang.Integer$IntegerCache".equals(integerCacheClass.getName()); + fields.add(metaAccess.lookupJavaField(integerCacheClass.getDeclaredField("cache"))); + + Class longCacheClass = Long.class.getDeclaredClasses()[0]; + assert "java.lang.Long$LongCache".equals(longCacheClass.getName()); + fields.add(metaAccess.lookupJavaField(longCacheClass.getDeclaredField("cache"))); + + fields.add(metaAccess.lookupJavaField(Throwable.class.getDeclaredField("UNASSIGNED_STACK"))); + fields.add(metaAccess.lookupJavaField(Throwable.class.getDeclaredField("SUPPRESSED_SENTINEL"))); + } catch (SecurityException | NoSuchFieldException e) { + throw new GraalInternalError(e); + } + } + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotForeignCallTarget.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotForeignCallTarget.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,41 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.meta.*; + +public class HotSpotForeignCallTarget { + /** + * The descriptor of the call. + */ + protected final ForeignCallDescriptor descriptor; + + /** + * The entry point address of this call's target. + */ + protected long address; + + public HotSpotForeignCallTarget(ForeignCallDescriptor descriptor, long address) { + this.descriptor = descriptor; + this.address = address; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotInstalledCode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotInstalledCode.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,97 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.compiler.common.UnsafeAccess.*; +import sun.misc.*; + +import com.oracle.graal.api.code.*; + +import edu.umd.cs.findbugs.annotations.*; + +/** + * 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; + } + + /** + * @return a copy of this code blob if it is {@linkplain #isValid() valid}, null otherwise. + */ + public byte[] getBlob() { + if (!isValid()) { + return null; + } + byte[] blob = new byte[size]; + unsafe.copyMemory(null, getAddress(), blob, Unsafe.ARRAY_BYTE_BASE_OFFSET, size); + return blob; + } + + @Override + public abstract String toString(); + + @Override + public long getStart() { + return codeStart; + } + + @Override + 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; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJavaType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJavaType.java Tue May 19 23:16:07 2015 +0200 @@ -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 com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.meta.*; + +/** + * 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; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMemoryAccessProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMemoryAccessProvider.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,40 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; + +/** + * 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); +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMemoryAccessProviderImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMemoryAccessProviderImpl.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.compiler.common.UnsafeAccess.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; + +/** + * HotSpot implementation of {@link MemoryAccessProvider}. + */ +public class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, HotSpotProxified { + + protected final HotSpotGraalRuntimeProvider runtime; + + public HotSpotMemoryAccessProviderImpl(HotSpotGraalRuntimeProvider 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) { + Object 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 if (displacement == runtime.getConfig().arrayKlassComponentMirrorOffset) { + // ArrayKlass::_component_mirror is only valid for all ArrayKlass* values + return ((HotSpotResolvedObjectTypeImpl) metaspaceObject).mirror().isArray(); + } + } else { + throw GraalInternalError.shouldNotReachHere(); + } + } + return false; + } + + private static long asRawPointer(Constant base) { + if (base instanceof HotSpotMetaspaceConstant) { + return ((HotSpotMetaspaceConstant) base).rawValue(); + } else if (base instanceof PrimitiveConstant) { + PrimitiveConstant prim = (PrimitiveConstant) base; + if (prim.getKind().isNumericInteger()) { + return prim.asLong(); + } + } + throw GraalInternalError.shouldNotReachHere(); + } + + private static long readRawValue(Constant baseConstant, long displacement, int bits) { + Object base = asObject(baseConstant); + if (base != null) { + switch (bits) { + case 8: + return unsafe.getByte(base, displacement); + case 16: + return unsafe.getShort(base, displacement); + case 32: + return unsafe.getInt(base, displacement); + case 64: + return unsafe.getLong(base, displacement); + default: + throw GraalInternalError.shouldNotReachHere(); + } + } else { + long pointer = asRawPointer(baseConstant); + switch (bits) { + case 8: + return unsafe.getByte(pointer + displacement); + case 16: + return unsafe.getShort(pointer + displacement); + case 32: + return unsafe.getInt(pointer + displacement); + case 64: + return unsafe.getLong(pointer + displacement); + default: + throw GraalInternalError.shouldNotReachHere(); + } + } + } + + 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) { + Object metaspaceObject = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base); + if (metaspaceObject instanceof HotSpotResolvedObjectTypeImpl) { + if (displacement == runtime.getConfig().classMirrorOffset) { + assert expected == ((HotSpotResolvedObjectTypeImpl) metaspaceObject).mirror(); + } else if (displacement == runtime.getConfig().arrayKlassComponentMirrorOffset) { + assert expected == ((HotSpotResolvedObjectTypeImpl) metaspaceObject).mirror().getComponentType(); + } + } + } + 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(Kind kind, JavaConstant baseConstant, long displacement) { + if (kind == Kind.Object) { + Object o = readRawObject(baseConstant, displacement, runtime.getConfig().useCompressedOops); + return HotSpotObjectConstantImpl.forObject(o); + } else { + return readPrimitiveConstant(kind, baseConstant, displacement, kind.getByteCount() * 8); + } + } + + @Override + public JavaConstant readPrimitiveConstant(Kind 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 GraalInternalError.shouldNotReachHere("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); + } + + @Override + public Constant readKlassPointerConstant(Constant base, long displacement) { + long klass = readRawValue(base, displacement, runtime.getTarget().wordSize * 8); + if (klass == 0) { + return JavaConstant.NULL_POINTER; + } + HotSpotResolvedObjectType metaKlass = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(klass); + return HotSpotMetaspaceConstantImpl.forMetaspaceObject(runtime.getTarget().wordKind, klass, metaKlass, false); + } + + @Override + public Constant readNarrowKlassPointerConstant(Constant base, long displacement, CompressEncoding encoding) { + int compressed = (int) readRawValue(base, displacement, 32); + long klass = encoding.uncompress(compressed); + if (klass == 0) { + return HotSpotCompressedNullConstant.COMPRESSED_NULL; + } + HotSpotResolvedObjectType metaKlass = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(klass); + return HotSpotMetaspaceConstantImpl.forMetaspaceObject(Kind.Int, compressed, metaKlass, true); + } + + @Override + public Constant readMethodPointerConstant(Constant base, long displacement) { + long method = readRawValue(base, displacement, runtime.getTarget().wordSize * 8); + HotSpotResolvedJavaMethod metaMethod = HotSpotResolvedJavaMethodImpl.fromMetaspace(method); + return HotSpotMetaspaceConstantImpl.forMetaspaceObject(runtime.getTarget().wordKind, method, metaMethod, false); + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMetaAccessProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMetaAccessProvider.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,310 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.compiler.common.UnsafeAccess.*; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; +import static com.oracle.graal.hotspot.jvmci.HotSpotResolvedJavaType.*; +import static com.oracle.graal.hotspot.jvmci.HotSpotResolvedObjectTypeImpl.*; + +import java.lang.reflect.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.replacements.*; + +/** + * HotSpot implementation of {@link MetaAccessProvider}. + */ +public class HotSpotMetaAccessProvider implements MetaAccessProvider, HotSpotProxified { + + protected final HotSpotGraalRuntimeProvider runtime; + + public HotSpotMetaAccessProvider(HotSpotGraalRuntimeProvider 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); + } + + /** + * {@link Field} object of {@link Method#slot}. + */ + @SuppressWarnings("javadoc") private Field reflectionMethodSlot = getReflectionSlotField(Method.class); + + /** + * {@link Field} object of {@link Constructor#slot}. + */ + @SuppressWarnings("javadoc") 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 GraalInternalError(e); + } + } + + public ResolvedJavaMethod lookupJavaMethod(Executable reflectionMethod) { + try { + Class holder = reflectionMethod.getDeclaringClass(); + Field slotField = reflectionMethod instanceof Constructor ? reflectionConstructorSlot : reflectionMethodSlot; + final int slot = slotField.getInt(reflectionMethod); + final long metaspaceMethod = runtime.getCompilerToVM().getMetaspaceMethod(holder, slot); + return HotSpotResolvedJavaMethodImpl.fromMetaspace(metaspaceMethod); + } catch (IllegalArgumentException | IllegalAccessException e) { + throw new GraalInternalError(e); + } + } + + public ResolvedJavaField lookupJavaField(Field reflectionField) { + String name = reflectionField.getName(); + Class fieldHolder = reflectionField.getDeclaringClass(); + Class fieldType = reflectionField.getType(); + // java.lang.reflect.Field's modifiers should be enough here since VM internal modifier bits + // are not used (yet). + final int modifiers = reflectionField.getModifiers(); + final long offset = Modifier.isStatic(modifiers) ? unsafe.staticFieldOffset(reflectionField) : unsafe.objectFieldOffset(reflectionField); + + HotSpotResolvedObjectType holder = fromObjectClass(fieldHolder); + JavaType type = fromClass(fieldType); + + if (offset != -1) { + HotSpotResolvedObjectType resolved = holder; + return resolved.createField(name, type, offset, modifiers); + } else { + throw GraalInternalError.shouldNotReachHere("unresolved field " + 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 GraalInternalError.shouldNotReachHere(); + } + } + + 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 GraalInternalError.shouldNotReachHere(); + } + + 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 GraalInternalError.shouldNotReachHere(); + } + } + + 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 GraalInternalError.shouldNotReachHere(Integer.toHexString(reason)); + } + + @Override + public long getMemorySize(JavaConstant constant) { + if (constant.getKind() == Kind.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(); + Kind elementKind = elementType.getKind(); + final int headerSize = runtime().getArrayBaseOffset(elementKind); + int sizeOfElement = HotSpotGraalRuntime.runtime().getTarget().getSizeInBytes(elementKind); + int alignment = HotSpotGraalRuntime.runtime().getTarget().wordSize; + int log2ElementSize = CodeUtil.log2(sizeOfElement); + return NewObjectSnippets.computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize); + } + return lookupJavaType.instanceSize(); + } + } else { + return constant.getKind().getByteCount(); + } + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMetaspaceConstant.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMetaspaceConstant.java Tue May 19 23:16:07 2015 +0200 @@ -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 com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; + +public interface HotSpotMetaspaceConstant extends HotSpotConstant, VMConstant { + + Constant compress(CompressEncoding encoding); + + Constant uncompress(CompressEncoding encoding); + + HotSpotResolvedObjectType asResolvedJavaType(); + + long rawValue(); +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMetaspaceConstantImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMetaspaceConstantImpl.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,92 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import java.util.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; + +public final class HotSpotMetaspaceConstantImpl extends PrimitiveConstant implements HotSpotMetaspaceConstant, VMConstant, HotSpotProxified { + + static HotSpotMetaspaceConstantImpl forMetaspaceObject(Kind kind, long primitive, Object metaspaceObject, boolean compressed) { + return new HotSpotMetaspaceConstantImpl(kind, primitive, metaspaceObject, compressed); + } + + static Object getMetaspaceObject(Constant constant) { + return ((HotSpotMetaspaceConstantImpl) constant).metaspaceObject; + } + + private final Object metaspaceObject; + private final boolean compressed; + + private HotSpotMetaspaceConstantImpl(Kind kind, long primitive, Object metaspaceObject, boolean compressed) { + super(kind, primitive); + this.metaspaceObject = metaspaceObject; + this.compressed = compressed; + } + + @Override + public int hashCode() { + return super.hashCode() ^ System.identityHashCode(metaspaceObject); + } + + @Override + public boolean equals(Object o) { + return o == this || (o instanceof HotSpotMetaspaceConstantImpl && super.equals(o) && Objects.equals(metaspaceObject, ((HotSpotMetaspaceConstantImpl) o).metaspaceObject)); + } + + @Override + public String toString() { + return super.toString() + "{" + metaspaceObject + (compressed ? ";compressed}" : "}"); + } + + public boolean isCompressed() { + return compressed; + } + + public JavaConstant compress(CompressEncoding encoding) { + assert !isCompressed(); + HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(Kind.Int, encoding.compress(asLong()), metaspaceObject, true); + assert res.isCompressed(); + return res; + } + + public JavaConstant uncompress(CompressEncoding encoding) { + assert isCompressed(); + HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(Kind.Long, encoding.uncompress(asInt()), metaspaceObject, false); + assert !res.isCompressed(); + return res; + } + + public HotSpotResolvedObjectType asResolvedJavaType() { + if (metaspaceObject instanceof HotSpotResolvedObjectType) { + return (HotSpotResolvedObjectType) metaspaceObject; + } + return null; + } + + public long rawValue() { + return asLong(); + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMethod.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMethod.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,63 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.debug.Debug.*; +import static java.util.FormattableFlags.*; + +import java.util.*; + +import com.oracle.graal.api.meta.*; + +public abstract class HotSpotMethod implements JavaMethod, Formattable { + + 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)); + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMethodData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMethodData.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,858 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.compiler.common.UnsafeAccess.*; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; +import static java.lang.String.*; + +import java.util.*; + +import sun.misc.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.api.meta.JavaMethodProfile.ProfiledMethod; +import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType; +import com.oracle.graal.hotspot.jvmci.HotSpotMethodDataAccessor.Tag; + +/** + * Access to a HotSpot MethodData structure (defined in methodData.hpp). + */ +public final class HotSpotMethodData { + + private static final HotSpotVMConfig config = runtime().getConfig(); + 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 TypeCheckData(), + new VirtualCallData(), + new RetData(), + new BranchData(), + new MultiBranchData(), + new ArgInfoData(), + null, // call_type_data_tag + null, // virtual_call_type_data_tag + null, // parameters_type_data_tag + null, // speculative_trap_data_tag + }; + // @formatter:on + + /** + * Reference to the C++ MethodData object. + */ + private final long metaspaceMethodData; + + public HotSpotMethodData(long metaspaceMethodData) { + this.metaspaceMethodData = metaspaceMethodData; + } + + /** + * @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().getHostProviders().getMetaAccess(); + int reasonIndex = metaAccess.convertDeoptReason(reason); + return unsafe.getByte(metaspaceMethodData + config.methodDataOopTrapHistoryOffset + reasonIndex) & 0xFF; + } + + public int getOSRDeoptimizationCount(DeoptimizationReason reason) { + HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) runtime().getHostProviders().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); + assert result != null : "NO_DATA tag is not allowed"; + 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 long readWord(int position, int offsetInBytes) { + long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); + return unsafe.getAddress(metaspaceMethodData + fullOffsetInBytes); + } + + 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 = 0x2; + + private final Tag tag; + private 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 int getSize(HotSpotMethodData data, int position) { + return staticSize + getDynamicSize(data, position); + } + + @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 = 0x01; + + 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(0); + + public 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(0); + protected static final int TAKEN_DISPLACEMENT_OFFSET = cellIndexToOffset(1); + + public 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; + + public 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(2); + + protected static final int NONPROFILED_COUNT_OFFSET = cellIndexToOffset(1); + protected static final int TYPE_DATA_FIRST_TYPE_OFFSET = cellIndexToOffset(2); + protected static final int TYPE_DATA_FIRST_TYPE_COUNT_OFFSET = cellIndexToOffset(3); + + 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++) { + long receiverKlass = data.readWord(position, getTypeOffset(i)); + if (receiverKlass != 0) { + HotSpotResolvedObjectTypeImpl klass = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(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 TypeCheckData extends AbstractTypeData { + + private static final int TYPE_CHECK_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; + + public TypeCheckData() { + super(Tag.ReceiverTypeData, TYPE_CHECK_DATA_SIZE); + } + + @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 AbstractTypeData { + + 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; + + public VirtualCallData() { + super(Tag.VirtualCallData, VIRTUAL_CALL_DATA_SIZE); + } + + @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++) { + long method = data.readWord(position, getMethodOffset(i)); + if (method != 0) { + methods[entries] = HotSpotResolvedJavaMethodImpl.fromMetaspace(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 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; + + public 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(2); + + public 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(0); + protected static final int ARRAY_DATA_START_OFFSET = cellIndexToOffset(1); + + public 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 = 2; + 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); + + public 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); + + public ArgInfoData() { + super(Tag.ArgInfoData, ARG_INFO_DATA_SIZE); + } + } + + public void setCompiledGraphSize(int nodeCount) { + unsafe.putInt(metaspaceMethodData + config.methodDataGraalNodeCountOffset, nodeCount); + } + + public int getCompiledGraphSize() { + return unsafe.getInt(metaspaceMethodData + config.methodDataGraalNodeCountOffset); + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMethodDataAccessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMethodDataAccessor.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,112 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + +import com.oracle.graal.api.meta.*; + +/** + * 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; + + private Tag(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + private static HotSpotVMConfig config() { + return runtime().getConfig(); + } + + 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); +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotNmethod.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotNmethod.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,116 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; + +/** + * 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; + private final boolean isExternal; + + public HotSpotNmethod(HotSpotResolvedJavaMethod method, String name, boolean isDefault) { + this(method, name, isDefault, false); + } + + public HotSpotNmethod(HotSpotResolvedJavaMethod method, String name, boolean isDefault, boolean isExternal) { + super(name); + this.method = method; + this.isDefault = isDefault; + this.isExternal = isExternal; + } + + public boolean isDefault() { + return isDefault; + } + + public boolean isExternal() { + return isExternal; + } + + public ResolvedJavaMethod getMethod() { + return method; + } + + @Override + public void invalidate() { + runtime().getCompilerToVM().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) == Kind.Object; + assert method.getSignature().getParameterKind(1) == Kind.Object; + assert !method.isStatic() || method.getSignature().getParameterKind(2) == Kind.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].getKind() == Kind.Object : method.format("%H.%n(%p): expected arg ") + i + " to be Object, not " + sig[i]; + } else if (sig[i].getKind() != Kind.Object) { + assert sig[i].getKind().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); + assert !isExternal(); + return runtime().getCompilerToVM().executeCompiledMethodVarargs(args, this); + } + + @Override + public long getStart() { + return isValid() ? super.getStart() : 0; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotObjectConstant.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotObjectConstant.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,113 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import java.lang.invoke.*; +import java.util.*; + +import com.oracle.graal.api.meta.*; + +/** + * 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); +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotObjectConstantImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotObjectConstantImpl.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,289 @@ +/* + * Copyright (c) 2009, 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.hotspot.jvmci.HotSpotResolvedObjectTypeImpl.*; + +import java.lang.invoke.*; + +import com.oracle.graal.api.meta.*; +import edu.umd.cs.findbugs.annotations.*; + +/** + * Represents a constant non-{@code null} object reference, within the compiler and across the + * compiler/runtime interface. + */ +public final class HotSpotObjectConstantImpl extends AbstractValue implements HotSpotObjectConstant, HotSpotProxified { + + public 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(Kind kind, Object value) { + if (kind == Kind.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) { + super(LIRKind.reference(compressed ? Kind.Int : Kind.Object)); + 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); + } + + /** + * Package-private accessor for the object represented by this constant. + */ + Object object() { + return object; + } + + /** + * Determines if the object represented by this constant is {@link Object#equals(Object) equal} + * to a given object. + */ + public boolean isEqualTo(Object obj) { + return object.equals(obj); + } + + /** + * Gets the class of the object represented by this constant. + */ + public Class getObjectClass() { + return object.getClass(); + } + + 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 super.equals(o) && 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 Kind.Object.format(object); + } + } + + @Override + public String toString() { + return (compressed ? "NarrowOop" : getKind().getJavaName()) + "[" + Kind.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; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotOptions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotOptions.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,122 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.compiler.GraalDebugConfig.*; +import static com.oracle.graal.hotspot.jvmci.HotSpotOptionsLoader.*; +import static java.lang.Double.*; + +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.options.*; +import com.oracle.graal.options.OptionUtils.OptionConsumer; + +//JaCoCo Exclude + +/** + * Sets Graal options from the HotSpot command line. Such options are distinguished by the + * {@link #GRAAL_OPTION_PREFIX} prefix. + */ +public class HotSpotOptions { + + private static final String GRAAL_OPTION_PREFIX = "-G:"; + + /** + * Parses the Graal specific options specified to HotSpot (e.g., on the command line). + */ + private static native void parseVMOptions(); + + static { + parseVMOptions(); + + assert !Debug.Initialization.isDebugInitialized() : "The class " + Debug.class.getName() + " must not be initialized before the Graal runtime has been initialized. " + + "This can be fixed by placing a call to " + Graal.class.getName() + ".runtime() on the path that triggers initialization of " + Debug.class.getName(); + if (areDebugScopePatternsEnabled()) { + System.setProperty(Debug.Initialization.INITIALIZER_PROPERTY_NAME, "true"); + } + if ("".equals(Meter.getValue())) { + System.setProperty(Debug.ENABLE_UNSCOPED_METRICS_PROPERTY_NAME, "true"); + } + if ("".equals(Time.getValue())) { + System.setProperty(Debug.ENABLE_UNSCOPED_TIMERS_PROPERTY_NAME, "true"); + } + if ("".equals(TrackMemUse.getValue())) { + System.setProperty(Debug.ENABLE_UNSCOPED_MEM_USE_TRACKERS_PROPERTY_NAME, "true"); + } + } + + /** + * Ensures {@link HotSpotOptions} is initialized. + */ + public static void initialize() { + } + + /** + * Helper for the VM code called by {@link #parseVMOptions()}. + * + * @param name the name of a parsed option + * @param option the object encapsulating the option + * @param spec specification of boolean option value, type of option value or action to take + */ + static void setOption(String name, OptionValue option, char spec, String stringValue, long primitiveValue) { + switch (spec) { + case '+': + option.setValue(Boolean.TRUE); + break; + case '-': + option.setValue(Boolean.FALSE); + break; + case '?': + OptionUtils.printFlags(options, GRAAL_OPTION_PREFIX); + break; + case ' ': + OptionUtils.printNoMatchMessage(options, name, GRAAL_OPTION_PREFIX); + break; + case 'i': + option.setValue((int) primitiveValue); + break; + case 'f': + option.setValue((float) longBitsToDouble(primitiveValue)); + break; + case 'd': + option.setValue(longBitsToDouble(primitiveValue)); + break; + case 's': + option.setValue(stringValue); + break; + } + } + + /** + * Parses a given option value specification. + * + * @param option the specification of an option and its value + * @param setter the object to notify of the parsed option and value. If null, the + * {@link OptionValue#setValue(Object)} method of the specified option is called + * instead. + */ + public static boolean parseOption(String option, OptionConsumer setter) { + return OptionUtils.parseOption(options, option, GRAAL_OPTION_PREFIX, setter); + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotOptionsLoader.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotOptionsLoader.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,57 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import java.util.*; + +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.options.*; + +/** + * Helper class for separating loading of options from option initialization at runtime. + */ +class HotSpotOptionsLoader { + static final SortedMap options = new TreeMap<>(); + + /** + * Initializes {@link #options} from {@link Options} services. + */ + static { + for (Options opts : Services.load(Options.class)) { + for (OptionDescriptor desc : opts) { + if (isHotSpotOption(desc)) { + String name = desc.getName(); + OptionDescriptor existing = options.put(name, desc); + assert existing == null : "Option named \"" + name + "\" has multiple definitions: " + existing.getLocation() + " and " + desc.getLocation(); + } + } + } + } + + /** + * Determines if a given option is a HotSpot command line option. + */ + private static boolean isHotSpotOption(OptionDescriptor desc) { + return desc.getClass().getName().startsWith("com.oracle.graal"); + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotProfilingInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotProfilingInfo.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,224 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.nodes.*; + +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; + } + + @Override + public boolean setCompilerIRSize(Class irType, int size) { + if (irType == StructuredGraph.class) { + methodData.setCompiledGraphSize(size); + return true; + } + return false; + } + + @Override + public int getCompilerIRSize(Class irType) { + if (irType == StructuredGraph.class) { + return methodData.getCompiledGraphSize(); + } + return -1; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotProxified.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotProxified.java Tue May 19 23:16:07 2015 +0200 @@ -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 com.oracle.graal.hotspot.jvmci; + +/** + * Marker interface for classes whose values are proxied during replay compilation capture. + */ +public interface HotSpotProxified { +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotReferenceMap.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotReferenceMap.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,509 @@ +/* + * Copyright (c) 2009, 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 com.oracle.graal.hotspot.jvmci; + +import java.util.*; + +import com.oracle.graal.api.code.CodeUtil.RefMapFormatter; +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; + +public final class HotSpotReferenceMap extends ReferenceMap { + + static final int OOP64 = 0b1010; + static final int OOP32 = 0b01; + static final int NARROW_LOW = OOP32; + static final int NARROW_HIGH = OOP32 << 2; + static final int NARROW_BOTH = NARROW_LOW | NARROW_HIGH; + + private enum MapEntry { + NoReference(0), + WideOop(OOP64), + NarrowOopLowerHalf(NARROW_LOW), + NarrowOopUpperHalf(NARROW_HIGH), + TwoNarrowOops(NARROW_BOTH), + Illegal(-1); + + MapEntry(int pattern) { + this.pattern = pattern; + } + + final int pattern; + + /** + * Create enum values from OopMap. + *

+ * These bits can have the following values (MSB first): + * + *

+         * 0000 - contains no references
+         * 1010 - contains a wide oop
+         * 0001 - contains a narrow oop in the lower half
+         * 0101 - contains a narrow oop in the upper half
+         * 0101 - contains two narrow oops
+         * 
+ * + * @see HotSpotReferenceMap#registerRefMap + * @see HotSpotReferenceMap#frameRefMap + */ + static MapEntry getFromBits(int idx, HotSpotOopMap set) { + int n = set.get(idx); + switch (n) { + case 0: + return NoReference; + case OOP64: + return WideOop; + case NARROW_LOW: + return NarrowOopLowerHalf; + case NARROW_HIGH: + return NarrowOopUpperHalf; + case NARROW_BOTH: + return TwoNarrowOops; + default: + return Illegal; + } + } + + String toBitString() { + int bits = toBit(this); + if (bits == -1) { + return "---"; + } + return String.format("%3s", Integer.toBinaryString(bits)).replace(' ', '0'); + } + + static int toBit(MapEntry type) { + return type.pattern; + } + } + + /** + * A specialized bit set that represents both wide and narrow oops in an efficient manner. The + * map consists of 4 bit entries that represent 8 bytes of memory. + * + */ + class HotSpotOopMap implements Cloneable { + + /** + * Each entry is 4 bits long and covers 8 bytes of memory. + */ + private static final int BITS_PER_ENTRY = 4; + private static final int BITS_PER_ELEMENT = 64; + + public HotSpotOopMap(int i) { + words = new long[(i * BITS_PER_ENTRY + BITS_PER_ELEMENT) / BITS_PER_ELEMENT]; + } + + public HotSpotOopMap(HotSpotOopMap other) { + words = other.words.clone(); + } + + private long[] words; + + private int get(int i) { + return getEntry(i); + } + + public void or(HotSpotOopMap src) { + if (words.length < src.words.length) { + long[] newWords = new long[src.words.length]; + System.arraycopy(src.words, 0, newWords, 0, src.words.length); + for (int i = 0; i < words.length; i++) { + newWords[i] |= words[i]; + } + words = newWords; + } else { + for (int i = 0; i < src.words.length; i++) { + words[i] |= src.words[i]; + } + } + } + + private void setOop(int regIdx) { + setEntry(regIdx, OOP64); + } + + public int size() { + return words.length * BITS_PER_ELEMENT / BITS_PER_ENTRY; + } + + @Override + public HotSpotOopMap clone() { + return new HotSpotOopMap(this); + } + + private void setNarrowOop(int offset) { + setNarrowEntry(offset, OOP32); + } + + private void setEntry(int regIdx, int value) { + assert regIdx % 2 == 0 : "must be alinged"; + int bitIndex = (regIdx >> 1) * BITS_PER_ENTRY; + int wordIndex = bitIndex / BITS_PER_ELEMENT; + int shift = bitIndex - wordIndex * BITS_PER_ELEMENT; + if (wordIndex >= words.length) { + if (value == 0) { + // Nothing to do since bits are clear + return; + } + words = Arrays.copyOf(words, wordIndex + 1); + } + assert verifyUpdate(this, this); + long orig = words[wordIndex]; + words[wordIndex] = (orig & (~(0b1111L << shift))) | ((long) value << shift); + assert get(regIdx / 2) == value; + assert verifyUpdate(this, this); + } + + private void setNarrowEntry(int offset, int value) { + int regIdx = offset >> 1; + boolean low = offset % 2 == 0; + int bitIndex = regIdx * BITS_PER_ENTRY; + int wordIndex = bitIndex / BITS_PER_ELEMENT; + int shift = bitIndex - wordIndex * BITS_PER_ELEMENT; + if (wordIndex >= words.length) { + if (value == 0) { + // Nothing to do since bits are clear + return; + } + words = Arrays.copyOf(words, wordIndex + 1); + } + long originalValue = words[wordIndex]; + int current = ((int) (originalValue >> shift)) & 0b1111; + if (current == OOP64) { + current = 0; + } + long newValue; + if (value != 0) { + newValue = current | (low ? value : (value << 2)); + } else { + newValue = current & (low ? 0b1100 : 0b0011); + } + long masked = originalValue & (~(0b1111L << shift)); + words[wordIndex] = masked | (newValue << shift); + assert verifyUpdate(this, this); + } + + private int getEntry(int regIdx) { + int bitIndex = regIdx * BITS_PER_ENTRY; + int wordIndex = bitIndex / BITS_PER_ELEMENT; + int shift = bitIndex - wordIndex * BITS_PER_ELEMENT; + return ((int) (words[wordIndex] >>> shift)) & 0b1111; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + + if (other instanceof HotSpotOopMap) { + HotSpotOopMap otherMap = (HotSpotOopMap) other; + int limit = Math.min(words.length, otherMap.words.length); + for (int i = 0; i < limit; i++) { + if (words[i] != otherMap.words[i]) { + return false; + } + } + for (int i = limit; i < words.length; i++) { + if (words[i] != 0) { + return false; + } + } + for (int i = limit; i < otherMap.words.length; i++) { + if (otherMap.words[i] != 0) { + return false; + } + } + return true; + } + return false; + } + + @Override + public int hashCode() { + long h = 1234; + for (int i = words.length; --i >= 0;) { + h ^= words[i] * (i + 1); + } + return (int) ((h >> 32) ^ h); + } + + @Override + public String toString() { + int count = 0; + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int idx = 0; idx < size(); idx++) { + MapEntry dstType = MapEntry.getFromBits(idx, this); + if (dstType == MapEntry.NoReference) { + continue; + } + if (count > 0) { + sb.append(", "); + } + if (dstType == MapEntry.Illegal) { + int value = get(idx); + sb.append("0x"); + sb.append(Integer.toHexString(value)); + } else { + sb.append(idx); + sb.append(':'); + sb.append(dstType); + } + count++; + } + sb.append("]"); + return sb.toString(); + } + } + + /** + * Contains 3 bits per scalar register, and n*3 bits per n-word vector register (e.g., on a + * 64-bit system, a 256-bit vector register requires 12 reference map bits). + *

+ * These bits can have the following values (LSB first): + * + *

+     * 000 - contains no references
+     * 100 - contains a wide oop
+     * 110 - contains a narrow oop in the lower half
+     * 101 - contains a narrow oop in the upper half
+     * 111 - contains two narrow oops
+     * 
+ */ + private final HotSpotOopMap registerRefMap; + + /** + * Contains 3 bits per stack word. + *

+ * These bits can have the following values (LSB first): + * + *

+     * 000 - contains no references
+     * 100 - contains a wide oop
+     * 110 - contains a narrow oop in the lower half
+     * 101 - contains a narrow oop in the upper half
+     * 111 - contains two narrow oops
+     * 
+ */ + private final HotSpotOopMap frameRefMap; + + private final TargetDescription target; + + public HotSpotReferenceMap(int registerCount, int frameSlotCount, TargetDescription target) { + if (registerCount > 0) { + this.registerRefMap = new HotSpotOopMap(registerCount); + } else { + this.registerRefMap = null; + } + this.frameRefMap = new HotSpotOopMap(frameSlotCount); + this.target = target; + } + + private HotSpotReferenceMap(HotSpotReferenceMap other) { + this.registerRefMap = other.registerRefMap.clone(); + this.frameRefMap = other.frameRefMap.clone(); + this.target = other.target; + } + + @Override + public ReferenceMap clone() { + return new HotSpotReferenceMap(this); + } + + // setters + @Override + public void setRegister(int idx, LIRKind kind) { + set(registerRefMap, idx * 2, kind); + } + + @Override + public void setStackSlot(int offset, LIRKind kind) { + assert offset % bytesPerElement(kind) == 0 : "unaligned value in ReferenceMap"; + set(frameRefMap, offset / 4, kind); + } + + private void set(HotSpotOopMap refMap, int index, LIRKind kind) { + if (kind.isDerivedReference()) { + throw new InternalError("derived reference cannot be inserted in ReferenceMap"); + } + + int bytesPerElement = bytesPerElement(kind); + int length = kind.getPlatformKind().getVectorLength(); + if (bytesPerElement == 8) { + for (int i = 0; i < length; i++) { + if (kind.isReference(i)) { + refMap.setOop(index + i * 2); + } + } + } else if (bytesPerElement == 4) { + for (int i = 0; i < length; i++) { + if (kind.isReference(i)) { + refMap.setNarrowOop(index + i); + } + } + } else { + assert kind.isValue() : "unknown reference kind " + kind; + } + } + + private int bytesPerElement(LIRKind kind) { + PlatformKind platformKind = kind.getPlatformKind(); + return target.getSizeInBytes(platformKind) / platformKind.getVectorLength(); + } + + public HotSpotOopMap getFrameMap() { + return frameRefMap == null ? null : (HotSpotOopMap) frameRefMap.clone(); + } + + public HotSpotOopMap getRegisterMap() { + return registerRefMap == null ? null : (HotSpotOopMap) registerRefMap.clone(); + } + + static MapEntry[] entries(HotSpotOopMap fixedMap) { + MapEntry[] result = new MapEntry[fixedMap.size()]; + for (int idx = 0; idx < fixedMap.size(); idx++) { + MapEntry dstType = MapEntry.getFromBits(idx, fixedMap); + result[idx] = dstType; + } + return result; + } + + private static boolean verifyUpdate(HotSpotOopMap dst, HotSpotOopMap src) { + return verifyUpdate(dst, src, true); + } + + private static boolean verifyUpdate(HotSpotOopMap dst, HotSpotOopMap src, boolean doAssert) { + for (int idx = 0; idx < Math.min(src.size(), dst.size()); idx++) { + if (!verifyUpdateEntry(idx, dst, src, doAssert)) { + return false; + } + } + return true; + } + + private static boolean verifyUpdateEntry(int idx, HotSpotOopMap dst, HotSpotOopMap src, boolean doAssert) { + MapEntry dstType = MapEntry.getFromBits(idx, dst); + MapEntry srcType = MapEntry.getFromBits(idx, src); + + if (dstType == MapEntry.Illegal || srcType == MapEntry.Illegal) { + assert !doAssert : String.format("Illegal RefMap bit pattern: %s (0b%s), %s (0b%s)", dstType, dstType.toBitString(), srcType, srcType.toBitString()); + return false; + } + switch (dstType) { + case NoReference: + return true; + case WideOop: + switch (srcType) { + case NoReference: + case WideOop: + return true; + default: + assert false : String.format("Illegal RefMap combination: %s (0b%s), %s (0b%s)", dstType, dstType.toBitString(), srcType, srcType.toBitString()); + return false; + } + case TwoNarrowOops: + case NarrowOopLowerHalf: + case NarrowOopUpperHalf: + switch (srcType) { + case TwoNarrowOops: + case NarrowOopLowerHalf: + case NarrowOopUpperHalf: + case NoReference: + return true; + default: + assert false : String.format("Illegal RefMap combination: %s (0b%s), %s (0b%s)", dstType, dstType.toBitString(), srcType, srcType.toBitString()); + return false; + } + default: + return false; + } + } + + @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 (this.frameRefMap.equals(that.frameRefMap) && Objects.equals(this.registerRefMap, that.registerRefMap) && this.target.equals(that.target)) { + return true; + } + } + return false; + } + + @Override + public boolean hasRegisterRefMap() { + return registerRefMap != null && registerRefMap.size() > 0; + } + + @Override + public boolean hasFrameRefMap() { + return frameRefMap != null && frameRefMap.size() > 0; + } + + @Override + public void appendRegisterMap(StringBuilder sb, RefMapFormatter formatter) { + for (int idx = 0; idx < registerRefMap.size(); idx++) { + MapEntry dstType = MapEntry.getFromBits(idx, registerRefMap); + if (dstType != MapEntry.NoReference) { + sb.append(' ').append(formatter.formatRegister(idx)).append(':').append(dstType); + } + } + } + + @Override + public void appendFrameMap(StringBuilder sb, RefMapFormatter formatter) { + for (int idx = 0; idx < frameRefMap.size(); idx++) { + MapEntry dstType = MapEntry.getFromBits(idx, frameRefMap); + if (dstType != MapEntry.NoReference) { + sb.append(' ').append(formatter.formatStackSlot(idx)).append(':').append(dstType); + } + } + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (registerRefMap != null) { + sb.append("Registers = "); + sb.append(registerRefMap); + } + sb.append("Stack = "); + sb.append(frameRefMap); + return sb.toString(); + } + + public void verify() { + assert verifyUpdate(frameRefMap, frameRefMap); + assert registerRefMap == null || verifyUpdate(registerRefMap, registerRefMap); + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaField.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaField.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.meta.*; + +/** + * 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(); + + /** + * Checks if this field has the {@link Stable} annotation. + * + * @return true if field has {@link Stable} annotation, false otherwise + */ + boolean isStable(); +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaFieldImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaFieldImpl.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,281 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.compiler.common.GraalOptions.*; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; +import static com.oracle.graal.hotspot.jvmci.HotSpotResolvedObjectTypeImpl.*; + +import java.lang.annotation.*; +import java.lang.reflect.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; + +/** + * Represents a field in a HotSpot type. + */ +public 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; + + public 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(); + } + } + + public 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 & getReflectionFieldModifiers(); + } + + @Override + public boolean isInternal() { + return (modifiers & runtime().getConfig().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 (runtime().getConfig().syntheticFlag & 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 ((runtime().getConfig().jvmAccFieldStable & modifiers) != 0) { + return true; + } + assert getAnnotation(Stable.class) == null; + if (ImplicitStableValues.getValue() && isImplicitStableField()) { + return true; + } + return false; + } + + @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 (isSynthetic()) { + if (isSyntheticImplicitStableField()) { + return true; + } + } else if (isWellKnownImplicitStableField()) { + return true; + } + return false; + } + + private boolean isSyntheticImplicitStableField() { + assert this.isSynthetic(); + if (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().getHostProviders().getMetaAccess(); + STRING_VALUE_FIELD = metaAccess.lookupJavaField(String.class.getDeclaredField("value")); + } catch (SecurityException | NoSuchFieldException e) { + throw new GraalInternalError(e); + } + } + } + + public LocationIdentity getLocationIdentity() { + return locationIdentity; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaMethod.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaMethod.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import java.lang.reflect.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; + +/** + * 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(); + + /** + * 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(); + + boolean hasBalancedMonitors(); + + 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); + + ProfilingInfo getCompilationProfilingInfo(boolean isOSR); + + 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); + + SpeculationLog getSpeculationLog(); +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaMethodImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaMethodImpl.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,752 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.compiler.common.GraalInternalError.*; +import static com.oracle.graal.compiler.common.GraalOptions.*; +import static com.oracle.graal.compiler.common.UnsafeAccess.*; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + +import java.lang.annotation.*; +import java.lang.reflect.*; +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.graphbuilderconf.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.nodes.*; + +/** + * Implementation of {@link JavaMethod} for resolved HotSpot methods. + */ +public final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSpotResolvedJavaMethod, HotSpotProxified, MethodIdHolder { + + /** + * 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 Member 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} + */ + public static HotSpotResolvedObjectTypeImpl getHolder(long metaspaceMethod) { + HotSpotVMConfig config = runtime().getConfig(); + final long metaspaceConstMethod = unsafe.getAddress(metaspaceMethod + config.methodConstMethodOffset); + final long metaspaceConstantPool = unsafe.getAddress(metaspaceConstMethod + config.constMethodConstantsOffset); + final long metaspaceKlass = unsafe.getAddress(metaspaceConstantPool + config.constantPoolHolderOffset); + return HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass); + } + + /** + * Gets the {@link ResolvedJavaMethod} for a HotSpot metaspace method native object. + * + * @param metaspaceMethod a metaspace Method object + * @return the {@link ResolvedJavaMethod} corresponding to {@code metaspaceMethod} + */ + public static HotSpotResolvedJavaMethod fromMetaspace(long metaspaceMethod) { + HotSpotResolvedObjectTypeImpl holder = getHolder(metaspaceMethod); + return holder.createMethod(metaspaceMethod); + } + + public 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 = runtime().getConfig(); + 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); + this.constantPool = new HotSpotConstantPool(metaspaceConstantPool); + + 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}). + * + * @return pointer to this method's ConstMethod + */ + private long getConstMethod() { + assert metaspaceMethod != 0; + return unsafe.getAddress(metaspaceMethod + runtime().getConfig().methodConstMethodOffset); + } + + @Override + public boolean equals(Object obj) { + 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.getByte(metaspaceMethod + runtime().getConfig().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() + runtime().getConfig().constMethodFlagsOffset); + } + + @Override + public HotSpotResolvedObjectTypeImpl getDeclaringClass() { + return holder; + } + + /** + * Gets the address of the C++ Method object for this method. + */ + public JavaConstant getMetaspaceMethodConstant() { + return HotSpotMetaspaceConstantImpl.forMetaspaceObject(getHostWordKind(), metaspaceMethod, this, false); + } + + public long getMetaspaceMethod() { + return metaspaceMethod; + } + + @Override + public JavaConstant 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 + runtime().getConfig().methodAccessFlagsOffset); + } + + @Override + public int getModifiers() { + return getAllModifiers() & Modifier.methodModifiers(); + } + + @Override + public boolean canBeStaticallyBound() { + return (isFinal() || isPrivate() || isStatic() || holder.isFinal()) && isConcrete(); + } + + @Override + public byte[] getCode() { + if (getCodeSize() == 0) { + return null; + } + if (code == null && holder.isLinked()) { + code = runtime().getCompilerToVM().getBytecode(metaspaceMethod); + assert code.length == getCodeSize() : "expected: " + getCodeSize() + ", actual: " + code.length; + } + return code; + } + + @Override + public int getCodeSize() { + return unsafe.getChar(getConstMethod() + runtime().getConfig().constMethodCodeSizeOffset); + } + + @Override + public ExceptionHandler[] getExceptionHandlers() { + final boolean hasExceptionTable = (getConstMethodFlags() & runtime().getConfig().constMethodHasExceptionTable) != 0; + if (!hasExceptionTable) { + return new ExceptionHandler[0]; + } + + HotSpotVMConfig config = runtime().getConfig(); + final int exceptionTableLength = runtime().getCompilerToVM().exceptionTableLength(metaspaceMethod); + ExceptionHandler[] handlers = new ExceptionHandler[exceptionTableLength]; + long exceptionTableElement = runtime().getCompilerToVM().exceptionTableStart(metaspaceMethod); + + 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() & runtime().getConfig().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() & runtime().getConfig().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() & runtime().getConfig().methodFlagsDontInline) != 0; + } + + /** + * Manually adds a DontInline annotation to this method. + */ + public void setNotInlineable() { + runtime().getCompilerToVM().doNotInlineOrCompile(metaspaceMethod); + } + + /** + * 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 runtime().getCompilerToVM().methodIsIgnoredBySecurityStackWalk(metaspaceMethod); + } + + public boolean hasBalancedMonitors() { + HotSpotVMConfig config = runtime().getConfig(); + final int modifiers = getAllModifiers(); + + // Method has no monitorenter/exit bytecodes. + if ((modifiers & config.jvmAccHasMonitorBytecodes) == 0) { + return false; + } + + // Check to see if a previous compilation computed the monitor-matching analysis. + if ((modifiers & config.jvmAccMonitorMatch) != 0) { + return true; + } + + // This either happens only once if monitors are balanced or very rarely multiple-times. + return runtime().getCompilerToVM().hasBalancedMonitors(metaspaceMethod); + } + + @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 = runtime().getConfig(); + return unsafe.getChar(getConstMethod() + config.methodMaxLocalsOffset); + } + + @Override + public int getMaxStackSize() { + if (isAbstract() || isNative()) { + return 0; + } + HotSpotVMConfig config = runtime().getConfig(); + 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 = runtime().getCompilerToVM().getStackTraceElement(metaspaceMethod, 0); + return new StackTraceElement(ste.getClassName(), ste.getMethodName(), ste.getFileName(), -1); + } + return runtime().getCompilerToVM().getStackTraceElement(metaspaceMethod, 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; + } + long metaspaceKlass = ((HotSpotResolvedObjectTypeImpl) receiver).getMetaspaceKlass(); + final long uniqueConcreteMethod = runtime().getCompilerToVM().findUniqueConcreteMethod(metaspaceKlass, metaspaceMethod); + if (uniqueConcreteMethod == 0) { + return null; + } + return fromMetaspace(uniqueConcreteMethod); + } + + @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 = runtime().getConfig(); + 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 + runtime().getConfig().nmethodCompLevelOffset) == level; + } + return false; + } + + private static final String TraceMethodDataFilter = System.getProperty("graal.traceMethodDataFilter"); + + @Override + public ProfilingInfo getProfilingInfo() { + return getProfilingInfo(true, true); + } + + public ProfilingInfo getCompilationProfilingInfo(boolean isOSR) { + return getProfilingInfo(!isOSR, isOSR); + } + + private ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) { + ProfilingInfo info; + + if (UseProfilingInformation.getValue() && methodData == null) { + long metaspaceMethodData = unsafe.getAddress(metaspaceMethod + runtime().getConfig().methodDataOffset); + if (metaspaceMethodData != 0) { + methodData = new HotSpotMethodData(metaspaceMethodData); + if (TraceMethodDataFilter != null && this.format("%H.%n").contains(TraceMethodDataFilter)) { + TTY.println("Raw method data for " + this.format("%H.%n(%p)") + ":"); + TTY.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() { + runtime().getCompilerToVM().reprofile(metaspaceMethod); + } + + @Override + public ConstantPool getConstantPool() { + return constantPool; + } + + @Override + public Annotation[][] getParameterAnnotations() { + if (isConstructor()) { + Constructor javaConstructor = toJavaConstructor(); + return javaConstructor == null ? null : javaConstructor.getParameterAnnotations(); + } + Method javaMethod = toJava(); + return javaMethod == null ? null : javaMethod.getParameterAnnotations(); + } + + @Override + public Annotation[] getAnnotations() { + if (isConstructor()) { + Constructor javaConstructor = toJavaConstructor(); + return javaConstructor == null ? new Annotation[0] : javaConstructor.getAnnotations(); + } + Method javaMethod = toJava(); + return javaMethod == null ? new Annotation[0] : javaMethod.getAnnotations(); + } + + @Override + public T getAnnotation(Class annotationClass) { + if (isConstructor()) { + Constructor javaConstructor = toJavaConstructor(); + return javaConstructor == null ? null : javaConstructor.getAnnotation(annotationClass); + } + Method javaMethod = toJava(); + return javaMethod == null ? null : javaMethod.getAnnotation(annotationClass); + } + + @Override + public boolean isSynthetic() { + int modifiers = getAllModifiers(); + return (runtime().getConfig().syntheticFlag & modifiers) != 0; + } + + 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() { + if (isConstructor()) { + Constructor javaConstructor = toJavaConstructor(); + return javaConstructor == null ? null : javaConstructor.getGenericParameterTypes(); + } + Method 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 Method toJava() { + if (toJavaCache != null) { + return (Method) toJavaCache; + } + try { + Method result = holder.mirror().getDeclaredMethod(name, signatureToTypes()); + toJavaCache = result; + return result; + } catch (NoSuchMethodException | NoClassDefFoundError e) { + return null; + } + } + + private Constructor toJavaConstructor() { + if (toJavaCache != null) { + return (Constructor) toJavaCache; + } + try { + Constructor result = holder.mirror().getDeclaredConstructor(signatureToTypes()); + toJavaCache = result; + return result; + } catch (NoSuchMethodException | NoClassDefFoundError e) { + return null; + } + } + + @Override + public boolean canBeInlined() { + if (isDontInline()) { + return false; + } + return runtime().getCompilerToVM().canInlineMethod(metaspaceMethod); + } + + @Override + public boolean shouldBeInlined() { + if (isForceInline()) { + return true; + } + return runtime().getCompilerToVM().shouldInlineMethod(metaspaceMethod); + } + + @Override + public LineNumberTable getLineNumberTable() { + final boolean hasLineNumberTable = (getConstMethodFlags() & runtime().getConfig().constMethodHasLineNumberTable) != 0; + if (!hasLineNumberTable) { + return null; + } + + long[] values = runtime().getCompilerToVM().getLineNumberTable(metaspaceMethod); + if (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() & runtime().getConfig().constMethodHasLocalVariableTable) != 0; + if (!hasLocalVariableTable) { + return null; + } + + HotSpotVMConfig config = runtime().getConfig(); + long localVariableTableElement = runtime().getCompilerToVM().getLocalVariableTableStart(metaspaceMethod); + final int localVariableTableLength = runtime().getCompilerToVM().getLocalVariableTableLength(metaspaceMethod); + 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) { + guarantee(isInVirtualMethodTable(resolved), "%s does not have a vtable entry", this); + HotSpotVMConfig config = runtime().getConfig(); + final int vtableIndex = getVtableIndex((HotSpotResolvedObjectTypeImpl) resolved); + return config.instanceKlassVtableStartOffset + 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 runtime().getConfig().invalidVtableIndex; + } + if (holder.isInterface()) { + if (resolved.isInterface()) { + return runtime().getConfig().invalidVtableIndex; + } + return getVtableIndexForInterface(resolved); + } + return getVtableIndex(); + } + + /** + * Returns this method's virtual table index. + * + * @return virtual table index + */ + private int getVtableIndex() { + assert !holder.isInterface(); + HotSpotVMConfig config = runtime().getConfig(); + int result = unsafe.getInt(metaspaceMethod + config.methodVtableIndexOffset); + assert result >= config.nonvirtualVtableIndex : "must be linked"; + return result; + } + + private int getVtableIndexForInterface(ResolvedJavaType resolved) { + HotSpotResolvedObjectTypeImpl hotspotType = (HotSpotResolvedObjectTypeImpl) resolved; + return runtime().getCompilerToVM().getVtableIndexForInterface(hotspotType.getMetaspaceKlass(), getMetaspaceMethod()); + } + + /** + * The {@link SpeculationLog} for methods compiled by Graal 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 = runtime().getConfig(); + return unsafe.getByte(metaspaceMethod + config.methodIntrinsicIdOffset) & 0xff; + } + + @Override + public JavaConstant invoke(JavaConstant receiver, JavaConstant[] arguments) { + assert !isConstructor(); + Method javaMethod = 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 runtime().getCompilerToVM().allocateCompileId(metaspaceMethod, entryBCI); + } + + public boolean hasCodeAtLevel(int entryBCI, int level) { + if (entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI) { + return hasCompiledCodeAtLevel(level); + } + return runtime().getCompilerToVM().hasCompiledCodeForOSR(metaspaceMethod, entryBCI, level); + } + + private int methodId; + + public void setMethodId(int id) { + assert methodId == 0; + methodId = id; + } + + public int getMethodId() { + return methodId; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaType.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2012, 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + +import com.oracle.graal.api.meta.*; + +public abstract class HotSpotResolvedJavaType extends HotSpotJavaType implements ResolvedJavaType { + + /** + * Gets the Graal mirror for a {@link Class} object. + * + * @return the {@link HotSpotResolvedJavaType} corresponding to {@code javaClass} + */ + public static ResolvedJavaType fromClass(Class javaClass) { + return runtime().fromClass(javaClass); + } + + public 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(); + } + +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectType.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.api.meta.Assumptions.AssumptionResult; +import com.oracle.graal.hotspot.*; + +/** + * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. + */ +public interface HotSpotResolvedObjectType extends ResolvedJavaType { + + HotSpotResolvedObjectType getArrayClass(); + + ResolvedJavaType getComponentType(); + + AssumptionResult findLeafConcreteSubtype(); + + HotSpotResolvedObjectType getSuperclass(); + + HotSpotResolvedObjectType[] getInterfaces(); + + HotSpotResolvedObjectType getSupertype(); + + HotSpotResolvedObjectType findLeastCommonAncestor(ResolvedJavaType otherType); + + HotSpotResolvedObjectType asExactType(); + + default boolean isPrimitive() { + return false; + } + + default Kind getKind() { + return Kind.Object; + } + + ConstantPool 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. + */ + 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 HotSpotGraalRuntime#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(); + + HotSpotResolvedObjectType getEnclosingType(); + + ResolvedJavaMethod getClassInitializer(); + + ResolvedJavaField createField(String name, JavaType type, long offset, int modifiers); +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectTypeImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectTypeImpl.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,903 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.compiler.common.UnsafeAccess.*; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; +import static java.util.Objects.*; + +import java.lang.annotation.*; +import java.lang.reflect.*; +import java.net.*; +import java.nio.*; +import java.util.*; + +import com.oracle.graal.api.meta.Assumptions.AssumptionResult; +import com.oracle.graal.api.meta.Assumptions.ConcreteMethod; +import com.oracle.graal.api.meta.Assumptions.ConcreteSubtype; +import com.oracle.graal.api.meta.Assumptions.LeafType; +import com.oracle.graal.api.meta.Assumptions.NoFinalizableSubclass; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; +import com.oracle.graal.hotspot.*; + +/** + * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. + */ +public final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implements HotSpotResolvedObjectType, HotSpotProxified { + + /** + * The Java class this type represents. + */ + private final Class javaClass; + + private HashMap fieldCache; + private HashMap methodCache; + private HotSpotResolvedJavaField[] instanceFields; + private HotSpotResolvedObjectTypeImpl[] interfaces; + private ConstantPool constantPool; + private HotSpotResolvedObjectType arrayOfType; + + /** + * Gets the Graal mirror for a {@link Class} object. + * + * @return the {@link HotSpotResolvedJavaType} corresponding to {@code javaClass} + */ + public static HotSpotResolvedObjectTypeImpl fromObjectClass(Class javaClass) { + return (HotSpotResolvedObjectTypeImpl) runtime().fromClass(javaClass); + } + + /** + * Gets the Graal mirror from a HotSpot metaspace Klass native object. + * + * @param metaspaceKlass a metaspace Klass object + * @return the {@link ResolvedJavaType} corresponding to {@code metaspaceKlass} + */ + public static HotSpotResolvedObjectTypeImpl fromMetaspaceKlass(long metaspaceKlass) { + assert metaspaceKlass != 0; + Class javaClass = runtime().getCompilerToVM().getJavaMirror(metaspaceKlass); + assert javaClass != null; + return fromObjectClass(javaClass); + } + + /** + * Creates the Graal 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 #fromMetaspaceKlass(long)} + * instead. + *

+ * + * @param javaClass the Class to create the mirror for + */ + public HotSpotResolvedObjectTypeImpl(Class javaClass) { + super(getSignatureName(javaClass)); + this.javaClass = javaClass; + 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. + */ + public long getMetaspaceKlass() { + if (HotSpotGraalRuntime.getHostWordKind() == Kind.Long) { + return unsafe.getLong(javaClass, (long) runtime().getConfig().klassOffset); + } + return unsafe.getInt(javaClass, (long) runtime().getConfig().klassOffset) & 0xFFFFFFFFL; + } + + @Override + public int getModifiers() { + return mirror().getModifiers(); + } + + public int getAccessFlags() { + HotSpotVMConfig config = runtime().getConfig(); + 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 : fromClass(javaComponentType); + } + + @Override + public AssumptionResult findLeafConcreteSubtype() { + HotSpotVMConfig config = runtime().getConfig(); + if (isArray()) { + return getElementalType().isFinal() ? 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()) { + long subklass = type.getSubklass(); + if (subklass == 0 || unsafe.getAddress(subklass + config.nextSiblingOffset) != 0) { + return null; + } + type = fromMetaspaceKlass(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() == 0; + } + + /** + * 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 long getSubklass() { + return unsafe.getAddress(getMetaspaceKlass() + runtime().getConfig().subklassOffset); + } + + @Override + public HotSpotResolvedObjectTypeImpl getSuperclass() { + Class javaSuperclass = mirror().getSuperclass(); + return javaSuperclass == null ? null : (HotSpotResolvedObjectTypeImpl) 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 GraalInternalError("Cannot call getImplementor() on a non-interface type: " + this); + } + final long implementorMetaspaceKlass = runtime().getCompilerToVM().getKlassImplementor(getMetaspaceKlass()); + + // No implementor. + if (implementorMetaspaceKlass == 0) { + return null; + } + + return fromMetaspaceKlass(implementorMetaspaceKlass); + } + + 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() { + if (isArray()) { + return getComponentType().asExactType() != null ? this : null; + } + return isFinal() ? this : null; + } + + @Override + public JavaConstant getJavaClass() { + return HotSpotObjectConstantImpl.forObject(mirror()); + } + + @Override + public JavaConstant getObjectHub() { + return klass(); + } + + @Override + public AssumptionResult hasFinalizableSubclass() { + assert !isArray(); + if (!runtime().getCompilerToVM().hasFinalizableSubclass(getMetaspaceKlass())) { + return new AssumptionResult<>(false, new NoFinalizableSubclass(this)); + } + return new AssumptionResult<>(true); + } + + @Override + public boolean hasFinalizer() { + HotSpotVMConfig config = runtime().getConfig(); + return (getAccessFlags() & config.klassHasFinalizerFlag) != 0; + } + + @Override + public boolean isPrimitive() { + return false; + } + + @Override + public boolean isArray() { + return mirror().isArray(); + } + + @Override + public boolean isInitialized() { + return isArray() ? true : getInitState() == runtime().getConfig().instanceKlassStateFullyInitialized; + } + + @Override + public boolean isLinked() { + return isArray() ? true : getInitState() >= runtime().getConfig().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() + runtime().getConfig().instanceKlassInitStateOffset) & 0xFF; + } + + @Override + public void initialize() { + if (!isInitialized()) { + unsafe.ensureClassInitialized(mirror()); + assert isInitialized(); + } + } + + @Override + public boolean isInstance(JavaConstant obj) { + if (obj.getKind() == Kind.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 Kind getKind() { + return Kind.Object; + } + + @Override + public ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { + ResolvedJavaMethod resolvedMethod = resolveMethod(method, callerType, true); + if (resolvedMethod == null || resolvedMethod.isAbstract()) { + return null; + } + return resolvedMethod; + } + + @Override + public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType, boolean includeAbstract) { + if (!includeAbstract) { + return resolveConcreteMethod(method, callerType); + } + assert !callerType.isArray(); + 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; + final long resolvedMetaspaceMethod = runtime().getCompilerToVM().resolveMethod(getMetaspaceKlass(), hotSpotMethod.getMetaspaceMethod(), hotSpotCallerType.getMetaspaceKlass()); + if (resolvedMetaspaceMethod == 0) { + return null; + } + return HotSpotResolvedJavaMethodImpl.fromMetaspace(resolvedMetaspaceMethod); + } + + public ConstantPool constantPool() { + if (constantPool == null) { + final long metaspaceConstantPool = unsafe.getAddress(getMetaspaceKlass() + runtime().getConfig().instanceKlassConstantsOffset); + constantPool = new HotSpotConstantPool(metaspaceConstantPool); + } + 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 = runtime().getConfig(); + final int layoutHelper = unsafe.getInt(getMetaspaceKlass() + config.klassLayoutHelperOffset); + 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 synchronized HotSpotResolvedJavaMethod createMethod(long metaspaceMethod) { + HotSpotResolvedJavaMethod 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); + } + return method; + } + + public int getVtableLength() { + HotSpotVMConfig config = runtime().getConfig(); + if (isInterface() || isArray()) { + /* Everything has the core vtable of java.lang.Object */ + return config.baseVtableLength; + } + int result = unsafe.getInt(getMetaspaceKlass() + config.instanceKlassVtableLengthOffset) / (config.vtableEntrySize / config.heapWordSize); + assert result >= config.baseVtableLength : unsafe.getInt(getMetaspaceKlass() + config.instanceKlassVtableLengthOffset) + " " + config.vtableEntrySize; + return result; + } + + /** + * Gets the mask used to filter out HotSpot internal flags for fields when a {@link Field} + * object is created. This is the value of {@code JVM_RECOGNIZED_FIELD_MODIFIERS} in + * {@code jvm.h}, not {@link Modifier#fieldModifiers()}. + */ + public static int getReflectionFieldModifiers() { + return runtime().getConfig().recognizedFieldModifiers; + } + + public synchronized HotSpotResolvedJavaField createField(String fieldName, JavaType type, long offset, int rawFlags) { + HotSpotResolvedJavaField result = null; + + final int flags = rawFlags & getReflectionFieldModifiers(); + + final long id = offset + ((long) flags << 32); + + // (thomaswue) 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, true); + 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 + */ + public FieldInfo(int index) { + HotSpotVMConfig config = runtime().getConfig(); + // 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(runtime().getConfig().fieldInfoAccessFlagsOffset); + } + + private int getNameIndex() { + return readFieldSlot(runtime().getConfig().fieldInfoNameIndexOffset); + } + + private int getSignatureIndex() { + return readFieldSlot(runtime().getConfig().fieldInfoSignatureIndexOffset); + } + + public int getOffset() { + HotSpotVMConfig config = runtime().getConfig(); + 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) : constantPool().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) : constantPool().lookupUtf8(signatureIndex); + } + + public JavaType getType() { + String signature = getSignature(); + return runtime().lookupType(signature, HotSpotResolvedObjectTypeImpl.this, false); + } + + private boolean isInternal() { + return (getAccessFlags() & runtime().getConfig().jvmAccFieldInternal) != 0; + } + + public boolean isStatic() { + return Modifier.isStatic(getAccessFlags()); + } + + public boolean hasGenericSignature() { + return (getAccessFlags() & runtime().getConfig().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 = runtime().getConfig(); + 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 = runtime().getConfig(); + final int sourceFileNameIndex = unsafe.getChar(getMetaspaceKlass() + config.instanceKlassSourceFileNameIndexOffset); + if (sourceFileNameIndex == 0) { + return null; + } + return constantPool().lookupUtf8(sourceFileNameIndex); + } + + @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 HotSpotGraalRuntime#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 JavaConstant klass() { + return HotSpotMetaspaceConstantImpl.forMetaspaceObject(runtime().getTarget().wordKind, getMetaspaceKlass(), this, false); + } + + public boolean isPrimaryType() { + return runtime().getConfig().secondarySuperCacheOffset != superCheckOffset(); + } + + public int superCheckOffset() { + HotSpotVMConfig config = runtime().getConfig(); + return unsafe.getInt(getMetaspaceKlass() + config.superCheckOffsetOffset); + } + + public long prototypeMarkWord() { + HotSpotVMConfig config = runtime().getConfig(); + if (isArray()) { + return config.arrayPrototypeMarkWord(); + } else { + return unsafe.getAddress(getMetaspaceKlass() + config.prototypeMarkWordOffset); + } + } + + @Override + public ResolvedJavaField findInstanceFieldWithOffset(long offset, Kind 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(Kind.Void) && + resolvedField.getKind().isPrimitive()) { + resolvedFieldOffset += + resolvedField.getKind().getByteCount() - + Math.min(resolvedField.getKind().getByteCount(), 4 + expectedEntryKind.getByteCount()); + } + if (resolvedFieldOffset == offset) { + return field; + } + // @formatter:on + } + return null; + } + + @Override + public URL getClassFilePath() { + Class cls = mirror(); + return cls.getResource(MetaUtil.getSimpleName(cls, true).replace('.', '$') + ".class"); + } + + @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().getHostProviders().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().getHostProviders().getMetaAccess().lookupJavaMethod(methods[i]); + assert !result[i].isConstructor(); + } + return result; + } + + public ResolvedJavaMethod getClassInitializer() { + final long metaspaceMethod = runtime().getCompilerToVM().getClassInitializer(getMetaspaceKlass()); + if (metaspaceMethod != 0L) { + return createMethod(metaspaceMethod); + } + return null; + } + + @Override + public String toString() { + return "HotSpotType<" + getName() + ", resolved>"; + } + + @Override + public boolean isTrustedInterfaceType() { + return TrustedInterface.class.isAssignableFrom(mirror()); + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedPrimitiveType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedPrimitiveType.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,280 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import static java.util.Objects.*; + +import java.lang.annotation.*; +import java.lang.reflect.*; +import java.net.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.api.meta.Assumptions.AssumptionResult; +import com.oracle.graal.compiler.common.*; + +/** + * Implementation of {@link JavaType} for primitive HotSpot types. + */ +public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType implements HotSpotProxified { + + private final Kind kind; + + /** + * Creates the Graal mirror for a primitive {@link Kind}. + * + *

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

+ * + * @param kind the Kind to create the mirror for + */ + public HotSpotResolvedPrimitiveType(Kind 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 == Kind.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 GraalInternalError("Cannot call getImplementor() on a non-interface type: " + this); + } + + @Override + public ResolvedJavaType findLeastCommonAncestor(ResolvedJavaType otherType) { + return null; + } + + @Override + public JavaConstant getObjectHub() { + throw GraalInternalError.unimplemented("HotSpotResolvedPrimitiveType.getObjectHub"); + } + + @Override + public JavaConstant getJavaClass() { + throw GraalInternalError.unimplemented("HotSpotResolvedPrimitiveType.getJavaClass"); + } + + @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 Kind getKind() { + return kind; + } + + @Override + public boolean isJavaLangObject() { + return false; + } + + @Override + public ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { + return null; + } + + @Override + public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType, boolean includeAbstract) { + 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 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, Kind expectedType) { + return null; + } + + @Override + public String getSourceFileName() { + throw GraalInternalError.shouldNotReachHere(); + } + + @Override + public Class mirror() { + return kind.toJavaClass(); + } + + @Override + public URL getClassFilePath() { + return null; + } + + @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; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotSignature.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotSignature.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,213 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import java.util.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; +import com.oracle.graal.hotspot.*; + +/** + * 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 HotSpotGraalRuntimeProvider runtime; + + public HotSpotSignature(HotSpotGraalRuntimeProvider 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(HotSpotGraalRuntimeProvider 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 GraalInternalError("Invalid character at index " + cur + " in signature: " + signature); + } + return cur; + } + + @Override + public int getParameterCount(boolean withReceiver) { + return parameters.size() + (withReceiver ? 1 : 0); + } + + @Override + public Kind getParameterKind(int index) { + return Kind.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(HotSpotGraalRuntimeProvider runtime, String name) { + if (name.length() == 1) { + Kind kind = Kind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); + return runtime.getHostProviders().getMetaAccess().lookupJavaType(kind.toJavaClass()); + } + return new HotSpotUnresolvedJavaType(name, runtime); + } + + @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 Kind getReturnKind() { + return Kind.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(); + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotStackFrameReference.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotStackFrameReference.java Tue May 19 23:16:07 2015 +0200 @@ -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 com.oracle.graal.hotspot.jvmci; + +import java.util.*; + +import com.oracle.graal.api.code.stack.*; +import com.oracle.graal.api.meta.*; + +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 long metaspaceMethod; + 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 HotSpotResolvedJavaMethodImpl.fromMetaspace(metaspaceMethod); + } + + @Override + public boolean isMethod(ResolvedJavaMethod method) { + return metaspaceMethod == ((HotSpotResolvedJavaMethodImpl) method).getMetaspaceMethod(); + } + + @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) + "]"; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotUnresolvedField.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotUnresolvedField.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2009, 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 com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.meta.*; + +/** + * A implementation of {@link JavaField} for an unresolved field. + */ +public class HotSpotUnresolvedField implements JavaField { + + private final String name; + private final JavaType holder; + private final JavaType type; + + public 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>"); + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotUnresolvedJavaType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotUnresolvedJavaType.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,104 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.*; + +/** + * Implementation of {@link JavaType} for unresolved HotSpot classes. + */ +public class HotSpotUnresolvedJavaType extends HotSpotJavaType { + + private final HotSpotGraalRuntimeProvider runtime; + + public HotSpotUnresolvedJavaType(String name, HotSpotGraalRuntimeProvider 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}. + */ + public static HotSpotUnresolvedJavaType create(HotSpotGraalRuntimeProvider 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 Kind getKind() { + return Kind.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; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfig.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,1687 @@ +/* + * Copyright (c) 2011, 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 com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.compiler.common.UnsafeAccess.*; + +import java.lang.reflect.*; +import java.util.*; + +import com.oracle.graal.compiler.common.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspotvmconfig.*; + +//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 { + + /** + * Determines if the current architecture is included in a given architecture set specification. + * + * @param currentArch + * @param archsSpecification specifies a set of architectures. A zero length value implies all + * architectures. + */ + private static boolean isRequired(String currentArch, String[] archsSpecification) { + if (archsSpecification.length == 0) { + return true; + } + for (String arch : archsSpecification) { + if (arch.equals(currentArch)) { + return true; + } + } + return false; + } + + /** + * Maximum allowed size of allocated area for a frame. + */ + public final int maxFrameSize = 16 * 1024; + + @Override + public String toString() { + return getClass().getSimpleName(); + } + + public HotSpotVMConfig(CompilerToVM compilerToVm) { + compilerToVm.initializeConfiguration(this); + assert verifyInitialization(); + + oopEncoding = new CompressEncoding(narrowOopBase, narrowOopShift, logMinObjAlignment()); + klassEncoding = new CompressEncoding(narrowKlassBase, narrowKlassShift, logKlassAlignment); + + codeCacheLowBoundary = unsafe.getAddress(codeCacheHeap + codeHeapMemoryOffset + virtualSpaceLowBoundaryOffset); + codeCacheHighBoundary = unsafe.getAddress(codeCacheHeap + codeHeapMemoryOffset + virtualSpaceHighBoundaryOffset); + + final long barrierSetAddress = unsafe.getAddress(universeCollectedHeap + collectedHeapBarrierSetOffset); + final int kind = unsafe.getInt(barrierSetAddress + barrierSetKindOffset); + if ((kind == barrierSetCardTableModRef) || (kind == barrierSetCardTableExtension) || (kind == barrierSetG1SATBCT) || (kind == barrierSetG1SATBCTLogging)) { + final long base = unsafe.getAddress(barrierSetAddress + cardTableModRefBSByteMapBaseOffset); + assert base != 0 : "unexpected byte_map_base: " + base; + cardtableStartAddress = base; + cardtableShift = cardTableModRefBSCardShift; + } else if ((kind == barrierSetModRef) || (kind == barrierSetOther)) { + // No post barriers + cardtableStartAddress = 0; + cardtableShift = 0; + } else { + cardtableStartAddress = -1; + cardtableShift = -1; + } + + inlineCacheMissStub = inlineCacheMissBlob + unsafe.getInt(inlineCacheMissBlob + codeBlobCodeOffsetOffset); + + assert check(); + assert HotSpotVMConfigVerifier.check(); + } + + /** + * Check that the initialization produces the same result as the values captured through + * vmStructs. + */ + private boolean verifyInitialization() { + /** These fields are set in {@link CompilerToVM#initializeConfiguration}. */ + assert gHotSpotVMStructs != 0; + assert gHotSpotVMTypes != 0; + assert gHotSpotVMIntConstants != 0; + assert gHotSpotVMLongConstants != 0; + + // Fill the VM fields hash map. + HashMap vmFields = new HashMap<>(); + for (VMFields.Field e : new VMFields(gHotSpotVMStructs)) { + vmFields.put(e.getName(), e); + } + + // Fill the VM types hash map. + HashMap vmTypes = new HashMap<>(); + for (VMTypes.Type e : new VMTypes(gHotSpotVMTypes)) { + vmTypes.put(e.getTypeName(), e); + } + + // Fill the VM constants hash map. + HashMap vmConstants = new HashMap<>(); + for (AbstractConstant e : new VMIntConstants(gHotSpotVMIntConstants)) { + vmConstants.put(e.getName(), e); + } + for (AbstractConstant e : new VMLongConstants(gHotSpotVMLongConstants)) { + vmConstants.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 currentArch = 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(currentArch, annotation.archs())) { + continue; + } + throw new IllegalArgumentException("field not found: " + name); + } + + // Make sure the native type is still the type we expect. + if (!type.equals("")) { + if (!type.equals(entry.getTypeString())) { + throw new IllegalArgumentException("compiler expects type " + type + " but field " + name + " is of type " + entry.getTypeString()); + } + } + + switch (annotation.get()) { + case OFFSET: + checkField(f, entry.getOffset()); + break; + case ADDRESS: + checkField(f, entry.getAddress()); + break; + case VALUE: + checkField(f, entry.getValue()); + break; + default: + throw GraalInternalError.shouldNotReachHere("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 IllegalArgumentException("type not found: " + name); + } + switch (annotation.get()) { + case SIZE: + checkField(f, entry.getSize()); + break; + default: + throw GraalInternalError.shouldNotReachHere("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(currentArch, annotation.archs())) { + continue; + } + throw new IllegalArgumentException("constant not found: " + name); + } + checkField(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(currentArch, annotation.archs())) { + continue; + } + throw new IllegalArgumentException("flag not found: " + name); + + } + checkField(f, entry.getValue()); + } + } + return true; + } + + private final CompressEncoding oopEncoding; + private final CompressEncoding klassEncoding; + + public CompressEncoding getOopEncoding() { + return oopEncoding; + } + + public CompressEncoding getKlassEncoding() { + return klassEncoding; + } + + private void checkField(Field field, Object value) { + try { + Class fieldType = field.getType(); + if (fieldType == boolean.class) { + if (value instanceof String) { + assert field.getBoolean(this) == Boolean.valueOf((String) value) : field + " " + value + " " + field.getBoolean(this); + } else if (value instanceof Boolean) { + assert field.getBoolean(this) == (boolean) value : field + " " + value + " " + field.getBoolean(this); + } else if (value instanceof Long) { + assert field.getBoolean(this) == (((long) value) != 0) : field + " " + value + " " + field.getBoolean(this); + } else { + GraalInternalError.shouldNotReachHere(value.getClass().getSimpleName()); + } + } else if (fieldType == int.class) { + if (value instanceof Integer) { + assert field.getInt(this) == (int) value : field + " " + value + " " + field.getInt(this); + } else if (value instanceof Long) { + assert field.getInt(this) == (int) (long) value : field + " " + value + " " + field.getInt(this); + } else { + GraalInternalError.shouldNotReachHere(value.getClass().getSimpleName()); + } + } else if (fieldType == long.class) { + assert field.getLong(this) == (long) value : field + " " + value + " " + field.getLong(this); + } else { + GraalInternalError.shouldNotReachHere(field.toString()); + } + } catch (IllegalAccessException e) { + throw GraalInternalError.shouldNotReachHere(field.toString() + ": " + e); + } + } + + /** + * Gets the host architecture name for the purpose of finding the corresponding + * {@linkplain HotSpotBackendFactory 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; + } + + /** + * VMStructEntry (see vmStructs.hpp). + */ + @HotSpotVMValue(expression = "gHotSpotVMStructs", get = HotSpotVMValue.Type.ADDRESS) @Stable private long gHotSpotVMStructs; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryTypeNameOffset") @Stable private long gHotSpotVMStructEntryTypeNameOffset; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryFieldNameOffset") @Stable private long gHotSpotVMStructEntryFieldNameOffset; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryTypeStringOffset") @Stable private long gHotSpotVMStructEntryTypeStringOffset; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryIsStaticOffset") @Stable private long gHotSpotVMStructEntryIsStaticOffset; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryOffsetOffset") @Stable private long gHotSpotVMStructEntryOffsetOffset; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryAddressOffset") @Stable private long gHotSpotVMStructEntryAddressOffset; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryArrayStride") @Stable private long gHotSpotVMStructEntryArrayStride; + + class VMFields implements Iterable { + + private long address; + + public VMFields(long address) { + this.address = address; + } + + public Iterator iterator() { + return new Iterator() { + + private int index = 0; + + private Field current() { + return new Field(address + gHotSpotVMStructEntryArrayStride * 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; + } + + @Override + public void remove() { + throw GraalInternalError.unimplemented(); + } + }; + } + + class Field { + + private long entryAddress; + + Field(long address) { + this.entryAddress = address; + } + + public String getTypeName() { + long typeNameAddress = unsafe.getAddress(entryAddress + gHotSpotVMStructEntryTypeNameOffset); + return readCString(typeNameAddress); + } + + public String getFieldName() { + long fieldNameAddress = unsafe.getAddress(entryAddress + gHotSpotVMStructEntryFieldNameOffset); + return readCString(fieldNameAddress); + } + + public String getTypeString() { + long typeStringAddress = unsafe.getAddress(entryAddress + gHotSpotVMStructEntryTypeStringOffset); + return readCString(typeStringAddress); + } + + public boolean isStatic() { + return unsafe.getInt(entryAddress + gHotSpotVMStructEntryIsStaticOffset) != 0; + } + + public long getOffset() { + return unsafe.getLong(entryAddress + gHotSpotVMStructEntryOffsetOffset); + } + + public long getAddress() { + return unsafe.getAddress(entryAddress + gHotSpotVMStructEntryAddressOffset); + } + + public String getName() { + String typeName = getTypeName(); + String fieldName = getFieldName(); + return typeName + "::" + fieldName; + } + + public long getValue() { + String type = getTypeString(); + switch (type) { + case "int": + return unsafe.getInt(getAddress()); + case "address": + case "intptr_t": + return unsafe.getAddress(getAddress()); + default: + // All foo* types are addresses. + if (type.endsWith("*")) { + return unsafe.getAddress(getAddress()); + } + throw GraalInternalError.shouldNotReachHere(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). + */ + @HotSpotVMValue(expression = "gHotSpotVMTypes", get = HotSpotVMValue.Type.ADDRESS) @Stable private long gHotSpotVMTypes; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntryTypeNameOffset") @Stable private long gHotSpotVMTypeEntryTypeNameOffset; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntrySuperclassNameOffset") @Stable private long gHotSpotVMTypeEntrySuperclassNameOffset; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntryIsOopTypeOffset") @Stable private long gHotSpotVMTypeEntryIsOopTypeOffset; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntryIsIntegerTypeOffset") @Stable private long gHotSpotVMTypeEntryIsIntegerTypeOffset; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntryIsUnsignedOffset") @Stable private long gHotSpotVMTypeEntryIsUnsignedOffset; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntrySizeOffset") @Stable private long gHotSpotVMTypeEntrySizeOffset; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntryArrayStride") @Stable private long gHotSpotVMTypeEntryArrayStride; + + class VMTypes implements Iterable { + + private long address; + + public VMTypes(long address) { + this.address = address; + } + + public Iterator iterator() { + return new Iterator() { + + private int index = 0; + + private Type current() { + return new Type(address + gHotSpotVMTypeEntryArrayStride * 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; + } + + @Override + public void remove() { + throw GraalInternalError.unimplemented(); + } + }; + } + + class Type { + + private long entryAddress; + + Type(long address) { + this.entryAddress = address; + } + + public String getTypeName() { + long typeNameAddress = unsafe.getAddress(entryAddress + gHotSpotVMTypeEntryTypeNameOffset); + return readCString(typeNameAddress); + } + + public String getSuperclassName() { + long superclassNameAddress = unsafe.getAddress(entryAddress + gHotSpotVMTypeEntrySuperclassNameOffset); + return readCString(superclassNameAddress); + } + + public boolean isOopType() { + return unsafe.getInt(entryAddress + gHotSpotVMTypeEntryIsOopTypeOffset) != 0; + } + + public boolean isIntegerType() { + return unsafe.getInt(entryAddress + gHotSpotVMTypeEntryIsIntegerTypeOffset) != 0; + } + + public boolean isUnsigned() { + return unsafe.getInt(entryAddress + gHotSpotVMTypeEntryIsUnsignedOffset) != 0; + } + + public long getSize() { + return unsafe.getLong(entryAddress + gHotSpotVMTypeEntrySizeOffset); + } + + @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 long address; + protected long nameOffset; + protected 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(nameAddress); + } + + public abstract long getValue(); + } + + /** + * VMIntConstantEntry (see vmStructs.hpp). + */ + @HotSpotVMValue(expression = "gHotSpotVMIntConstants", get = HotSpotVMValue.Type.ADDRESS) @Stable private long gHotSpotVMIntConstants; + @HotSpotVMValue(expression = "gHotSpotVMIntConstantEntryNameOffset") @Stable private long gHotSpotVMIntConstantEntryNameOffset; + @HotSpotVMValue(expression = "gHotSpotVMIntConstantEntryValueOffset") @Stable private long gHotSpotVMIntConstantEntryValueOffset; + @HotSpotVMValue(expression = "gHotSpotVMIntConstantEntryArrayStride") @Stable private long gHotSpotVMIntConstantEntryArrayStride; + + class VMIntConstants implements Iterable { + + private long address; + + public VMIntConstants(long address) { + this.address = address; + } + + public Iterator iterator() { + return new Iterator() { + + private int index = 0; + + private Constant current() { + return new Constant(address + gHotSpotVMIntConstantEntryArrayStride * 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; + } + + @Override + public void remove() { + throw GraalInternalError.unimplemented(); + } + }; + } + + class Constant extends AbstractConstant { + + Constant(long address) { + super(address, gHotSpotVMIntConstantEntryNameOffset, gHotSpotVMIntConstantEntryValueOffset); + } + + @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). + */ + @HotSpotVMValue(expression = "gHotSpotVMLongConstants", get = HotSpotVMValue.Type.ADDRESS) @Stable private long gHotSpotVMLongConstants; + @HotSpotVMValue(expression = "gHotSpotVMLongConstantEntryNameOffset") @Stable private long gHotSpotVMLongConstantEntryNameOffset; + @HotSpotVMValue(expression = "gHotSpotVMLongConstantEntryValueOffset") @Stable private long gHotSpotVMLongConstantEntryValueOffset; + @HotSpotVMValue(expression = "gHotSpotVMLongConstantEntryArrayStride") @Stable private long gHotSpotVMLongConstantEntryArrayStride; + + class VMLongConstants implements Iterable { + + private long address; + + public VMLongConstants(long address) { + this.address = address; + } + + public Iterator iterator() { + return new Iterator() { + + private int index = 0; + + private Constant currentEntry() { + return new Constant(address + gHotSpotVMLongConstantEntryArrayStride * 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; + } + + @Override + public void remove() { + throw GraalInternalError.unimplemented(); + } + }; + } + + class Constant extends AbstractConstant { + + Constant(long address) { + super(address, gHotSpotVMLongConstantEntryNameOffset, gHotSpotVMLongConstantEntryValueOffset); + } + + @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()); + } + } + } + + class Flags implements Iterable { + + private long address; + private long entrySize; + private long typeOffset; + private long nameOffset; + private long addrOffset; + + public 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; + } + + @Override + public void remove() { + throw GraalInternalError.unimplemented(); + } + }; + } + + class Flag { + + private long entryAddress; + + Flag(long address) { + this.entryAddress = address; + } + + public String getType() { + long typeAddress = unsafe.getAddress(entryAddress + typeOffset); + return readCString(typeAddress); + } + + public String getName() { + long nameAddress = unsafe.getAddress(entryAddress + nameOffset); + return readCString(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(getAddr()); + default: + throw GraalInternalError.shouldNotReachHere(getType()); + } + } + + @Override + public String toString() { + return String.format("Flag[type=%s, name=%s, value=%s]", getType(), getName(), getValue()); + } + } + } + + // os information, register layout, code generation, ... + @HotSpotVMValue(expression = "DEBUG_ONLY(1) NOT_DEBUG(0)") @Stable public boolean cAssertions; + public final boolean windowsOs = System.getProperty("os.name", "").startsWith("Windows"); + + @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 = "GraalUseFastLocking") @Stable public boolean useFastLocking; + @HotSpotVMFlag(name = "ForceUnreachable") @Stable public boolean forceUnreachable; + + @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 = "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 = "GraalDeferredInitBarriers") @Stable public boolean useDeferredInitBarriers; + @HotSpotVMFlag(name = "GraalHProfEnabled") @Stable public boolean useHeapProfiler; + + // Compressed Oops related values. + @HotSpotVMFlag(name = "UseCompressedOops") @Stable public boolean useCompressedOops; + @HotSpotVMFlag(name = "UseCompressedClassPointers") @Stable public boolean useCompressedClassPointers; + + @HotSpotVMField(name = "Universe::_narrow_oop._base", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long narrowOopBase; + @HotSpotVMField(name = "Universe::_narrow_oop._shift", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int narrowOopShift; + @HotSpotVMFlag(name = "ObjectAlignmentInBytes") @Stable public int objectAlignment; + + public int logMinObjAlignment() { + return (int) (Math.log(objectAlignment) / Math.log(2)); + } + + @HotSpotVMField(name = "Universe::_narrow_klass._base", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long narrowKlassBase; + @HotSpotVMField(name = "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; + + // X86 specific values + @HotSpotVMField(name = "VM_Version::_cpuFeatures", type = "int", get = HotSpotVMField.Type.VALUE, archs = {"amd64"}) @Stable public int x86CPUFeatures; + @HotSpotVMConstant(name = "VM_Version::CPU_CX8", archs = {"amd64"}) @Stable public int cpuCX8; + @HotSpotVMConstant(name = "VM_Version::CPU_CMOV", archs = {"amd64"}) @Stable public int cpuCMOV; + @HotSpotVMConstant(name = "VM_Version::CPU_FXSR", archs = {"amd64"}) @Stable public int cpuFXSR; + @HotSpotVMConstant(name = "VM_Version::CPU_HT", archs = {"amd64"}) @Stable public int cpuHT; + @HotSpotVMConstant(name = "VM_Version::CPU_MMX", archs = {"amd64"}) @Stable public int cpuMMX; + @HotSpotVMConstant(name = "VM_Version::CPU_3DNOW_PREFETCH", archs = {"amd64"}) @Stable public int cpu3DNOWPREFETCH; + @HotSpotVMConstant(name = "VM_Version::CPU_SSE", archs = {"amd64"}) @Stable public int cpuSSE; + @HotSpotVMConstant(name = "VM_Version::CPU_SSE2", archs = {"amd64"}) @Stable public int cpuSSE2; + @HotSpotVMConstant(name = "VM_Version::CPU_SSE3", archs = {"amd64"}) @Stable public int cpuSSE3; + @HotSpotVMConstant(name = "VM_Version::CPU_SSSE3", archs = {"amd64"}) @Stable public int cpuSSSE3; + @HotSpotVMConstant(name = "VM_Version::CPU_SSE4A", archs = {"amd64"}) @Stable public int cpuSSE4A; + @HotSpotVMConstant(name = "VM_Version::CPU_SSE4_1", archs = {"amd64"}) @Stable public int cpuSSE41; + @HotSpotVMConstant(name = "VM_Version::CPU_SSE4_2", archs = {"amd64"}) @Stable public int cpuSSE42; + @HotSpotVMConstant(name = "VM_Version::CPU_POPCNT", archs = {"amd64"}) @Stable public int cpuPOPCNT; + @HotSpotVMConstant(name = "VM_Version::CPU_LZCNT", archs = {"amd64"}) @Stable public int cpuLZCNT; + @HotSpotVMConstant(name = "VM_Version::CPU_TSC", archs = {"amd64"}) @Stable public int cpuTSC; + @HotSpotVMConstant(name = "VM_Version::CPU_TSCINV", archs = {"amd64"}) @Stable public int cpuTSCINV; + @HotSpotVMConstant(name = "VM_Version::CPU_AVX", archs = {"amd64"}) @Stable public int cpuAVX; + @HotSpotVMConstant(name = "VM_Version::CPU_AVX2", archs = {"amd64"}) @Stable public int cpuAVX2; + @HotSpotVMConstant(name = "VM_Version::CPU_AES", archs = {"amd64"}) @Stable public int cpuAES; + @HotSpotVMConstant(name = "VM_Version::CPU_ERMS", archs = {"amd64"}) @Stable public int cpuERMS; + @HotSpotVMConstant(name = "VM_Version::CPU_CLMUL", archs = {"amd64"}) @Stable public int cpuCLMUL; + @HotSpotVMConstant(name = "VM_Version::CPU_BMI1", archs = {"amd64"}) @Stable public int cpuBMI1; + + // SPARC specific values + @HotSpotVMField(name = "VM_Version::_features", type = "int", get = HotSpotVMField.Type.VALUE, archs = {"sparc"}) @Stable public int sparcFeatures; + @HotSpotVMConstant(name = "VM_Version::vis3_instructions_m", archs = {"sparc"}) @Stable public int vis3Instructions; + @HotSpotVMConstant(name = "VM_Version::vis2_instructions_m", archs = {"sparc"}) @Stable public int vis2Instructions; + @HotSpotVMConstant(name = "VM_Version::vis1_instructions_m", archs = {"sparc"}) @Stable public int vis1Instructions; + @HotSpotVMConstant(name = "VM_Version::cbcond_instructions_m", archs = {"sparc"}) @Stable public int cbcondInstructions; + + // offsets, ... + @HotSpotVMFlag(name = "StackShadowPages") @Stable public int stackShadowPages; + @HotSpotVMFlag(name = "UseStackBanging") @Stable public boolean useStackBanging; + @HotSpotVMConstant(name = "STACK_BIAS") @Stable public int stackBias; + + @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; + + @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; + + @HotSpotVMField(name = "ArrayKlass::_component_mirror", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayKlassComponentMirrorOffset; + + @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; + @HotSpotVMValue(expression = "InstanceKlass::vtable_start_offset() * HeapWordSize") @Stable public int instanceKlassVtableStartOffset; + @HotSpotVMValue(expression = "InstanceKlass::vtable_length_offset() * HeapWordSize") @Stable public int instanceKlassVtableLengthOffset; + @HotSpotVMValue(expression = "Universe::base_vtable_size() / vtableEntry::size()") @Stable public int baseVtableLength; + + /** + * The offset of the array length word in an array object's header. + */ + @HotSpotVMValue(expression = "arrayOopDesc::length_offset_in_bytes()") @Stable public int arrayLengthOffset; + + @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 = "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; + + @HotSpotVMConstant(name = "InstanceKlass::linked") @Stable public int instanceKlassStateLinked; + @HotSpotVMConstant(name = "InstanceKlass::fully_initialized") @Stable public int instanceKlassStateFullyInitialized; + + @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_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; + + @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 = "ObjPtrQueue", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadSatbMarkQueueOffset; + @HotSpotVMField(name = "JavaThread::_vm_result", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadObjectResultOffset; + @HotSpotVMValue(expression = "in_bytes(JavaThread::graal_counters_offset())") @Stable public int graalCountersThreadOffset; + + /** + * 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)
+     * 
+ */ + @HotSpotVMValue(expression = "os::dll_load", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dllLoad; + + /** + * Address of the library lookup routine. The C signature of this routine is: + * + *
+     *     void* (void* handle, const char* name)
+     * 
+ */ + @HotSpotVMValue(expression = "os::dll_lookup", get = HotSpotVMValue.Type.ADDRESS) @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. + */ + @HotSpotVMValue(expression = "RTLD_DEFAULT", defines = {"TARGET_OS_FAMILY_bsd", "TARGET_OS_FAMILY_linux"}, get = HotSpotVMValue.Type.ADDRESS) @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. + *

+ * NOTE: This is not the same as {@link #pendingExceptionOffset}. + */ + @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 = "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 = {"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; + } + + /** + * This value is only valid on AMD64. + */ + public int threadLastJavaFpOffset() { + // TODO add an assert for 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; + + @HotSpotVMField(name = "PtrQueue::_active", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int ptrQueueActiveOffset; + @HotSpotVMField(name = "PtrQueue::_buf", type = "void**", get = HotSpotVMField.Type.OFFSET) @Stable public int ptrQueueBufferOffset; + @HotSpotVMField(name = "PtrQueue::_index", type = "size_t", get = HotSpotVMField.Type.OFFSET) @Stable public int ptrQueueIndexOffset; + + @HotSpotVMField(name = "OSThread::_interrupted", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int osThreadInterruptedOffset; + + @HotSpotVMConstant(name = "markOopDesc::unlocked_value") @Stable public int unlockedMask; + @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_shift") @Stable public long markOopDescHashShift; + @HotSpotVMConstant(name = "markOopDesc::hash_mask") @Stable public long markOopDescHashMask; + @HotSpotVMConstant(name = "markOopDesc::hash_mask_in_place") @Stable public long markOopDescHashMaskInPlace; + + @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 markOopDesc::prototype(). + */ + public long arrayPrototypeMarkWord() { + return markWordNoHashInPlace | markWordNoLockInPlace; + } + + /** + * See markOopDesc::copy_set_hash(). + */ + public long tlabIntArrayMarkWord() { + long tmp = arrayPrototypeMarkWord() & (~markOopDescHashMaskInPlace); + tmp |= ((0x2 & markOopDescHashMask) << markOopDescHashShift); + return tmp; + } + + /** + * Offset of the _pending_exception field in ThreadShadow (defined in exceptions.hpp). This + * field is used to propagate exceptions through C/C++ calls. + *

+ * NOTE: This is not the same as {@link #threadExceptionOopOffset}. + */ + @HotSpotVMField(name = "ThreadShadow::_pending_exception", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingExceptionOffset; + @HotSpotVMField(name = "ThreadShadow::_pending_deoptimization", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingDeoptimizationOffset; + @HotSpotVMField(name = "ThreadShadow::_pending_failed_speculation", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingFailedSpeculationOffset; + @HotSpotVMField(name = "ThreadShadow::_pending_transfer_to_interpreter", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingTransferToInterpreterOffset; + + /** + * 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 = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int methodIntrinsicIdOffset; + @HotSpotVMField(name = "Method::_flags", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int methodFlagsOffset; + @HotSpotVMField(name = "Method::_vtable_index", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodVtableIndexOffset; + + @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::nonvirtual_vtable_index") @Stable public int nonvirtualVtableIndex; + @HotSpotVMConstant(name = "Method::invalid_vtable_index") @Stable public int invalidVtableIndex; + + @HotSpotVMConstant(name = "JVM_ACC_MONITOR_MATCH") @Stable public int jvmAccMonitorMatch; + @HotSpotVMConstant(name = "JVM_ACC_HAS_MONITOR_BYTECODES") @Stable public int jvmAccHasMonitorBytecodes; + + @HotSpotVMField(name = "GraalEnv::_task", type = "CompileTask*", get = HotSpotVMField.Type.OFFSET) @Stable public int graalEnvTaskOffset; + @HotSpotVMField(name = "GraalEnv::_jvmti_can_hotswap_or_post_breakpoint", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int graalEnvJvmtiCanHotswapOrPostBreakpointOffset; + @HotSpotVMField(name = "CompileTask::_num_inlined_bytecodes", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int compileTaskNumInlinedBytecodesOffset; + + /** + * Value of Method::extra_stack_entries(). + */ + @HotSpotVMValue(expression = "Method::extra_stack_entries()") @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 = "Symbol::_length", type = "unsigned short", get = HotSpotVMField.Type.OFFSET) @Stable public int symbolLengthOffset; + @HotSpotVMField(name = "Symbol::_body[0]", type = "jbyte", get = HotSpotVMField.Type.OFFSET) @Stable public int symbolBodyOffset; + + @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; + + @HotSpotVMConstant(name = "JVM_ACC_HAS_FINALIZER") @Stable public int klassHasFinalizerFlag; + + // Modifier.SYNTHETIC is not public so we get it via vmStructs. + @HotSpotVMConstant(name = "JVM_ACC_SYNTHETIC") @Stable public int syntheticFlag; + + /** + * @see HotSpotResolvedObjectTypeImpl#createField + */ + @HotSpotVMConstant(name = "JVM_RECOGNIZED_FIELD_MODIFIERS") @Stable public int recognizedFieldModifiers; + + /** + * 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 = "Universe::_non_oop_bits", type = "intptr_t", get = HotSpotVMField.Type.VALUE) @Stable public long nonOopBits; + + @HotSpotVMField(name = "StubRoutines::_verify_oop_count", type = "jint", get = HotSpotVMField.Type.ADDRESS) @Stable public long verifyOopCounterAddress; + @HotSpotVMValue(expression = "Universe::verify_oop_mask()") @Stable public long verifyOopMask; + @HotSpotVMValue(expression = "Universe::verify_oop_bits()") @Stable public long verifyOopBits; + + @HotSpotVMField(name = "CollectedHeap::_barrier_set", type = "BarrierSet*", get = HotSpotVMField.Type.OFFSET) @Stable public int collectedHeapBarrierSetOffset; + + @HotSpotVMField(name = "HeapRegion::LogOfHRGrainBytes", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int logOfHRGrainBytes; + + @HotSpotVMField(name = "BarrierSet::_kind", type = "BarrierSet::Name", get = HotSpotVMField.Type.OFFSET) @Stable private int barrierSetKindOffset; + @HotSpotVMConstant(name = "BarrierSet::CardTableModRef") @Stable public int barrierSetCardTableModRef; + @HotSpotVMConstant(name = "BarrierSet::CardTableExtension") @Stable public int barrierSetCardTableExtension; + @HotSpotVMConstant(name = "BarrierSet::G1SATBCT") @Stable public int barrierSetG1SATBCT; + @HotSpotVMConstant(name = "BarrierSet::G1SATBCTLogging") @Stable public int barrierSetG1SATBCTLogging; + @HotSpotVMConstant(name = "BarrierSet::ModRef") @Stable public int barrierSetModRef; + @HotSpotVMConstant(name = "BarrierSet::Other") @Stable public int barrierSetOther; + + @HotSpotVMField(name = "CardTableModRefBS::byte_map_base", type = "jbyte*", get = HotSpotVMField.Type.OFFSET) @Stable private int cardTableModRefBSByteMapBaseOffset; + @HotSpotVMConstant(name = "CardTableModRefBS::card_shift") @Stable public int cardTableModRefBSCardShift; + + @HotSpotVMValue(expression = "(jbyte)CardTableModRefBS::dirty_card_val()") @Stable public byte dirtyCardValue; + @HotSpotVMValue(expression = "(jbyte)G1SATBCardTableModRefBS::g1_young_card_val()") @Stable public byte g1YoungCardValue; + + private final long cardtableStartAddress; + private final int cardtableShift; + + public long cardtableStartAddress() { + if (cardtableStartAddress == -1) { + throw GraalInternalError.shouldNotReachHere(); + } + return cardtableStartAddress; + } + + public int cardtableShift() { + if (cardtableShift == -1) { + throw GraalInternalError.shouldNotReachHere(); + } + 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 + ptrQueueIndexOffset; + } + + public int g1CardQueueBufferOffset() { + return javaThreadDirtyCardQueueOffset + ptrQueueBufferOffset; + } + + public int g1SATBQueueMarkingOffset() { + return javaThreadSatbMarkQueueOffset + ptrQueueActiveOffset; + } + + public int g1SATBQueueIndexOffset() { + return javaThreadSatbMarkQueueOffset + ptrQueueIndexOffset; + } + + public int g1SATBQueueBufferOffset() { + return javaThreadSatbMarkQueueOffset + ptrQueueBufferOffset; + } + + @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; + + @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 = "nmethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCodeOffset; + + @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::_graal_node_count", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataGraalNodeCountOffset; + + @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; + + @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; + + @HotSpotVMValue(expression = "Universe::heap()->supports_inline_contig_alloc() ? Universe::heap()->end_addr() : (HeapWord**)-1", get = HotSpotVMValue.Type.ADDRESS) @Stable public long heapEndAddress; + @HotSpotVMValue(expression = "Universe::heap()->supports_inline_contig_alloc() ? Universe::heap()->top_addr() : (HeapWord**)-1", get = HotSpotVMValue.Type.ADDRESS) @Stable public long heapTopAddress; + + @HotSpotVMField(name = "Thread::_allocated_bytes", type = "jlong", get = HotSpotVMField.Type.OFFSET) @Stable public int threadAllocatedBytesOffset; + + @HotSpotVMFlag(name = "TLABWasteIncrement") @Stable public int tlabRefillWasteIncrement; + @HotSpotVMValue(expression = "ThreadLocalAllocBuffer::alignment_reserve()") @Stable public int tlabAlignmentReserve; + + @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; + } + + @HotSpotVMFlag(name = "TLABStats") @Stable public boolean tlabStats; + @HotSpotVMValue(expression = " !CMSIncrementalMode && Universe::heap()->supports_inline_contig_alloc()") @Stable public boolean inlineContiguousAllocationSupported; + + /** + * 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 = "CodeBlob::_code_offset", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable private int codeBlobCodeOffsetOffset; + @HotSpotVMField(name = "SharedRuntime::_ic_miss_blob", type = "RuntimeStub*", get = HotSpotVMField.Type.VALUE) @Stable private long inlineCacheMissBlob; + + @HotSpotVMValue(expression = "SharedRuntime::deopt_blob()->unpack()", get = HotSpotVMValue.Type.ADDRESS) @Stable public long handleDeoptStub; + @HotSpotVMValue(expression = "SharedRuntime::deopt_blob()->uncommon_trap()", get = HotSpotVMValue.Type.ADDRESS) @Stable public long uncommonTrapStub; + + private final long inlineCacheMissStub; + + public long inlineCacheMissStub() { + return inlineCacheMissStub; + } + + @HotSpotVMField(name = "CodeCache::_heap", type = "CodeHeap*", get = HotSpotVMField.Type.VALUE) @Stable private long codeCacheHeap; + @HotSpotVMField(name = "CodeHeap::_memory", type = "VirtualSpace", get = HotSpotVMField.Type.OFFSET) @Stable private int codeHeapMemoryOffset; + @HotSpotVMField(name = "VirtualSpace::_low_boundary", type = "char*", get = HotSpotVMField.Type.OFFSET) @Stable private int virtualSpaceLowBoundaryOffset; + @HotSpotVMField(name = "VirtualSpace::_high_boundary", type = "char*", get = HotSpotVMField.Type.OFFSET) @Stable private int virtualSpaceHighBoundaryOffset; + + private final long codeCacheLowBoundary; + private final long codeCacheHighBoundary; + + /** + * @return CodeCache::_heap->_memory._low_boundary + */ + public long codeCacheLowBoundary() { + return codeCacheLowBoundary; + } + + /** + * @return CodeCache::_heap->_memory._high_boundary + */ + public long codeCacheHighBoundary() { + return codeCacheHighBoundary; + } + + @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::_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; + + @HotSpotVMValue(expression = "GraalRuntime::new_instance", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newInstanceAddress; + @HotSpotVMValue(expression = "GraalRuntime::new_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newArrayAddress; + @HotSpotVMValue(expression = "GraalRuntime::new_multi_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newMultiArrayAddress; + @HotSpotVMValue(expression = "GraalRuntime::dynamic_new_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dynamicNewArrayAddress; + @HotSpotVMValue(expression = "GraalRuntime::dynamic_new_instance", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dynamicNewInstanceAddress; + @HotSpotVMValue(expression = "GraalRuntime::thread_is_interrupted", get = HotSpotVMValue.Type.ADDRESS) @Stable public long threadIsInterruptedAddress; + @HotSpotVMValue(expression = "GraalRuntime::vm_message", signature = "(unsigned char, long, long, long, long)", get = HotSpotVMValue.Type.ADDRESS) @Stable public long vmMessageAddress; + @HotSpotVMValue(expression = "GraalRuntime::identity_hash_code", get = HotSpotVMValue.Type.ADDRESS) @Stable public long identityHashCodeAddress; + @HotSpotVMValue(expression = "GraalRuntime::exception_handler_for_pc", signature = "(JavaThread*)", get = HotSpotVMValue.Type.ADDRESS) @Stable public long exceptionHandlerForPcAddress; + @HotSpotVMValue(expression = "GraalRuntime::monitorenter", get = HotSpotVMValue.Type.ADDRESS) @Stable public long monitorenterAddress; + @HotSpotVMValue(expression = "GraalRuntime::monitorexit", get = HotSpotVMValue.Type.ADDRESS) @Stable public long monitorexitAddress; + @HotSpotVMValue(expression = "GraalRuntime::create_null_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long createNullPointerExceptionAddress; + @HotSpotVMValue(expression = "GraalRuntime::create_out_of_bounds_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long createOutOfBoundsExceptionAddress; + @HotSpotVMValue(expression = "GraalRuntime::log_primitive", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logPrimitiveAddress; + @HotSpotVMValue(expression = "GraalRuntime::log_object", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logObjectAddress; + @HotSpotVMValue(expression = "GraalRuntime::log_printf", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logPrintfAddress; + @HotSpotVMValue(expression = "GraalRuntime::vm_error", get = HotSpotVMValue.Type.ADDRESS) @Stable public long vmErrorAddress; + @HotSpotVMValue(expression = "GraalRuntime::load_and_clear_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long loadAndClearExceptionAddress; + @HotSpotVMValue(expression = "GraalRuntime::write_barrier_pre", get = HotSpotVMValue.Type.ADDRESS) @Stable public long writeBarrierPreAddress; + @HotSpotVMValue(expression = "GraalRuntime::write_barrier_post", get = HotSpotVMValue.Type.ADDRESS) @Stable public long writeBarrierPostAddress; + @HotSpotVMValue(expression = "GraalRuntime::validate_object", get = HotSpotVMValue.Type.ADDRESS) @Stable public long validateObject; + + @HotSpotVMValue(expression = "GraalRuntime::test_deoptimize_call_int", get = HotSpotVMValue.Type.ADDRESS) @Stable public long testDeoptimizeCallInt; + + @HotSpotVMValue(expression = "SharedRuntime::register_finalizer", get = HotSpotVMValue.Type.ADDRESS) @Stable public long registerFinalizerAddress; + @HotSpotVMValue(expression = "SharedRuntime::exception_handler_for_return_address", get = HotSpotVMValue.Type.ADDRESS) @Stable public long exceptionHandlerForReturnAddressAddress; + @HotSpotVMValue(expression = "SharedRuntime::OSR_migration_end", get = HotSpotVMValue.Type.ADDRESS) @Stable public long osrMigrationEndAddress; + + @HotSpotVMValue(expression = "os::javaTimeMillis", get = HotSpotVMValue.Type.ADDRESS) @Stable public long javaTimeMillisAddress; + @HotSpotVMValue(expression = "os::javaTimeNanos", get = HotSpotVMValue.Type.ADDRESS) @Stable public long javaTimeNanosAddress; + @HotSpotVMValue(expression = "SharedRuntime::dsin", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticSinAddress; + @HotSpotVMValue(expression = "SharedRuntime::dcos", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticCosAddress; + @HotSpotVMValue(expression = "SharedRuntime::dtan", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticTanAddress; + @HotSpotVMValue(expression = "SharedRuntime::dexp", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticExpAddress; + @HotSpotVMValue(expression = "SharedRuntime::dlog", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticLogAddress; + @HotSpotVMValue(expression = "SharedRuntime::dlog10", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticLog10Address; + @HotSpotVMValue(expression = "SharedRuntime::dpow", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticPowAddress; + + @HotSpotVMValue(expression = "(jint) GraalCounterSize") @Stable public int graalCountersSize; + + @HotSpotVMValue(expression = "Deoptimization::fetch_unroll_info", signature = "(JavaThread*)", get = HotSpotVMValue.Type.ADDRESS) @Stable public long deoptimizationFetchUnrollInfo; + @HotSpotVMValue(expression = "Deoptimization::uncommon_trap", get = HotSpotVMValue.Type.ADDRESS) @Stable public long deoptimizationUncommonTrap; + @HotSpotVMValue(expression = "Deoptimization::unpack_frames", signature = "(JavaThread*, int)", get = HotSpotVMValue.Type.ADDRESS) @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::_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 = "GraalEnv::ok") @Stable public int codeInstallResultOk; + @HotSpotVMConstant(name = "GraalEnv::dependencies_failed") @Stable public int codeInstallResultDependenciesFailed; + @HotSpotVMConstant(name = "GraalEnv::dependencies_invalid") @Stable public int codeInstallResultDependenciesInvalid; + @HotSpotVMConstant(name = "GraalEnv::cache_full") @Stable public int codeInstallResultCacheFull; + @HotSpotVMConstant(name = "GraalEnv::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"; + } + + @HotSpotVMConstant(name = "CompilerToVM::KLASS_TAG") @Stable public int compilerToVMKlassTag; + @HotSpotVMConstant(name = "CompilerToVM::SYMBOL_TAG") @Stable public int compilerToVMSymbolTag; + + // 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::INVOKE_INVALID") @Stable public int MARKID_INVOKE_INVALID; + + // Checkstyle: resume + + public 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; + } + } + } + + /** + * Returns the name of the C/C++ symbol that is associated (via HotSpotVMValue annotation) with + * the HotSpotVMConfig object's field containing {@code value}; returns null if no field holds + * the provided address. + * + * @param value value of the field + * @return C/C++ symbol name or null + */ + public String getVMValueCSymbol(long value) { + for (Field f : HotSpotVMConfig.class.getDeclaredFields()) { + if (f.isAnnotationPresent(HotSpotVMValue.class)) { + HotSpotVMValue annotation = f.getAnnotation(HotSpotVMValue.class); + + if (annotation.get() == HotSpotVMValue.Type.ADDRESS) { + try { + if (value == f.getLong(this)) { + return (annotation.expression() + annotation.signature()); + } + } catch (IllegalArgumentException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (IllegalAccessException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + return null; + } + + /** + * Returns the name of the C/C++ symbol that is associated (via HotSpotVMField annotation) with + * the HotSpotVMConfig object's field containing {@code value}; returns null if no field holds + * the provided address. + * + * @param value value of the field + * @return C/C++ symbol name or null + */ + public String getVMFieldCSymbol(long value) { + for (Field f : HotSpotVMConfig.class.getDeclaredFields()) { + if (f.isAnnotationPresent(HotSpotVMField.class)) { + HotSpotVMField annotation = f.getAnnotation(HotSpotVMField.class); + + if (annotation.get() == HotSpotVMField.Type.VALUE) { + try { + if (value == f.getLong(this)) { + return (annotation.name()); + } + } catch (IllegalArgumentException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (IllegalAccessException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + return null; + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfigVerifier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfigVerifier.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,156 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import static java.lang.String.*; + +import java.io.*; +import java.lang.reflect.*; +import java.util.*; + +import com.oracle.graal.compiler.common.*; + +import jdk.internal.org.objectweb.asm.*; +import jdk.internal.org.objectweb.asm.Type; +import sun.misc.*; + +/** + * 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 GraalInternalError(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 InternalError(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 InternalError(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; + } + } +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/Stable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/Stable.java Tue May 19 23:16:07 2015 +0200 @@ -0,0 +1,36 @@ +/* + * 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 com.oracle.graal.hotspot.jvmci; + +import java.lang.annotation.*; + +/** + * This annotation functions as an alias for the sun.invoke.Stable annotation within Graal 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 { +} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/Logger.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/Logger.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/Logger.java Tue May 19 23:16:07 2015 +0200 @@ -27,7 +27,7 @@ import java.util.*; import com.oracle.graal.debug.*; -import com.oracle.graal.hotspot.bridge.*; +import com.oracle.graal.hotspot.jvmci.*; /** * Scoped logging class used to display the call hierarchy of {@link CompilerToVM} calls. diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java Tue May 19 23:16:07 2015 +0200 @@ -36,6 +36,7 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.hotspot.replacements.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,333 +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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.hotspot.meta.HotSpotCompressedNullConstant.*; - -import java.lang.reflect.*; -import java.util.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CodeUtil.DefaultRefMapFormatter; -import com.oracle.graal.api.code.CodeUtil.RefMapFormatter; -import com.oracle.graal.api.code.CompilationResult.Call; -import com.oracle.graal.api.code.CompilationResult.ConstantReference; -import com.oracle.graal.api.code.CompilationResult.DataPatch; -import com.oracle.graal.api.code.CompilationResult.Infopoint; -import com.oracle.graal.api.code.CompilationResult.Mark; -import com.oracle.graal.api.code.DataSection.Data; -import com.oracle.graal.api.code.DataSection.DataBuilder; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.bridge.*; -import com.oracle.graal.printer.*; - -/** - * HotSpot implementation of {@link CodeCacheProvider}. - */ -public class HotSpotCodeCacheProvider implements CodeCacheProvider { - - protected final HotSpotGraalRuntimeProvider runtime; - public final HotSpotVMConfig config; - protected final TargetDescription target; - protected final RegisterConfig regConfig; - - public HotSpotCodeCacheProvider(HotSpotGraalRuntimeProvider runtime, HotSpotVMConfig config, TargetDescription target, RegisterConfig regConfig) { - this.runtime = runtime; - this.config = config; - this.target = target; - this.regConfig = regConfig; - } - - @Override - public String disassemble(CompilationResult compResult, InstalledCode installedCode) { - byte[] code = installedCode == null ? Arrays.copyOf(compResult.getTargetCode(), compResult.getTargetCodeSize()) : installedCode.getCode(); - if (code == null) { - // Method was deoptimized/invalidated - return ""; - } - long start = installedCode == null ? 0L : installedCode.getStart(); - HexCodeFile hcf = new HexCodeFile(code, start, target.arch.getName(), target.wordSize * 8); - if (compResult != null) { - HexCodeFile.addAnnotations(hcf, compResult.getAnnotations()); - addExceptionHandlersComment(compResult, hcf); - Register fp = regConfig.getFrameRegister(); - RefMapFormatter slotFormatter = new DefaultRefMapFormatter(target.arch, target.wordSize, fp, 0); - for (Infopoint infopoint : compResult.getInfopoints()) { - if (infopoint instanceof Call) { - Call call = (Call) infopoint; - if (call.debugInfo != null) { - hcf.addComment(call.pcOffset + call.size, CodeUtil.append(new StringBuilder(100), call.debugInfo, slotFormatter).toString()); - } - addOperandComment(hcf, call.pcOffset, "{" + getTargetName(call) + "}"); - } else { - if (infopoint.debugInfo != null) { - hcf.addComment(infopoint.pcOffset, CodeUtil.append(new StringBuilder(100), infopoint.debugInfo, slotFormatter).toString()); - } - addOperandComment(hcf, infopoint.pcOffset, "{infopoint: " + infopoint.reason + "}"); - } - } - for (DataPatch site : compResult.getDataPatches()) { - hcf.addOperandComment(site.pcOffset, "{" + site.reference.toString() + "}"); - } - for (Mark mark : compResult.getMarks()) { - hcf.addComment(mark.pcOffset, getMarkIdName((int) mark.id)); - } - } - String hcfEmbeddedString = hcf.toEmbeddedString(); - return HexCodeFileDisTool.tryDisassemble(hcfEmbeddedString); - } - - /** - * Interface to the tool for disassembling an {@link HexCodeFile#toEmbeddedString() embedded} - * {@link HexCodeFile}. - */ - static class HexCodeFileDisTool { - static final Method processMethod; - static { - Method toolMethod = null; - try { - Class toolClass = Class.forName("com.oracle.max.hcfdis.HexCodeFileDis", true, ClassLoader.getSystemClassLoader()); - toolMethod = toolClass.getDeclaredMethod("processEmbeddedString", String.class); - } catch (Exception e) { - // Tool not available on the class path - } - processMethod = toolMethod; - } - - public static String tryDisassemble(String hcfEmbeddedString) { - if (processMethod != null) { - try { - return (String) processMethod.invoke(null, hcfEmbeddedString); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - // If the tool is available, for now let's be noisy when it fails - throw new GraalInternalError(e); - } - } - return hcfEmbeddedString; - } - } - - private String getMarkIdName(int markId) { - 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 String.valueOf(markId); - } - - /** - * Decodes a call target to a mnemonic if possible. - */ - private 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 String.valueOf(call.target); - } - - private static void addExceptionHandlersComment(CompilationResult compResult, HexCodeFile hcf) { - if (!compResult.getExceptionHandlers().isEmpty()) { - String nl = HexCodeFile.NEW_LINE; - StringBuilder buf = new StringBuilder("------ Exception Handlers ------").append(nl); - for (CompilationResult.ExceptionHandler e : compResult.getExceptionHandlers()) { - buf.append(" ").append(e.pcOffset).append(" -> ").append(e.handlerPos).append(nl); - hcf.addComment(e.pcOffset, "[exception -> " + e.handlerPos + "]"); - hcf.addComment(e.handlerPos, "[exception handler for " + e.pcOffset + "]"); - } - hcf.addComment(0, buf.toString()); - } - } - - private static void addOperandComment(HexCodeFile hcf, int pos, String comment) { - String oldValue = hcf.addOperandComment(pos, comment); - assert oldValue == null : "multiple comments for operand of instruction at " + pos + ": " + comment + ", " + oldValue; - } - - @Override - public RegisterConfig getRegisterConfig() { - return regConfig; - } - - @Override - public int getMinimumOutgoingSize() { - return runtime.getConfig().runtimeCallStackSize; - } - - public InstalledCode logOrDump(InstalledCode installedCode, CompilationResult compResult) { - if (Debug.isDumpEnabled()) { - Debug.dump(new Object[]{compResult, installedCode}, "After code installation"); - } - if (Debug.isLogEnabled()) { - Debug.log("%s", disassemble(installedCode)); - } - return installedCode; - } - - public InstalledCode installMethod(HotSpotResolvedJavaMethod method, CompilationResult compResult, long graalEnv, boolean isDefault) { - if (compResult.getId() == -1) { - compResult.setId(method.allocateCompileId(compResult.getEntryBCI())); - } - HotSpotInstalledCode installedCode = new HotSpotNmethod(method, compResult.getName(), isDefault); - runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(method, compResult, graalEnv), installedCode, method.getSpeculationLog()); - return logOrDump(installedCode, compResult); - } - - @Override - public InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult, SpeculationLog log, InstalledCode predefinedInstalledCode) { - HotSpotResolvedJavaMethod hotspotMethod = (HotSpotResolvedJavaMethod) method; - if (compResult.getId() == -1) { - compResult.setId(hotspotMethod.allocateCompileId(compResult.getEntryBCI())); - } - InstalledCode installedCode = predefinedInstalledCode; - if (installedCode == null) { - HotSpotInstalledCode code = new HotSpotNmethod(hotspotMethod, compResult.getName(), false); - installedCode = code; - } - HotSpotCompiledNmethod compiledCode = new HotSpotCompiledNmethod(hotspotMethod, compResult); - int result = runtime.getCompilerToVM().installCode(compiledCode, installedCode, log); - if (result != config.codeInstallResultOk) { - String msg = compiledCode.getInstallationFailureMessage(); - String resultDesc = config.getCodeInstallResultDescription(result); - 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); - } - return logOrDump(installedCode, compResult); - } - - @Override - public InstalledCode setDefaultMethod(ResolvedJavaMethod method, CompilationResult compResult) { - HotSpotResolvedJavaMethod hotspotMethod = (HotSpotResolvedJavaMethod) method; - return installMethod(hotspotMethod, compResult, 0L, true); - } - - public HotSpotNmethod addExternalMethod(ResolvedJavaMethod method, CompilationResult compResult) { - HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) method; - if (compResult.getId() == -1) { - compResult.setId(javaMethod.allocateCompileId(compResult.getEntryBCI())); - } - HotSpotNmethod code = new HotSpotNmethod(javaMethod, compResult.getName(), false, true); - HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(javaMethod, compResult); - CompilerToVM vm = runtime.getCompilerToVM(); - int result = vm.installCode(compiled, code, null); - if (result != runtime.getConfig().codeInstallResultOk) { - return null; - } - return code; - } - - public boolean needsDataPatch(JavaConstant constant) { - return constant instanceof HotSpotMetaspaceConstant; - } - - public Data createDataItem(Constant constant) { - int size; - DataBuilder builder; - if (constant instanceof VMConstant) { - VMConstant vmConstant = (VMConstant) constant; - boolean compressed; - long raw; - if (constant instanceof HotSpotObjectConstant) { - HotSpotObjectConstant c = (HotSpotObjectConstant) vmConstant; - compressed = c.isCompressed(); - raw = 0xDEADDEADDEADDEADL; - } else if (constant instanceof HotSpotMetaspaceConstant) { - HotSpotMetaspaceConstant meta = (HotSpotMetaspaceConstant) constant; - compressed = meta.isCompressed(); - raw = meta.rawValue(); - } else { - throw GraalInternalError.shouldNotReachHere(); - } - - size = target.getSizeInBytes(compressed ? Kind.Int : target.wordKind); - if (size == 4) { - builder = (buffer, patch) -> { - patch.accept(new DataPatch(buffer.position(), new ConstantReference(vmConstant))); - buffer.putInt((int) raw); - }; - } else { - assert size == 8; - builder = (buffer, patch) -> { - patch.accept(new DataPatch(buffer.position(), new ConstantReference(vmConstant))); - buffer.putLong(raw); - }; - } - } else if (JavaConstant.isNull(constant)) { - boolean compressed = COMPRESSED_NULL.equals(constant); - size = target.getSizeInBytes(compressed ? Kind.Int : target.wordKind); - builder = DataBuilder.zero(size); - } else if (constant instanceof SerializableConstant) { - SerializableConstant s = (SerializableConstant) constant; - size = s.getSerializedSize(); - builder = DataBuilder.serializable(s); - } else { - throw GraalInternalError.shouldNotReachHere(); - } - - return new Data(size, size, builder); - } - - @Override - public TargetDescription getTarget() { - return target; - } - - public String disassemble(InstalledCode code) { - if (code.isValid()) { - long codeBlob = code.getAddress(); - return runtime.getCompilerToVM().disassembleCodeBlob(codeBlob); - } - return null; - } - - public SpeculationLog createSpeculationLog() { - return new HotSpotSpeculationLog(); - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCompressedNullConstant.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCompressedNullConstant.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +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 com.oracle.graal.hotspot.meta; - -import com.oracle.graal.api.meta.*; - -/** - * The compressed representation of the {@link JavaConstant#NULL_POINTER null constant}. - */ -public final class HotSpotCompressedNullConstant extends AbstractValue implements JavaConstant, HotSpotConstant { - - public static final JavaConstant COMPRESSED_NULL = new HotSpotCompressedNullConstant(); - - private HotSpotCompressedNullConstant() { - super(LIRKind.reference(Kind.Int)); - } - - @Override - public boolean isNull() { - return true; - } - - @Override - public boolean isCompressed() { - 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 "null"; - } - - @Override - public int hashCode() { - return System.identityHashCode(this); - } - - @Override - public boolean equals(Object o) { - return o instanceof HotSpotCompressedNullConstant; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstant.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstant.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +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 com.oracle.graal.hotspot.meta; - -import com.oracle.graal.api.meta.*; - -/** - * Marker interface for hotspot specific constants. - */ -public interface HotSpotConstant extends Constant { - - boolean isCompressed(); -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,618 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.compiler.common.UnsafeAccess.*; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; - -import java.lang.invoke.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.bytecode.*; -import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.*; - -/** - * Implementation of {@link ConstantPool} for HotSpot. - */ -public class HotSpotConstantPool implements ConstantPool, HotSpotProxified { - - /** - * 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; - - private JVM_CONSTANT(int tag) { - this.tag = tag; - } - - private static HotSpotVMConfig config() { - return runtime().getConfig(); - } - - /** - * 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 GraalInternalError.shouldNotReachHere("unknown JVM_CONSTANT tag " + tag); - } - } - - public static JVM_CONSTANT getEnum(int tag) { - return TagValueMap.get(tag); - } - } - - private static class LookupTypeCacheElement { - int lastCpi = Integer.MIN_VALUE; - JavaType javaType; - - public LookupTypeCacheElement(int lastCpi, JavaType javaType) { - super(); - this.lastCpi = lastCpi; - this.javaType = javaType; - } - } - - /** - * Reference to the C++ ConstantPool object. - */ - private final long metaspaceConstantPool; - private final Object[] cache; - private volatile LookupTypeCacheElement lastLookupType; - - public HotSpotConstantPool(long metaspaceConstantPool) { - this.metaspaceConstantPool = metaspaceConstantPool; - cache = new Object[length()]; - } - - /** - * Gets the holder for this constant pool as {@link HotSpotResolvedObjectTypeImpl}. - * - * @return holder for this constant pool - */ - private HotSpotResolvedObjectType getHolder() { - final long metaspaceKlass = unsafe.getAddress(metaspaceConstantPool + runtime().getConfig().constantPoolHolderOffset); - return HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass); - } - - /** - * 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 toConstantPoolIndex(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 " + Bytecodes.nameOf(opcode); - index = rawIndex + runtime().getConfig().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 - runtime().getConfig().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; - } - - /** - * 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 = runtime().getConfig(); - final long metaspaceConstantPoolTags = unsafe.getAddress(metaspaceConstantPool + 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(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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 runtime().getCompilerToVM().lookupNameAndTypeRefIndexInPool(metaspaceConstantPool, index); - } - - /** - * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index - * {@code index}. - * - * @param index constant pool index - * @return name as {@link String} - */ - private String getNameRefAt(int index) { - return runtime().getCompilerToVM().lookupNameRefInPool(metaspaceConstantPool, index); - } - - /** - * 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 at index - * {@code index}. - * - * @param index constant pool index - * @return signature as {@link String} - */ - private String getSignatureRefAt(int index) { - return runtime().getCompilerToVM().lookupSignatureRefInPool(metaspaceConstantPool, index); - } - - /** - * 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 runtime().getCompilerToVM().lookupKlassRefIndexInPool(metaspaceConstantPool, 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) { - assert getTagAt(index) == JVM_CONSTANT.Fieldref || getTagAt(index) == JVM_CONSTANT.MethodRef || getTagAt(index) == JVM_CONSTANT.InterfaceMethodref; - final int refIndex = unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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) { - assert getTagAt(index) == tag : "constant pool tag at index " + index + " is " + getTagAt(index) + " but expected " + tag; - } - - @Override - public int length() { - return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().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: - Object string = runtime().getCompilerToVM().resolvePossiblyCachedConstantInPool(metaspaceConstantPool, cpi); - return HotSpotObjectConstantImpl.forObject(string); - case MethodHandle: - case MethodHandleInError: - case MethodType: - case MethodTypeInError: - Object obj = runtime().getCompilerToVM().resolveConstantInPool(metaspaceConstantPool, cpi); - return HotSpotObjectConstantImpl.forObject(obj); - default: - throw GraalInternalError.shouldNotReachHere("unknown constant pool tag " + tag); - } - } - - @Override - public String lookupUtf8(int cpi) { - assertTag(cpi, JVM_CONSTANT.Utf8); - return runtime().getCompilerToVM().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 = toConstantPoolIndex(cpi, opcode); - Object result = runtime().getCompilerToVM().lookupAppendixInPool(metaspaceConstantPool, index); - if (result == null) { - return null; - } else { - return HotSpotObjectConstantImpl.forObject(result); - } - } - - /** - * Gets a {@link JavaType} corresponding a given metaspace Klass or a metaspace Symbol depending - * on the {@link HotSpotVMConfig#compilerToVMKlassTag tag}. - * - * @param metaspacePointer either a metaspace Klass or a metaspace Symbol - */ - private static JavaType getJavaType(final long metaspacePointer) { - HotSpotGraalRuntimeProvider runtime = runtime(); - HotSpotVMConfig config = runtime.getConfig(); - if ((metaspacePointer & config.compilerToVMSymbolTag) != 0) { - final long metaspaceSymbol = metaspacePointer & ~config.compilerToVMSymbolTag; - String name = runtime.getCompilerToVM().getSymbol(metaspaceSymbol); - return HotSpotUnresolvedJavaType.create(runtime(), "L" + name + ";"); - } else { - assert (metaspacePointer & config.compilerToVMKlassTag) == 0; - return HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspacePointer); - } - } - - @Override - public JavaMethod lookupMethod(int cpi, int opcode) { - if (opcode != Bytecodes.INVOKEDYNAMIC) { - Object result = cache[cpi]; - if (result != null) { - return (ResolvedJavaMethod) result; - } - } - final int index = toConstantPoolIndex(cpi, opcode); - final long metaspaceMethod = runtime().getCompilerToVM().lookupMethodInPool(metaspaceConstantPool, index, (byte) opcode); - if (metaspaceMethod != 0L) { - HotSpotResolvedJavaMethod result = HotSpotResolvedJavaMethodImpl.fromMetaspace(metaspaceMethod); - if (opcode != Bytecodes.INVOKEDYNAMIC) { - cache[cpi] = result; - } - return result; - } else { - // Get the method's name and signature. - String name = getNameRefAt(index); - HotSpotSignature signature = new HotSpotSignature(runtime(), getSignatureRefAt(index)); - if (opcode == Bytecodes.INVOKEDYNAMIC) { - HotSpotResolvedObjectType holder = HotSpotResolvedObjectTypeImpl.fromObjectClass(MethodHandle.class); - return new HotSpotMethodUnresolved(name, signature, holder); - } else { - final int klassIndex = getKlassRefIndexAt(index); - final long metaspacePointer = runtime().getCompilerToVM().lookupKlassInPool(metaspaceConstantPool, klassIndex); - JavaType holder = getJavaType(metaspacePointer); - 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 long metaspacePointer = runtime().getCompilerToVM().lookupKlassInPool(metaspaceConstantPool, cpi); - JavaType result = getJavaType(metaspacePointer); - if (result instanceof ResolvedJavaType) { - this.lastLookupType = new LookupTypeCacheElement(cpi, result); - } - return result; - } - } - - @Override - public JavaField lookupField(int cpi, int opcode) { - Object resolvedJavaField = cache[cpi]; - if (resolvedJavaField != null) { - return (ResolvedJavaField) resolvedJavaField; - } - final int index = toConstantPoolIndex(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]; - long metaspaceKlass; - try { - metaspaceKlass = runtime().getCompilerToVM().resolveField(metaspaceConstantPool, 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); - } - HotSpotResolvedObjectTypeImpl resolvedHolder = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass); - final int flags = (int) info[0]; - final long offset = info[1]; - HotSpotResolvedJavaField result = resolvedHolder.createField(name, type, offset, flags); - if (type instanceof ResolvedJavaType) { - cache[cpi] = result; - } - return result; - } else { - return new HotSpotUnresolvedField(holder, name, type); - } - } - - @Override - 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) + runtime().getConfig().constantPoolCpCacheIndexTag; - index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(metaspaceConstantPool, index); - break; - default: - index = toConstantPoolIndex(cpi, opcode); - index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(metaspaceConstantPool, index); - } - - 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 Fieldref: - case MethodRef: - case InterfaceMethodref: - index = getUncachedKlassRefIndexAt(index); - tag = getTagAt(index); - assert tag == JVM_CONSTANT.Class || tag == JVM_CONSTANT.UnresolvedClass || tag == JVM_CONSTANT.UnresolvedClassInError : tag; - // fall through - case Class: - case UnresolvedClass: - case UnresolvedClassInError: - final long metaspaceKlass = runtime().getCompilerToVM().constantPoolKlassAt(metaspaceConstantPool, index); - HotSpotResolvedObjectTypeImpl type = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass); - Class klass = type.mirror(); - if (!klass.isPrimitive() && !klass.isArray()) { - unsafe.ensureClassInitialized(klass); - } - break; - case InvokeDynamic: - if (isInvokedynamicIndex(cpi)) { - runtime().getCompilerToVM().resolveInvokeDynamic(metaspaceConstantPool, cpi); - } - break; - default: - // nothing - break; - } - } - - @Override - public String toString() { - HotSpotResolvedObjectType holder = getHolder(); - return "HotSpotConstantPool<" + holder.toJavaName() + ">"; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantReflectionProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantReflectionProvider.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,442 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.compiler.common.GraalOptions.*; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; -import static com.oracle.graal.hotspot.stubs.SnippetStub.*; - -import java.lang.reflect.*; -import java.util.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.options.*; -import com.oracle.graal.replacements.*; -import com.oracle.graal.replacements.SnippetTemplate.Arguments; - -/** - * HotSpot implementation of {@link ConstantReflectionProvider}. - */ -public class HotSpotConstantReflectionProvider implements ConstantReflectionProvider, HotSpotProxified { - private static final String SystemClassName = "Ljava/lang/System;"; - - protected final HotSpotGraalRuntimeProvider runtime; - protected final HotSpotMethodHandleAccessProvider methodHandleAccess; - protected final HotSpotMemoryAccessProviderImpl memoryAccess; - - public HotSpotConstantReflectionProvider(HotSpotGraalRuntimeProvider 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 x.equals(y); - } - } - - @Override - public Integer readArrayLength(JavaConstant array) { - if (array.getKind() != Kind.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 -1 if the offset isn't within the array or the computed index - */ - private int indexForOffset(JavaConstant array, long offset) { - if (array.getKind() != Kind.Object || array.isNull()) { - return -1; - } - Class componentType = ((HotSpotObjectConstantImpl) array).object().getClass().getComponentType(); - Kind kind = runtime.getHostProviders().getMetaAccess().lookupJavaType(componentType).getKind(); - int arraybase = runtime.getArrayBaseOffset(kind); - int scale = runtime.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.getKind() != Kind.Object || array.isNull()) { - return null; - } - Object a = ((HotSpotObjectConstantImpl) array).object(); - - if (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.getKind()) { - 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.getKind()); - } - } - - @Override - public JavaConstant boxPrimitive(JavaConstant source) { - if (!source.getKind().isPrimitive() || !isBoxCached(source)) { - return null; - } - return HotSpotObjectConstantImpl.forObject(source.asBoxedPrimitive()); - } - - @Override - public JavaConstant unboxPrimitive(JavaConstant source) { - if (!source.getKind().isObject()) { - return null; - } - if (source.isNull()) { - return null; - } - return JavaConstant.forBoxedPrimitive(((HotSpotObjectConstantImpl) source).object()); - } - - public JavaConstant forString(String 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.getHostProviders().getMetaAccess().lookupJavaType((Class) obj); - } - } - if (constant instanceof HotSpotMetaspaceConstant) { - Object obj = HotSpotMetaspaceConstantImpl.getMetaspaceObject(constant); - if (obj instanceof HotSpotResolvedObjectTypeImpl) { - return (ResolvedJavaType) obj; - } - } - return null; - } - - /** - * {@inheritDoc} - *

- * The {@code value} field in {@link OptionValue} is considered constant if the type of - * {@code receiver} is (assignable to) {@link StableOptionValue}. - */ - public JavaConstant readConstantFieldValue(JavaField field, JavaConstant receiver) { - assert !ImmutableCode.getValue() || isCalledForSnippets() || SnippetGraphUnderConstruction.get() != null || HotSpotLoadFieldPlugin.FieldReadEnabledInImmutableCode.get() == Boolean.TRUE : receiver; - HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; - - if (hotspotField.isStatic()) { - if (hotspotField.isFinal() || hotspotField.isStable()) { - ResolvedJavaType holder = hotspotField.getDeclaringClass(); - if (holder.isInitialized() && !holder.getName().equals(SystemClassName) && isEmbeddable(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 (!value.isDefaultForKind() || assumeNonStaticFinalDefaultFieldsAsFinal(object.getClass())) { - return value; - } - } - } else if (hotspotField.isStable()) { - if (hotspotField.isInObject(object)) { - JavaConstant value = readFieldValue(field, receiver); - if (assumeDefaultStableFieldsAsFinal(object.getClass()) || !value.isDefaultForKind()) { - return value; - } - } - } else { - Class clazz = object.getClass(); - if (StableOptionValue.class.isAssignableFrom(clazz)) { - if (hotspotField.isInObject(object) && hotspotField.getName().equals("value")) { - StableOptionValue option = (StableOptionValue) object; - return HotSpotObjectConstantImpl.forObject(option.getValue()); - } - } - } - } - } - return null; - } - - public JavaConstant readFieldValue(JavaField field, JavaConstant receiver) { - HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; - if (!hotspotField.isStable()) { - return readNonStableFieldValue(field, receiver); - } else { - return readStableFieldValue(field, receiver, false); - } - } - - private JavaConstant readNonStableFieldValue(JavaField field, JavaConstant receiver) { - HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; - if (hotspotField.isStatic()) { - HotSpotResolvedJavaType holder = (HotSpotResolvedJavaType) hotspotField.getDeclaringClass(); - if (holder.isInitialized()) { - return memoryAccess.readUnsafeConstant(hotspotField.getKind(), HotSpotObjectConstantImpl.forObject(holder.mirror()), hotspotField.offset()); - } - } else { - if (receiver.isNonNull() && hotspotField.isInObject(((HotSpotObjectConstantImpl) receiver).object())) { - return memoryAccess.readUnsafeConstant(hotspotField.getKind(), receiver, hotspotField.offset()); - } - } - return null; - } - - public JavaConstant readStableFieldValue(JavaField field, JavaConstant receiver, boolean isDefaultStable) { - JavaConstant fieldValue = readNonStableFieldValue(field, receiver); - if (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; - } - - /** - * Compares two {@link StackTraceElement}s for equality, ignoring differences in - * {@linkplain StackTraceElement#getLineNumber() line number}. - */ - private static boolean equalsIgnoringLine(StackTraceElement left, StackTraceElement right) { - return left.getClassName().equals(right.getClassName()) && left.getMethodName().equals(right.getMethodName()) && left.getFileName().equals(right.getFileName()); - } - - /** - * If the compiler is configured for AOT mode, - * {@link #readConstantFieldValue(JavaField, JavaConstant)} should be only called for snippets - * or replacements. - */ - private static boolean isCalledForSnippets() { - MetaAccessProvider metaAccess = runtime().getHostProviders().getMetaAccess(); - ResolvedJavaMethod makeGraphMethod = null; - ResolvedJavaMethod initMethod = null; - try { - Class rjm = ResolvedJavaMethod.class; - makeGraphMethod = metaAccess.lookupJavaMethod(ReplacementsImpl.class.getDeclaredMethod("makeGraph", rjm, Object[].class, rjm)); - initMethod = metaAccess.lookupJavaMethod(SnippetTemplate.AbstractTemplates.class.getDeclaredMethod("template", Arguments.class)); - } catch (NoSuchMethodException | SecurityException e) { - throw new GraalInternalError(e); - } - StackTraceElement makeGraphSTE = makeGraphMethod.asStackTraceElement(0); - StackTraceElement initSTE = initMethod.asStackTraceElement(0); - - StackTraceElement[] stackTrace = new Exception().getStackTrace(); - for (StackTraceElement element : stackTrace) { - // Ignoring line numbers should not weaken this check too much while at - // the same time making it more robust against source code changes - if (equalsIgnoringLine(makeGraphSTE, element) || equalsIgnoringLine(initSTE, element)) { - return true; - } - } - return false; - } - - private static boolean assumeNonStaticFinalDefaultFieldsAsFinal(Class clazz) { - if (TrustFinalDefaultFields.getValue()) { - return true; - } - return clazz == SnippetCounter.class || clazz == NodeClass.class; - } - - /** - * Usually {@link Stable} fields are not considered constant if the value is the - * {@link JavaConstant#isDefaultForKind default value}. For some special classes we want to - * override this behavior. - */ - private static boolean assumeDefaultStableFieldsAsFinal(Class clazz) { - // HotSpotVMConfig has a lot of zero-value fields which we know are stable and want to be - // considered as constants. - if (clazz == HotSpotVMConfig.class) { - return true; - } - return false; - } - - /** - * in AOT mode, some fields should never be embedded even for snippets/replacements. - */ - private static boolean isEmbeddable(HotSpotResolvedJavaField field) { - return Embeddable.test(field); - } - - /** - * Separate out the static initialization to eliminate cycles between clinit and other locks - * that could lead to deadlock. Static code that doesn't call back into type or field machinery - * is probably ok but anything else should be made lazy. - */ - static class Embeddable { - - /** - * @return Return true if it's ok to embed the value of {@code field}. - */ - public static boolean test(HotSpotResolvedJavaField field) { - return !ImmutableCode.getValue() || !fields.contains(field); - } - - private static final List fields = new ArrayList<>(); - static { - try { - MetaAccessProvider metaAccess = runtime().getHostProviders().getMetaAccess(); - fields.add(metaAccess.lookupJavaField(Boolean.class.getDeclaredField("TRUE"))); - fields.add(metaAccess.lookupJavaField(Boolean.class.getDeclaredField("FALSE"))); - - Class characterCacheClass = Character.class.getDeclaredClasses()[0]; - assert "java.lang.Character$CharacterCache".equals(characterCacheClass.getName()); - fields.add(metaAccess.lookupJavaField(characterCacheClass.getDeclaredField("cache"))); - - Class byteCacheClass = Byte.class.getDeclaredClasses()[0]; - assert "java.lang.Byte$ByteCache".equals(byteCacheClass.getName()); - fields.add(metaAccess.lookupJavaField(byteCacheClass.getDeclaredField("cache"))); - - Class shortCacheClass = Short.class.getDeclaredClasses()[0]; - assert "java.lang.Short$ShortCache".equals(shortCacheClass.getName()); - fields.add(metaAccess.lookupJavaField(shortCacheClass.getDeclaredField("cache"))); - - Class integerCacheClass = Integer.class.getDeclaredClasses()[0]; - assert "java.lang.Integer$IntegerCache".equals(integerCacheClass.getName()); - fields.add(metaAccess.lookupJavaField(integerCacheClass.getDeclaredField("cache"))); - - Class longCacheClass = Long.class.getDeclaredClasses()[0]; - assert "java.lang.Long$LongCache".equals(longCacheClass.getName()); - fields.add(metaAccess.lookupJavaField(longCacheClass.getDeclaredField("cache"))); - - fields.add(metaAccess.lookupJavaField(Throwable.class.getDeclaredField("UNASSIGNED_STACK"))); - fields.add(metaAccess.lookupJavaField(Throwable.class.getDeclaredField("SUPPRESSED_SENTINEL"))); - } catch (SecurityException | NoSuchFieldException e) { - throw new GraalInternalError(e); - } - } - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotDisassemblerProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotDisassemblerProvider.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotDisassemblerProvider.java Tue May 19 23:16:07 2015 +0200 @@ -24,6 +24,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; /** * HotSpot implementation of {@link DisassemblerProvider}. diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Tue May 19 23:16:07 2015 +0200 @@ -37,7 +37,7 @@ import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.graphbuilderconf.MethodIdMap.Receiver; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.replacements.*; import com.oracle.graal.hotspot.replacements.arraycopy.*; @@ -86,7 +86,7 @@ registerThreadPlugins(invocationPlugins, metaAccess, wordTypes, config); registerCallSitePlugins(invocationPlugins); registerReflectionPlugins(invocationPlugins); - registerStableOptionPlugins(invocationPlugins); + registerStableOptionPlugins(invocationPlugins, snippetReflection); registerAESPlugins(invocationPlugins, config); registerCRC32Plugins(invocationPlugins, config); StandardGraphBuilderPlugins.registerInvocationPlugins(metaAccess, invocationPlugins, !config.useHeapProfiler); @@ -216,13 +216,12 @@ }); } - private static void registerStableOptionPlugins(InvocationPlugins plugins) { + private static void registerStableOptionPlugins(InvocationPlugins plugins, SnippetReflectionProvider snippetReflection) { Registration r = new Registration(plugins, StableOptionValue.class); r.register1("getValue", Receiver.class, new InvocationPlugin() { public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { if (receiver.isConstant()) { - Object object = ((HotSpotObjectConstantImpl) receiver.get().asConstant()).object(); - StableOptionValue option = (StableOptionValue) object; + StableOptionValue option = snippetReflection.asObject(StableOptionValue.class, (JavaConstant) receiver.get().asConstant()); b.addPush(Kind.Object, ConstantNode.forConstant(HotSpotObjectConstantImpl.forObject(option.getValue()), b.getMetaAccess())); return true; } diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java Tue May 19 23:16:07 2015 +0200 @@ -51,6 +51,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.word.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInstalledCode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInstalledCode.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.compiler.common.UnsafeAccess.*; -import sun.misc.*; - -import com.oracle.graal.api.code.*; - -import edu.umd.cs.findbugs.annotations.*; - -/** - * 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; - } - - /** - * @return a copy of this code blob if it is {@linkplain #isValid() valid}, null otherwise. - */ - public byte[] getBlob() { - if (!isValid()) { - return null; - } - byte[] blob = new byte[size]; - unsafe.copyMemory(null, getAddress(), blob, Unsafe.ARRAY_BYTE_BASE_OFFSET, size); - return blob; - } - - @Override - public abstract String toString(); - - @Override - public long getStart() { - return codeStart; - } - - @Override - 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; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInvocationPlugins.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInvocationPlugins.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInvocationPlugins.java Tue May 19 23:16:07 2015 +0200 @@ -27,7 +27,7 @@ import com.oracle.graal.graph.*; import com.oracle.graal.graph.iterators.*; import com.oracle.graal.graphbuilderconf.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.phases.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.type.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotJavaType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotJavaType.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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 com.oracle.graal.hotspot.meta; - -import com.oracle.graal.api.meta.*; - -/** - * 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; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoadFieldPlugin.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoadFieldPlugin.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoadFieldPlugin.java Tue May 19 23:16:07 2015 +0200 @@ -37,7 +37,7 @@ this.constantReflection = constantReflection; } - static final ThreadLocal FieldReadEnabledInImmutableCode = new ThreadLocal<>(); + public static final ThreadLocal FieldReadEnabledInImmutableCode = new ThreadLocal<>(); public boolean apply(GraphBuilderContext b, ValueNode receiver, ResolvedJavaField field) { if (!ImmutableCode.getValue() || b.parsingIntrinsic()) { diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java Tue May 19 23:16:07 2015 +0200 @@ -25,7 +25,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMemoryAccessProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMemoryAccessProvider.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +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 com.oracle.graal.hotspot.meta; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; - -/** - * 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); -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMemoryAccessProviderImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMemoryAccessProviderImpl.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.compiler.common.UnsafeAccess.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; - -/** - * HotSpot implementation of {@link MemoryAccessProvider}. - */ -public class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, HotSpotProxified { - - protected final HotSpotGraalRuntimeProvider runtime; - - public HotSpotMemoryAccessProviderImpl(HotSpotGraalRuntimeProvider 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) { - Object 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 if (displacement == runtime.getConfig().arrayKlassComponentMirrorOffset) { - // ArrayKlass::_component_mirror is only valid for all ArrayKlass* values - return ((HotSpotResolvedObjectTypeImpl) metaspaceObject).mirror().isArray(); - } - } else { - throw GraalInternalError.shouldNotReachHere(); - } - } - return false; - } - - private static long asRawPointer(Constant base) { - if (base instanceof HotSpotMetaspaceConstant) { - return ((HotSpotMetaspaceConstant) base).rawValue(); - } else if (base instanceof PrimitiveConstant) { - PrimitiveConstant prim = (PrimitiveConstant) base; - if (prim.getKind().isNumericInteger()) { - return prim.asLong(); - } - } - throw GraalInternalError.shouldNotReachHere(); - } - - private static long readRawValue(Constant baseConstant, long displacement, int bits) { - Object base = asObject(baseConstant); - if (base != null) { - switch (bits) { - case 8: - return unsafe.getByte(base, displacement); - case 16: - return unsafe.getShort(base, displacement); - case 32: - return unsafe.getInt(base, displacement); - case 64: - return unsafe.getLong(base, displacement); - default: - throw GraalInternalError.shouldNotReachHere(); - } - } else { - long pointer = asRawPointer(baseConstant); - switch (bits) { - case 8: - return unsafe.getByte(pointer + displacement); - case 16: - return unsafe.getShort(pointer + displacement); - case 32: - return unsafe.getInt(pointer + displacement); - case 64: - return unsafe.getLong(pointer + displacement); - default: - throw GraalInternalError.shouldNotReachHere(); - } - } - } - - 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) { - Object metaspaceObject = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base); - if (metaspaceObject instanceof HotSpotResolvedObjectTypeImpl) { - if (displacement == runtime.getConfig().classMirrorOffset) { - assert expected == ((HotSpotResolvedObjectTypeImpl) metaspaceObject).mirror(); - } else if (displacement == runtime.getConfig().arrayKlassComponentMirrorOffset) { - assert expected == ((HotSpotResolvedObjectTypeImpl) metaspaceObject).mirror().getComponentType(); - } - } - } - 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(Kind kind, JavaConstant baseConstant, long displacement) { - if (kind == Kind.Object) { - Object o = readRawObject(baseConstant, displacement, runtime.getConfig().useCompressedOops); - return HotSpotObjectConstantImpl.forObject(o); - } else { - return readPrimitiveConstant(kind, baseConstant, displacement, kind.getByteCount() * 8); - } - } - - @Override - public JavaConstant readPrimitiveConstant(Kind 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 GraalInternalError.shouldNotReachHere("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); - } - - @Override - public Constant readKlassPointerConstant(Constant base, long displacement) { - long klass = readRawValue(base, displacement, runtime.getTarget().wordSize * 8); - if (klass == 0) { - return JavaConstant.NULL_POINTER; - } - HotSpotResolvedObjectType metaKlass = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(klass); - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(runtime.getTarget().wordKind, klass, metaKlass, false); - } - - @Override - public Constant readNarrowKlassPointerConstant(Constant base, long displacement, CompressEncoding encoding) { - int compressed = (int) readRawValue(base, displacement, 32); - long klass = encoding.uncompress(compressed); - if (klass == 0) { - return HotSpotCompressedNullConstant.COMPRESSED_NULL; - } - HotSpotResolvedObjectType metaKlass = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(klass); - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(Kind.Int, compressed, metaKlass, true); - } - - @Override - public Constant readMethodPointerConstant(Constant base, long displacement) { - long method = readRawValue(base, displacement, runtime.getTarget().wordSize * 8); - HotSpotResolvedJavaMethod metaMethod = HotSpotResolvedJavaMethodImpl.fromMetaspace(method); - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(runtime.getTarget().wordKind, method, metaMethod, false); - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaAccessProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaAccessProvider.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,310 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.compiler.common.UnsafeAccess.*; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; -import static com.oracle.graal.hotspot.meta.HotSpotResolvedJavaType.*; -import static com.oracle.graal.hotspot.meta.HotSpotResolvedObjectTypeImpl.*; - -import java.lang.reflect.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.replacements.*; - -/** - * HotSpot implementation of {@link MetaAccessProvider}. - */ -public class HotSpotMetaAccessProvider implements MetaAccessProvider, HotSpotProxified { - - protected final HotSpotGraalRuntimeProvider runtime; - - public HotSpotMetaAccessProvider(HotSpotGraalRuntimeProvider 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); - } - - /** - * {@link Field} object of {@link Method#slot}. - */ - @SuppressWarnings("javadoc") private Field reflectionMethodSlot = getReflectionSlotField(Method.class); - - /** - * {@link Field} object of {@link Constructor#slot}. - */ - @SuppressWarnings("javadoc") 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 GraalInternalError(e); - } - } - - public ResolvedJavaMethod lookupJavaMethod(Executable reflectionMethod) { - try { - Class holder = reflectionMethod.getDeclaringClass(); - Field slotField = reflectionMethod instanceof Constructor ? reflectionConstructorSlot : reflectionMethodSlot; - final int slot = slotField.getInt(reflectionMethod); - final long metaspaceMethod = runtime.getCompilerToVM().getMetaspaceMethod(holder, slot); - return HotSpotResolvedJavaMethodImpl.fromMetaspace(metaspaceMethod); - } catch (IllegalArgumentException | IllegalAccessException e) { - throw new GraalInternalError(e); - } - } - - public ResolvedJavaField lookupJavaField(Field reflectionField) { - String name = reflectionField.getName(); - Class fieldHolder = reflectionField.getDeclaringClass(); - Class fieldType = reflectionField.getType(); - // java.lang.reflect.Field's modifiers should be enough here since VM internal modifier bits - // are not used (yet). - final int modifiers = reflectionField.getModifiers(); - final long offset = Modifier.isStatic(modifiers) ? unsafe.staticFieldOffset(reflectionField) : unsafe.objectFieldOffset(reflectionField); - - HotSpotResolvedObjectType holder = fromObjectClass(fieldHolder); - JavaType type = fromClass(fieldType); - - if (offset != -1) { - HotSpotResolvedObjectType resolved = holder; - return resolved.createField(name, type, offset, modifiers); - } else { - throw GraalInternalError.shouldNotReachHere("unresolved field " + 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 GraalInternalError.shouldNotReachHere(); - } - } - - 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 GraalInternalError.shouldNotReachHere(); - } - - 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 GraalInternalError.shouldNotReachHere(); - } - } - - 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 GraalInternalError.shouldNotReachHere(Integer.toHexString(reason)); - } - - @Override - public long getMemorySize(JavaConstant constant) { - if (constant.getKind() == Kind.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(); - Kind elementKind = elementType.getKind(); - final int headerSize = runtime().getArrayBaseOffset(elementKind); - int sizeOfElement = HotSpotGraalRuntime.runtime().getTarget().getSizeInBytes(elementKind); - int alignment = HotSpotGraalRuntime.runtime().getTarget().wordSize; - int log2ElementSize = CodeUtil.log2(sizeOfElement); - return NewObjectSnippets.computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize); - } - return lookupJavaType.instanceSize(); - } - } else { - return constant.getKind().getByteCount(); - } - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstant.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstant.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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 com.oracle.graal.hotspot.meta; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; - -public interface HotSpotMetaspaceConstant extends HotSpotConstant, VMConstant { - - Constant compress(CompressEncoding encoding); - - Constant uncompress(CompressEncoding encoding); - - HotSpotResolvedObjectType asResolvedJavaType(); - - long rawValue(); -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstantImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstantImpl.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +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 com.oracle.graal.hotspot.meta; - -import java.util.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; - -public final class HotSpotMetaspaceConstantImpl extends PrimitiveConstant implements HotSpotMetaspaceConstant, VMConstant, HotSpotProxified { - - static HotSpotMetaspaceConstantImpl forMetaspaceObject(Kind kind, long primitive, Object metaspaceObject, boolean compressed) { - return new HotSpotMetaspaceConstantImpl(kind, primitive, metaspaceObject, compressed); - } - - static Object getMetaspaceObject(Constant constant) { - return ((HotSpotMetaspaceConstantImpl) constant).metaspaceObject; - } - - private final Object metaspaceObject; - private final boolean compressed; - - private HotSpotMetaspaceConstantImpl(Kind kind, long primitive, Object metaspaceObject, boolean compressed) { - super(kind, primitive); - this.metaspaceObject = metaspaceObject; - this.compressed = compressed; - } - - @Override - public int hashCode() { - return super.hashCode() ^ System.identityHashCode(metaspaceObject); - } - - @Override - public boolean equals(Object o) { - return o == this || (o instanceof HotSpotMetaspaceConstantImpl && super.equals(o) && Objects.equals(metaspaceObject, ((HotSpotMetaspaceConstantImpl) o).metaspaceObject)); - } - - @Override - public String toString() { - return super.toString() + "{" + metaspaceObject + (compressed ? ";compressed}" : "}"); - } - - public boolean isCompressed() { - return compressed; - } - - public JavaConstant compress(CompressEncoding encoding) { - assert !isCompressed(); - HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(Kind.Int, encoding.compress(asLong()), metaspaceObject, true); - assert res.isCompressed(); - return res; - } - - public JavaConstant uncompress(CompressEncoding encoding) { - assert isCompressed(); - HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(Kind.Long, encoding.uncompress(asInt()), metaspaceObject, false); - assert !res.isCompressed(); - return res; - } - - public HotSpotResolvedObjectType asResolvedJavaType() { - if (metaspaceObject instanceof HotSpotResolvedObjectType) { - return (HotSpotResolvedObjectType) metaspaceObject; - } - return null; - } - - public long rawValue() { - return asLong(); - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethod.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.debug.Debug.*; -import static java.util.FormattableFlags.*; - -import java.util.*; - -import com.oracle.graal.api.meta.*; - -public abstract class HotSpotMethod implements JavaMethod, Formattable { - - 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)); - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,859 +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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.compiler.common.UnsafeAccess.*; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; -import static java.lang.String.*; - -import java.util.*; - -import sun.misc.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.JavaMethodProfile.ProfiledMethod; -import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.meta.HotSpotMethodDataAccessor.Tag; - -/** - * Access to a HotSpot MethodData structure (defined in methodData.hpp). - */ -public final class HotSpotMethodData { - - private static final HotSpotVMConfig config = runtime().getConfig(); - 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 TypeCheckData(), - new VirtualCallData(), - new RetData(), - new BranchData(), - new MultiBranchData(), - new ArgInfoData(), - null, // call_type_data_tag - null, // virtual_call_type_data_tag - null, // parameters_type_data_tag - null, // speculative_trap_data_tag - }; - // @formatter:on - - /** - * Reference to the C++ MethodData object. - */ - private final long metaspaceMethodData; - - public HotSpotMethodData(long metaspaceMethodData) { - this.metaspaceMethodData = metaspaceMethodData; - } - - /** - * @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().getHostProviders().getMetaAccess(); - int reasonIndex = metaAccess.convertDeoptReason(reason); - return unsafe.getByte(metaspaceMethodData + config.methodDataOopTrapHistoryOffset + reasonIndex) & 0xFF; - } - - public int getOSRDeoptimizationCount(DeoptimizationReason reason) { - HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) runtime().getHostProviders().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); - assert result != null : "NO_DATA tag is not allowed"; - 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 long readWord(int position, int offsetInBytes) { - long fullOffsetInBytes = computeFullOffset(position, offsetInBytes); - return unsafe.getAddress(metaspaceMethodData + fullOffsetInBytes); - } - - 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 = 0x2; - - private final Tag tag; - private 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 int getSize(HotSpotMethodData data, int position) { - return staticSize + getDynamicSize(data, position); - } - - @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 = 0x01; - - 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(0); - - public 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(0); - protected static final int TAKEN_DISPLACEMENT_OFFSET = cellIndexToOffset(1); - - public 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; - - public 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(2); - - protected static final int NONPROFILED_COUNT_OFFSET = cellIndexToOffset(1); - protected static final int TYPE_DATA_FIRST_TYPE_OFFSET = cellIndexToOffset(2); - protected static final int TYPE_DATA_FIRST_TYPE_COUNT_OFFSET = cellIndexToOffset(3); - - 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++) { - long receiverKlass = data.readWord(position, getTypeOffset(i)); - if (receiverKlass != 0) { - HotSpotResolvedObjectTypeImpl klass = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(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 TypeCheckData extends AbstractTypeData { - - private static final int TYPE_CHECK_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; - - public TypeCheckData() { - super(Tag.ReceiverTypeData, TYPE_CHECK_DATA_SIZE); - } - - @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 AbstractTypeData { - - 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; - - public VirtualCallData() { - super(Tag.VirtualCallData, VIRTUAL_CALL_DATA_SIZE); - } - - @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++) { - long method = data.readWord(position, getMethodOffset(i)); - if (method != 0) { - methods[entries] = HotSpotResolvedJavaMethodImpl.fromMetaspace(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 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; - - public 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(2); - - public 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(0); - protected static final int ARRAY_DATA_START_OFFSET = cellIndexToOffset(1); - - public 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 = 2; - 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); - - public 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); - - public ArgInfoData() { - super(Tag.ArgInfoData, ARG_INFO_DATA_SIZE); - } - } - - public void setCompiledGraphSize(int nodeCount) { - unsafe.putInt(metaspaceMethodData + config.methodDataGraalNodeCountOffset, nodeCount); - } - - public int getCompiledGraphSize() { - return unsafe.getInt(metaspaceMethodData + config.methodDataGraalNodeCountOffset); - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodDataAccessor.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodDataAccessor.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.*; - -/** - * 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; - - private Tag(int value) { - this.value = value; - } - - public int getValue() { - return value; - } - - private static HotSpotVMConfig config() { - return runtime().getConfig(); - } - - 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); -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodHandleAccessProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodHandleAccessProvider.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodHandleAccessProvider.java Tue May 19 23:16:07 2015 +0200 @@ -23,12 +23,13 @@ package com.oracle.graal.hotspot.meta; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; -import static com.oracle.graal.hotspot.meta.HotSpotResolvedJavaType.*; -import static com.oracle.graal.hotspot.meta.HotSpotResolvedObjectTypeImpl.*; +import static com.oracle.graal.hotspot.jvmci.HotSpotResolvedJavaType.*; +import static com.oracle.graal.hotspot.jvmci.HotSpotResolvedObjectTypeImpl.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider, HotSpotProxified { diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodUnresolved.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodUnresolved.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodUnresolved.java Tue May 19 23:16:07 2015 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.hotspot.meta; import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.jvmci.*; /** * Implementation of {@link JavaMethod} for unresolved HotSpot methods. diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; - -/** - * 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; - private final boolean isExternal; - - public HotSpotNmethod(HotSpotResolvedJavaMethod method, String name, boolean isDefault) { - this(method, name, isDefault, false); - } - - public HotSpotNmethod(HotSpotResolvedJavaMethod method, String name, boolean isDefault, boolean isExternal) { - super(name); - this.method = method; - this.isDefault = isDefault; - this.isExternal = isExternal; - } - - public boolean isDefault() { - return isDefault; - } - - public boolean isExternal() { - return isExternal; - } - - public ResolvedJavaMethod getMethod() { - return method; - } - - @Override - public void invalidate() { - runtime().getCompilerToVM().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) == Kind.Object; - assert method.getSignature().getParameterKind(1) == Kind.Object; - assert !method.isStatic() || method.getSignature().getParameterKind(2) == Kind.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].getKind() == Kind.Object : method.format("%H.%n(%p): expected arg ") + i + " to be Object, not " + sig[i]; - } else if (sig[i].getKind() != Kind.Object) { - assert sig[i].getKind().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); - assert !isExternal(); - return runtime().getCompilerToVM().executeCompiledMethodVarargs(args, this); - } - - @Override - public long getStart() { - return isValid() ? super.getStart() : 0; - } - - public JavaConstant asConstant() { - return HotSpotObjectConstantImpl.forObject(this); - } - -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +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 com.oracle.graal.hotspot.meta; - -import java.lang.invoke.*; -import java.util.*; - -import com.oracle.graal.api.meta.*; - -/** - * 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); -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,291 +0,0 @@ -/* - * Copyright (c) 2009, 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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.hotspot.meta.HotSpotResolvedObjectTypeImpl.*; - -import java.lang.invoke.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.*; - -import edu.umd.cs.findbugs.annotations.*; - -/** - * Represents a constant non-{@code null} object reference, within the compiler and across the - * compiler/runtime interface. - */ -public final class HotSpotObjectConstantImpl extends AbstractValue 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(Kind kind, Object value) { - if (kind == Kind.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) { - super(LIRKind.reference(compressed ? Kind.Int : Kind.Object)); - 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); - } - - /** - * Package-private accessor for the object represented by this constant. - */ - Object object() { - return object; - } - - /** - * Determines if the object represented by this constant is {@link Object#equals(Object) equal} - * to a given object. - */ - public boolean isEqualTo(Object obj) { - return object.equals(obj); - } - - /** - * Gets the class of the object represented by this constant. - */ - public Class getObjectClass() { - return object.getClass(); - } - - 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 super.equals(o) && 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 Kind.Object.format(object); - } - } - - @Override - public String toString() { - return (compressed ? "NarrowOop" : getKind().getJavaName()) + "[" + Kind.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; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,225 +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 com.oracle.graal.hotspot.meta; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.nodes.*; - -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; - } - - @Override - public boolean setCompilerIRSize(Class irType, int size) { - if (irType == StructuredGraph.class) { - methodData.setCompiledGraphSize(size); - return true; - } - return false; - } - - @Override - public int getCompilerIRSize(Class irType) { - if (irType == StructuredGraph.class) { - return methodData.getCompiledGraphSize(); - } - return -1; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProviders.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProviders.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProviders.java Tue May 19 23:16:07 2015 +0200 @@ -25,6 +25,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.word.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.phases.tiers.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot.meta; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.*; - -/** - * 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(); - - /** - * Checks if this field has the {@link Stable} annotation. - * - * @return true if field has {@link Stable} annotation, false otherwise - */ - boolean isStable(); -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,282 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.compiler.common.GraalOptions.*; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; -import static com.oracle.graal.hotspot.meta.HotSpotResolvedObjectTypeImpl.*; - -import java.lang.annotation.*; -import java.lang.reflect.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.*; - -/** - * Represents a field in a HotSpot type. - */ -public 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; - - public 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(); - } - } - - public 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 & getReflectionFieldModifiers(); - } - - @Override - public boolean isInternal() { - return (modifiers & runtime().getConfig().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 (runtime().getConfig().syntheticFlag & 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 ((runtime().getConfig().jvmAccFieldStable & modifiers) != 0) { - return true; - } - assert getAnnotation(Stable.class) == null; - if (ImplicitStableValues.getValue() && isImplicitStableField()) { - return true; - } - return false; - } - - @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 (isSynthetic()) { - if (isSyntheticImplicitStableField()) { - return true; - } - } else if (isWellKnownImplicitStableField()) { - return true; - } - return false; - } - - private boolean isSyntheticImplicitStableField() { - assert this.isSynthetic(); - if (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().getHostProviders().getMetaAccess(); - STRING_VALUE_FIELD = metaAccess.lookupJavaField(String.class.getDeclaredField("value")); - } catch (SecurityException | NoSuchFieldException e) { - throw new GraalInternalError(e); - } - } - } - - public LocationIdentity getLocationIdentity() { - return locationIdentity; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot.meta; - -import java.lang.reflect.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; - -/** - * 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(); - - /** - * 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(); - - boolean hasBalancedMonitors(); - - 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); - - ProfilingInfo getCompilationProfilingInfo(boolean isOSR); - - 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); - - SpeculationLog getSpeculationLog(); -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethodImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethodImpl.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,752 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.compiler.common.GraalInternalError.*; -import static com.oracle.graal.compiler.common.GraalOptions.*; -import static com.oracle.graal.compiler.common.UnsafeAccess.*; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; - -import java.lang.annotation.*; -import java.lang.reflect.*; -import java.util.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.graphbuilderconf.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.nodes.*; - -/** - * Implementation of {@link JavaMethod} for resolved HotSpot methods. - */ -public final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSpotResolvedJavaMethod, HotSpotProxified, MethodIdHolder { - - /** - * 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 Member 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} - */ - public static HotSpotResolvedObjectTypeImpl getHolder(long metaspaceMethod) { - HotSpotVMConfig config = runtime().getConfig(); - final long metaspaceConstMethod = unsafe.getAddress(metaspaceMethod + config.methodConstMethodOffset); - final long metaspaceConstantPool = unsafe.getAddress(metaspaceConstMethod + config.constMethodConstantsOffset); - final long metaspaceKlass = unsafe.getAddress(metaspaceConstantPool + config.constantPoolHolderOffset); - return HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass); - } - - /** - * Gets the {@link ResolvedJavaMethod} for a HotSpot metaspace method native object. - * - * @param metaspaceMethod a metaspace Method object - * @return the {@link ResolvedJavaMethod} corresponding to {@code metaspaceMethod} - */ - public static HotSpotResolvedJavaMethod fromMetaspace(long metaspaceMethod) { - HotSpotResolvedObjectTypeImpl holder = getHolder(metaspaceMethod); - return holder.createMethod(metaspaceMethod); - } - - public 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 = runtime().getConfig(); - 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); - this.constantPool = new HotSpotConstantPool(metaspaceConstantPool); - - 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}). - * - * @return pointer to this method's ConstMethod - */ - private long getConstMethod() { - assert metaspaceMethod != 0; - return unsafe.getAddress(metaspaceMethod + runtime().getConfig().methodConstMethodOffset); - } - - @Override - public boolean equals(Object obj) { - 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.getByte(metaspaceMethod + runtime().getConfig().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() + runtime().getConfig().constMethodFlagsOffset); - } - - @Override - public HotSpotResolvedObjectTypeImpl getDeclaringClass() { - return holder; - } - - /** - * Gets the address of the C++ Method object for this method. - */ - public JavaConstant getMetaspaceMethodConstant() { - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(getHostWordKind(), metaspaceMethod, this, false); - } - - public long getMetaspaceMethod() { - return metaspaceMethod; - } - - @Override - public JavaConstant 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 + runtime().getConfig().methodAccessFlagsOffset); - } - - @Override - public int getModifiers() { - return getAllModifiers() & Modifier.methodModifiers(); - } - - @Override - public boolean canBeStaticallyBound() { - return (isFinal() || isPrivate() || isStatic() || holder.isFinal()) && isConcrete(); - } - - @Override - public byte[] getCode() { - if (getCodeSize() == 0) { - return null; - } - if (code == null && holder.isLinked()) { - code = runtime().getCompilerToVM().getBytecode(metaspaceMethod); - assert code.length == getCodeSize() : "expected: " + getCodeSize() + ", actual: " + code.length; - } - return code; - } - - @Override - public int getCodeSize() { - return unsafe.getChar(getConstMethod() + runtime().getConfig().constMethodCodeSizeOffset); - } - - @Override - public ExceptionHandler[] getExceptionHandlers() { - final boolean hasExceptionTable = (getConstMethodFlags() & runtime().getConfig().constMethodHasExceptionTable) != 0; - if (!hasExceptionTable) { - return new ExceptionHandler[0]; - } - - HotSpotVMConfig config = runtime().getConfig(); - final int exceptionTableLength = runtime().getCompilerToVM().exceptionTableLength(metaspaceMethod); - ExceptionHandler[] handlers = new ExceptionHandler[exceptionTableLength]; - long exceptionTableElement = runtime().getCompilerToVM().exceptionTableStart(metaspaceMethod); - - 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() & runtime().getConfig().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() & runtime().getConfig().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() & runtime().getConfig().methodFlagsDontInline) != 0; - } - - /** - * Manually adds a DontInline annotation to this method. - */ - public void setNotInlineable() { - runtime().getCompilerToVM().doNotInlineOrCompile(metaspaceMethod); - } - - /** - * 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 runtime().getCompilerToVM().methodIsIgnoredBySecurityStackWalk(metaspaceMethod); - } - - public boolean hasBalancedMonitors() { - HotSpotVMConfig config = runtime().getConfig(); - final int modifiers = getAllModifiers(); - - // Method has no monitorenter/exit bytecodes. - if ((modifiers & config.jvmAccHasMonitorBytecodes) == 0) { - return false; - } - - // Check to see if a previous compilation computed the monitor-matching analysis. - if ((modifiers & config.jvmAccMonitorMatch) != 0) { - return true; - } - - // This either happens only once if monitors are balanced or very rarely multiple-times. - return runtime().getCompilerToVM().hasBalancedMonitors(metaspaceMethod); - } - - @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 = runtime().getConfig(); - return unsafe.getChar(getConstMethod() + config.methodMaxLocalsOffset); - } - - @Override - public int getMaxStackSize() { - if (isAbstract() || isNative()) { - return 0; - } - HotSpotVMConfig config = runtime().getConfig(); - 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 = runtime().getCompilerToVM().getStackTraceElement(metaspaceMethod, 0); - return new StackTraceElement(ste.getClassName(), ste.getMethodName(), ste.getFileName(), -1); - } - return runtime().getCompilerToVM().getStackTraceElement(metaspaceMethod, 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; - } - long metaspaceKlass = ((HotSpotResolvedObjectTypeImpl) receiver).getMetaspaceKlass(); - final long uniqueConcreteMethod = runtime().getCompilerToVM().findUniqueConcreteMethod(metaspaceKlass, metaspaceMethod); - if (uniqueConcreteMethod == 0) { - return null; - } - return fromMetaspace(uniqueConcreteMethod); - } - - @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 = runtime().getConfig(); - 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 + runtime().getConfig().nmethodCompLevelOffset) == level; - } - return false; - } - - private static final String TraceMethodDataFilter = System.getProperty("graal.traceMethodDataFilter"); - - @Override - public ProfilingInfo getProfilingInfo() { - return getProfilingInfo(true, true); - } - - public ProfilingInfo getCompilationProfilingInfo(boolean isOSR) { - return getProfilingInfo(!isOSR, isOSR); - } - - private ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) { - ProfilingInfo info; - - if (UseProfilingInformation.getValue() && methodData == null) { - long metaspaceMethodData = unsafe.getAddress(metaspaceMethod + runtime().getConfig().methodDataOffset); - if (metaspaceMethodData != 0) { - methodData = new HotSpotMethodData(metaspaceMethodData); - if (TraceMethodDataFilter != null && this.format("%H.%n").contains(TraceMethodDataFilter)) { - TTY.println("Raw method data for " + this.format("%H.%n(%p)") + ":"); - TTY.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() { - runtime().getCompilerToVM().reprofile(metaspaceMethod); - } - - @Override - public ConstantPool getConstantPool() { - return constantPool; - } - - @Override - public Annotation[][] getParameterAnnotations() { - if (isConstructor()) { - Constructor javaConstructor = toJavaConstructor(); - return javaConstructor == null ? null : javaConstructor.getParameterAnnotations(); - } - Method javaMethod = toJava(); - return javaMethod == null ? null : javaMethod.getParameterAnnotations(); - } - - @Override - public Annotation[] getAnnotations() { - if (isConstructor()) { - Constructor javaConstructor = toJavaConstructor(); - return javaConstructor == null ? new Annotation[0] : javaConstructor.getAnnotations(); - } - Method javaMethod = toJava(); - return javaMethod == null ? new Annotation[0] : javaMethod.getAnnotations(); - } - - @Override - public T getAnnotation(Class annotationClass) { - if (isConstructor()) { - Constructor javaConstructor = toJavaConstructor(); - return javaConstructor == null ? null : javaConstructor.getAnnotation(annotationClass); - } - Method javaMethod = toJava(); - return javaMethod == null ? null : javaMethod.getAnnotation(annotationClass); - } - - @Override - public boolean isSynthetic() { - int modifiers = getAllModifiers(); - return (runtime().getConfig().syntheticFlag & modifiers) != 0; - } - - 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() { - if (isConstructor()) { - Constructor javaConstructor = toJavaConstructor(); - return javaConstructor == null ? null : javaConstructor.getGenericParameterTypes(); - } - Method 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 Method toJava() { - if (toJavaCache != null) { - return (Method) toJavaCache; - } - try { - Method result = holder.mirror().getDeclaredMethod(name, signatureToTypes()); - toJavaCache = result; - return result; - } catch (NoSuchMethodException | NoClassDefFoundError e) { - return null; - } - } - - private Constructor toJavaConstructor() { - if (toJavaCache != null) { - return (Constructor) toJavaCache; - } - try { - Constructor result = holder.mirror().getDeclaredConstructor(signatureToTypes()); - toJavaCache = result; - return result; - } catch (NoSuchMethodException | NoClassDefFoundError e) { - return null; - } - } - - @Override - public boolean canBeInlined() { - if (isDontInline()) { - return false; - } - return runtime().getCompilerToVM().canInlineMethod(metaspaceMethod); - } - - @Override - public boolean shouldBeInlined() { - if (isForceInline()) { - return true; - } - return runtime().getCompilerToVM().shouldInlineMethod(metaspaceMethod); - } - - @Override - public LineNumberTable getLineNumberTable() { - final boolean hasLineNumberTable = (getConstMethodFlags() & runtime().getConfig().constMethodHasLineNumberTable) != 0; - if (!hasLineNumberTable) { - return null; - } - - long[] values = runtime().getCompilerToVM().getLineNumberTable(metaspaceMethod); - if (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() & runtime().getConfig().constMethodHasLocalVariableTable) != 0; - if (!hasLocalVariableTable) { - return null; - } - - HotSpotVMConfig config = runtime().getConfig(); - long localVariableTableElement = runtime().getCompilerToVM().getLocalVariableTableStart(metaspaceMethod); - final int localVariableTableLength = runtime().getCompilerToVM().getLocalVariableTableLength(metaspaceMethod); - 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) { - guarantee(isInVirtualMethodTable(resolved), "%s does not have a vtable entry", this); - HotSpotVMConfig config = runtime().getConfig(); - final int vtableIndex = getVtableIndex((HotSpotResolvedObjectTypeImpl) resolved); - return config.instanceKlassVtableStartOffset + 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 runtime().getConfig().invalidVtableIndex; - } - if (holder.isInterface()) { - if (resolved.isInterface()) { - return runtime().getConfig().invalidVtableIndex; - } - return getVtableIndexForInterface(resolved); - } - return getVtableIndex(); - } - - /** - * Returns this method's virtual table index. - * - * @return virtual table index - */ - private int getVtableIndex() { - assert !holder.isInterface(); - HotSpotVMConfig config = runtime().getConfig(); - int result = unsafe.getInt(metaspaceMethod + config.methodVtableIndexOffset); - assert result >= config.nonvirtualVtableIndex : "must be linked"; - return result; - } - - private int getVtableIndexForInterface(ResolvedJavaType resolved) { - HotSpotResolvedObjectTypeImpl hotspotType = (HotSpotResolvedObjectTypeImpl) resolved; - return runtime().getCompilerToVM().getVtableIndexForInterface(hotspotType.getMetaspaceKlass(), getMetaspaceMethod()); - } - - /** - * The {@link SpeculationLog} for methods compiled by Graal 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 = runtime().getConfig(); - return unsafe.getByte(metaspaceMethod + config.methodIntrinsicIdOffset) & 0xff; - } - - @Override - public JavaConstant invoke(JavaConstant receiver, JavaConstant[] arguments) { - assert !isConstructor(); - Method javaMethod = 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 runtime().getCompilerToVM().allocateCompileId(metaspaceMethod, entryBCI); - } - - public boolean hasCodeAtLevel(int entryBCI, int level) { - if (entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI) { - return hasCompiledCodeAtLevel(level); - } - return runtime().getCompilerToVM().hasCompiledCodeForOSR(metaspaceMethod, entryBCI, level); - } - - private int methodId; - - public void setMethodId(int id) { - assert methodId == 0; - methodId = id; - } - - public int getMethodId() { - return methodId; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2012, 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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; - -import com.oracle.graal.api.meta.*; - -public abstract class HotSpotResolvedJavaType extends HotSpotJavaType implements ResolvedJavaType { - - /** - * Gets the Graal mirror for a {@link Class} object. - * - * @return the {@link HotSpotResolvedJavaType} corresponding to {@code javaClass} - */ - public static ResolvedJavaType fromClass(Class javaClass) { - return runtime().fromClass(javaClass); - } - - public 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(); - } - -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot.meta; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.Assumptions.AssumptionResult; -import com.oracle.graal.hotspot.*; - -/** - * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. - */ -public interface HotSpotResolvedObjectType extends ResolvedJavaType { - - HotSpotResolvedObjectType getArrayClass(); - - ResolvedJavaType getComponentType(); - - AssumptionResult findLeafConcreteSubtype(); - - HotSpotResolvedObjectType getSuperclass(); - - HotSpotResolvedObjectType[] getInterfaces(); - - HotSpotResolvedObjectType getSupertype(); - - HotSpotResolvedObjectType findLeastCommonAncestor(ResolvedJavaType otherType); - - HotSpotResolvedObjectType asExactType(); - - default boolean isPrimitive() { - return false; - } - - default Kind getKind() { - return Kind.Object; - } - - ConstantPool 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. - */ - 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 HotSpotGraalRuntime#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(); - - HotSpotResolvedObjectType getEnclosingType(); - - ResolvedJavaMethod getClassInitializer(); - - ResolvedJavaField createField(String name, JavaType type, long offset, int modifiers); -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,899 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.compiler.common.UnsafeAccess.*; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; -import static java.util.Objects.*; - -import java.lang.annotation.*; -import java.lang.reflect.*; -import java.net.*; -import java.nio.*; -import java.util.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.Assumptions.*; -import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.*; - -/** - * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. - */ -public final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implements HotSpotResolvedObjectType, HotSpotProxified { - - /** - * The Java class this type represents. - */ - private final Class javaClass; - - private HashMap fieldCache; - private HashMap methodCache; - private HotSpotResolvedJavaField[] instanceFields; - private HotSpotResolvedObjectTypeImpl[] interfaces; - private ConstantPool constantPool; - private HotSpotResolvedObjectType arrayOfType; - - /** - * Gets the Graal mirror for a {@link Class} object. - * - * @return the {@link HotSpotResolvedJavaType} corresponding to {@code javaClass} - */ - public static HotSpotResolvedObjectTypeImpl fromObjectClass(Class javaClass) { - return (HotSpotResolvedObjectTypeImpl) runtime().fromClass(javaClass); - } - - /** - * Gets the Graal mirror from a HotSpot metaspace Klass native object. - * - * @param metaspaceKlass a metaspace Klass object - * @return the {@link ResolvedJavaType} corresponding to {@code metaspaceKlass} - */ - public static HotSpotResolvedObjectTypeImpl fromMetaspaceKlass(long metaspaceKlass) { - assert metaspaceKlass != 0; - Class javaClass = runtime().getCompilerToVM().getJavaMirror(metaspaceKlass); - assert javaClass != null; - return fromObjectClass(javaClass); - } - - /** - * Creates the Graal 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 #fromMetaspaceKlass(long)} - * instead. - *

- * - * @param javaClass the Class to create the mirror for - */ - public HotSpotResolvedObjectTypeImpl(Class javaClass) { - super(getSignatureName(javaClass)); - this.javaClass = javaClass; - 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. - */ - public long getMetaspaceKlass() { - if (HotSpotGraalRuntime.getHostWordKind() == Kind.Long) { - return unsafe.getLong(javaClass, (long) runtime().getConfig().klassOffset); - } - return unsafe.getInt(javaClass, (long) runtime().getConfig().klassOffset) & 0xFFFFFFFFL; - } - - @Override - public int getModifiers() { - return mirror().getModifiers(); - } - - public int getAccessFlags() { - HotSpotVMConfig config = runtime().getConfig(); - 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 : fromClass(javaComponentType); - } - - @Override - public AssumptionResult findLeafConcreteSubtype() { - HotSpotVMConfig config = runtime().getConfig(); - if (isArray()) { - return getElementalType().isFinal() ? 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()) { - long subklass = type.getSubklass(); - if (subklass == 0 || unsafe.getAddress(subklass + config.nextSiblingOffset) != 0) { - return null; - } - type = fromMetaspaceKlass(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() == 0; - } - - /** - * 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 long getSubklass() { - return unsafe.getAddress(getMetaspaceKlass() + runtime().getConfig().subklassOffset); - } - - @Override - public HotSpotResolvedObjectTypeImpl getSuperclass() { - Class javaSuperclass = mirror().getSuperclass(); - return javaSuperclass == null ? null : (HotSpotResolvedObjectTypeImpl) 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 GraalInternalError("Cannot call getImplementor() on a non-interface type: " + this); - } - final long implementorMetaspaceKlass = runtime().getCompilerToVM().getKlassImplementor(getMetaspaceKlass()); - - // No implementor. - if (implementorMetaspaceKlass == 0) { - return null; - } - - return fromMetaspaceKlass(implementorMetaspaceKlass); - } - - 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() { - if (isArray()) { - return getComponentType().asExactType() != null ? this : null; - } - return isFinal() ? this : null; - } - - @Override - public JavaConstant getJavaClass() { - return HotSpotObjectConstantImpl.forObject(mirror()); - } - - @Override - public JavaConstant getObjectHub() { - return klass(); - } - - @Override - public AssumptionResult hasFinalizableSubclass() { - assert !isArray(); - if (!runtime().getCompilerToVM().hasFinalizableSubclass(getMetaspaceKlass())) { - return new AssumptionResult<>(false, new NoFinalizableSubclass(this)); - } - return new AssumptionResult<>(true); - } - - @Override - public boolean hasFinalizer() { - HotSpotVMConfig config = runtime().getConfig(); - return (getAccessFlags() & config.klassHasFinalizerFlag) != 0; - } - - @Override - public boolean isPrimitive() { - return false; - } - - @Override - public boolean isArray() { - return mirror().isArray(); - } - - @Override - public boolean isInitialized() { - return isArray() ? true : getInitState() == runtime().getConfig().instanceKlassStateFullyInitialized; - } - - @Override - public boolean isLinked() { - return isArray() ? true : getInitState() >= runtime().getConfig().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() + runtime().getConfig().instanceKlassInitStateOffset) & 0xFF; - } - - @Override - public void initialize() { - if (!isInitialized()) { - unsafe.ensureClassInitialized(mirror()); - assert isInitialized(); - } - } - - @Override - public boolean isInstance(JavaConstant obj) { - if (obj.getKind() == Kind.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 Kind getKind() { - return Kind.Object; - } - - @Override - public ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { - ResolvedJavaMethod resolvedMethod = resolveMethod(method, callerType, true); - if (resolvedMethod == null || resolvedMethod.isAbstract()) { - return null; - } - return resolvedMethod; - } - - @Override - public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType, boolean includeAbstract) { - if (!includeAbstract) { - return resolveConcreteMethod(method, callerType); - } - assert !callerType.isArray(); - 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; - final long resolvedMetaspaceMethod = runtime().getCompilerToVM().resolveMethod(getMetaspaceKlass(), hotSpotMethod.getMetaspaceMethod(), hotSpotCallerType.getMetaspaceKlass()); - if (resolvedMetaspaceMethod == 0) { - return null; - } - return HotSpotResolvedJavaMethodImpl.fromMetaspace(resolvedMetaspaceMethod); - } - - public ConstantPool constantPool() { - if (constantPool == null) { - final long metaspaceConstantPool = unsafe.getAddress(getMetaspaceKlass() + runtime().getConfig().instanceKlassConstantsOffset); - constantPool = new HotSpotConstantPool(metaspaceConstantPool); - } - 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 = runtime().getConfig(); - final int layoutHelper = unsafe.getInt(getMetaspaceKlass() + config.klassLayoutHelperOffset); - 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 synchronized HotSpotResolvedJavaMethod createMethod(long metaspaceMethod) { - HotSpotResolvedJavaMethod 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); - } - return method; - } - - public int getVtableLength() { - HotSpotVMConfig config = runtime().getConfig(); - if (isInterface() || isArray()) { - /* Everything has the core vtable of java.lang.Object */ - return config.baseVtableLength; - } - int result = unsafe.getInt(getMetaspaceKlass() + config.instanceKlassVtableLengthOffset) / (config.vtableEntrySize / config.heapWordSize); - assert result >= config.baseVtableLength : unsafe.getInt(getMetaspaceKlass() + config.instanceKlassVtableLengthOffset) + " " + config.vtableEntrySize; - return result; - } - - /** - * Gets the mask used to filter out HotSpot internal flags for fields when a {@link Field} - * object is created. This is the value of {@code JVM_RECOGNIZED_FIELD_MODIFIERS} in - * {@code jvm.h}, not {@link Modifier#fieldModifiers()}. - */ - public static int getReflectionFieldModifiers() { - return runtime().getConfig().recognizedFieldModifiers; - } - - public synchronized HotSpotResolvedJavaField createField(String fieldName, JavaType type, long offset, int rawFlags) { - HotSpotResolvedJavaField result = null; - - final int flags = rawFlags & getReflectionFieldModifiers(); - - final long id = offset + ((long) flags << 32); - - // (thomaswue) 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, true); - 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 - */ - public FieldInfo(int index) { - HotSpotVMConfig config = runtime().getConfig(); - // 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(runtime().getConfig().fieldInfoAccessFlagsOffset); - } - - private int getNameIndex() { - return readFieldSlot(runtime().getConfig().fieldInfoNameIndexOffset); - } - - private int getSignatureIndex() { - return readFieldSlot(runtime().getConfig().fieldInfoSignatureIndexOffset); - } - - public int getOffset() { - HotSpotVMConfig config = runtime().getConfig(); - 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) : constantPool().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) : constantPool().lookupUtf8(signatureIndex); - } - - public JavaType getType() { - String signature = getSignature(); - return runtime().lookupType(signature, HotSpotResolvedObjectTypeImpl.this, false); - } - - private boolean isInternal() { - return (getAccessFlags() & runtime().getConfig().jvmAccFieldInternal) != 0; - } - - public boolean isStatic() { - return Modifier.isStatic(getAccessFlags()); - } - - public boolean hasGenericSignature() { - return (getAccessFlags() & runtime().getConfig().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 = runtime().getConfig(); - 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 = runtime().getConfig(); - final int sourceFileNameIndex = unsafe.getChar(getMetaspaceKlass() + config.instanceKlassSourceFileNameIndexOffset); - if (sourceFileNameIndex == 0) { - return null; - } - return constantPool().lookupUtf8(sourceFileNameIndex); - } - - @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 HotSpotGraalRuntime#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 JavaConstant klass() { - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(runtime().getTarget().wordKind, getMetaspaceKlass(), this, false); - } - - public boolean isPrimaryType() { - return runtime().getConfig().secondarySuperCacheOffset != superCheckOffset(); - } - - public int superCheckOffset() { - HotSpotVMConfig config = runtime().getConfig(); - return unsafe.getInt(getMetaspaceKlass() + config.superCheckOffsetOffset); - } - - public long prototypeMarkWord() { - HotSpotVMConfig config = runtime().getConfig(); - if (isArray()) { - return config.arrayPrototypeMarkWord(); - } else { - return unsafe.getAddress(getMetaspaceKlass() + config.prototypeMarkWordOffset); - } - } - - @Override - public ResolvedJavaField findInstanceFieldWithOffset(long offset, Kind 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(Kind.Void) && - resolvedField.getKind().isPrimitive()) { - resolvedFieldOffset += - resolvedField.getKind().getByteCount() - - Math.min(resolvedField.getKind().getByteCount(), 4 + expectedEntryKind.getByteCount()); - } - if (resolvedFieldOffset == offset) { - return field; - } - // @formatter:on - } - return null; - } - - @Override - public URL getClassFilePath() { - Class cls = mirror(); - return cls.getResource(MetaUtil.getSimpleName(cls, true).replace('.', '$') + ".class"); - } - - @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().getHostProviders().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().getHostProviders().getMetaAccess().lookupJavaMethod(methods[i]); - assert !result[i].isConstructor(); - } - return result; - } - - public ResolvedJavaMethod getClassInitializer() { - final long metaspaceMethod = runtime().getCompilerToVM().getClassInitializer(getMetaspaceKlass()); - if (metaspaceMethod != 0L) { - return createMethod(metaspaceMethod); - } - return null; - } - - @Override - public String toString() { - return "HotSpotType<" + getName() + ", resolved>"; - } - - @Override - public boolean isTrustedInterfaceType() { - return TrustedInterface.class.isAssignableFrom(mirror()); - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,281 +0,0 @@ -/* - * Copyright (c) 2011, 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 com.oracle.graal.hotspot.meta; - -import static java.util.Objects.*; - -import java.lang.annotation.*; -import java.lang.reflect.*; -import java.net.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.Assumptions.AssumptionResult; -import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.*; - -/** - * Implementation of {@link JavaType} for primitive HotSpot types. - */ -public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType implements HotSpotProxified { - - private final Kind kind; - - /** - * Creates the Graal mirror for a primitive {@link Kind}. - * - *

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

- * - * @param kind the Kind to create the mirror for - */ - public HotSpotResolvedPrimitiveType(Kind 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 == Kind.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 GraalInternalError("Cannot call getImplementor() on a non-interface type: " + this); - } - - @Override - public ResolvedJavaType findLeastCommonAncestor(ResolvedJavaType otherType) { - return null; - } - - @Override - public JavaConstant getObjectHub() { - throw GraalInternalError.unimplemented("HotSpotResolvedPrimitiveType.getObjectHub"); - } - - @Override - public JavaConstant getJavaClass() { - throw GraalInternalError.unimplemented("HotSpotResolvedPrimitiveType.getJavaClass"); - } - - @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 Kind getKind() { - return kind; - } - - @Override - public boolean isJavaLangObject() { - return false; - } - - @Override - public ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { - return null; - } - - @Override - public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType, boolean includeAbstract) { - 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 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, Kind expectedType) { - return null; - } - - @Override - public String getSourceFileName() { - throw GraalInternalError.shouldNotReachHere(); - } - - @Override - public Class mirror() { - return kind.toJavaClass(); - } - - @Override - public URL getClassFilePath() { - return null; - } - - @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; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntimeStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntimeStub.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntimeStub.java Tue May 19 23:16:07 2015 +0200 @@ -24,7 +24,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.stubs.*; /** @@ -59,6 +59,6 @@ @Override public Object executeVarargs(Object... args) throws InvalidInstalledCodeException { - throw new GraalInternalError("Cannot call stub %s", stub); + throw new InternalError("Cannot call stub " + stub); } } diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,213 +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 com.oracle.graal.hotspot.meta; - -import java.util.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.*; - -/** - * 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 HotSpotGraalRuntimeProvider runtime; - - public HotSpotSignature(HotSpotGraalRuntimeProvider 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(HotSpotGraalRuntimeProvider 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 GraalInternalError("Invalid character at index " + cur + " in signature: " + signature); - } - return cur; - } - - @Override - public int getParameterCount(boolean withReceiver) { - return parameters.size() + (withReceiver ? 1 : 0); - } - - @Override - public Kind getParameterKind(int index) { - return Kind.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(HotSpotGraalRuntimeProvider runtime, String name) { - if (name.length() == 1) { - Kind kind = Kind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); - return runtime.getHostProviders().getMetaAccess().lookupJavaType(kind.toJavaClass()); - } - return new HotSpotUnresolvedJavaType(name, runtime); - } - - @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 Kind getReturnKind() { - return Kind.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(); - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSnippetReflectionProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSnippetReflectionProvider.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSnippetReflectionProvider.java Tue May 19 23:16:07 2015 +0200 @@ -25,6 +25,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; public class HotSpotSnippetReflectionProvider implements SnippetReflectionProvider { diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSpeculationLog.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSpeculationLog.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSpeculationLog.java Tue May 19 23:16:07 2015 +0200 @@ -24,6 +24,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.jvmci.*; public class HotSpotSpeculationLog extends SpeculationLog { diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Tue May 19 23:16:07 2015 +0200 @@ -27,7 +27,7 @@ import com.oracle.graal.graphbuilderconf.*; import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.bridge.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.phases.*; import com.oracle.graal.java.*; import com.oracle.graal.lir.phases.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedField.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedField.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2009, 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 com.oracle.graal.hotspot.meta; - -import com.oracle.graal.api.meta.*; - -/** - * A implementation of {@link JavaField} for an unresolved field. - */ -public class HotSpotUnresolvedField implements JavaField { - - private final String name; - private final JavaType holder; - private final JavaType type; - - public 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>"); - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedJavaType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedJavaType.java Tue May 26 16:46:25 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +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 com.oracle.graal.hotspot.meta; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.*; - -/** - * Implementation of {@link JavaType} for unresolved HotSpot classes. - */ -public class HotSpotUnresolvedJavaType extends HotSpotJavaType { - - private final HotSpotGraalRuntimeProvider runtime; - - public HotSpotUnresolvedJavaType(String name, HotSpotGraalRuntimeProvider 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}. - */ - public static HotSpotUnresolvedJavaType create(HotSpotGraalRuntimeProvider 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 Kind getKind() { - return Kind.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; - } -} diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java Tue May 19 23:16:07 2015 +0200 @@ -28,8 +28,8 @@ import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.nodeinfo.*; import com.oracle.graal.nodes.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/KlassPointerStamp.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/KlassPointerStamp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/KlassPointerStamp.java Tue May 19 23:16:07 2015 +0200 @@ -27,8 +27,8 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.spi.*; import com.oracle.graal.compiler.common.type.*; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; public final class KlassPointerStamp extends MetaspacePointerStamp { diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/MethodPointerStamp.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/MethodPointerStamp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/MethodPointerStamp.java Tue May 19 23:16:07 2015 +0200 @@ -24,7 +24,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.type.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; public final class MethodPointerStamp extends MetaspacePointerStamp { diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java Tue May 19 23:16:07 2015 +0200 @@ -25,8 +25,8 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.spi.*; import com.oracle.graal.compiler.common.type.*; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; public class NarrowOopStamp extends AbstractObjectStamp { diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java Tue May 19 23:16:07 2015 +0200 @@ -25,7 +25,7 @@ import static com.oracle.graal.nodes.ConstantNode.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/LoadJavaMirrorWithKlassPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/LoadJavaMirrorWithKlassPhase.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/LoadJavaMirrorWithKlassPhase.java Tue May 19 23:16:07 2015 +0200 @@ -29,8 +29,8 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.type.*; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.nodes.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java Tue May 19 23:16:07 2015 +0200 @@ -24,7 +24,7 @@ import com.oracle.graal.compiler.common.*; import com.oracle.graal.graph.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteTargetNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteTargetNode.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteTargetNode.java Tue May 19 23:16:07 2015 +0200 @@ -25,7 +25,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.nodeinfo.*; import com.oracle.graal.nodes.CallTargetNode.InvokeKind; import com.oracle.graal.nodes.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassGetHubNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassGetHubNode.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassGetHubNode.java Tue May 19 23:16:07 2015 +0200 @@ -26,7 +26,7 @@ import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.hotspot.word.*; import com.oracle.graal.nodeinfo.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CompilerToVMImplSubstitutions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CompilerToVMImplSubstitutions.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CompilerToVMImplSubstitutions.java Tue May 19 23:16:07 2015 +0200 @@ -23,13 +23,13 @@ package com.oracle.graal.hotspot.replacements; import com.oracle.graal.api.replacements.*; -import com.oracle.graal.hotspot.bridge.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.word.*; /** * Substitutions for {@link CompilerToVMImpl} methods. */ -@ClassSubstitution(com.oracle.graal.hotspot.bridge.CompilerToVMImpl.class) +@ClassSubstitution(com.oracle.graal.hotspot.jvmci.CompilerToVMImpl.class) public class CompilerToVMImplSubstitutions { @MethodSubstitution(isStatic = false) diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java Tue May 19 23:16:07 2015 +0200 @@ -33,7 +33,7 @@ import com.oracle.graal.compiler.common.*; import com.oracle.graal.graph.Node.ConstantNodeParameter; import com.oracle.graal.graph.Node.NodeIntrinsic; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.word.*; import com.oracle.graal.nodes.extended.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotSubstitutions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotSubstitutions.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotSubstitutions.java Tue May 19 23:16:07 2015 +0200 @@ -29,7 +29,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.api.runtime.*; -import com.oracle.graal.hotspot.bridge.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.replacements.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HubGetClassNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HubGetClassNode.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HubGetClassNode.java Tue May 19 23:16:07 2015 +0200 @@ -26,7 +26,7 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.word.*; import com.oracle.graal.nodeinfo.*; import com.oracle.graal.nodes.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/IdentityHashCodeNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/IdentityHashCodeNode.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/IdentityHashCodeNode.java Tue May 19 23:16:07 2015 +0200 @@ -26,7 +26,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.nodeinfo.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.CallTargetNode.InvokeKind; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Tue May 19 23:16:07 2015 +0200 @@ -33,6 +33,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.type.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.nodes.type.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/KlassLayoutHelperNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/KlassLayoutHelperNode.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/KlassLayoutHelperNode.java Tue May 19 23:16:07 2015 +0200 @@ -26,8 +26,7 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.nodeinfo.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Tue May 19 23:16:07 2015 +0200 @@ -41,6 +41,7 @@ import com.oracle.graal.graph.Node.ConstantNodeParameter; import com.oracle.graal.graph.Node.NodeIntrinsic; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.nodes.type.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java Tue May 19 23:16:07 2015 +0200 @@ -26,7 +26,7 @@ import com.oracle.graal.compiler.common.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.nodeinfo.*; import com.oracle.graal.nodes.CallTargetNode.InvokeKind; import com.oracle.graal.nodes.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/TypeCheckSnippetUtils.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/TypeCheckSnippetUtils.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/TypeCheckSnippetUtils.java Tue May 19 23:16:07 2015 +0200 @@ -30,7 +30,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.hotspot.word.*; import com.oracle.graal.nodes.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java Tue May 19 23:16:07 2015 +0200 @@ -33,7 +33,7 @@ import com.oracle.graal.compiler.common.*; import com.oracle.graal.graph.Node.ConstantNodeParameter; import com.oracle.graal.graph.Node.NodeIntrinsic; -import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.nodes.type.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/DeoptimizationStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/DeoptimizationStub.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/DeoptimizationStub.java Tue May 19 23:16:07 2015 +0200 @@ -36,6 +36,7 @@ import com.oracle.graal.graph.Node.ConstantNodeParameter; import com.oracle.graal.graph.Node.NodeIntrinsic; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.replacements.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java Tue May 19 23:16:07 2015 +0200 @@ -33,6 +33,7 @@ import com.oracle.graal.graph.Node.ConstantNodeParameter; import com.oracle.graal.graph.Node.NodeIntrinsic; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.replacements.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Tue May 19 23:16:07 2015 +0200 @@ -30,6 +30,7 @@ import com.oracle.graal.debug.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.HotSpotForeignCallLinkage.Transition; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.replacements.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Tue May 19 23:16:07 2015 +0200 @@ -33,6 +33,7 @@ import com.oracle.graal.graph.Node.ConstantNodeParameter; import com.oracle.graal.graph.Node.NodeIntrinsic; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.nodes.type.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Tue May 19 23:16:07 2015 +0200 @@ -33,6 +33,7 @@ import com.oracle.graal.graph.Node.ConstantNodeParameter; import com.oracle.graal.graph.Node.NodeIntrinsic; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.nodes.type.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Tue May 19 23:16:07 2015 +0200 @@ -35,6 +35,7 @@ import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.debug.internal.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.lir.asm.*; @@ -191,7 +192,7 @@ try (Scope s = Debug.scope("CodeInstall")) { Stub stub = Stub.this; HotSpotRuntimeStub installedCode = new HotSpotRuntimeStub(stub); - HotSpotCompiledCode hsCompResult = new HotSpotCompiledRuntimeStub(stub, compResult); + HotSpotCompiledCode hsCompResult = new HotSpotCompiledRuntimeStub(compResult); HotSpotGraalRuntime runtime = runtime(); int result = runtime.getCompilerToVM().installCode(hsCompResult, installedCode, null); diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64OptimizedCallTargetInstrumentationFactory.java --- a/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64OptimizedCallTargetInstrumentationFactory.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64OptimizedCallTargetInstrumentationFactory.java Tue May 19 23:16:07 2015 +0200 @@ -30,7 +30,7 @@ import com.oracle.graal.asm.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.framemap.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.truffle.hotspot.sparc/src/com/oracle/graal/truffle/hotspot/sparc/SPARCOptimizedCallTargetInstumentationFactory.java --- a/graal/com.oracle.graal.truffle.hotspot.sparc/src/com/oracle/graal/truffle/hotspot/sparc/SPARCOptimizedCallTargetInstumentationFactory.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot.sparc/src/com/oracle/graal/truffle/hotspot/sparc/SPARCOptimizedCallTargetInstumentationFactory.java Tue May 19 23:16:07 2015 +0200 @@ -36,7 +36,7 @@ import com.oracle.graal.asm.*; import com.oracle.graal.asm.sparc.*; import com.oracle.graal.asm.sparc.SPARCMacroAssembler.ScratchRegister; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.framemap.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java --- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Tue May 19 23:16:07 2015 +0200 @@ -44,6 +44,7 @@ import com.oracle.graal.graphbuilderconf.*; import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.java.*; import com.oracle.graal.lir.asm.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/OptimizedCallTargetInstrumentation.java --- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/OptimizedCallTargetInstrumentation.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/OptimizedCallTargetInstrumentation.java Tue May 19 23:16:07 2015 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.asm.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.framemap.*; diff -r b3f1d8b23037 -r 1da7aef31a08 graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/HotSpotNativeFunctionInterface.java --- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/HotSpotNativeFunctionInterface.java Tue May 26 16:46:25 2015 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/HotSpotNativeFunctionInterface.java Tue May 19 23:16:07 2015 +0200 @@ -33,7 +33,7 @@ import com.oracle.graal.compiler.target.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.phases.*; diff -r b3f1d8b23037 -r 1da7aef31a08 src/share/vm/classfile/classFileParser.cpp --- a/src/share/vm/classfile/classFileParser.cpp Tue May 26 16:46:25 2015 +0200 +++ b/src/share/vm/classfile/classFileParser.cpp Tue May 19 23:16:07 2015 +0200 @@ -1792,7 +1792,7 @@ if (!privileged) break; // only allow in privileged code return _method_LambdaForm_Hidden; #ifdef GRAAL - case vmSymbols::VM_SYMBOL_ENUM_NAME(com_oracle_graal_hotspot_Stable_signature): + case vmSymbols::VM_SYMBOL_ENUM_NAME(com_oracle_graal_hotspot_jvmci_Stable_signature): if (_location != _in_field) break; // only allow for fields if (!privileged && loader_data->class_loader() != SystemDictionary::graal_loader()) break; // only allow in privileged code return _field_Stable; diff -r b3f1d8b23037 -r 1da7aef31a08 src/share/vm/classfile/systemDictionary.hpp --- a/src/share/vm/classfile/systemDictionary.hpp Tue May 26 16:46:25 2015 +0200 +++ b/src/share/vm/classfile/systemDictionary.hpp Tue May 19 23:16:07 2015 +0200 @@ -200,21 +200,20 @@ do_klass(BitSet_klass, java_util_BitSet, Opt ) \ /* Graal classes. These are loaded on-demand. */ \ GRAAL_ONLY(do_klass(Debug_klass, com_oracle_graal_debug_Debug, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotCompiledCode_klass, com_oracle_graal_hotspot_HotSpotCompiledCode, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotCompiledCode_Comment_klass, com_oracle_graal_hotspot_HotSpotCompiledCode_Comment, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotCompiledNmethod_klass, com_oracle_graal_hotspot_HotSpotCompiledNmethod, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotCompiledRuntimeStub_klass, com_oracle_graal_hotspot_HotSpotCompiledRuntimeStub, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotForeignCallLinkageImpl_klass, com_oracle_graal_hotspot_HotSpotForeignCallLinkageImpl, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotReferenceMap_klass, com_oracle_graal_hotspot_HotSpotReferenceMap, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotOopMap_klass, com_oracle_graal_hotspot_HotSpotReferenceMap_HotSpotOopMap, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotInstalledCode_klass, com_oracle_graal_hotspot_meta_HotSpotInstalledCode, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotNmethod_klass, com_oracle_graal_hotspot_meta_HotSpotNmethod, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotResolvedJavaMethodImpl_klass, com_oracle_graal_hotspot_meta_HotSpotResolvedJavaMethodImpl, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotResolvedObjectTypeImpl_klass, com_oracle_graal_hotspot_meta_HotSpotResolvedObjectTypeImpl, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotCompressedNullConstant_klass, com_oracle_graal_hotspot_meta_HotSpotCompressedNullConstant, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotObjectConstantImpl_klass, com_oracle_graal_hotspot_meta_HotSpotObjectConstantImpl, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotMetaspaceConstantImpl_klass, com_oracle_graal_hotspot_meta_HotSpotMetaspaceConstantImpl, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotStackFrameReference_klass, com_oracle_graal_hotspot_HotSpotStackFrameReference, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotCompiledCode_klass, com_oracle_graal_hotspot_jvmci_HotSpotCompiledCode, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotCompiledCode_Comment_klass, com_oracle_graal_hotspot_jvmci_HotSpotCompiledCode_Comment, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotCompiledNmethod_klass, com_oracle_graal_hotspot_jvmci_HotSpotCompiledNmethod, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotForeignCallTarget_klass, com_oracle_graal_hotspot_jvmci_HotSpotForeignCallTarget, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotReferenceMap_klass, com_oracle_graal_hotspot_jvmci_HotSpotReferenceMap, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotOopMap_klass, com_oracle_graal_hotspot_jvmci_HotSpotReferenceMap_HotSpotOopMap, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotInstalledCode_klass, com_oracle_graal_hotspot_jvmci_HotSpotInstalledCode, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotNmethod_klass, com_oracle_graal_hotspot_jvmci_HotSpotNmethod, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotResolvedJavaMethodImpl_klass, com_oracle_graal_hotspot_jvmci_HotSpotResolvedJavaMethodImpl, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotResolvedObjectTypeImpl_klass, com_oracle_graal_hotspot_jvmci_HotSpotResolvedObjectTypeImpl, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotCompressedNullConstant_klass, com_oracle_graal_hotspot_jvmci_HotSpotCompressedNullConstant, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotObjectConstantImpl_klass, com_oracle_graal_hotspot_jvmci_HotSpotObjectConstantImpl, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotMetaspaceConstantImpl_klass, com_oracle_graal_hotspot_jvmci_HotSpotMetaspaceConstantImpl, Graal)) \ + GRAAL_ONLY(do_klass(HotSpotStackFrameReference_klass, com_oracle_graal_hotspot_jvmci_HotSpotStackFrameReference, Graal)) \ GRAAL_ONLY(do_klass(CompilationTask_klass, com_oracle_graal_hotspot_CompilationTask, Graal)) \ GRAAL_ONLY(do_klass(Assumptions_ConcreteMethod_klass, com_oracle_graal_api_meta_Assumptions_ConcreteMethod, Graal)) \ GRAAL_ONLY(do_klass(Assumptions_NoFinalizableSubclass_klass, com_oracle_graal_api_meta_Assumptions_NoFinalizableSubclass, Graal))\ diff -r b3f1d8b23037 -r 1da7aef31a08 src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Tue May 26 16:46:25 2015 +0200 +++ b/src/share/vm/classfile/vmSymbols.hpp Tue May 19 23:16:07 2015 +0200 @@ -300,24 +300,23 @@ \ /* Support for Graal */ \ template(java_util_BitSet, "java/util/BitSet") \ - GRAAL_ONLY(template(com_oracle_graal_debug_Debug, "com/oracle/graal/debug/Debug")) \ + GRAAL_ONLY(template(com_oracle_graal_debug_Debug, "com/oracle/graal/debug/Debug")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotCompiledCode, "com/oracle/graal/hotspot/jvmci/HotSpotCompiledCode")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotCompiledCode_Comment, "com/oracle/graal/hotspot/jvmci/HotSpotCompiledCode$Comment")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotCompiledNmethod, "com/oracle/graal/hotspot/jvmci/HotSpotCompiledNmethod")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotForeignCallTarget, "com/oracle/graal/hotspot/jvmci/HotSpotForeignCallTarget")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotReferenceMap, "com/oracle/graal/hotspot/jvmci/HotSpotReferenceMap")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotReferenceMap_HotSpotOopMap, "com/oracle/graal/hotspot/jvmci/HotSpotReferenceMap$HotSpotOopMap"))\ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_CompilerToVMImpl, "com/oracle/graal/hotspot/jvmci/CompilerToVMImpl")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotInstalledCode, "com/oracle/graal/hotspot/jvmci/HotSpotInstalledCode")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotNmethod, "com/oracle/graal/hotspot/jvmci/HotSpotNmethod")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotResolvedJavaMethodImpl, "com/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaMethodImpl")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotResolvedObjectTypeImpl, "com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectTypeImpl")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotCompressedNullConstant, "com/oracle/graal/hotspot/jvmci/HotSpotCompressedNullConstant")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotObjectConstantImpl, "com/oracle/graal/hotspot/jvmci/HotSpotObjectConstantImpl")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotMetaspaceConstantImpl, "com/oracle/graal/hotspot/jvmci/HotSpotMetaspaceConstantImpl")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotStackFrameReference, "com/oracle/graal/hotspot/jvmci/HotSpotStackFrameReference")) \ GRAAL_ONLY(template(com_oracle_graal_hotspot_HotSpotGraalRuntime, "com/oracle/graal/hotspot/HotSpotGraalRuntime")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_HotSpotCompiledCode, "com/oracle/graal/hotspot/HotSpotCompiledCode")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_HotSpotCompiledCode_Comment, "com/oracle/graal/hotspot/HotSpotCompiledCode$Comment")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_HotSpotCompiledNmethod, "com/oracle/graal/hotspot/HotSpotCompiledNmethod")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_HotSpotCompiledRuntimeStub, "com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_HotSpotForeignCallLinkageImpl, "com/oracle/graal/hotspot/HotSpotForeignCallLinkageImpl")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_HotSpotReferenceMap, "com/oracle/graal/hotspot/HotSpotReferenceMap")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_HotSpotReferenceMap_HotSpotOopMap, "com/oracle/graal/hotspot/HotSpotReferenceMap$HotSpotOopMap")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_bridge_CompilerToVMImpl, "com/oracle/graal/hotspot/bridge/CompilerToVMImpl")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotInstalledCode, "com/oracle/graal/hotspot/meta/HotSpotInstalledCode")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotNmethod, "com/oracle/graal/hotspot/meta/HotSpotNmethod")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotResolvedJavaMethodImpl, "com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethodImpl")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotResolvedObjectTypeImpl, "com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotCompressedNullConstant, "com/oracle/graal/hotspot/meta/HotSpotCompressedNullConstant")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotObjectConstantImpl, "com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_meta_HotSpotMetaspaceConstantImpl,"com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstantImpl")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_HotSpotStackFrameReference, "com/oracle/graal/hotspot/HotSpotStackFrameReference")) \ GRAAL_ONLY(template(com_oracle_graal_hotspot_CompilationTask, "com/oracle/graal/hotspot/CompilationTask")) \ GRAAL_ONLY(template(com_oracle_graal_api_meta_JavaConstant, "com/oracle/graal/api/meta/JavaConstant")) \ GRAAL_ONLY(template(com_oracle_graal_api_meta_PrimitiveConstant, "com/oracle/graal/api/meta/PrimitiveConstant")) \ @@ -357,10 +356,10 @@ GRAAL_ONLY(template(com_oracle_graal_api_code_RegisterSaveLayout, "com/oracle/graal/api/code/RegisterSaveLayout")) \ GRAAL_ONLY(template(com_oracle_graal_api_code_InvalidInstalledCodeException, "com/oracle/graal/api/code/InvalidInstalledCodeException")) \ GRAAL_ONLY(template(com_oracle_graal_api_code_SpeculationLog, "com/oracle/graal/api/code/SpeculationLog")) \ - GRAAL_ONLY(template(compileMetaspaceMethod_name, "compileMetaspaceMethod")) \ - GRAAL_ONLY(template(compileMetaspaceMethod_signature, "(JIJI)V")) \ - GRAAL_ONLY(template(graal_mirror_name, "graal_mirror")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_Stable_signature, "Lcom/oracle/graal/hotspot/Stable;")) \ + GRAAL_ONLY(template(compileMetaspaceMethod_name, "compileMetaspaceMethod")) \ + GRAAL_ONLY(template(compileMetaspaceMethod_signature, "(JIJI)V")) \ + GRAAL_ONLY(template(graal_mirror_name, "graal_mirror")) \ + GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_Stable_signature, "Lcom/oracle/graal/hotspot/jvmci/Stable;")) \ \ /* common method and field names */ \ template(object_initializer_name, "") \ diff -r b3f1d8b23037 -r 1da7aef31a08 src/share/vm/graal/graalCodeInstaller.cpp --- a/src/share/vm/graal/graalCodeInstaller.cpp Tue May 26 16:46:25 2015 +0200 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Tue May 19 23:16:07 2015 +0200 @@ -450,8 +450,8 @@ int stack_slots = _total_frame_size / HeapWordSize; // conversion to words GraalEnv::CodeInstallResult result; - if (compiled_code->is_a(HotSpotCompiledRuntimeStub::klass())) { - oop stubName = HotSpotCompiledRuntimeStub::stubName(compiled_code); + if (!compiled_code->is_a(HotSpotCompiledNmethod::klass())) { + oop stubName = CompilationResult::name(HotSpotCompiledCode::comp(compiled_code_obj)); char* name = strdup(java_lang_String::as_utf8_string(stubName)); cb = RuntimeStub::new_runtime_stub(name, &buffer, @@ -490,7 +490,7 @@ _parameter_count = method->size_of_parameters(); TRACE_graal_1("installing code for %s", method->name_and_sig_as_C_string()); } else { - assert(compiled_code->is_a(HotSpotCompiledRuntimeStub::klass()), "CCE"); + // Must be a HotSpotCompiledRuntimeStub // TODO (ds) not sure if this is correct - only used in OopMap constructor for non-product builds _parameter_count = 0; } @@ -878,7 +878,7 @@ oop hotspot_method = NULL; // JavaMethod oop foreign_call = NULL; - if (target_klass->is_subclass_of(SystemDictionary::HotSpotForeignCallLinkageImpl_klass())) { + if (target_klass->is_subclass_of(SystemDictionary::HotSpotForeignCallTarget_klass())) { foreign_call = target; } else { hotspot_method = target; @@ -897,7 +897,7 @@ } if (foreign_call != NULL) { - jlong foreign_call_destination = HotSpotForeignCallLinkageImpl::address(foreign_call); + jlong foreign_call_destination = HotSpotForeignCallTarget::address(foreign_call); CodeInstaller::pd_relocate_ForeignCall(inst, foreign_call_destination); } else { // method != NULL assert(hotspot_method != NULL, "unexpected JavaMethod"); diff -r b3f1d8b23037 -r 1da7aef31a08 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Tue May 26 16:46:25 2015 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Tue May 19 23:16:07 2015 +0200 @@ -1040,12 +1040,12 @@ #define OBJECT "Ljava/lang/Object;" #define CLASS "Ljava/lang/Class;" #define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;" -#define HS_RESOLVED_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod;" +#define HS_RESOLVED_METHOD "Lcom/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaMethod;" #define RESOLVED_METHOD "Lcom/oracle/graal/api/meta/ResolvedJavaMethod;" -#define HS_COMPILED_CODE "Lcom/oracle/graal/hotspot/HotSpotCompiledCode;" -#define HS_CONFIG "Lcom/oracle/graal/hotspot/HotSpotVMConfig;" +#define HS_COMPILED_CODE "Lcom/oracle/graal/hotspot/jvmci/HotSpotCompiledCode;" +#define HS_CONFIG "Lcom/oracle/graal/hotspot/jvmci/HotSpotVMConfig;" #define INSTALLED_CODE "Lcom/oracle/graal/api/code/InstalledCode;" -#define HS_STACK_FRAME_REF "Lcom/oracle/graal/hotspot/HotSpotStackFrameReference;" +#define HS_STACK_FRAME_REF "Lcom/oracle/graal/hotspot/jvmci/HotSpotStackFrameReference;" #define METASPACE_KLASS "J" #define METASPACE_METHOD "J" #define METASPACE_METHOD_DATA "J" diff -r b3f1d8b23037 -r 1da7aef31a08 src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Tue May 26 16:46:25 2015 +0200 +++ b/src/share/vm/graal/graalJavaAccess.hpp Tue May 19 23:16:07 2015 +0200 @@ -48,11 +48,11 @@ */ #define COMPILER_CLASSES_DO(start_class, end_class, char_field, int_field, boolean_field, long_field, float_field, oop_field, typeArrayOop_field, objArrayOop_field, static_oop_field, static_int_field, static_boolean_field) \ - start_class(HotSpotResolvedObjectTypeImpl) \ - oop_field(HotSpotResolvedObjectTypeImpl, javaClass, "Ljava/lang/Class;") \ + start_class(HotSpotResolvedObjectTypeImpl) \ + oop_field(HotSpotResolvedObjectTypeImpl, javaClass, "Ljava/lang/Class;") \ end_class \ - start_class(HotSpotResolvedJavaMethodImpl) \ - long_field(HotSpotResolvedJavaMethodImpl, metaspaceMethod) \ + start_class(HotSpotResolvedJavaMethodImpl) \ + long_field(HotSpotResolvedJavaMethodImpl, metaspaceMethod) \ end_class \ start_class(InstalledCode) \ long_field(InstalledCode, address) \ @@ -71,7 +71,7 @@ oop_field(HotSpotCompiledCode, comp, "Lcom/oracle/graal/api/code/CompilationResult;") \ objArrayOop_field(HotSpotCompiledCode, sites, "[Lcom/oracle/graal/api/code/CompilationResult$Site;") \ objArrayOop_field(HotSpotCompiledCode, exceptionHandlers, "[Lcom/oracle/graal/api/code/CompilationResult$ExceptionHandler;") \ - objArrayOop_field(HotSpotCompiledCode, comments, "[Lcom/oracle/graal/hotspot/HotSpotCompiledCode$Comment;") \ + objArrayOop_field(HotSpotCompiledCode, comments, "[Lcom/oracle/graal/hotspot/jvmci/HotSpotCompiledCode$Comment;") \ typeArrayOop_field(HotSpotCompiledCode, dataSection, "[B") \ int_field(HotSpotCompiledCode, dataSectionAlignment) \ objArrayOop_field(HotSpotCompiledCode, dataSectionPatches, "[Lcom/oracle/graal/api/code/CompilationResult$DataPatch;") \ @@ -81,21 +81,19 @@ int_field(HotSpotCompiledCode_Comment, pcOffset) \ end_class \ start_class(HotSpotCompiledNmethod) \ - oop_field(HotSpotCompiledNmethod, method, "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod;") \ + oop_field(HotSpotCompiledNmethod, method, "Lcom/oracle/graal/hotspot/jvmci/HotSpotResolvedJavaMethod;") \ oop_field(HotSpotCompiledNmethod, installationFailureMessage, "Ljava/lang/String;") \ int_field(HotSpotCompiledNmethod, entryBCI) \ int_field(HotSpotCompiledNmethod, id) \ long_field(HotSpotCompiledNmethod, graalEnv) \ end_class \ - start_class(HotSpotCompiledRuntimeStub) \ - oop_field(HotSpotCompiledRuntimeStub, stubName, "Ljava/lang/String;") \ - end_class \ - start_class(HotSpotForeignCallLinkageImpl) \ - long_field(HotSpotForeignCallLinkageImpl, address) \ + start_class(HotSpotForeignCallTarget) \ + long_field(HotSpotForeignCallTarget, address) \ end_class \ start_class(CompilationResult) \ int_field(CompilationResult, totalFrameSize) \ int_field(CompilationResult, customStackAreaOffset) \ + oop_field(CompilationResult, name, "Ljava/lang/String;") \ typeArrayOop_field(CompilationResult, targetCode, "[B") \ objArrayOop_field(CompilationResult, assumptions, "[Lcom/oracle/graal/api/meta/Assumptions$Assumption;") \ objArrayOop_field(CompilationResult, methods, "[Lcom/oracle/graal/api/meta/ResolvedJavaMethod;") \ @@ -162,8 +160,8 @@ objArrayOop_field(DebugInfo, virtualObjectMapping, "[Lcom/oracle/graal/api/meta/Value;") \ end_class \ start_class(HotSpotReferenceMap) \ - oop_field(HotSpotReferenceMap, registerRefMap, "Lcom/oracle/graal/hotspot/HotSpotReferenceMap$HotSpotOopMap;") \ - oop_field(HotSpotReferenceMap, frameRefMap, "Lcom/oracle/graal/hotspot/HotSpotReferenceMap$HotSpotOopMap;") \ + oop_field(HotSpotReferenceMap, registerRefMap, "Lcom/oracle/graal/hotspot/jvmci/HotSpotReferenceMap$HotSpotOopMap;") \ + oop_field(HotSpotReferenceMap, frameRefMap, "Lcom/oracle/graal/hotspot/jvmci/HotSpotReferenceMap$HotSpotOopMap;") \ end_class \ start_class(RegisterSaveLayout) \ objArrayOop_field(RegisterSaveLayout, registers, "[Lcom/oracle/graal/api/code/Register;") \ @@ -256,7 +254,7 @@ oop_field(SpeculationLog, lastFailed, "Ljava/lang/Object;") \ end_class \ start_class(HotSpotStackFrameReference) \ - oop_field(HotSpotStackFrameReference, compilerToVM, "Lcom/oracle/graal/hotspot/bridge/CompilerToVM;") \ + oop_field(HotSpotStackFrameReference, compilerToVM, "Lcom/oracle/graal/hotspot/jvmci/CompilerToVM;") \ long_field(HotSpotStackFrameReference, stackPointer) \ int_field(HotSpotStackFrameReference, frameNumber) \ int_field(HotSpotStackFrameReference, bci) \ diff -r b3f1d8b23037 -r 1da7aef31a08 src/share/vm/graal/graalRuntime.cpp --- a/src/share/vm/graal/graalRuntime.cpp Tue May 26 16:46:25 2015 +0200 +++ b/src/share/vm/graal/graalRuntime.cpp Tue May 19 23:16:07 2015 +0200 @@ -782,7 +782,7 @@ // We now load and initialize HotSpotOptions which in turn // causes argument parsing to be redone with better error messages. CLEAR_PENDING_EXCEPTION; - TempNewSymbol name = SymbolTable::new_symbol("Lcom/oracle/graal/hotspot/HotSpotOptions;", CHECK_ABORT_(JNI_ERR)); + TempNewSymbol name = SymbolTable::new_symbol("Lcom/oracle/graal/hotspot/jvmci/HotSpotOptions;", CHECK_ABORT_(JNI_ERR)); instanceKlassHandle hotSpotOptionsClass = resolve_or_fail(name, CHECK_ABORT_(JNI_ERR)); parse_arguments(hotSpotOptionsClass, THREAD); diff -r b3f1d8b23037 -r 1da7aef31a08 src/share/vm/prims/nativeLookup.cpp --- a/src/share/vm/prims/nativeLookup.cpp Tue May 26 16:46:25 2015 +0200 +++ b/src/share/vm/prims/nativeLookup.cpp Tue May 19 23:16:07 2015 +0200 @@ -154,8 +154,8 @@ { CC"Java_com_oracle_graal_api_runtime_Services_getServiceImpls", NULL, FN_PTR(JVM_GetGraalServiceImpls) }, { CC"Java_com_oracle_truffle_api_Truffle_createRuntime", NULL, FN_PTR(JVM_CreateTruffleRuntime) }, { CC"Java_com_oracle_nfi_NativeFunctionInterfaceRuntime_createInterface", NULL, FN_PTR(JVM_CreateNativeFunctionInterface) }, - { CC"Java_com_oracle_graal_hotspot_bridge_CompilerToVMImpl_init", NULL, FN_PTR(JVM_InitializeGraalNatives) }, - { CC"Java_com_oracle_graal_hotspot_HotSpotOptions_parseVMOptions", NULL, FN_PTR(JVM_ParseGraalOptions) }, + { CC"Java_com_oracle_graal_hotspot_jvmci_CompilerToVMImpl_init", NULL, FN_PTR(JVM_InitializeGraalNatives) }, + { CC"Java_com_oracle_graal_hotspot_jvmci_HotSpotOptions_parseVMOptions", NULL, FN_PTR(JVM_ParseGraalOptions) }, #endif };