comparison graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/DSLOptions.java @ 18761:a665483c3881

Truffle-DSL: new node layout implementation.
author Christian Humer <christian.humer@gmail.com>
date Mon, 29 Dec 2014 23:38:54 +0100
parents
children a720bf2e2f43
comparison
equal deleted inserted replaced
18760:6fa3999631d8 18761:a665483c3881
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 /** Enable the new DSL generation layout. */
38 boolean useNewLayout() default false;
39
40 /**
41 * Lazy class loading ensures that all generated specialization classes are loaded lazily.
42 * Disabling this feature will eagerly load all classes but will also reduce the generated code
43 * size.
44 */
45 boolean useLazyClassLoading() default true;
46
47 /**
48 * Sets the optimization strategy for implicit casts.
49 */
50 ImplicitCastOptimization implicitCastOptimization() default ImplicitCastOptimization.DUPLICATE_TAIL;
51
52 /** Not yet implemented. */
53 boolean useDisjunctiveMethodGuardOptimization() default true;
54
55 public enum ImplicitCastOptimization {
56
57 /** Perform no informed optimization for implicit casts. */
58 NONE,
59
60 /** Duplicate specializations for each used implicit cast combination */
61 DUPLICATE_TAIL,
62
63 /**
64 * Use the same specialization for multiple combinations of implicit casts and specialize
65 * them independently. Not yet fully implemented.
66 */
67 MERGE_CASTS;
68
69 public boolean isNone() {
70 return this == NONE;
71 }
72
73 public boolean isDuplicateTail() {
74 return this == DUPLICATE_TAIL;
75 }
76
77 public boolean isMergeCasts() {
78 return this == MERGE_CASTS;
79 }
80 }
81
82 public enum TypeBoxingOptimization {
83 /** Perform the optimization for all types. */
84 ALWAYS,
85 /** Perform the optimization just for primitive types. */
86 PRIMITIVE,
87 /** Perform the optimization for no types. */
88 NONE;
89 }
90
91 /**
92 * Defines the range of the generation of type specialized execute methods for return types and
93 * for specialized parameter types. A type specialized execute method is generated as soon as
94 * one declared type is either returned or used a specialized parameter.
95 */
96 TypeBoxingOptimization monomorphicTypeBoxingOptimization() default TypeBoxingOptimization.PRIMITIVE;
97
98 /**
99 * Defines the range of types for which type specialized execute methods should be used for
100 * polymorphic operations.
101 */
102 TypeBoxingOptimization polymorphicTypeBoxingElimination() default TypeBoxingOptimization.PRIMITIVE;
103
104 /**
105 * Defines the range of types for which type specialized execute methods for implicit cast
106 * optimizations are used. This option only has an effect if
107 * {@link ImplicitCastOptimization#DUPLICATE_TAIL} or
108 * {@link ImplicitCastOptimization#MERGE_CASTS} is set in {@link #implicitCastOptimization()}.
109 */
110 TypeBoxingOptimization implicitTypeBoxingOptimization() default TypeBoxingOptimization.PRIMITIVE;
111
112 /**
113 * Defines range of specialization return types in which the void boxing optimization is used.
114 * Void boxing generates an extra execute method with {@link Void} return type in order to avoid
115 * boxing and type checking of the return type in case the return type is not needed. For this
116 * to work the operation class needs to provide an overridable execute method returning
117 * {@link Void}.
118 */
119 TypeBoxingOptimization voidBoxingOptimization() default TypeBoxingOptimization.PRIMITIVE;
120
121 public enum FallbackOptimization {
122 /** Always generate an optimized fallback specialization. */
123 ALWAYS,
124
125 /**
126 * Only generate an optimized fallback specialization if a method annotated with @Fallback
127 * is used in the operation.
128 */
129 DECLARED,
130
131 /**
132 * Never generate an optimized fallback specialization. Please be aware that triggering a @Fallback
133 * case without optimization will also invalidate your compiled code.
134 */
135 NEVER;
136 }
137
138 /** Defines the optimization strategy that is used to optimize @Fallback annotated methods. */
139 FallbackOptimization optimizeFallback() default FallbackOptimization.DECLARED;
140
141 }