43972
|
1 |
/*
|
52910
|
2 |
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
43972
|
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 |
*/
|
50858
|
23 |
|
|
24 |
|
43972
|
25 |
package org.graalvm.compiler.nodes;
|
|
26 |
|
|
27 |
import java.util.List;
|
|
28 |
|
49873
|
29 |
import jdk.internal.vm.compiler.collections.EconomicSet;
|
43972
|
30 |
import org.graalvm.compiler.graph.NodeClass;
|
|
31 |
|
|
32 |
import jdk.vm.ci.meta.Assumptions;
|
49451
|
33 |
import jdk.vm.ci.meta.ResolvedJavaField;
|
43972
|
34 |
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
|
35 |
|
|
36 |
/**
|
|
37 |
* A {@link StructuredGraph} encoded in a compact binary representation as a byte[] array. See
|
|
38 |
* {@link GraphEncoder} for a description of the encoding format. Use {@link GraphDecoder} for
|
|
39 |
* decoding.
|
|
40 |
*/
|
52956
|
41 |
public class EncodedGraph {
|
43972
|
42 |
|
|
43 |
private final byte[] encoding;
|
46344
|
44 |
private final int startOffset;
|
52956
|
45 |
protected final Object[] objects;
|
43972
|
46 |
private final NodeClass<?>[] types;
|
|
47 |
private final Assumptions assumptions;
|
|
48 |
private final List<ResolvedJavaMethod> inlinedMethods;
|
49451
|
49 |
private final boolean trackNodeSourcePosition;
|
|
50 |
private final EconomicSet<ResolvedJavaField> fields;
|
|
51 |
private final boolean hasUnsafeAccess;
|
43972
|
52 |
|
|
53 |
/**
|
|
54 |
* The "table of contents" of the encoded graph, i.e., the mapping from orderId numbers to the
|
|
55 |
* offset in the encoded byte[] array. Used as a cache during decoding.
|
|
56 |
*/
|
46344
|
57 |
protected int[] nodeStartOffsets;
|
43972
|
58 |
|
49451
|
59 |
public EncodedGraph(byte[] encoding, int startOffset, Object[] objects, NodeClass<?>[] types, StructuredGraph sourceGraph) {
|
|
60 |
this(encoding, startOffset, objects, types, sourceGraph.getAssumptions(), sourceGraph.getMethods(), sourceGraph.getFields(), sourceGraph.hasUnsafeAccess(),
|
|
61 |
sourceGraph.trackNodeSourcePosition());
|
|
62 |
}
|
|
63 |
|
|
64 |
public EncodedGraph(byte[] encoding, int startOffset, Object[] objects, NodeClass<?>[] types, Assumptions assumptions, List<ResolvedJavaMethod> inlinedMethods,
|
|
65 |
EconomicSet<ResolvedJavaField> fields, boolean hasUnsafeAccess, boolean trackNodeSourcePosition) {
|
43972
|
66 |
this.encoding = encoding;
|
|
67 |
this.startOffset = startOffset;
|
|
68 |
this.objects = objects;
|
|
69 |
this.types = types;
|
|
70 |
this.assumptions = assumptions;
|
|
71 |
this.inlinedMethods = inlinedMethods;
|
49451
|
72 |
this.trackNodeSourcePosition = trackNodeSourcePosition;
|
|
73 |
this.fields = fields;
|
|
74 |
this.hasUnsafeAccess = hasUnsafeAccess;
|
43972
|
75 |
}
|
|
76 |
|
|
77 |
public byte[] getEncoding() {
|
|
78 |
return encoding;
|
|
79 |
}
|
|
80 |
|
46344
|
81 |
public int getStartOffset() {
|
43972
|
82 |
return startOffset;
|
|
83 |
}
|
|
84 |
|
54084
|
85 |
public Object[] getObjects() {
|
43972
|
86 |
return objects;
|
|
87 |
}
|
|
88 |
|
52956
|
89 |
public int getNumObjects() {
|
|
90 |
return objects.length;
|
|
91 |
}
|
|
92 |
|
|
93 |
public Object getObject(int i) {
|
|
94 |
return objects[i];
|
|
95 |
}
|
|
96 |
|
43972
|
97 |
public NodeClass<?>[] getNodeClasses() {
|
|
98 |
return types;
|
|
99 |
}
|
|
100 |
|
|
101 |
public Assumptions getAssumptions() {
|
|
102 |
return assumptions;
|
|
103 |
}
|
|
104 |
|
|
105 |
public List<ResolvedJavaMethod> getInlinedMethods() {
|
|
106 |
return inlinedMethods;
|
|
107 |
}
|
49451
|
108 |
|
|
109 |
public boolean trackNodeSourcePosition() {
|
|
110 |
return trackNodeSourcePosition;
|
|
111 |
}
|
|
112 |
|
|
113 |
public EconomicSet<ResolvedJavaField> getFields() {
|
|
114 |
return fields;
|
|
115 |
}
|
|
116 |
|
|
117 |
public boolean hasUnsafeAccess() {
|
|
118 |
return hasUnsafeAccess;
|
|
119 |
}
|
52956
|
120 |
|
|
121 |
@SuppressWarnings("unused")
|
|
122 |
public boolean isCallToOriginal(ResolvedJavaMethod callTarget) {
|
|
123 |
return false;
|
|
124 |
}
|
43972
|
125 |
}
|