annotate graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java @ 20110:51f2e71b57aa

Improvements to the Stamp infrastructure. New methods Stamp#improveWith, Stamp#tryImproveWith, Stamp#isIllegal.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 01 Apr 2015 16:36:15 +0200
parents 5ea169a3bf81
children 7b0ff8da6057
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
1 /*
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
4 *
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
8 *
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
13 * accompanied this code).
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
14 *
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
18 *
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
21 * questions.
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
22 */
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15198
diff changeset
23 package com.oracle.graal.compiler.common.type;
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
24
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
25 import com.oracle.graal.api.meta.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 14997
diff changeset
26 import com.oracle.graal.compiler.common.*;
15198
2c0cfbf454b5 Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
27 import com.oracle.graal.compiler.common.spi.*;
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
28
11387
9088d13767f3 Keep a kind in the illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11265
diff changeset
29 /**
9088d13767f3 Keep a kind in the illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11265
diff changeset
30 * This stamp represents the illegal type. Values with this type can not exist at run time.
9088d13767f3 Keep a kind in the illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11265
diff changeset
31 */
14997
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
32 public final class IllegalStamp extends Stamp {
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
33
14997
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
34 private IllegalStamp() {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
35 }
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
36
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
37 @Override
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
38 public Kind getStackKind() {
14997
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
39 return Kind.Illegal;
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
40 }
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
41
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
42 @Override
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15198
diff changeset
43 public LIRKind getLIRKind(LIRKindTool tool) {
14003
0c38906450a0 Make conversion from Stamp to PlatformKind extensible by backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
44 throw GraalInternalError.shouldNotReachHere("illegal stamp should not reach backend");
0c38906450a0 Make conversion from Stamp to PlatformKind extensible by backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
45 }
0c38906450a0 Make conversion from Stamp to PlatformKind extensible by backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
46
0c38906450a0 Make conversion from Stamp to PlatformKind extensible by backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
47 @Override
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
48 public Stamp unrestricted() {
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
49 return this;
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
50 }
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
51
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
52 @Override
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
53 public Stamp illegal() {
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
54 return this;
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
55 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
56
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
57 @Override
18188
8652481a1110 Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
58 public Stamp constant(Constant c, MetaAccessProvider meta) {
16328
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15198
diff changeset
59 throw GraalInternalError.shouldNotReachHere("illegal stamp has no value");
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15198
diff changeset
60 }
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15198
diff changeset
61
34ac3ddfd5ac [SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15198
diff changeset
62 @Override
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
63 public ResolvedJavaType javaType(MetaAccessProvider metaAccess) {
14997
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
64 throw GraalInternalError.shouldNotReachHere("illegal stamp has no Java type");
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
65 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
66
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
67 @Override
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
68 public Stamp meet(Stamp other) {
14997
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
69 return this;
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
70 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
71
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
72 @Override
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
73 public Stamp join(Stamp other) {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
74 return this;
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
75 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
76
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
77 @Override
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
78 public boolean isCompatible(Stamp stamp) {
14997
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
79 return false;
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
80 }
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
81
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 11887
diff changeset
82 @Override
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
83 public String toString() {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
84 return "ILLEGAL";
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
85 }
14997
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
86
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
87 @Override
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
88 public boolean isLegal() {
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
89 return false;
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
90 }
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
91
18359
a3a2359ac88e Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents: 18188
diff changeset
92 @Override
20110
51f2e71b57aa Improvements to the Stamp infrastructure. New methods Stamp#improveWith, Stamp#tryImproveWith, Stamp#isIllegal.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19358
diff changeset
93 public Stamp improveWith(Stamp other) {
51f2e71b57aa Improvements to the Stamp infrastructure. New methods Stamp#improveWith, Stamp#tryImproveWith, Stamp#isIllegal.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19358
diff changeset
94 return this;
51f2e71b57aa Improvements to the Stamp infrastructure. New methods Stamp#improveWith, Stamp#tryImproveWith, Stamp#isIllegal.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19358
diff changeset
95 }
51f2e71b57aa Improvements to the Stamp infrastructure. New methods Stamp#improveWith, Stamp#tryImproveWith, Stamp#isIllegal.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19358
diff changeset
96
51f2e71b57aa Improvements to the Stamp infrastructure. New methods Stamp#improveWith, Stamp#tryImproveWith, Stamp#isIllegal.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19358
diff changeset
97 @Override
18482
b8a622c3e99f Move raw memory access operations to a separate interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 18359
diff changeset
98 public Constant readConstant(MemoryAccessProvider provider, Constant base, long displacement) {
18359
a3a2359ac88e Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents: 18188
diff changeset
99 throw GraalInternalError.shouldNotReachHere("can't read values of illegal stamp");
a3a2359ac88e Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents: 18188
diff changeset
100 }
a3a2359ac88e Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents: 18188
diff changeset
101
19358
5ea169a3bf81 make various fields final
Lukas Stadler <lukas.stadler@oracle.com>
parents: 18482
diff changeset
102 private static final IllegalStamp instance = new IllegalStamp();
14997
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
103
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
104 static IllegalStamp getInstance() {
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
105 return instance;
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 14558
diff changeset
106 }
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
107 }