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