NodeSize.java revision 12651:6ef01bd40ce2
1/*
2 * Copyright (c) 2016, 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 */
23package org.graalvm.compiler.nodeinfo;
24
25/**
26 * Constants representing an estimation of of the size needed to represent a compiler node in
27 * machine code.
28 */
29public enum NodeSize {
30
31    /**
32     * The default value of the {@link NodeInfo#size()} property.
33     * <p>
34     * For further information about the use of {@code SIZE_UNSET} see {@link NodeInfo#size()}.
35     */
36    SIZE_UNSET(0),
37    /**
38     * Nodes for which, due to arbitrary reasons, no estimation can be made either (1) statically
39     * without inspecting the properties of a node or (2) at all (like e.g. for an invocation).
40     * <p>
41     * Nodes annotated with {@code SIZE_UNKNOWN} should specify the {@link NodeInfo#sizeRationale()}
42     * property to clarify why an estimation cannot be done.
43     */
44    SIZE_UNKNOWN(0),
45    /**
46     * Nodes for which code size information is irrelevant and can be ignored, e.g. for test nodes.
47     */
48    SIZE_IGNORED(0),
49    /**
50     * Nodes that do not require any code to be generated in order to be "executed", e.g. a phi
51     * node.
52     */
53    SIZE_0(0),
54    SIZE_1(1),
55    SIZE_2(2),
56    SIZE_3(3),
57    SIZE_4(4),
58    SIZE_6(6),
59    SIZE_8(8),
60    SIZE_10(10),
61    SIZE_15(15),
62    SIZE_20(20),
63    SIZE_30(30),
64    SIZE_40(40),
65    SIZE_50(50),
66    SIZE_80(80),
67    SIZE_100(100),
68    SIZE_200(200);
69
70    public final int estimatedCodeSize;
71
72    NodeSize(int estimatedCodeSize) {
73        this.estimatedCodeSize = estimatedCodeSize;
74    }
75
76    public static final int IGNORE_SIZE_CONTRACT_FACTOR = 0xFFFF;
77}
78