1 /*
2 * Copyright (c) 2015, 2018, 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
238 * Gets the inline depth of this context. A return value of 0 implies that this is the context
239 * for the parse root.
240 */
241 default int getDepth() {
242 GraphBuilderContext parent = getParent();
243 int result = 0;
244 while (parent != null) {
245 result++;
246 parent = parent.getParent();
247 }
248 return result;
249 }
250
251 /**
252 * Determines if this parsing context is within the bytecode of an intrinsic or a method inlined
253 * by an intrinsic.
254 */
255 @Override
256 default boolean parsingIntrinsic() {
257 return getIntrinsic() != null;
258 }
259
260 /**
261 * Gets the intrinsic of the current parsing context or {@code null} if not
262 * {@link #parsingIntrinsic() parsing an intrinsic}.
263 */
264 IntrinsicContext getIntrinsic();
265
266 BailoutException bailout(String string);
267
268 default ValueNode nullCheckedValue(ValueNode value) {
269 return nullCheckedValue(value, InvalidateReprofile);
270 }
271
272 /**
273 * Gets a version of a given value that has a {@linkplain StampTool#isPointerNonNull(ValueNode)
274 * non-null} stamp.
275 */
276 default ValueNode nullCheckedValue(ValueNode value, DeoptimizationAction action) {
277 if (!StampTool.isPointerNonNull(value)) {
|
1 /*
2 * Copyright (c) 2015, 2019, 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
238 * Gets the inline depth of this context. A return value of 0 implies that this is the context
239 * for the parse root.
240 */
241 default int getDepth() {
242 GraphBuilderContext parent = getParent();
243 int result = 0;
244 while (parent != null) {
245 result++;
246 parent = parent.getParent();
247 }
248 return result;
249 }
250
251 /**
252 * Determines if this parsing context is within the bytecode of an intrinsic or a method inlined
253 * by an intrinsic.
254 */
255 @Override
256 default boolean parsingIntrinsic() {
257 return getIntrinsic() != null;
258 }
259
260 /**
261 * Determines if a graph builder plugin is enabled under current context.
262 */
263 default boolean isPluginEnabled(GraphBuilderPlugin plugin) {
264 return parsingIntrinsic() || !(plugin instanceof GeneratedInvocationPlugin && ((GeneratedInvocationPlugin) plugin).isGeneratedFromFoldOrNodeIntrinsic());
265 }
266
267 /**
268 * Gets the intrinsic of the current parsing context or {@code null} if not
269 * {@link #parsingIntrinsic() parsing an intrinsic}.
270 */
271 IntrinsicContext getIntrinsic();
272
273 BailoutException bailout(String string);
274
275 default ValueNode nullCheckedValue(ValueNode value) {
276 return nullCheckedValue(value, InvalidateReprofile);
277 }
278
279 /**
280 * Gets a version of a given value that has a {@linkplain StampTool#isPointerNonNull(ValueNode)
281 * non-null} stamp.
282 */
283 default ValueNode nullCheckedValue(ValueNode value, DeoptimizationAction action) {
284 if (!StampTool.isPointerNonNull(value)) {
|