001/*
002 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 *  This file is licensed to You under the Eclipse Public License (EPL);
005 *  You may not use this file except in compliance with the License. You
006 *  may obtain a copy of the License at
007 *
008 *      http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 *  See the COPYRIGHT.txt file distributed with this work for information
011 *  regarding copyright ownership.
012 */
013package org.vmmagic.pragma;
014
015import java.lang.annotation.Retention;
016import java.lang.annotation.Target;
017import java.lang.annotation.RetentionPolicy;
018import java.lang.annotation.ElementType;
019import org.vmmagic.Pragma;
020
021/**
022 * This pragma indicates that a particular method should always be inlined
023 * by the optimizing compiler.
024 */
025@Retention(RetentionPolicy.RUNTIME)
026@Target(ElementType.METHOD)
027@Pragma
028public @interface Inline {
029  /**
030   * Enumeration defining when to inline
031   */
032  enum When {
033    /**
034     * Always inline, regardless of arguments
035     */
036    Always,
037    /**
038     * Inline when all the arguments are constants
039     */
040    AllArgumentsAreConstant,
041    /**
042     * Inline when the specified arguments are constants
043     */
044    ArgumentsAreConstant,
045    /**
046     * Inline when the VM is built without Assertions (VM.VerifyAssertions == false).
047     * Note: It would be nicer to have the more general ExpressionIsTrue annotation,
048     * but the argument expression to the annotation is restricted to be a fairly
049     * trivial constant, and that isn't enough to handle how VM.VERIFY_ASSERTIONS
050     * is defined in MMTk.
051     */
052    AssertionsDisabled
053  }
054  /**
055   * @return when to inline, default When.Always
056   */
057  When value() default When.Always;
058  /**
059   * Arguments that must be constant to cause inlining. NB for static methods 0
060   * is the first argument whilst for virtual methods 0 is this.
061   *
062   * @return indexes of the arguments that must be constant to cause inlining
063   */
064  int[] arguments() default {};
065}