Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/RegisterFinalizerNode.java @ 16895:06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 18 Aug 2014 14:04:21 +0200 |
parents | cbd42807a31f |
children | f90dcdbbb75e |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15926
diff
changeset
|
2 * Copyright (c) 2011, 2014, 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.*; |
15261
882f4cb7cfcf
Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15001
diff
changeset
|
28 import com.oracle.graal.compiler.common.type.*; |
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
|
29 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
|
30 import com.oracle.graal.nodeinfo.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
32 import com.oracle.graal.nodes.spi.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7300
diff
changeset
|
35 * 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
|
36 * constructor. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 */ |
16811
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16332
diff
changeset
|
38 @NodeInfo |
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16332
diff
changeset
|
39 public 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
|
40 |
16332
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16248
diff
changeset
|
41 @OptionalInput(InputType.State) private FrameState deoptState; |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15926
diff
changeset
|
42 @Input private ValueNode value; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
44 public static RegisterFinalizerNode create(ValueNode value) { |
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
45 return new RegisterFinalizerNodeGen(value); |
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
46 } |
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
47 |
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
48 RegisterFinalizerNode(ValueNode value) { |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15926
diff
changeset
|
49 super(StampFactory.forVoid()); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 @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
|
64 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
|
65 if (!(forValue.stamp() instanceof ObjectStamp)) { |
11265 | 66 return this; |
67 } | |
68 | |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15926
diff
changeset
|
69 ObjectStamp stamp = (ObjectStamp) forValue.stamp(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 boolean needsCheck = true; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5375
diff
changeset
|
72 if (stamp.isExactType()) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5375
diff
changeset
|
73 needsCheck = stamp.type().hasFinalizer(); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5375
diff
changeset
|
74 } else if (stamp.type() != null && !stamp.type().hasFinalizableSubclass()) { |
8485
ba0458c143bb
finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents:
8449
diff
changeset
|
75 // if either the declared type of receiver or the holder |
ba0458c143bb
finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents:
8449
diff
changeset
|
76 // can be assumed to have no finalizers |
9012
2979aaac95af
assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents:
8955
diff
changeset
|
77 if (tool.assumptions().useOptimisticAssumptions()) { |
2979aaac95af
assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents:
8955
diff
changeset
|
78 tool.assumptions().recordNoFinalizableSubclassAssumption(stamp.type()); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5375
diff
changeset
|
79 needsCheck = false; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 if (!needsCheck) { |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
84 return null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 } |
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 return this; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 } |
8400
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
89 |
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
90 @Override |
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
91 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
|
92 State state = tool.getObjectState(getValue()); |
8400
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
93 if (state != null && !state.getVirtualObject().type().hasFinalizer()) { |
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
94 tool.delete(); |
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
95 } |
afb190b1eeb3
added RegisterFinalizer.virtualize
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
96 } |
8485
ba0458c143bb
finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents:
8449
diff
changeset
|
97 |
8892
2c0c708a0ad6
Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8485
diff
changeset
|
98 @Override |
2c0c708a0ad6
Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8485
diff
changeset
|
99 public boolean canDeoptimize() { |
2c0c708a0ad6
Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8485
diff
changeset
|
100 return true; |
2c0c708a0ad6
Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8485
diff
changeset
|
101 } |
2c0c708a0ad6
Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8485
diff
changeset
|
102 |
8485
ba0458c143bb
finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents:
8449
diff
changeset
|
103 @SuppressWarnings("unused") |
ba0458c143bb
finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents:
8449
diff
changeset
|
104 @NodeIntrinsic |
ba0458c143bb
finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents:
8449
diff
changeset
|
105 public static void register(Object thisObj) { |
ba0458c143bb
finalizer registration is now done via method substitution (again)
Doug Simon <doug.simon@oracle.com>
parents:
8449
diff
changeset
|
106 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 } |