comparison truffle/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/DSLOptions.java @ 21951:9c8c0937da41

Moving all sources into truffle subdirectory
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 17 Jun 2015 10:58:08 +0200
parents graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/DSLOptions.java@ae81dd154fb6
children dc83cc1f94f2
comparison
equal deleted inserted replaced
21950:2a5011c7e641 21951:9c8c0937da41
1 /*
2 * Copyright (c) 2014, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package com.oracle.truffle.api.dsl.internal;
26
27 import java.lang.annotation.*;
28
29 /**
30 * Internal DSL options to tune the generated code. These are expert options and not intended to be
31 * changed used for guest language implementations.
32 */
33 @Retention(RetentionPolicy.RUNTIME)
34 @Target({ElementType.TYPE})
35 public @interface DSLOptions {
36
37 /** Flag has no effect anymore. Is going to be removed soon. */
38 @Deprecated
39 boolean useNewLayout() default true;
40
41 /**
42 * Lazy class loading ensures that all generated specialization classes are loaded lazily.
43 * Disabling this feature will eagerly load all classes but will also reduce the generated code
44 * size.
45 */
46 boolean useLazyClassLoading() default true;
47
48 /**
49 * Sets the optimization strategy for implicit casts.
50 */
51 ImplicitCastOptimization implicitCastOptimization() default ImplicitCastOptimization.DUPLICATE_TAIL;
52
53 /** Not yet implemented. */
54 boolean useDisjunctiveMethodGuardOptimization() default true;
55
56 public enum ImplicitCastOptimization {
57
58 /** Perform no informed optimization for implicit casts. */
59 NONE,
60
61 /** Duplicate specializations for each used implicit cast combination. */
62 DUPLICATE_TAIL,
63
64 /**
65 * Use the same specialization for multiple combinations of implicit casts and specialize
66 * them independently. Not yet fully implemented.
67 */
68 MERGE_CASTS;
69
70 public boolean isNone() {
71 return this == NONE;
72 }
73
74 public boolean isDuplicateTail() {
75 return this == DUPLICATE_TAIL;
76 }
77
78 public boolean isMergeCasts() {
79 return this == MERGE_CASTS;
80 }
81 }
82
83 public enum TypeBoxingOptimization {
84 /** Perform the optimization for all types. */
85 ALWAYS,
86 /** Perform the optimization just for primitive types. */
87 PRIMITIVE,
88 /** Perform the optimization for no types. */
89 NONE;
90 }
91
92 /**
93 * Defines the range of the generation of type specialized execute methods for return types and
94 * for specialized parameter types. A type specialized execute method is generated as soon as
95 * one declared type is either returned or used a specialized parameter.
96 */
97 TypeBoxingOptimization monomorphicTypeBoxingOptimization() default TypeBoxingOptimization.PRIMITIVE;
98
99 /**
100 * Defines the range of types for which type specialized execute methods should be used for
101 * polymorphic operations.
102 */
103 TypeBoxingOptimization polymorphicTypeBoxingElimination() default TypeBoxingOptimization.PRIMITIVE;
104
105 /**
106 * Defines the range of types for which type specialized execute methods for implicit cast
107 * optimizations are used. This option only has an effect if
108 * {@link ImplicitCastOptimization#DUPLICATE_TAIL} or
109 * {@link ImplicitCastOptimization#MERGE_CASTS} is set in {@link #implicitCastOptimization()}.
110 */
111 TypeBoxingOptimization implicitTypeBoxingOptimization() default TypeBoxingOptimization.PRIMITIVE;
112
113 /**
114 * Defines range of specialization return types in which the void boxing optimization is used.
115 * Void boxing generates an extra execute method with {@link Void} return type in order to avoid
116 * boxing and type checking of the return type in case the return type is not needed. For this
117 * to work the operation class needs to provide an overridable execute method returning
118 * {@link Void}.
119 */
120 TypeBoxingOptimization voidBoxingOptimization() default TypeBoxingOptimization.PRIMITIVE;
121
122 public enum FallbackOptimization {
123 /** Always generate an optimized fallback specialization. */
124 ALWAYS,
125
126 /**
127 * Only generate an optimized fallback specialization if a method annotated with @Fallback
128 * is used in the operation.
129 */
130 DECLARED,
131
132 /**
133 * Never generate an optimized fallback specialization. Please be aware that triggering a @Fallback
134 * case without optimization will also invalidate your compiled code.
135 */
136 NEVER;
137 }
138
139 /** Defines the optimization strategy that is used to optimize @Fallback annotated methods. */
140 FallbackOptimization optimizeFallback() default FallbackOptimization.DECLARED;
141
142 }