001/* 002 * Copyright (c) 2015, 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.graphbuilderconf; 024 025import jdk.internal.jvmci.meta.*; 026 027import com.oracle.graal.nodes.*; 028 029public interface NodePlugin extends GraphBuilderPlugin { 030 /** 031 * Handle the parsing of a method invocation bytecode to a method that can be bound statically. 032 * If the method returns true, it must {@link GraphBuilderContext#push push} a value as the 033 * result of the method invocation using the {@link Signature#getReturnKind return kind} of the 034 * method. 035 * 036 * @param b the context 037 * @param method the statically bound, invoked method 038 * @param args the arguments of the method invocation 039 * @return true if the plugin handles the invocation, false otherwise 040 */ 041 default boolean handleInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) { 042 return false; 043 } 044 045 /** 046 * Handle the parsing of a GETFIELD bytecode. If the method returns true, it must 047 * {@link GraphBuilderContext#push push} a value using the {@link ResolvedJavaField#getKind() 048 * kind} of the field. 049 * 050 * @param b the context 051 * @param object the receiver object for the field access 052 * @param field the accessed field 053 * @return true if the plugin handles the field access, false otherwise 054 */ 055 default boolean handleLoadField(GraphBuilderContext b, ValueNode object, ResolvedJavaField field) { 056 return false; 057 } 058 059 /** 060 * Handle the parsing of a GETSTATIC bytecode. If the method returns true, it must 061 * {@link GraphBuilderContext#push push} a value using the {@link ResolvedJavaField#getKind() 062 * kind} of the field. 063 * 064 * @param b the context 065 * @param field the accessed field 066 * @return true if the plugin handles the field access, false otherwise 067 */ 068 default boolean handleLoadStaticField(GraphBuilderContext b, ResolvedJavaField field) { 069 return false; 070 } 071 072 /** 073 * Handle the parsing of a PUTFIELD bytecode. 074 * 075 * @param b the context 076 * @param object the receiver object for the field access 077 * @param field the accessed field 078 * @param value the value to be stored into the field 079 * @return true if the plugin handles the field access, false otherwise 080 */ 081 default boolean handleStoreField(GraphBuilderContext b, ValueNode object, ResolvedJavaField field, ValueNode value) { 082 return false; 083 } 084 085 /** 086 * Handle the parsing of a PUTSTATIC bytecode. 087 * 088 * @param b the context 089 * @param field the accessed field 090 * @param value the value to be stored into the field 091 * @return true if the plugin handles the field access, false otherwise. 092 */ 093 default boolean handleStoreStaticField(GraphBuilderContext b, ResolvedJavaField field, ValueNode value) { 094 return false; 095 } 096 097 /** 098 * Handle the parsing of an array load bytecode. If the method returns true, it must 099 * {@link GraphBuilderContext#push push} a value using the provided elementKind. 100 * 101 * @param b the context 102 * @param array the accessed array 103 * @param index the index for the array access 104 * @param elementKind the element kind of the accessed array 105 * @return true if the plugin handles the array access, false otherwise. 106 */ 107 default boolean handleLoadIndexed(GraphBuilderContext b, ValueNode array, ValueNode index, Kind elementKind) { 108 return false; 109 } 110 111 /** 112 * Handle the parsing of an array store bytecode. 113 * 114 * @param b the context 115 * @param array the accessed array 116 * @param index the index for the array access 117 * @param elementKind the element kind of the accessed array 118 * @param value the value to be stored into the array 119 * @return true if the plugin handles the array access, false otherwise. 120 */ 121 default boolean handleStoreIndexed(GraphBuilderContext b, ValueNode array, ValueNode index, Kind elementKind, ValueNode value) { 122 return false; 123 } 124 125 /** 126 * Handle the parsing of a CHECKCAST bytecode. If the method returns true, it must 127 * {@link GraphBuilderContext#push push} a value with the result of the cast using 128 * {@link Kind#Object}. 129 * 130 * @param b the context 131 * @param object the object to be type checked 132 * @param type the type that the object is checked against 133 * @param profile the profiling information for the type check, or null if no profiling 134 * information is available 135 * @return true if the plugin handles the cast, false otherwise 136 */ 137 default boolean handleCheckCast(GraphBuilderContext b, ValueNode object, ResolvedJavaType type, JavaTypeProfile profile) { 138 return false; 139 } 140 141 /** 142 * Handle the parsing of a INSTANCEOF bytecode. If the method returns true, it must 143 * {@link GraphBuilderContext#push push} a value with the result of the instanceof using 144 * {@link Kind#Int}. 145 * 146 * @param b the context 147 * @param object the object to be type checked 148 * @param type the type that the object is checked against 149 * @param profile the profiling information for the type check, or null if no profiling 150 * information is available 151 * @return true if the plugin handles the instanceof, false otherwise 152 */ 153 default boolean handleInstanceOf(GraphBuilderContext b, ValueNode object, ResolvedJavaType type, JavaTypeProfile profile) { 154 return false; 155 } 156 157 /** 158 * If the plugin {@link GraphBuilderContext#push pushes} a value with a different {@link Kind} 159 * than specified by the bytecode, it must override this method and return {@code true}. This 160 * disables assertion checking for value kinds. 161 * 162 * @param b the context 163 */ 164 default boolean canChangeStackKind(GraphBuilderContext b) { 165 return false; 166 } 167}