1 /* 2 * Copyright (c) 2012, 2019, 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 accept(Visitor v)49 public void accept(Visitor v) { 50 } 51 52 @Override getStackKind()53 public JavaKind getStackKind() { 54 return JavaKind.Illegal; 55 } 56 57 @Override getLIRKind(LIRKindTool tool)58 public LIRKind getLIRKind(LIRKindTool tool) { 59 return LIRKind.Illegal; 60 } 61 62 @Override unrestricted()63 public Stamp unrestricted() { 64 return this; 65 } 66 67 @Override isUnrestricted()68 public boolean isUnrestricted() { 69 return true; 70 } 71 72 @Override empty()73 public Stamp empty() { 74 return this; 75 } 76 77 @Override constant(Constant c, MetaAccessProvider meta)78 public Stamp constant(Constant c, MetaAccessProvider meta) { 79 assert ((PrimitiveConstant) c).getJavaKind() == JavaKind.Illegal; 80 return this; 81 } 82 83 @Override javaType(MetaAccessProvider metaAccess)84 public ResolvedJavaType javaType(MetaAccessProvider metaAccess) { 85 throw GraalError.shouldNotReachHere("illegal stamp has no Java type"); 86 } 87 88 @Override meet(Stamp other)89 public Stamp meet(Stamp other) { 90 assert other instanceof IllegalStamp; 91 return this; 92 } 93 94 @Override join(Stamp other)95 public Stamp join(Stamp other) { 96 assert other instanceof IllegalStamp; 97 return this; 98 } 99 100 @Override isCompatible(Stamp stamp)101 public boolean isCompatible(Stamp stamp) { 102 return stamp instanceof IllegalStamp; 103 } 104 105 @Override isCompatible(Constant constant)106 public boolean isCompatible(Constant constant) { 107 if (constant instanceof PrimitiveConstant) { 108 PrimitiveConstant prim = (PrimitiveConstant) constant; 109 return prim.getJavaKind() == JavaKind.Illegal; 110 } 111 return false; 112 } 113 114 @Override toString()115 public String toString() { 116 return "ILLEGAL"; 117 } 118 119 @Override hasValues()120 public boolean hasValues() { 121 return true; 122 } 123 124 @Override improveWith(Stamp other)125 public Stamp improveWith(Stamp other) { 126 assert other instanceof IllegalStamp; 127 return this; 128 } 129 130 @Override readConstant(MemoryAccessProvider provider, Constant base, long displacement)131 public Constant readConstant(MemoryAccessProvider provider, Constant base, long displacement) { 132 throw GraalError.shouldNotReachHere("can't read values of illegal stamp"); 133 } 134 135 private static final IllegalStamp instance = new IllegalStamp(); 136 getInstance()137 static IllegalStamp getInstance() { 138 return instance; 139 } 140 } 141