Mercurial > hg > truffle
changeset 10873:de55425d3cf5
small cleanups and extra documentation around foreign call linkage
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 25 Jul 2013 11:34:37 +0200 |
parents | c3b09d69dfde |
children | 191a9e4a2d2c |
files | graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java |
diffstat | 4 files changed, 30 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Wed Jul 24 17:57:52 2013 -0700 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Thu Jul 25 11:34:37 2013 +0200 @@ -355,9 +355,9 @@ @Override public void emitUnwind(Value exception) { ForeignCallLinkage linkage = getRuntime().lookupForeignCall(HotSpotBackend.UNWIND_EXCEPTION_TO_CALLER); - CallingConvention linkageCc = linkage.getOutgoingCallingConvention(); - assert linkageCc.getArgumentCount() == 2; - RegisterValue exceptionParameter = (RegisterValue) linkageCc.getArgument(0); + CallingConvention outgoingCc = linkage.getOutgoingCallingConvention(); + assert outgoingCc.getArgumentCount() == 2; + RegisterValue exceptionParameter = (RegisterValue) outgoingCc.getArgument(0); emitMove(exceptionParameter, exception); append(new AMD64HotSpotUnwindOp(exceptionParameter)); } @@ -381,10 +381,10 @@ public void emitJumpToExceptionHandlerInCaller(ValueNode handlerInCallerPc, ValueNode exception, ValueNode exceptionPc) { Variable handler = load(operand(handlerInCallerPc)); ForeignCallLinkage linkage = getRuntime().lookupForeignCall(EXCEPTION_HANDLER_IN_CALLER); - CallingConvention linkageCc = linkage.getOutgoingCallingConvention(); - assert linkageCc.getArgumentCount() == 2; - RegisterValue exceptionFixed = (RegisterValue) linkageCc.getArgument(0); - RegisterValue exceptionPcFixed = (RegisterValue) linkageCc.getArgument(1); + CallingConvention outgoingCc = linkage.getOutgoingCallingConvention(); + assert outgoingCc.getArgumentCount() == 2; + RegisterValue exceptionFixed = (RegisterValue) outgoingCc.getArgument(0); + RegisterValue exceptionPcFixed = (RegisterValue) outgoingCc.getArgument(1); emitMove(exceptionFixed, operand(exception)); emitMove(exceptionPcFixed, operand(exceptionPc)); AMD64HotSpotJumpToExceptionHandlerInCallerOp op = new AMD64HotSpotJumpToExceptionHandlerInCallerOp(handler, exceptionFixed, exceptionPcFixed);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java Wed Jul 24 17:57:52 2013 -0700 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java Thu Jul 25 11:34:37 2013 +0200 @@ -61,8 +61,8 @@ RegisterValue exception = rax.asValue(Kind.Object); RegisterValue exceptionPc = rdx.asValue(word); CallingConvention exceptionCc = new CallingConvention(0, ILLEGAL, exception, exceptionPc); - register(new HotSpotForeignCallLinkage(EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF, exceptionCc, exceptionCc, NOT_REEXECUTABLE, ANY_LOCATION)); - register(new HotSpotForeignCallLinkage(EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF, exceptionCc, exceptionCc, NOT_REEXECUTABLE, ANY_LOCATION)); + register(new HotSpotForeignCallLinkage(EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF, null, exceptionCc, NOT_REEXECUTABLE, ANY_LOCATION)); + register(new HotSpotForeignCallLinkage(EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF, exceptionCc, null, NOT_REEXECUTABLE, ANY_LOCATION)); // The x86 crypto stubs do callee saving registerForeignCall(ENCRYPT_BLOCK, config.aescryptEncryptBlockStub, NativeCall, PRESERVES_REGISTERS, LEAF, NOT_REEXECUTABLE, ANY_LOCATION);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java Wed Jul 24 17:57:52 2013 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java Thu Jul 25 11:34:37 2013 +0200 @@ -113,7 +113,7 @@ * @param effect specifies if the call destroys or preserves all registers (apart from * temporaries which are always destroyed) * @param outgoingCcType outgoing (caller) calling convention type - * @param incomingCcType incoming (callee) calling convention type + * @param incomingCcType incoming (callee) calling convention type (can be null) * @param transition specifies if this is a {@linkplain #canDeoptimize() leaf} call * @param reexecutable specifies if the call can be re-executed without (meaningful) side * effects. Deoptimization will not return to a point before a call that cannot be @@ -123,7 +123,7 @@ public static HotSpotForeignCallLinkage create(ForeignCallDescriptor descriptor, long address, RegisterEffect effect, Type outgoingCcType, Type incomingCcType, Transition transition, boolean reexecutable, LocationIdentity... killedLocations) { CallingConvention outgoingCc = createCallingConvention(descriptor, outgoingCcType); - CallingConvention incomingCc = createCallingConvention(descriptor, incomingCcType); + CallingConvention incomingCc = incomingCcType == null ? null : createCallingConvention(descriptor, incomingCcType); return new HotSpotForeignCallLinkage(descriptor, address, effect, transition, outgoingCc, incomingCc, reexecutable, killedLocations); } @@ -131,6 +131,7 @@ * Gets a calling convention for a given descriptor and call type. */ public static CallingConvention createCallingConvention(ForeignCallDescriptor descriptor, Type ccType) { + assert ccType != null; HotSpotRuntime runtime = graalRuntime().getRuntime(); Class<?>[] argumentTypes = descriptor.getArgumentTypes(); JavaType[] parameterTypes = new JavaType[argumentTypes.length];
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Wed Jul 24 17:57:52 2013 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Jul 25 11:34:37 2013 +0200 @@ -201,9 +201,11 @@ /** * Creates and registers the details for linking a foreign call to a {@link Stub}. * + * @param descriptor the signature of the call to the stub * @param reexecutable specifies if the stub call can be re-executed without (meaningful) side * effects. Deoptimization will not return to a point before a stub call that cannot * be re-executed. + * @param transition specifies if this is a {@linkplain Transition#LEAF leaf} call * @param killedLocations the memory locations killed by the stub call */ protected HotSpotForeignCallLinkage registerStubCall(ForeignCallDescriptor descriptor, boolean reexecutable, Transition transition, LocationIdentity... killedLocations) { @@ -213,16 +215,22 @@ /** * Creates and registers the linkage for a foreign call. * - * @param reexecutable specifies if the stub call can be re-executed without (meaningful) side - * effects. Deoptimization will not return to a point before a stub call that cannot - * be re-executed. - * @param killedLocations the memory locations killed by the stub call + * @param descriptor the signature of the foreign call + * @param address the address of the code to call + * @param outgoingCcType outgoing (caller) calling convention type + * @param effect specifies if the call destroys or preserves all registers (apart from + * temporaries which are always destroyed) + * @param transition specifies if this is a {@linkplain Transition#LEAF leaf} call + * @param reexecutable specifies if the foreign call can be re-executed without (meaningful) + * side effects. Deoptimization will not return to a point before a foreign call that + * cannot be re-executed. + * @param killedLocations the memory locations killed by the foreign call */ - protected HotSpotForeignCallLinkage registerForeignCall(ForeignCallDescriptor descriptor, long address, CallingConvention.Type ccType, RegisterEffect effect, Transition transition, + protected HotSpotForeignCallLinkage registerForeignCall(ForeignCallDescriptor descriptor, long address, CallingConvention.Type outgoingCcType, RegisterEffect effect, Transition transition, boolean reexecutable, LocationIdentity... killedLocations) { Class<?> resultType = descriptor.getResultType(); assert transition == LEAF || resultType.isPrimitive() || Word.class.isAssignableFrom(resultType) : "non-leaf foreign calls must return objects in thread local storage: " + descriptor; - return register(HotSpotForeignCallLinkage.create(descriptor, address, effect, ccType, ccType, transition, reexecutable, killedLocations)); + return register(HotSpotForeignCallLinkage.create(descriptor, address, effect, outgoingCcType, null, transition, reexecutable, killedLocations)); } private static void link(Stub stub) { @@ -230,12 +238,13 @@ } /** - * Creates a {@linkplain ForeignCallStub stub} for a non-leaf foreign call. + * Creates a {@linkplain ForeignCallStub stub} for a foreign call. * - * @param descriptor the signature of the call to this stub - * @param address the address of the code to call + * @param descriptor the signature of the call to the stub + * @param address the address of the foreign code to call * @param prependThread true if the JavaThread value for the current thread is to be prepended * to the arguments for the call to {@code address} + * @param transition specifies if this is a {@linkplain Transition#LEAF leaf} call * @param reexecutable specifies if the foreign call can be re-executed without (meaningful) * side effects. Deoptimization will not return to a point before a foreign call that * cannot be re-executed.