Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Fallback.java @ 21441:1fc2966023e1
SSALinarScanResolveDataFlowPhase: do not allow registers as phi operands.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Mon, 18 May 2015 14:40:32 +0200 |
parents | 7b6a4ae58de4 |
children |
rev | line source |
---|---|
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
18128
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
11279
494b818b527c
Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10597
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
494b818b527c
Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10597
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
494b818b527c
Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10597
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * accompanied this code). |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 * questions. |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 */ |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 package com.oracle.truffle.api.dsl; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import java.lang.annotation.*; |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 |
18128
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
29 import com.oracle.truffle.api.nodes.*; |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
30 |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 /** |
18128
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
32 * <p> |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
33 * A method annotated with {@link Fallback} is treated as a {@link Specialization} that implicitly |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
34 * links all the guards of all other declared {@link Specialization} annotated methods of the |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
35 * operation in a negated form. As a consequence it cannot declare any other guards. The expected |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
36 * signature of the method must match to the signature of a {@link Specialization} with the |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
37 * additional limitation that only generically executable argument types are allowed. A generically |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
38 * executable argument is a an argument hat can be executed from the child {@link Node} using an |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
39 * execute method without {@link UnsupportedOperationException}. In many cases the generically |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
40 * executable type is {@link Object}. An operation is limited to just one {@link Fallback} |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
41 * specialization which is always ordered at the end of the specialization chain. |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
42 * </p> |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 * |
18128
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
44 * <p> |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
45 * A simple example showing the use of the {@link Fallback} annotation in a DSL operation: |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
46 * </p> |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
47 * |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
48 * <pre> |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
49 * @Specialization int doInt(int a) {..} |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
50 * @Specialization int doDouble(double a) {..} |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
51 * @Fallback int orElse(Object a) {..} |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
52 * </pre> |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
53 * |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
54 * <p> |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
55 * The previous example could be redeclared just using {@link Specialization} annotated methods as |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
56 * follows: |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
57 * </p> |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
58 * |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
59 * <pre> |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
60 * @Specialization int doInt(int a) {..} |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
61 * @Specialization int doDouble(double a) {..} |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
62 * @Specialization(guard={"!isInt(a)", "!isDouble(a)"}) |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
63 * int orElse(Object a) {..} |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
64 * </pre> |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
65 * |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
66 * <p> |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
67 * <b>Performance note:</b> For operations with a lot of {@link Specialization} annotated methods |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
68 * the use of {@link Fallback} might generate a guard that is very big. Try to avoid the use of |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
69 * {@link Fallback} for specializations that are significantly important for peak performance. |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
70 * </p> |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
71 * |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
72 * @see Specialization |
7b6a4ae58de4
Truffle-DSL: improve JavaDoc for @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
73 * @see NodeChild |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 */ |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
75 @Retention(RetentionPolicy.CLASS) |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
76 @Target({ElementType.METHOD}) |
16760
9f38d222fa6c
Truffle-DSL: renamed @Generic to @Fallback.
Christian Humer <christian.humer@gmail.com>
parents:
11279
diff
changeset
|
77 public @interface Fallback { |
10597
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
78 |
79041ab43660
Truffle-DSL: API-change: Renamed truffle.api.codegen to truffle.api.dsl for all projects and packages.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
79 } |