Mercurial > hg > graal-compiler
view graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java @ 9746:82e3c8d5c77f
removed CRuntimeCall and replaced its usages with ForeignCallNode
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 16 May 2013 20:26:46 +0200 |
parents | c4b1aa93b9af |
children | 82689c1c0dab |
line wrap: on
line source
/* * 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.stubs; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import static com.oracle.graal.hotspot.nodes.JumpToExceptionHandlerInCallerNode.*; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; import static com.oracle.graal.hotspot.stubs.ExceptionHandlerStub.*; import static com.oracle.graal.hotspot.stubs.StubUtil.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.Node.ConstantNodeParameter; import com.oracle.graal.graph.Node.NodeIntrinsic; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.replacements.*; import com.oracle.graal.replacements.Snippet.Fold; import com.oracle.graal.word.*; /** * Stub called by an {@link UnwindNode}. This stub executes in the frame of the method throwing an * exception and completes by jumping to the exception handler in the calling frame. */ public class UnwindExceptionToCallerStub extends CRuntimeStub { public UnwindExceptionToCallerStub(final HotSpotRuntime runtime, Replacements replacements, TargetDescription target, HotSpotForeignCallLinkage linkage) { super(runtime, replacements, target, linkage); } /** * The current frame is unwound by this stub. Therefore, it does not need to save any registers * as HotSpot uses a caller save convention. */ @Override public boolean preservesRegisters() { return false; } @Snippet private static void unwindExceptionToCaller(Object exception, Word returnAddress) { Pointer exceptionOop = Word.fromObject(exception); if (logging()) { printf("unwinding exception %p (", exceptionOop.rawValue()); decipher(exceptionOop.rawValue()); printf(") at %p (", returnAddress.rawValue()); decipher(returnAddress.rawValue()); printf(")\n"); } checkNoExceptionInThread(assertionsEnabled()); checkExceptionNotNull(assertionsEnabled(), exception); Word handlerInCallerPc = exceptionHandlerForReturnAddress(EXCEPTION_HANDLER_FOR_RETURN_ADDRESS, thread(), returnAddress); if (logging()) { printf("handler for exception %p at return address %p is at %p (", exceptionOop.rawValue(), returnAddress.rawValue(), handlerInCallerPc.rawValue()); decipher(handlerInCallerPc.rawValue()); printf(")\n"); } jumpToExceptionHandlerInCaller(handlerInCallerPc, exception, returnAddress); } @Fold private static boolean logging() { return Boolean.getBoolean("graal.logUnwindExceptionToCallerStub"); } @Fold @SuppressWarnings("all") private static boolean assertionsEnabled() { boolean enabled = false; assert enabled = true; return enabled || graalRuntime().getConfig().cAssertions; } public static final ForeignCallDescriptor EXCEPTION_HANDLER_FOR_RETURN_ADDRESS = descriptorFor(UnwindExceptionToCallerStub.class, "exceptionHandlerForReturnAddress"); @NodeIntrinsic(value = ForeignCallNode.class, setStampFromReturnType = true) public static native Word exceptionHandlerForReturnAddress(@ConstantNodeParameter ForeignCallDescriptor exceptionHandlerForReturnAddress, Word thread, Word returnAddress); }