1 /*
2 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
45 import org.graalvm.compiler.graph.Node.NodeIntrinsic;
46 import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig;
47 import org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage;
48 import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
49 import org.graalvm.compiler.hotspot.nodes.StubForeignCallNode;
50 import org.graalvm.compiler.nodes.UnwindNode;
51 import org.graalvm.compiler.options.OptionValues;
52 import org.graalvm.compiler.word.Word;
53 import jdk.internal.vm.compiler.word.Pointer;
54
55 import jdk.vm.ci.code.Register;
56
57 /**
58 * Stub called by an {@link UnwindNode}. This stub executes in the frame of the method throwing an
59 * exception and completes by jumping to the exception handler in the calling frame.
60 */
61 public class UnwindExceptionToCallerStub extends SnippetStub {
62
63 public UnwindExceptionToCallerStub(OptionValues options, HotSpotProviders providers, HotSpotForeignCallLinkage linkage) {
64 super("unwindExceptionToCaller", options, providers, linkage);
65 }
66
67 /**
68 * The current frame is unwound by this stub. Therefore, it does not need to save any registers
69 * as HotSpot uses a caller save convention.
70 */
71 @Override
72 public boolean preservesRegisters() {
73 return false;
74 }
75
76 @Override
77 protected Object getConstantParameterValue(int index, String name) {
78 if (index == 2) {
79 return providers.getRegisters().getThreadRegister();
80 }
81 throw new InternalError();
82 }
83
84 @Snippet
85 private static void unwindExceptionToCaller(Object exception, Word returnAddress, @ConstantParameter Register threadRegister) {
86 Pointer exceptionOop = Word.objectToTrackedPointer(exception);
87 if (logging(INJECTED_OPTIONVALUES)) {
88 printf("unwinding exception %p (", exceptionOop.rawValue());
89 decipher(exceptionOop.rawValue());
90 printf(") at %p (", returnAddress.rawValue());
91 decipher(returnAddress.rawValue());
92 printf(")\n");
93 }
|
1 /*
2 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
45 import org.graalvm.compiler.graph.Node.NodeIntrinsic;
46 import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig;
47 import org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage;
48 import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
49 import org.graalvm.compiler.hotspot.nodes.StubForeignCallNode;
50 import org.graalvm.compiler.nodes.UnwindNode;
51 import org.graalvm.compiler.options.OptionValues;
52 import org.graalvm.compiler.word.Word;
53 import jdk.internal.vm.compiler.word.Pointer;
54
55 import jdk.vm.ci.code.Register;
56
57 /**
58 * Stub called by an {@link UnwindNode}. This stub executes in the frame of the method throwing an
59 * exception and completes by jumping to the exception handler in the calling frame.
60 */
61 public class UnwindExceptionToCallerStub extends SnippetStub {
62
63 public UnwindExceptionToCallerStub(OptionValues options, HotSpotProviders providers, HotSpotForeignCallLinkage linkage) {
64 super("unwindExceptionToCaller", options, providers, linkage);
65 }
66
67 @Override
68 protected Object getConstantParameterValue(int index, String name) {
69 if (index == 2) {
70 return providers.getRegisters().getThreadRegister();
71 }
72 throw new InternalError();
73 }
74
75 @Snippet
76 private static void unwindExceptionToCaller(Object exception, Word returnAddress, @ConstantParameter Register threadRegister) {
77 Pointer exceptionOop = Word.objectToTrackedPointer(exception);
78 if (logging(INJECTED_OPTIONVALUES)) {
79 printf("unwinding exception %p (", exceptionOop.rawValue());
80 decipher(exceptionOop.rawValue());
81 printf(") at %p (", returnAddress.rawValue());
82 decipher(returnAddress.rawValue());
83 printf(")\n");
84 }
|