|
| 1 | +/* |
| 2 | + * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. |
| 3 | + * |
| 4 | + * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product |
| 5 | + * that is described in this document. In particular, and without limitation, these intellectual property |
| 6 | + * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or |
| 7 | + * more additional patents or pending patent applications in the U.S. and in other countries. |
| 8 | + * |
| 9 | + * U.S. Government Rights - Commercial software. Government users are subject to the Sun |
| 10 | + * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its |
| 11 | + * supplements. |
| 12 | + * |
| 13 | + * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or |
| 14 | + * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks |
| 15 | + * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the |
| 16 | + * U.S. and other countries. |
| 17 | + * |
| 18 | + * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open |
| 19 | + * Company, Ltd. |
| 20 | + */ |
| 21 | +package com.sun.max.annotate; |
| 22 | +import java.lang.annotation.*; |
| 23 | + |
| 24 | +/** |
| 25 | + * Every thus annotated method is to be inlined unconditionally by the VM's optimizing compiler |
| 26 | + * and the receiver is never null-checked. |
| 27 | + * |
| 28 | + * This annotation exists primarily for annotating methods that <b>must</b> be inlined |
| 29 | + * for semantic reasons as opposed to those that could be inlined for performance reasons. |
| 30 | + * Using this annotation for the latter should be done very rarely and only when |
| 31 | + * profiling highlights a performance bottleneck or such a bottleneck is known <i>a priori</i>. |
| 32 | + * |
| 33 | + * If the {@linkplain #override() override} element of this annotation is set to true, then |
| 34 | + * an annotated method must be {@code static} or {@code final} (implicitly or explicitly). |
| 35 | + * Additionally, only a INLINE virtual method with this element set to true can be overridden. |
| 36 | + * |
| 37 | + * @author Bernd Mathiske |
| 38 | + * @author Doug Simon |
| 39 | + */ |
| 40 | +@Retention(RetentionPolicy.RUNTIME) |
| 41 | +@Target(ElementType.METHOD) |
| 42 | +public @interface INLINE { |
| 43 | + |
| 44 | + /** |
| 45 | + * If true, this element specifies that the annotated method provides the prototypical implementation |
| 46 | + * of the functionality expected (in the target VM) of every method that overrides |
| 47 | + * the annotated method. That is, the code produced by the compiler for every overriding method |
| 48 | + * must be functionality equivalent to the code produced for the prototypical method. |
| 49 | + * |
| 50 | + * <b>WARNING: Setting this element to true implies that you guarantee that all overriders |
| 51 | + * satisfy the above stated invariant.</b> There is no (easy) way to test for violations of |
| 52 | + * the invariant. |
| 53 | + * |
| 54 | + * A method annotated with INLINE should only be overridden for one of the following reasons: |
| 55 | + * |
| 56 | + * 1. To coerce the value returned by the overridden method to a subtype. |
| 57 | + * See {@link MemberActor#holder()} and {@link FieldActor#holder()} for an example. |
| 58 | + * |
| 59 | + * 2. A method is overridden to make bootstrapping work. |
| 60 | + * See {@link ClassActor#toJava()} and {@link ArrayClassActor#toJava()} for an example. |
| 61 | + * |
| 62 | + * 3. A method is overridden because a subclass can provide a more efficient implementation |
| 63 | + * and it is known that certain call sites will be reduced to a constant receiver |
| 64 | + * (not just a known receiver type but a known receiver object) via annotation driven |
| 65 | + * compile-time {@linkplain FOLD folding}. This is how calls to the {@link GeneralLayout layout} |
| 66 | + * interface methods are reduced to monomorphic calls at compile-time. |
| 67 | + * |
| 68 | + * See {@link ClassActor#toJava()} and {@link ArrayClassActor#toJava()} for an example. |
| 69 | + */ |
| 70 | + boolean override() default false; |
| 71 | + |
| 72 | + /** |
| 73 | + * If true, this element specifies that inlining of the thus annotated method is only allowed |
| 74 | + * after snippet compilation has concluded. |
| 75 | + * |
| 76 | + * @see CompilerScheme#areSnippetsCompiled() |
| 77 | + */ |
| 78 | + boolean afterSnippetsAreCompiled() default false; |
| 79 | +} |
0 commit comments