Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java @ 21995:922a0438914b
Introduce common superclass for all write barriers.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Wed, 17 Jun 2015 15:42:27 +0200 |
parents | ae2a39857ab4 |
children | 0e095e2c24e2 |
rev | line source |
---|---|
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@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:
18998
diff
changeset
|
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
4 * |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
8 * |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
14 * |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
18 * |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
22 */ |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot.nodes; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
24 |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21554
diff
changeset
|
25 import com.oracle.jvmci.meta.Value; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21554
diff
changeset
|
26 import com.oracle.jvmci.meta.JavaConstant; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21554
diff
changeset
|
27 import com.oracle.jvmci.meta.ConstantReflectionProvider; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21554
diff
changeset
|
28 import com.oracle.jvmci.meta.Constant; |
15198
2c0cfbf454b5
Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
29 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:
18998
diff
changeset
|
30 import com.oracle.graal.graph.*; |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.graph.spi.*; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.hotspot.*; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.hotspot.nodes.type.*; |
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:
16837
diff
changeset
|
34 import com.oracle.graal.nodeinfo.*; |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.nodes.*; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.nodes.calc.*; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.graal.nodes.spi.*; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.graal.nodes.type.*; |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21526
diff
changeset
|
39 import com.oracle.jvmci.common.*; |
21551
5324104ac4f3
moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21543
diff
changeset
|
40 import com.oracle.jvmci.hotspot.*; |
21554
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
41 import com.oracle.jvmci.hotspot.HotSpotVMConfig.CompressEncoding; |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
42 |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
43 /** |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
44 * Compress or uncompress an oop or metaspace pointer. |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
45 */ |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
46 @NodeInfo(nameTemplate = "{p#op/s}") |
18998
ec0733b5a90a
Allow final modifier on node subclasses and start adding the modifier to leaf classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
47 public final class CompressionNode extends UnaryNode implements ConvertNode, LIRLowerable { |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
48 |
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
|
49 public static final NodeClass<CompressionNode> TYPE = NodeClass.create(CompressionNode.class); |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18998
diff
changeset
|
50 |
18178
b9f31ed0643b
Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
51 public enum CompressionOp { |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
52 Compress, |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
53 Uncompress |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
54 } |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
55 |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
56 protected final CompressionOp op; |
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
57 protected final CompressEncoding encoding; |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
58 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18720
diff
changeset
|
59 public CompressionNode(CompressionOp op, ValueNode input, CompressEncoding encoding) { |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18998
diff
changeset
|
60 super(TYPE, mkStamp(op, input.stamp(), encoding), input); |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
61 this.op = op; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
62 this.encoding = encoding; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
63 } |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
64 |
16593
ba48a694e4c1
inferStamp for CompressionNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16216
diff
changeset
|
65 @Override |
ba48a694e4c1
inferStamp for CompressionNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16216
diff
changeset
|
66 public boolean inferStamp() { |
ba48a694e4c1
inferStamp for CompressionNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16216
diff
changeset
|
67 return updateStamp(mkStamp(op, getValue().stamp(), encoding)); |
ba48a694e4c1
inferStamp for CompressionNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16216
diff
changeset
|
68 } |
ba48a694e4c1
inferStamp for CompressionNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16216
diff
changeset
|
69 |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
70 public static CompressionNode compress(ValueNode input, CompressEncoding encoding) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18720
diff
changeset
|
71 return input.graph().unique(new CompressionNode(CompressionOp.Compress, input, encoding)); |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
72 } |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
73 |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
74 public static CompressionNode uncompress(ValueNode input, CompressEncoding encoding) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18720
diff
changeset
|
75 return input.graph().unique(new CompressionNode(CompressionOp.Uncompress, input, encoding)); |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
76 } |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
77 |
18188
8652481a1110
Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
78 private static Constant compress(Constant c, CompressEncoding encoding) { |
18490
ca81508f2a19
Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18487
diff
changeset
|
79 if (JavaConstant.NULL_POINTER.equals(c)) { |
15912
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
80 return HotSpotCompressedNullConstant.COMPRESSED_NULL; |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
81 } else if (c instanceof HotSpotObjectConstant) { |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
82 return ((HotSpotObjectConstant) c).compress(); |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
83 } else if (c instanceof HotSpotMetaspaceConstant) { |
18266
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18188
diff
changeset
|
84 return ((HotSpotMetaspaceConstant) c).compress(encoding); |
15912
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
85 } else { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21526
diff
changeset
|
86 throw JVMCIError.shouldNotReachHere("invalid constant input for compress op: " + c); |
15912
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
87 } |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
88 } |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
89 |
18188
8652481a1110
Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
90 private static Constant uncompress(Constant c, CompressEncoding encoding) { |
15912
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
91 if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(c)) { |
18490
ca81508f2a19
Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18487
diff
changeset
|
92 return JavaConstant.NULL_POINTER; |
15912
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
93 } else if (c instanceof HotSpotObjectConstant) { |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
94 return ((HotSpotObjectConstant) c).uncompress(); |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
95 } else if (c instanceof HotSpotMetaspaceConstant) { |
18266
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18188
diff
changeset
|
96 return ((HotSpotMetaspaceConstant) c).uncompress(encoding); |
15912
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
97 } else { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21526
diff
changeset
|
98 throw JVMCIError.shouldNotReachHere("invalid constant input for uncompress op: " + c); |
15912
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
99 } |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
100 } |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
101 |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
102 @Override |
18720
ab9d3ff6829b
Pass constant reflection into ConvertNode.convert
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18490
diff
changeset
|
103 public Constant convert(Constant c, ConstantReflectionProvider constantReflection) { |
15912
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
104 switch (op) { |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
105 case Compress: |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
106 return compress(c, encoding); |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
107 case Uncompress: |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
108 return uncompress(c, encoding); |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
109 default: |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21526
diff
changeset
|
110 throw JVMCIError.shouldNotReachHere(); |
15912
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
111 } |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
112 } |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
113 |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
114 @Override |
18720
ab9d3ff6829b
Pass constant reflection into ConvertNode.convert
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18490
diff
changeset
|
115 public Constant reverse(Constant c, ConstantReflectionProvider constantReflection) { |
15912
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
116 switch (op) { |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
117 case Compress: |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
118 return uncompress(c, encoding); |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
119 case Uncompress: |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
120 return compress(c, encoding); |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
121 default: |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21526
diff
changeset
|
122 throw JVMCIError.shouldNotReachHere(); |
15912
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
123 } |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
124 } |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
125 |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
126 @Override |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
127 public boolean isLossless() { |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
128 return true; |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
129 } |
c44f617fb8d7
Optimize compare compressed pattern.
Roland Schatz <roland.schatz@oracle.com>
parents:
15817
diff
changeset
|
130 |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
131 private static Stamp mkStamp(CompressionOp op, Stamp input, CompressEncoding encoding) { |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
132 switch (op) { |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
133 case Compress: |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
134 if (input instanceof ObjectStamp) { |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
135 // compressed oop |
15817
8b24f4684aa0
Introduce AbstractObjectStamp, make ObjectStamp and NarrowOopStamp incompatible.
Roland Schatz <roland.schatz@oracle.com>
parents:
15532
diff
changeset
|
136 return NarrowOopStamp.compressed((ObjectStamp) input, encoding); |
18481
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18400
diff
changeset
|
137 } else if (input instanceof KlassPointerStamp) { |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18400
diff
changeset
|
138 // compressed klass pointer |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18400
diff
changeset
|
139 return ((KlassPointerStamp) input).compressed(encoding); |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
140 } |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
141 break; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
142 case Uncompress: |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
143 if (input instanceof NarrowOopStamp) { |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
144 // oop |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
145 assert encoding.equals(((NarrowOopStamp) input).getEncoding()); |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
146 return ((NarrowOopStamp) input).uncompressed(); |
18481
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18400
diff
changeset
|
147 } else if (input instanceof KlassPointerStamp) { |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
148 // metaspace pointer |
18481
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18400
diff
changeset
|
149 assert encoding.equals(((KlassPointerStamp) input).getEncoding()); |
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18400
diff
changeset
|
150 return ((KlassPointerStamp) input).uncompressed(); |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
151 } |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
152 break; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
153 } |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21526
diff
changeset
|
154 throw JVMCIError.shouldNotReachHere(String.format("Unexpected input stamp %s", input)); |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
155 } |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
156 |
21786
ae2a39857ab4
Use AMD64 addressing modes for direct reading from narrow oops.
Roland Schatz <roland.schatz@oracle.com>
parents:
21556
diff
changeset
|
157 public CompressionOp getOp() { |
ae2a39857ab4
Use AMD64 addressing modes for direct reading from narrow oops.
Roland Schatz <roland.schatz@oracle.com>
parents:
21556
diff
changeset
|
158 return op; |
ae2a39857ab4
Use AMD64 addressing modes for direct reading from narrow oops.
Roland Schatz <roland.schatz@oracle.com>
parents:
21556
diff
changeset
|
159 } |
ae2a39857ab4
Use AMD64 addressing modes for direct reading from narrow oops.
Roland Schatz <roland.schatz@oracle.com>
parents:
21556
diff
changeset
|
160 |
15522
589c3627fab8
special cases for addresses involving compressed references
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15370
diff
changeset
|
161 public CompressEncoding getEncoding() { |
589c3627fab8
special cases for addresses involving compressed references
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15370
diff
changeset
|
162 return encoding; |
589c3627fab8
special cases for addresses involving compressed references
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15370
diff
changeset
|
163 } |
589c3627fab8
special cases for addresses involving compressed references
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15370
diff
changeset
|
164 |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
165 @Override |
16216
388b787a5fe6
implement Canonicalizable.Unary in the UnaryNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16156
diff
changeset
|
166 public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) { |
388b787a5fe6
implement Canonicalizable.Unary in the UnaryNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16156
diff
changeset
|
167 if (forValue.isConstant()) { |
18720
ab9d3ff6829b
Pass constant reflection into ConvertNode.convert
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18490
diff
changeset
|
168 return ConstantNode.forConstant(stamp(), convert(forValue.asConstant(), tool.getConstantReflection()), tool.getMetaAccess()); |
16216
388b787a5fe6
implement Canonicalizable.Unary in the UnaryNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16156
diff
changeset
|
169 } else if (forValue instanceof CompressionNode) { |
388b787a5fe6
implement Canonicalizable.Unary in the UnaryNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16156
diff
changeset
|
170 CompressionNode other = (CompressionNode) forValue; |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
171 if (op != other.op && encoding.equals(other.encoding)) { |
16156
0993768dfc8e
new UnaryNode base class
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16003
diff
changeset
|
172 return other.getValue(); |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
173 } |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
174 } |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
175 return this; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
176 } |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
177 |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
178 @Override |
14950
d5a1206e1923
NodeLIRBuilderTool: fix typo in interface name.
Josef Eisl <josef.eisl@jku.at>
parents:
14943
diff
changeset
|
179 public void generate(NodeLIRBuilderTool gen) { |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
180 HotSpotLIRGenerator hsGen = (HotSpotLIRGenerator) gen.getLIRGeneratorTool(); |
15058
895e9ecedfe8
Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
14950
diff
changeset
|
181 boolean nonNull; |
16156
0993768dfc8e
new UnaryNode base class
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16003
diff
changeset
|
182 if (getValue().stamp() instanceof AbstractObjectStamp) { |
18490
ca81508f2a19
Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18487
diff
changeset
|
183 nonNull = StampTool.isPointerNonNull(getValue().stamp()); |
15058
895e9ecedfe8
Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
14950
diff
changeset
|
184 } else { |
895e9ecedfe8
Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
14950
diff
changeset
|
185 // metaspace pointers are never null |
895e9ecedfe8
Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
14950
diff
changeset
|
186 nonNull = true; |
895e9ecedfe8
Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
14950
diff
changeset
|
187 } |
895e9ecedfe8
Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
14950
diff
changeset
|
188 |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
189 Value result; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
190 switch (op) { |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
191 case Compress: |
16156
0993768dfc8e
new UnaryNode base class
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16003
diff
changeset
|
192 result = hsGen.emitCompress(gen.operand(getValue()), encoding, nonNull); |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
193 break; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
194 case Uncompress: |
16156
0993768dfc8e
new UnaryNode base class
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16003
diff
changeset
|
195 result = hsGen.emitUncompress(gen.operand(getValue()), encoding, nonNull); |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
196 break; |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
197 default: |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21526
diff
changeset
|
198 throw JVMCIError.shouldNotReachHere(); |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
199 } |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
200 gen.setResult(this, result); |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
201 } |
18178
b9f31ed0643b
Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
202 |
b9f31ed0643b
Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
203 @NodeIntrinsic |
b9f31ed0643b
Unit tests for data patches.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
204 public static native Object compression(@ConstantNodeParameter CompressionOp op, Object object, @ConstantNodeParameter CompressEncoding encoding); |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
205 } |