Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/LoadExceptionObjectSnippets.java @ 9015:92d2bedb5dfc
Change of Snippet template and instantiation process
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Thu, 11 Apr 2013 14:22:03 -0700 |
parents | 3d2c2b68fe93 |
children | 659bb6cf930c |
rev | line source |
---|---|
8643
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot.replacements; |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import static com.oracle.graal.hotspot.replacements.HotSpotSnippetUtils.*; |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 import static com.oracle.graal.nodes.extended.UnsafeCastNode.*; |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import static com.oracle.graal.replacements.SnippetTemplate.*; |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.api.code.*; |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.nodes.java.*; |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.nodes.spi.*; |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.nodes.type.*; |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.replacements.*; |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates; |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.replacements.SnippetTemplate.Arguments; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8643
diff
changeset
|
36 import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo; |
8643
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.graal.word.*; |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 /** |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 * Snippet for loading the exception object at the start of an exception dispatcher. |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 */ |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 public class LoadExceptionObjectSnippets implements Snippets { |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 @Snippet |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 public static Object loadException() { |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 Word thread = thread(); |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 Object exception = readExceptionOop(thread); |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 writeExceptionOop(thread, null); |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 writeExceptionPc(thread, Word.zero()); |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 return unsafeCast(exception, StampFactory.forNodeIntrinsic()); |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 } |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8643
diff
changeset
|
53 public static class Templates extends AbstractTemplates { |
8643
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8643
diff
changeset
|
55 private final SnippetInfo loadException = snippet(LoadExceptionObjectSnippets.class, "loadException"); |
8643
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 public Templates(CodeCacheProvider runtime, Replacements replacements, TargetDescription target) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8643
diff
changeset
|
58 super(runtime, replacements, target); |
8643
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 } |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 public void lower(LoadExceptionObjectNode loadExceptionObject) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8643
diff
changeset
|
62 Arguments args = new Arguments(loadException); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8643
diff
changeset
|
63 template(args).instantiate(runtime, loadExceptionObject, DEFAULT_REPLACER, args); |
8643
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 } |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 } |
3d2c2b68fe93
lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 } |