# HG changeset patch # User Doug Simon # Date 1401291719 -7200 # Node ID 42eaa579e134aea6bd12ef13b4ab731910f3967d # Parent 9a7803400ba7d3e5700ea6b7dcb9a9830e6f3e58 more improvements to runtime initialization: - replaced HotSpotSymbol with native method for reading a symbol - moved more ForeignCallDescriptors to HotSpotBackend to reduce class initialization diff -r 9a7803400ba7 -r 42eaa579e134 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotEnterUnpackFramesStackFrameOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotEnterUnpackFramesStackFrameOp.java Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotEnterUnpackFramesStackFrameOp.java Wed May 28 17:41:59 2014 +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.stubs.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.*; import com.oracle.graal.lir.amd64.*; @@ -37,7 +37,7 @@ /** * Emits code that enters a stack frame which is tailored to call the C++ method - * {@link DeoptimizationStub#UNPACK_FRAMES Deoptimization::unpack_frames}. + * {@link HotSpotBackend#UNPACK_FRAMES Deoptimization::unpack_frames}. */ @Opcode("ENTER_UNPACK_FRAMES_STACK_FRAME") final class AMD64HotSpotEnterUnpackFramesStackFrameOp extends AMD64LIRInstruction { diff -r 9a7803400ba7 -r 42eaa579e134 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 Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Wed May 28 17:41:59 2014 +0200 @@ -42,7 +42,6 @@ import com.oracle.graal.hotspot.amd64.AMD64HotSpotMove.HotSpotStoreConstantOp; import com.oracle.graal.hotspot.data.*; import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.nodes.type.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.*; @@ -323,7 +322,7 @@ } public Value emitDeoptimizationFetchUnrollInfoCall(SaveRegistersOp saveRegisterOp) { - ForeignCallLinkage linkage = getForeignCalls().lookupForeignCall(DeoptimizationFetchUnrollInfoCallNode.FETCH_UNROLL_INFO); + ForeignCallLinkage linkage = getForeignCalls().lookupForeignCall(FETCH_UNROLL_INFO); Register thread = getProviders().getRegisters().getThreadRegister(); append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread)); diff -r 9a7803400ba7 -r 42eaa579e134 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLeaveUnpackFramesStackFrameOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLeaveUnpackFramesStackFrameOp.java Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLeaveUnpackFramesStackFrameOp.java Wed May 28 17:41:59 2014 +0200 @@ -25,7 +25,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.hotspot.stubs.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.*; import com.oracle.graal.lir.amd64.*; @@ -33,7 +33,7 @@ /** * Emits code that leaves a stack frame which is tailored to call the C++ method - * {@link DeoptimizationStub#UNPACK_FRAMES Deoptimization::unpack_frames}. + * {@link HotSpotBackend#UNPACK_FRAMES Deoptimization::unpack_frames}. */ @Opcode("LEAVE_UNPACK_FRAMES_STACK_FRAME") final class AMD64HotSpotLeaveUnpackFramesStackFrameOp extends AMD64LIRInstruction { diff -r 9a7803400ba7 -r 42eaa579e134 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotEnterUnpackFramesStackFrameOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotEnterUnpackFramesStackFrameOp.java Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotEnterUnpackFramesStackFrameOp.java Wed May 28 17:41:59 2014 +0200 @@ -30,14 +30,14 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.sparc.*; -import com.oracle.graal.hotspot.stubs.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.sparc.*; import com.oracle.graal.lir.asm.*; /** * Emits code that enters a stack frame which is tailored to call the C++ method - * {@link DeoptimizationStub#UNPACK_FRAMES Deoptimization::unpack_frames}. + * {@link HotSpotBackend#UNPACK_FRAMES Deoptimization::unpack_frames}. */ @Opcode("ENTER_UNPACK_FRAMES_STACK_FRAME") final class SPARCHotSpotEnterUnpackFramesStackFrameOp extends SPARCLIRInstruction { diff -r 9a7803400ba7 -r 42eaa579e134 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLeaveUnpackFramesStackFrameOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLeaveUnpackFramesStackFrameOp.java Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLeaveUnpackFramesStackFrameOp.java Wed May 28 17:41:59 2014 +0200 @@ -27,14 +27,14 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.asm.sparc.*; -import com.oracle.graal.hotspot.stubs.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.sparc.*; import com.oracle.graal.lir.asm.*; /** * Emits code that leaves a stack frame which is tailored to call the C++ method - * {@link DeoptimizationStub#UNPACK_FRAMES Deoptimization::unpack_frames}. + * {@link HotSpotBackend#UNPACK_FRAMES Deoptimization::unpack_frames}. */ @Opcode("LEAVE_UNPACK_FRAMES_STACK_FRAME") final class SPARCHotSpotLeaveUnpackFramesStackFrameOp extends SPARCLIRInstruction { diff -r 9a7803400ba7 -r 42eaa579e134 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 Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java Wed May 28 17:41:59 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot; +import static com.oracle.graal.hotspot.stubs.StubUtil.*; + import java.util.*; import com.oracle.graal.api.code.*; @@ -72,6 +74,16 @@ private final HotSpotGraalRuntime runtime; /** + * @see DeoptimizationFetchUnrollInfoCallNode + */ + public static final ForeignCallDescriptor FETCH_UNROLL_INFO = newDescriptor(DeoptimizationStub.class, "fetchUnrollInfo", Word.class, Word.class); + + /** + * @see DeoptimizationStub#unpackFrames(ForeignCallDescriptor, Word, int) + */ + public static final ForeignCallDescriptor UNPACK_FRAMES = newDescriptor(DeoptimizationStub.class, "unpackFrames", int.class, Word.class, int.class); + + /** * @see AESCryptSubstitutions#encryptBlockStub(ForeignCallDescriptor, Word, Word, Word) */ public static final ForeignCallDescriptor ENCRYPT_BLOCK = new ForeignCallDescriptor("encrypt_block", void.class, Word.class, Word.class, Word.class); diff -r 9a7803400ba7 -r 42eaa579e134 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotSymbol.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotSymbol.java Wed May 28 15:51:21 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +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 static com.oracle.graal.compiler.common.UnsafeAccess.*; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; - -import java.io.*; - -import com.oracle.graal.compiler.common.*; - -/** - * Represents a metaspace {@code Symbol}. - */ -public class HotSpotSymbol { - - private final long metaspaceSymbol; - - public HotSpotSymbol(long metaspaceSymbol) { - assert metaspaceSymbol != 0; - this.metaspaceSymbol = metaspaceSymbol; - } - - /** - * Decodes this {@code Symbol} and returns the symbol string as {@link java.lang.String}. - */ - public String asString() { - return readModifiedUTF8(asByteArray()); - } - - private static String readModifiedUTF8(byte[] buf) { - try { - final int length = buf.length; - byte[] tmp = new byte[length + 2]; - // write modified UTF-8 length as short in big endian - tmp[0] = (byte) ((length >>> 8) & 0xFF); - tmp[1] = (byte) ((length >>> 0) & 0xFF); - // copy the data - System.arraycopy(buf, 0, tmp, 2, length); - DataInputStream dis = new DataInputStream(new ByteArrayInputStream(tmp)); - return dis.readUTF(); - } catch (IOException e) { - // This should never happen so let's fail hard here. - throw GraalInternalError.shouldNotReachHere("error reading symbol: " + e); - } - } - - private byte[] asByteArray() { - final int length = getLength(); - byte[] result = new byte[length]; - for (int index = 0; index < length; index++) { - result[index] = getByteAt(index); - } - return result; - } - - private int getLength() { - return unsafe.getShort(metaspaceSymbol + runtime().getConfig().symbolLengthOffset); - } - - private byte getByteAt(int index) { - return unsafe.getByte(metaspaceSymbol + runtime().getConfig().symbolBodyOffset + index); - } -} diff -r 9a7803400ba7 -r 42eaa579e134 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 Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVmSymbols.java Wed May 28 17:41:59 2014 +0200 @@ -32,17 +32,17 @@ public final class HotSpotVmSymbols { /** - * Returns the {@link HotSpotSymbol} in the {@code vmSymbols} table at position {@code index} as - * {@link String}. - * + * Returns the symbol in the {@code vmSymbols} table at position {@code index} as {@link String} + * . + * * @param index position in the symbol table * @return the symbol at position id */ public static String symbolAt(int index) { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotGraalRuntime runtime = runtime(); + HotSpotVMConfig config = runtime.getConfig(); assert config.vmSymbolsFirstSID <= index && index < config.vmSymbolsSIDLimit : "index " + index + " is out of bounds"; assert config.symbolPointerSize == Unsafe.ADDRESS_SIZE : "the following address read is broken"; - final long metaspaceSymbol = unsafe.getAddress(config.vmSymbolsSymbols + index * config.symbolPointerSize); - return new HotSpotSymbol(metaspaceSymbol).asString(); + return runtime.getCompilerToVM().getSymbol(unsafe.getAddress(config.vmSymbolsSymbols + index * config.symbolPointerSize)); } } diff -r 9a7803400ba7 -r 42eaa579e134 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 Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Wed May 28 17:41:59 2014 +0200 @@ -123,9 +123,9 @@ int lookupNameAndTypeRefIndexInPool(long metaspaceConstantPool, int cpi); - long lookupNameRefInPool(long metaspaceConstantPool, int cpi); + String lookupNameRefInPool(long metaspaceConstantPool, int cpi); - long lookupSignatureRefInPool(long metaspaceConstantPool, int cpi); + String lookupSignatureRefInPool(long metaspaceConstantPool, int cpi); int lookupKlassRefIndexInPool(long metaspaceConstantPool, int cpi); @@ -333,6 +333,13 @@ 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 diff -r 9a7803400ba7 -r 42eaa579e134 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 Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Wed May 28 17:41:59 2014 +0200 @@ -71,10 +71,10 @@ public native int lookupNameAndTypeRefIndexInPool(long metaspaceConstantPool, int cpi); @Override - public native long lookupNameRefInPool(long metaspaceConstantPool, int cpi); + public native String lookupNameRefInPool(long metaspaceConstantPool, int cpi); @Override - public native long lookupSignatureRefInPool(long metaspaceConstantPool, int cpi); + public native String lookupSignatureRefInPool(long metaspaceConstantPool, int cpi); @Override public native int lookupKlassRefIndexInPool(long metaspaceConstantPool, int cpi); @@ -181,6 +181,8 @@ 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); diff -r 9a7803400ba7 -r 42eaa579e134 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 Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java Wed May 28 17:41:59 2014 +0200 @@ -256,9 +256,7 @@ * @return name as {@link String} */ private String getNameRefAt(int index) { - final long name = runtime().getCompilerToVM().lookupNameRefInPool(metaspaceConstantPool, index); - HotSpotSymbol symbol = new HotSpotSymbol(name); - return symbol.asString(); + return runtime().getCompilerToVM().lookupNameRefInPool(metaspaceConstantPool, index); } /** @@ -282,9 +280,7 @@ * @return signature as {@link String} */ private String getSignatureRefAt(int index) { - final long name = runtime().getCompilerToVM().lookupSignatureRefInPool(metaspaceConstantPool, index); - HotSpotSymbol symbol = new HotSpotSymbol(name); - return symbol.asString(); + return runtime().getCompilerToVM().lookupSignatureRefInPool(metaspaceConstantPool, index); } /** @@ -383,9 +379,7 @@ @Override public String lookupUtf8(int cpi) { assertTag(cpi, JVM_CONSTANT.Utf8); - final long metaspaceSymbol = getEntryAt(cpi); - HotSpotSymbol symbol = new HotSpotSymbol(metaspaceSymbol); - return symbol.asString(); + return runtime().getCompilerToVM().getSymbol(getEntryAt(cpi)); } @Override @@ -412,10 +406,11 @@ * @param metaspacePointer either a metaspace Klass or a metaspace Symbol */ private static JavaType getJavaType(final long metaspacePointer) { - HotSpotVMConfig config = runtime().getConfig(); + HotSpotGraalRuntime runtime = runtime(); + HotSpotVMConfig config = runtime.getConfig(); if ((metaspacePointer & config.compilerToVMSymbolTag) != 0) { final long metaspaceSymbol = metaspacePointer & ~config.compilerToVMSymbolTag; - String name = new HotSpotSymbol(metaspaceSymbol).asString(); + String name = runtime.getCompilerToVM().getSymbol(metaspaceSymbol); return HotSpotUnresolvedJavaType.create("L" + name + ";"); } else { assert (metaspacePointer & config.compilerToVMKlassTag) == 0; diff -r 9a7803400ba7 -r 42eaa579e134 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 Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java Wed May 28 17:41:59 2014 +0200 @@ -34,7 +34,6 @@ import static com.oracle.graal.hotspot.replacements.SystemSubstitutions.*; import static com.oracle.graal.hotspot.replacements.ThreadSubstitutions.*; import static com.oracle.graal.hotspot.replacements.WriteBarrierSnippets.*; -import static com.oracle.graal.hotspot.stubs.DeoptimizationStub.*; import static com.oracle.graal.hotspot.stubs.ExceptionHandlerStub.*; import static com.oracle.graal.hotspot.stubs.NewArrayStub.*; import static com.oracle.graal.hotspot.stubs.NewInstanceStub.*; diff -r 9a7803400ba7 -r 42eaa579e134 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DeoptimizationFetchUnrollInfoCallNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DeoptimizationFetchUnrollInfoCallNode.java Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DeoptimizationFetchUnrollInfoCallNode.java Wed May 28 17:41:59 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot.nodes; +import static com.oracle.graal.hotspot.HotSpotBackend.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.type.*; @@ -41,7 +43,6 @@ @Input private SaveAllRegistersNode registerSaver; private final ForeignCallsProvider foreignCalls; - public static final ForeignCallDescriptor FETCH_UNROLL_INFO = new ForeignCallDescriptor("fetchUnrollInfo", Word.class, Word.class); public DeoptimizationFetchUnrollInfoCallNode(@InjectedNodeParameter ForeignCallsProvider foreignCalls, ValueNode registerSaver) { super(StampFactory.forKind(Kind.fromJavaClass(FETCH_UNROLL_INFO.getResultType()))); diff -r 9a7803400ba7 -r 42eaa579e134 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/EnterUnpackFramesStackFrameNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/EnterUnpackFramesStackFrameNode.java Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/EnterUnpackFramesStackFrameNode.java Wed May 28 17:41:59 2014 +0200 @@ -25,7 +25,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.StandardOp.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; @@ -33,7 +32,7 @@ /** * Emits code to enter a low-level stack frame specifically to call out to the C++ method - * {@link DeoptimizationStub#UNPACK_FRAMES Deoptimization::unpack_frames}. + * {@link HotSpotBackend#UNPACK_FRAMES Deoptimization::unpack_frames}. */ public class EnterUnpackFramesStackFrameNode extends FixedWithNextNode implements LIRLowerable { diff -r 9a7803400ba7 -r 42eaa579e134 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/LeaveUnpackFramesStackFrameNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/LeaveUnpackFramesStackFrameNode.java Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/LeaveUnpackFramesStackFrameNode.java Wed May 28 17:41:59 2014 +0200 @@ -24,14 +24,13 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.StandardOp.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; /** * Emits code to leave a low-level stack frame specifically to call out to the C++ method - * {@link DeoptimizationStub#UNPACK_FRAMES Deoptimization::unpack_frames}. + * {@link HotSpotBackend#UNPACK_FRAMES Deoptimization::unpack_frames}. */ public class LeaveUnpackFramesStackFrameNode extends FixedWithNextNode implements LIRLowerable { diff -r 9a7803400ba7 -r 42eaa579e134 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 Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/DeoptimizationStub.java Wed May 28 17:41:59 2014 +0200 @@ -22,8 +22,9 @@ */ package com.oracle.graal.hotspot.stubs; +import static com.oracle.graal.hotspot.HotSpotBackend.*; +import static com.oracle.graal.hotspot.nodes.DeoptimizationFetchUnrollInfoCallNode.*; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; -import static com.oracle.graal.hotspot.stubs.StubUtil.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; @@ -111,7 +112,7 @@ final Word thread = registerAsWord(threadRegister); final long registerSaver = SaveAllRegistersNode.saveAllRegisters(); - final Word unrollBlock = DeoptimizationFetchUnrollInfoCallNode.fetchUnrollInfo(registerSaver); + final Word unrollBlock = fetchUnrollInfo(registerSaver); // Pop all the frames we must move/replace. // @@ -271,12 +272,6 @@ return config().deoptimizationUnpackUncommonTrap; } - public static final ForeignCallDescriptor FETCH_UNROLL_INFO = newDescriptor(DeoptimizationStub.class, "fetchUnrollInfo", Word.class, Word.class); - public static final ForeignCallDescriptor UNPACK_FRAMES = newDescriptor(DeoptimizationStub.class, "unpackFrames", int.class, Word.class, int.class); - - @NodeIntrinsic(value = StubForeignCallNode.class, setStampFromReturnType = true) - public static native Word fetchUnrollInfo(@ConstantNodeParameter ForeignCallDescriptor fetchUnrollInfo, Word thread); - @NodeIntrinsic(value = StubForeignCallNode.class, setStampFromReturnType = true) public static native int unpackFrames(@ConstantNodeParameter ForeignCallDescriptor unpackFrames, Word thread, int mode); } diff -r 9a7803400ba7 -r 42eaa579e134 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Wed May 28 15:51:21 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Wed May 28 17:41:59 2014 +0200 @@ -27,6 +27,7 @@ import static com.oracle.graal.compiler.common.GraalOptions.*; import static com.oracle.graal.debug.Debug.*; import static com.oracle.graal.graph.util.CollectionsAccess.*; +import static com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates.*; import static java.util.FormattableFlags.*; import java.io.*; @@ -418,7 +419,6 @@ private static final DebugMetric SnippetTemplates = Debug.metric("SnippetTemplateCount"); private static final String MAX_TEMPLATES_PER_SNIPPET_PROPERTY_NAME = "graal.maxTemplatesPerSnippet"; - private static final boolean UseSnippetTemplateCache = Boolean.parseBoolean(System.getProperty("graal.useSnippetTemplateCache", "true")); private static final int MaxTemplatesPerSnippet = Integer.getInteger(MAX_TEMPLATES_PER_SNIPPET_PROPERTY_NAME, 50); /** @@ -426,6 +426,8 @@ */ public abstract static class AbstractTemplates implements SnippetTemplateCache { + static final boolean UseSnippetTemplateCache = Boolean.parseBoolean(System.getProperty("graal.useSnippetTemplateCache", "true")); + protected final Providers providers; protected final SnippetReflectionProvider snippetReflection; protected final TargetDescription target; @@ -891,7 +893,6 @@ * lowered and the stamp of the snippet's return value. */ public interface UsageReplacer { - /** * Replaces all usages of {@code oldNode} with direct or indirect usages of {@code newNode}. */ diff -r 9a7803400ba7 -r 42eaa579e134 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Wed May 28 15:51:21 2014 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Wed May 28 17:41:59 2014 +0200 @@ -267,14 +267,16 @@ return cp->name_and_type_ref_index_at(index); C2V_END -C2V_VMENTRY(jlong, lookupNameRefInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) +C2V_VMENTRY(jobject, lookupNameRefInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; - return (jlong) (address) cp->name_ref_at(index); + Handle sym = java_lang_String::create_from_symbol(cp->name_ref_at(index), CHECK_NULL); + return JNIHandles::make_local(THREAD, sym()); C2V_END -C2V_VMENTRY(jlong, lookupSignatureRefInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) +C2V_VMENTRY(jobject, lookupSignatureRefInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; - return (jlong) (address) cp->signature_ref_at(index); + Handle sym = java_lang_String::create_from_symbol(cp->signature_ref_at(index), CHECK_NULL); + return JNIHandles::make_local(THREAD, sym()); C2V_END C2V_VMENTRY(jint, lookupKlassRefIndexInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) @@ -729,6 +731,11 @@ return tty->time_stamp().milliseconds(); C2V_END +C2V_VMENTRY(jobject, getSymbol, (JNIEnv*, jobject, jlong metaspaceSymbol)) + Handle sym = java_lang_String::create_from_symbol((Symbol*)(address)metaspaceSymbol, CHECK_NULL); + return JNIHandles::make_local(THREAD, sym()); +C2V_END + bool matches(jlongArray methods, Method* method) { typeArrayOop methods_oop = (typeArrayOop) JNIHandles::resolve(methods); @@ -999,7 +1006,6 @@ #define METASPACE_METHOD "J" #define METASPACE_METHOD_DATA "J" #define METASPACE_CONSTANT_POOL "J" -#define METASPACE_SYMBOL "J" JNINativeMethod CompilerToVM_methods[] = { {CC"getBytecode", CC"("METASPACE_METHOD")[B", FN_PTR(getBytecode)}, @@ -1016,9 +1022,9 @@ {CC"lookupType", CC"("STRING CLASS"Z)"METASPACE_KLASS, FN_PTR(lookupType)}, {CC"resolveConstantInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(resolveConstantInPool)}, {CC"resolvePossiblyCachedConstantInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(resolvePossiblyCachedConstantInPool)}, - {CC"lookupNameRefInPool", CC"("METASPACE_CONSTANT_POOL"I)"METASPACE_SYMBOL, FN_PTR(lookupNameRefInPool)}, + {CC"lookupNameRefInPool", CC"("METASPACE_CONSTANT_POOL"I)"STRING, FN_PTR(lookupNameRefInPool)}, {CC"lookupNameAndTypeRefIndexInPool", CC"("METASPACE_CONSTANT_POOL"I)I", FN_PTR(lookupNameAndTypeRefIndexInPool)}, - {CC"lookupSignatureRefInPool", CC"("METASPACE_CONSTANT_POOL"I)"METASPACE_SYMBOL, FN_PTR(lookupSignatureRefInPool)}, + {CC"lookupSignatureRefInPool", CC"("METASPACE_CONSTANT_POOL"I)"STRING, FN_PTR(lookupSignatureRefInPool)}, {CC"lookupKlassRefIndexInPool", CC"("METASPACE_CONSTANT_POOL"I)I", FN_PTR(lookupKlassRefIndexInPool)}, {CC"constantPoolKlassAt", CC"("METASPACE_CONSTANT_POOL"I)"METASPACE_KLASS, FN_PTR(constantPoolKlassAt)}, {CC"lookupKlassInPool", CC"("METASPACE_CONSTANT_POOL"I)"METASPACE_KLASS, FN_PTR(lookupKlassInPool)}, @@ -1052,6 +1058,7 @@ {CC"allocateCompileId", CC"("METASPACE_METHOD"I)I", FN_PTR(allocateCompileId)}, {CC"isMature", CC"("METASPACE_METHOD_DATA")Z", FN_PTR(isMature)}, {CC"hasCompiledCodeForOSR", CC"("METASPACE_METHOD"II)Z", FN_PTR(hasCompiledCodeForOSR)}, + {CC"getSymbol", CC"(J)"STRING, FN_PTR(getSymbol)}, {CC"getTimeStamp", CC"()J", FN_PTR(getTimeStamp)}, {CC"getNextStackFrame", CC"("HS_STACK_FRAME_REF "[JI)"HS_STACK_FRAME_REF, FN_PTR(getNextStackFrame)}, {CC"materializeVirtualObjects", CC"("HS_STACK_FRAME_REF"Z)V", FN_PTR(materializeVirtualObjects)},