001/* 002 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package com.oracle.graal.truffle; 024 025import jdk.internal.jvmci.code.*; 026 027import com.oracle.graal.nodes.*; 028import com.oracle.truffle.api.nodes.*; 029 030/** 031 * Enables implementations of this interface to listen to compilation related events of the Graal 032 * Truffle runtime. The states for a particular {@link OptimizedCallTarget} that is compiled using 033 * the Graal Truffle system can be described using the following deterministic automata: * <code> 034 * <pre> 035 * ( (split | (queue . unqueue))* 036 * . queue . started 037 * . (truffleTierFinished . graalTierFinished . success) 038 * | ([truffleTierFinished] . [graalTierFinished] . failed) 039 * . invalidate )* 040 * </pre> 041 * </code> 042 * <p> 043 * Note: <code>|</code> is the 'or' and <code>.</code> is the sequential operator. The 044 * <code>*</code> represents the Kleene Closure. 045 * </p> 046 * 047 * @see GraalTruffleRuntime#addCompilationListener(GraalTruffleCompilationListener) 048 */ 049public interface GraalTruffleCompilationListener { 050 051 void notifyCompilationSplit(OptimizedDirectCallNode callNode); 052 053 /** 054 * Invoked if a call target was queued to the compilation queue. 055 */ 056 void notifyCompilationQueued(OptimizedCallTarget target); 057 058 /** 059 * Invoked if a call target was unqueued from the compilation queue. 060 * 061 * @param source the source object that caused the compilation to be unqueued. For example the 062 * source {@link Node} object. May be <code>null</code>. 063 * @param reason a textual description of the reason why the compilation was unqueued. May be 064 * <code>null</code>. 065 */ 066 void notifyCompilationDequeued(OptimizedCallTarget target, Object source, CharSequence reason); 067 068 void notifyCompilationFailed(OptimizedCallTarget target, StructuredGraph graph, Throwable t); 069 070 void notifyCompilationStarted(OptimizedCallTarget target); 071 072 void notifyCompilationTruffleTierFinished(OptimizedCallTarget target, StructuredGraph graph); 073 074 void notifyCompilationGraalTierFinished(OptimizedCallTarget target, StructuredGraph graph); 075 076 void notifyCompilationSuccess(OptimizedCallTarget target, StructuredGraph graph, CompilationResult result); 077 078 /** 079 * Invoked if a compiled call target was invalidated. 080 * 081 * @param source the source object that caused the compilation to be invalidated. For example 082 * the source {@link Node} object. May be <code>null</code>. 083 * @param reason a textual description of the reason why the compilation was invalidated. May be 084 * <code>null</code>. 085 */ 086 void notifyCompilationInvalidated(OptimizedCallTarget target, Object source, CharSequence reason); 087 088 /** 089 * Invoked as the compiler gets shut down. 090 */ 091 void notifyShutdown(GraalTruffleRuntime runtime); 092 093 /** 094 * Invoked as soon as the compiler is ready to use. 095 */ 096 void notifyStartup(GraalTruffleRuntime runtime); 097 098}