Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/RegisterFinalizerNode.java @ 19800:3362ba500371
Connect required Assumptions with answer to CHA query
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 11 Mar 2015 17:32:04 -0700 |
parents | 14e703edb2ab |
children | d256b81b6335 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.nodes.java; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15301
diff
changeset
|
25 import static com.oracle.graal.nodes.java.ForeignCallDescriptors.*; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15301
diff
changeset
|
26 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5443
diff
changeset
|
27 import com.oracle.graal.api.code.*; |
19800
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19775
diff
changeset
|
28 import com.oracle.graal.api.meta.*; |
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19775
diff
changeset
|
29 import com.oracle.graal.api.meta.Assumptions.AssumptionResult; |
15261
882f4cb7cfcf
Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15001
diff
changeset
|
30 import com.oracle.graal.compiler.common.type.*; |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
31 import com.oracle.graal.graph.*; |
11881
da9db8331658
moved Canonicalizable and Simplifiable to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11880
diff
changeset
|
32 import com.oracle.graal.graph.spi.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16811
diff
changeset
|
33 import com.oracle.graal.nodeinfo.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
34 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.nodes.spi.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7300
diff
changeset
|
38 * This node is used to perform the finalizer registration at the end of the java.lang.Object |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7300
diff
changeset
|
39 * constructor. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 */ |
16811
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16332
diff
changeset
|
41 @NodeInfo |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
42 public final class RegisterFinalizerNode extends AbstractStateSplit implements Canonicalizable.Unary<ValueNode>, LIRLowerable, Virtualizable, DeoptimizingNode.DeoptAfter { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 |
19529
8fc336a04d77
Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19410
diff
changeset
|
44 public static final NodeClass<RegisterFinalizerNode> TYPE = NodeClass.create(RegisterFinalizerNode.class); |
16897
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
45 @OptionalInput(InputType.State) FrameState deoptState; |
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
46 @Input ValueNode value; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
17450
diff
changeset
|
48 public RegisterFinalizerNode(ValueNode value) { |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19306
diff
changeset
|
49 super(TYPE, StampFactory.forVoid()); |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15926
diff
changeset
|
50 this.value = value; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15926
diff
changeset
|
53 public ValueNode getValue() { |
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15926
diff
changeset
|
54 return value; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 @Override |
14950
d5a1206e1923
NodeLIRBuilderTool: fix typo in interface name.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
58 public void generate(NodeLIRBuilderTool gen) { |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14836
diff
changeset
|
59 ForeignCallLinkage linkage = gen.getLIRGeneratorTool().getForeignCalls().lookupForeignCall(REGISTER_FINALIZER); |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15926
diff
changeset
|
60 gen.getLIRGeneratorTool().emitForeignCall(linkage, gen.state(this), gen.operand(getValue())); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 |
19068
0499dbe2da01
factored out common code
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
63 /** |
0499dbe2da01
factored out common code
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
64 * Determines if the compiler should emit code to test whether a given object has a finalizer |
0499dbe2da01
factored out common code
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
65 * that must be registered with the runtime upon object initialization. |
0499dbe2da01
factored out common code
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
66 */ |
0499dbe2da01
factored out common code
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
67 public static boolean mayHaveFinalizer(ValueNode object, Assumptions assumptions) { |
0499dbe2da01
factored out common code
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
68 ObjectStamp objectStamp = (ObjectStamp) object.stamp(); |
0499dbe2da01
factored out common code
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
69 if (objectStamp.isExactType()) { |
0499dbe2da01
factored out common code
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
70 return objectStamp.type().hasFinalizer(); |
19800
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19775
diff
changeset
|
71 } else if (objectStamp.type() != null && assumptions != null) { |
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19775
diff
changeset
|
72 AssumptionResult<Boolean> result = objectStamp.type().hasFinalizableSubclass(); |
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19775
diff
changeset
|
73 assumptions.record(result); |
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19775
diff
changeset
|
74 return result.getResult(); |
19068
0499dbe2da01
factored out common code
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
75 } |
0499dbe2da01
factored out common code
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
76 return true; |
0499dbe2da01
factored out common code
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
77 } |
0499dbe2da01
factored out common code
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
78 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 @Override |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15926
diff
changeset
|
80 public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) { |
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15926
diff
changeset
|
81 if (!(forValue.stamp() instanceof ObjectStamp)) { |
11265 | 82 return this; |
83 } | |
19250
8ab925a6f724
made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents:
19068
diff
changeset
|
84 if (!mayHaveFinalizer(forValue, graph().getAssumptions())) { |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
85 return null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 return this; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 } |
8400
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
90 |
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
91 @Override |
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
92 public void virtualize(VirtualizerTool tool) { |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15926
diff
changeset
|
93 State state = tool.getObjectState(getValue()); |
8400
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
94 if (state != null && !state.getVirtualObject().type().hasFinalizer()) { |
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
95 tool.delete(); |
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
96 } |
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
97 } |
8485
ba0458c143bb
finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents:
8449
diff
changeset
|
98 |
8892
2c0c708a0ad6
Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8485
diff
changeset
|
99 @Override |
2c0c708a0ad6
Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8485
diff
changeset
|
100 public boolean canDeoptimize() { |
2c0c708a0ad6
Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8485
diff
changeset
|
101 return true; |
2c0c708a0ad6
Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8485
diff
changeset
|
102 } |
2c0c708a0ad6
Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8485
diff
changeset
|
103 |
8485
ba0458c143bb
finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents:
8449
diff
changeset
|
104 @NodeIntrinsic |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19529
diff
changeset
|
105 public static native void register(Object thisObj); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 } |