1 /* 2 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. 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 */ 23 24 25 package org.graalvm.compiler.core.common.type; 26 27 import org.graalvm.compiler.core.common.LIRKind; 28 import org.graalvm.compiler.core.common.spi.LIRKindTool; 29 import org.graalvm.compiler.debug.GraalError; 30 31 import jdk.vm.ci.meta.Constant; 32 import jdk.vm.ci.meta.JavaKind; 33 import jdk.vm.ci.meta.MemoryAccessProvider; 34 import jdk.vm.ci.meta.MetaAccessProvider; 35 import jdk.vm.ci.meta.PrimitiveConstant; 36 import jdk.vm.ci.meta.ResolvedJavaType; 37 38 /** 39 * This stamp represents the type of the {@link JavaKind#Illegal} value in the second slot of 40 * {@link JavaKind#Long} and {@link JavaKind#Double} values. It can only appear in framestates or 41 * virtual objects. 42 */ 43 public final class IllegalStamp extends Stamp { 44 IllegalStamp()45 private IllegalStamp() { 46 } 47 48 @Override getStackKind()49 public JavaKind getStackKind() { 50 return JavaKind.Illegal; 51 } 52 53 @Override getLIRKind(LIRKindTool tool)54 public LIRKind getLIRKind(LIRKindTool tool) { 55 return LIRKind.Illegal; 56 } 57 58 @Override unrestricted()59 public Stamp unrestricted() { 60 return this; 61 } 62 63 @Override isUnrestricted()64 public boolean isUnrestricted() { 65 return true; 66 } 67 68 @Override empty()69 public Stamp empty() { 70 return this; 71 } 72 73 @Override constant(Constant c, MetaAccessProvider meta)74 public Stamp constant(Constant c, MetaAccessProvider meta) { 75 assert ((PrimitiveConstant) c).getJavaKind() == JavaKind.Illegal; 76 return this; 77 } 78 79 @Override javaType(MetaAccessProvider metaAccess)80 public ResolvedJavaType javaType(MetaAccessProvider metaAccess) { 81 throw GraalError.shouldNotReachHere("illegal stamp has no Java type"); 82 } 83 84 @Override meet(Stamp other)85 public Stamp meet(Stamp other) { 86 assert other instanceof IllegalStamp; 87 return this; 88 } 89 90 @Override join(Stamp other)91 public Stamp join(Stamp other) { 92 assert other instanceof IllegalStamp; 93 return this; 94 } 95 96 @Override isCompatible(Stamp stamp)97 public boolean isCompatible(Stamp stamp) { 98 return stamp instanceof IllegalStamp; 99 } 100 101 @Override isCompatible(Constant constant)102 public boolean isCompatible(Constant constant) { 103 if (constant instanceof PrimitiveConstant) { 104 PrimitiveConstant prim = (PrimitiveConstant) constant; 105 return prim.getJavaKind() == JavaKind.Illegal; 106 } 107 return false; 108 } 109 110 @Override toString()111 public String toString() { 112 return "ILLEGAL"; 113 } 114 115 @Override hasValues()116 public boolean hasValues() { 117 return true; 118 } 119 120 @Override improveWith(Stamp other)121 public Stamp improveWith(Stamp other) { 122 assert other instanceof IllegalStamp; 123 return this; 124 } 125 126 @Override readConstant(MemoryAccessProvider provider, Constant base, long displacement)127 public Constant readConstant(MemoryAccessProvider provider, Constant base, long displacement) { 128 throw GraalError.shouldNotReachHere("can't read values of illegal stamp"); 129 } 130 131 private static final IllegalStamp instance = new IllegalStamp(); 132 getInstance()133 static IllegalStamp getInstance() { 134 return instance; 135 } 136 } 137