annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java @ 11897:992508ee13b6

Adjustment to unsafe customization macro node.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 05 Oct 2013 15:01:01 +0200
parents 3662471dcfaa
children f753092f608d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9244
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.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: 11269
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: 11269
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: 11269
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
9244
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 *
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * This code is distributed in the hope that it will be useful, but WITHOUT
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 * version 2 for more details (a copy is included in the LICENSE file that
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * accompanied this code).
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 *
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License version
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 * 2 along with this work; if not, write to the Free Software Foundation,
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 *
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 * or visit www.oracle.com if you need additional information or have any
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23 * questions.
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24 */
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 package com.oracle.truffle.api;
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26
9313
6369d37b37d1 Added annotation CompilerDirectives.CompilationFinal for fields that should be considered final during compilation, but are not final while executing in the Truffle interpreter.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9283
diff changeset
27 import java.lang.annotation.*;
9244
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 import java.util.concurrent.*;
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 /**
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 * Directives that influence the optimizations of the Truffle compiler. All of the operations have
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 * no effect when executed in the Truffle interpreter.
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33 */
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 public class CompilerDirectives {
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35
9319
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
36 public static final double LIKELY_PROBABILITY = 0.75;
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
37 public static final double UNLIKELY_PROBABILITY = 1.0 - LIKELY_PROBABILITY;
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
38
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
39 public static final double SLOWPATH_PROBABILITY = 0.0001;
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
40 public static final double FASTPATH_PROBABILITY = 1.0 - SLOWPATH_PROBABILITY;
9244
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42 /**
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
43 * Directive for the compiler to discontinue compilation at this code position and instead
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44 * insert a transfer to the interpreter.
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45 */
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46 public static void transferToInterpreter() {
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 }
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49 /**
11269
f00c85ee46a2 Truffle: add CompilerDirectives.inInterpreter()
Andreas Woess <andreas.woess@jku.at>
parents: 10687
diff changeset
50 * Returns a boolean value indicating whether the method is executed in the interpreter.
f00c85ee46a2 Truffle: add CompilerDirectives.inInterpreter()
Andreas Woess <andreas.woess@jku.at>
parents: 10687
diff changeset
51 *
f00c85ee46a2 Truffle: add CompilerDirectives.inInterpreter()
Andreas Woess <andreas.woess@jku.at>
parents: 10687
diff changeset
52 * @return {@code true} when executed in the interpreter, {@code false} in compiled code.
f00c85ee46a2 Truffle: add CompilerDirectives.inInterpreter()
Andreas Woess <andreas.woess@jku.at>
parents: 10687
diff changeset
53 */
f00c85ee46a2 Truffle: add CompilerDirectives.inInterpreter()
Andreas Woess <andreas.woess@jku.at>
parents: 10687
diff changeset
54 public static boolean inInterpreter() {
f00c85ee46a2 Truffle: add CompilerDirectives.inInterpreter()
Andreas Woess <andreas.woess@jku.at>
parents: 10687
diff changeset
55 return true;
f00c85ee46a2 Truffle: add CompilerDirectives.inInterpreter()
Andreas Woess <andreas.woess@jku.at>
parents: 10687
diff changeset
56 }
f00c85ee46a2 Truffle: add CompilerDirectives.inInterpreter()
Andreas Woess <andreas.woess@jku.at>
parents: 10687
diff changeset
57
f00c85ee46a2 Truffle: add CompilerDirectives.inInterpreter()
Andreas Woess <andreas.woess@jku.at>
parents: 10687
diff changeset
58 /**
9244
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 * Directive for the compiler that the given runnable should only be executed in the interpreter
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 * and ignored in the compiled code.
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 *
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 * @param runnable the closure that should only be executed in the interpreter
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 */
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 public static void interpreterOnly(Runnable runnable) {
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 runnable.run();
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 }
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 /**
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 * Directive for the compiler that the given callable should only be executed in the
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 * interpreter.
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71 *
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 * @param callable the closure that should only be executed in the interpreter
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73 * @return the result of executing the closure in the interpreter and null in the compiled code
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 * @throws Exception If the closure throws an exception when executed in the interpreter.
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 */
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76 public static <T> T interpreterOnly(Callable<T> callable) throws Exception {
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 return callable.call();
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 }
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 /**
9319
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
81 * Injects a probability for the given condition into the probability information of the
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
82 * immediately succeeding branch instruction for the condition. The probability must be a value
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
83 * between 0.0 and 1.0 (inclusive). The condition should not be a combined condition.
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
84 *
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
85 * Example usage immediately before an if statement (it specifies that the likelihood for a to
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
86 * be greater than b is 90%):
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
87 *
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
88 * <code>
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
89 * if (injectBranchProbability(0.9, a > b)) {
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
90 * // ...
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
91 * }
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
92 * </code>
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
93 *
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
94 * Example usage for a combined condition (it specifies that the likelihood for a to be greater
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
95 * than b is 90% and under the assumption that this is true, the likelihood for a being 0 is
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
96 * 10%):
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
97 *
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
98 * <code>
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
99 * if (injectBranchProbability(0.9, a > b) && injectBranchProbability(0.1, a == 0)) {
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
100 * // ...
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
101 * }
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
102 * </code>
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
103 *
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
104 * There are predefined constants for commonly used probabilities (see
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
105 * {@link #LIKELY_PROBABILITY} , {@link #UNLIKELY_PROBABILITY}, {@link #SLOWPATH_PROBABILITY},
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
106 * {@link #FASTPATH_PROBABILITY} ).
9244
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 *
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108 * @param probability the probability value between 0.0 and 1.0 that should be injected
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109 */
9319
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
110 public static boolean injectBranchProbability(double probability, boolean condition) {
9244
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111 assert probability >= 0.0 && probability <= 1.0;
9319
1188b7c42196 Changed the behavior of CompilerDirectives.injectBranchProbability and added javadoc to document the new behavior. Introduced probability constants. Removed CompilerDirectives.slowpath().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9313
diff changeset
112 return condition;
9244
8f540423a5be Added two new classes to the Truffle API: CompilerDirectives and CompilerAsserts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 }
9282
f5e58a1eca55 Added method CompilerDirectives.bailout to the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9244
diff changeset
114
f5e58a1eca55 Added method CompilerDirectives.bailout to the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9244
diff changeset
115 /**
f5e58a1eca55 Added method CompilerDirectives.bailout to the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9244
diff changeset
116 * Bails out of a compilation (e.g., for guest language features that should never be compiled).
f5e58a1eca55 Added method CompilerDirectives.bailout to the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9244
diff changeset
117 *
f5e58a1eca55 Added method CompilerDirectives.bailout to the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9244
diff changeset
118 * @param reason the reason for the bailout
f5e58a1eca55 Added method CompilerDirectives.bailout to the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9244
diff changeset
119 */
f5e58a1eca55 Added method CompilerDirectives.bailout to the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9244
diff changeset
120 public static void bailout(String reason) {
f5e58a1eca55 Added method CompilerDirectives.bailout to the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9244
diff changeset
121 }
9313
6369d37b37d1 Added annotation CompilerDirectives.CompilationFinal for fields that should be considered final during compilation, but are not final while executing in the Truffle interpreter.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9283
diff changeset
122
6369d37b37d1 Added annotation CompilerDirectives.CompilationFinal for fields that should be considered final during compilation, but are not final while executing in the Truffle interpreter.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9283
diff changeset
123 /**
6369d37b37d1 Added annotation CompilerDirectives.CompilationFinal for fields that should be considered final during compilation, but are not final while executing in the Truffle interpreter.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9283
diff changeset
124 * Marks fields that should be considered final for a Truffle compilation although they are not
6369d37b37d1 Added annotation CompilerDirectives.CompilationFinal for fields that should be considered final during compilation, but are not final while executing in the Truffle interpreter.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9283
diff changeset
125 * final while executing in the interpreter.
6369d37b37d1 Added annotation CompilerDirectives.CompilationFinal for fields that should be considered final during compilation, but are not final while executing in the Truffle interpreter.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9283
diff changeset
126 */
6369d37b37d1 Added annotation CompilerDirectives.CompilationFinal for fields that should be considered final during compilation, but are not final while executing in the Truffle interpreter.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9283
diff changeset
127 @Retention(RetentionPolicy.RUNTIME)
6369d37b37d1 Added annotation CompilerDirectives.CompilationFinal for fields that should be considered final during compilation, but are not final while executing in the Truffle interpreter.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9283
diff changeset
128 @Target({ElementType.FIELD})
6369d37b37d1 Added annotation CompilerDirectives.CompilationFinal for fields that should be considered final during compilation, but are not final while executing in the Truffle interpreter.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9283
diff changeset
129 public @interface CompilationFinal {
6369d37b37d1 Added annotation CompilerDirectives.CompilationFinal for fields that should be considered final during compilation, but are not final while executing in the Truffle interpreter.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9283
diff changeset
130 }
9349
0fccad3ce40d Introduce CompilerDirectives.Unsafe. Mark Frame.getArguments method as unsafe.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9319
diff changeset
131
0fccad3ce40d Introduce CompilerDirectives.Unsafe. Mark Frame.getArguments method as unsafe.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9319
diff changeset
132 /**
0fccad3ce40d Introduce CompilerDirectives.Unsafe. Mark Frame.getArguments method as unsafe.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9319
diff changeset
133 * Marks methods that are considered unsafe. Wrong usage of those methods can lead to unexpected
0fccad3ce40d Introduce CompilerDirectives.Unsafe. Mark Frame.getArguments method as unsafe.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9319
diff changeset
134 * behavior including a crash of the runtime. Therefore, special care should be taken.
0fccad3ce40d Introduce CompilerDirectives.Unsafe. Mark Frame.getArguments method as unsafe.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9319
diff changeset
135 */
0fccad3ce40d Introduce CompilerDirectives.Unsafe. Mark Frame.getArguments method as unsafe.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9319
diff changeset
136 @Retention(RetentionPolicy.RUNTIME)
0fccad3ce40d Introduce CompilerDirectives.Unsafe. Mark Frame.getArguments method as unsafe.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9319
diff changeset
137 @Target({ElementType.METHOD})
0fccad3ce40d Introduce CompilerDirectives.Unsafe. Mark Frame.getArguments method as unsafe.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9319
diff changeset
138 public @interface Unsafe {
0fccad3ce40d Introduce CompilerDirectives.Unsafe. Mark Frame.getArguments method as unsafe.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9319
diff changeset
139 }
10649
ac8b195fd3aa New unsafe cast CompilerDirectives method in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9349
diff changeset
140
ac8b195fd3aa New unsafe cast CompilerDirectives method in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9349
diff changeset
141 /**
ac8b195fd3aa New unsafe cast CompilerDirectives method in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9349
diff changeset
142 * Treats the given value as a value of the given class. The class must evaluate to a constant.
ac8b195fd3aa New unsafe cast CompilerDirectives method in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9349
diff changeset
143 *
ac8b195fd3aa New unsafe cast CompilerDirectives method in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9349
diff changeset
144 * @param value the value that is known to have the specified type
ac8b195fd3aa New unsafe cast CompilerDirectives method in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9349
diff changeset
145 * @param clazz the specified type of the value
ac8b195fd3aa New unsafe cast CompilerDirectives method in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9349
diff changeset
146 * @return the value
ac8b195fd3aa New unsafe cast CompilerDirectives method in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9349
diff changeset
147 */
ac8b195fd3aa New unsafe cast CompilerDirectives method in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9349
diff changeset
148 @Unsafe
10650
b6e46324233f Make CompilerDirectives.unsafeCast a generic method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10649
diff changeset
149 public static <T> T unsafeCast(Object value, Class<T> clazz) {
11322
760e838b3560 Add parameter to CompilerDirectives.unsafeCast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11312
diff changeset
150 return unsafeCast(value, clazz, null, null);
10649
ac8b195fd3aa New unsafe cast CompilerDirectives method in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9349
diff changeset
151 }
10687
d2055a110396 Introduce CompilerDirectives.SlowPath annotation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10650
diff changeset
152
d2055a110396 Introduce CompilerDirectives.SlowPath annotation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10650
diff changeset
153 /**
11303
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
154 * Associates the given type token with the given value for the case that condition is true.
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
155 *
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
156 * @param condition the custom type check
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
157 * @param value the value that is of the given custom type after the check
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
158 * @param customType the custom type that should be associated with the value
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
159 * @return the type check condition
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
160 */
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
161 public static boolean customTypeCheck(boolean condition, Object value, Object customType) {
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
162 return condition;
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
163 }
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
164
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
165 /**
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
166 * Treats the given value as a value of the given class. The class must evaluate to a constant.
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
167 * If the compiler can prove that the given value is of the given custom type, the cast is safe.
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
168 *
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
169 * @param value the value that is known to have the specified type
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
170 * @param clazz the specified type of the value
11322
760e838b3560 Add parameter to CompilerDirectives.unsafeCast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11312
diff changeset
171 * @param receiver the receiver on which the custom type is tested
11303
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
172 * @param customType the custom type that if present on a value makes this unsafe cast safe
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
173 * @return the value
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
174 */
11312
f0c8303cf88e Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11307
diff changeset
175 @SuppressWarnings("unchecked")
11303
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
176 @Unsafe
11322
760e838b3560 Add parameter to CompilerDirectives.unsafeCast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11312
diff changeset
177 public static <T> T unsafeCast(Object value, Class<T> clazz, Object receiver, Object customType) {
11312
f0c8303cf88e Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11307
diff changeset
178 return (T) value;
11303
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
179 }
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
180
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
181 /**
11312
f0c8303cf88e Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11307
diff changeset
182 * Proxies an object instance into an instance that adds a custom location identity on its
f0c8303cf88e Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11307
diff changeset
183 * accesses via sun.misc.Unsafe. This means that the accesses on these kind of location
f0c8303cf88e Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11307
diff changeset
184 * identities can only alias among themselves. It also allows to specify a custom type for the
f0c8303cf88e Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11307
diff changeset
185 * receiver values of follow-up unsafe accesses. Both the custom type and the location identity
f0c8303cf88e Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11307
diff changeset
186 * must evaluate to a constant. Furthermore, you should use the proxied receiver object
f0c8303cf88e Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11307
diff changeset
187 * immediately for one read or write access via a sun.misc.Unsafe method and not store it
f0c8303cf88e Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11307
diff changeset
188 * anywhere.
11303
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
189 *
11312
f0c8303cf88e Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11307
diff changeset
190 * @param receiver the object that is accessed via sun.misc.Unsafe
11897
992508ee13b6 Adjustment to unsafe customization macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11495
diff changeset
191 * @param condition the condition that ifTrue allows this unsafe access to be floating
11303
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
192 * @param locationIdentity the location identity token that can be used for improved global
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
193 * value numbering or null
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
194 * @return the accessed value
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
195 */
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
196 @Unsafe
11897
992508ee13b6 Adjustment to unsafe customization macro node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11495
diff changeset
197 public static Object unsafeCustomization(Object receiver, boolean condition, Object locationIdentity) {
11312
f0c8303cf88e Restructure Truffle API node intrinsics and introduce new intrinsics for type system modelling.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11307
diff changeset
198 return receiver;
11303
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
199 }
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
200
28da427847c5 New Truffle API methods for efficient implementation of a custom type system on top of the JVM.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11279
diff changeset
201 /**
10687
d2055a110396 Introduce CompilerDirectives.SlowPath annotation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10650
diff changeset
202 * Marks methods that are considered slowpath and should therefore not be inlined by default.
d2055a110396 Introduce CompilerDirectives.SlowPath annotation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10650
diff changeset
203 */
d2055a110396 Introduce CompilerDirectives.SlowPath annotation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10650
diff changeset
204 @Retention(RetentionPolicy.RUNTIME)
d2055a110396 Introduce CompilerDirectives.SlowPath annotation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10650
diff changeset
205 @Target({ElementType.METHOD})
d2055a110396 Introduce CompilerDirectives.SlowPath annotation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10650
diff changeset
206 public @interface SlowPath {
d2055a110396 Introduce CompilerDirectives.SlowPath annotation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10650
diff changeset
207 }
11495
3662471dcfaa Introduce CompilerDirectives.ValueType annotation in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11322
diff changeset
208
3662471dcfaa Introduce CompilerDirectives.ValueType annotation in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11322
diff changeset
209 /**
3662471dcfaa Introduce CompilerDirectives.ValueType annotation in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11322
diff changeset
210 * Marks classes as value types. Reference comparisons (==) between instances of those classes
3662471dcfaa Introduce CompilerDirectives.ValueType annotation in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11322
diff changeset
211 * have undefined semantics and can either return true or false.
3662471dcfaa Introduce CompilerDirectives.ValueType annotation in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11322
diff changeset
212 */
3662471dcfaa Introduce CompilerDirectives.ValueType annotation in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11322
diff changeset
213 @Retention(RetentionPolicy.RUNTIME)
3662471dcfaa Introduce CompilerDirectives.ValueType annotation in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11322
diff changeset
214 @Target({ElementType.TYPE})
3662471dcfaa Introduce CompilerDirectives.ValueType annotation in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11322
diff changeset
215 public @interface ValueType {
3662471dcfaa Introduce CompilerDirectives.ValueType annotation in Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11322
diff changeset
216 }
9283
159ac409c27a Fix new line at end of file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9282
diff changeset
217 }