本文整理汇总了Java中jdk.vm.ci.meta.JavaConstant.getJavaKind方法的典型用法代码示例。如果您正苦于以下问题:Java JavaConstant.getJavaKind方法的具体用法?Java JavaConstant.getJavaKind怎么用?Java JavaConstant.getJavaKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.vm.ci.meta.JavaConstant
的用法示例。
在下文中一共展示了JavaConstant.getJavaKind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMemorySize
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Override
public long getMemorySize(JavaConstant constant) {
if (constant.getJavaKind() == JavaKind.Object) {
HotSpotResolvedObjectType lookupJavaType = lookupJavaType(constant);
if (lookupJavaType == null) {
return 0;
} else {
if (lookupJavaType.isArray()) {
int length = Array.getLength(((HotSpotObjectConstantImpl) constant).object());
ResolvedJavaType elementType = lookupJavaType.getComponentType();
JavaKind elementKind = elementType.getJavaKind();
final int headerSize = getArrayBaseOffset(elementKind);
TargetDescription target = runtime.getHostJVMCIBackend().getTarget();
int sizeOfElement = getArrayIndexScale(elementKind);
int alignment = target.wordSize;
int log2ElementSize = CodeUtil.log2(sizeOfElement);
return computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize);
}
return lookupJavaType.instanceSize();
}
} else {
return constant.getJavaKind().getByteCount();
}
}
示例2: canInlineConstant
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Override
public boolean canInlineConstant(Constant con) {
if (con instanceof JavaConstant) {
JavaConstant c = (JavaConstant) con;
switch (c.getJavaKind()) {
case Boolean:
case Byte:
case Char:
case Short:
case Int:
return SPARCAssembler.isSimm13(c.asInt());
case Long:
return SPARCAssembler.isSimm13(c.asLong());
case Object:
return c.isNull();
default:
return false;
}
}
return false;
}
示例3: canInlineConstant
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Override
public boolean canInlineConstant(Constant con) {
if (con instanceof JavaConstant) {
JavaConstant c = (JavaConstant) con;
switch (c.getJavaKind()) {
case Boolean:
case Byte:
case Char:
case Short:
case Int:
return AArch64MacroAssembler.isMovableImmediate(c.asInt());
case Long:
return AArch64MacroAssembler.isMovableImmediate(c.asLong());
case Object:
return c.isNull();
default:
return false;
}
}
return false;
}
示例4: isSimm13
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
public static boolean isSimm13(JavaConstant constant) {
long bits;
switch (constant.getJavaKind()) {
case Double:
bits = Double.doubleToRawLongBits(constant.asDouble());
break;
case Float:
bits = Float.floatToRawIntBits(constant.asFloat());
break;
case Object:
return constant.isNull();
default:
bits = constant.asLong();
break;
}
return constant.isNull() || isSimm13(bits);
}
示例5: updateStringPropertiesForConstant
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
/**
* Sets or updates the {@code "rawvalue"} and {@code "toString"} properties in {@code props} for
* {@code cn} if it's a boxed Object value and {@code snippetReflection} can access the raw
* value.
*/
default void updateStringPropertiesForConstant(Map<Object, Object> props, ConstantNode cn) {
SnippetReflectionProvider snippetReflection = getSnippetReflectionProvider();
if (snippetReflection != null && cn.getValue() instanceof JavaConstant) {
JavaConstant constant = (JavaConstant) cn.getValue();
if (constant.getJavaKind() == JavaKind.Object) {
Object obj = snippetReflection.asObject(Object.class, constant);
if (obj != null) {
String toString = GraphPrinter.constantToString(obj);
String rawvalue = GraphPrinter.truncate(toString);
// Overwrite the value inserted by
// ConstantNode.getDebugProperties()
props.put("rawvalue", rawvalue);
if (!rawvalue.equals(toString)) {
props.put("toString", toString);
}
}
}
}
}
示例6: isInstanceTest
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Test
public void isInstanceTest() {
for (ConstantValue cv : constants()) {
JavaConstant c = cv.value;
if (c.getJavaKind() == JavaKind.Object && !c.isNull()) {
ResolvedJavaType cType = metaAccess.lookupJavaType(c);
for (ResolvedJavaType t : javaTypes) {
if (t.isAssignableFrom(cType)) {
assertTrue(t.isInstance(c));
} else {
assertFalse(t.isInstance(c));
}
}
}
}
}
示例7: readArrayElement
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Override
public JavaConstant readArrayElement(JavaConstant array, int index) {
if (array == null || array.getJavaKind() != JavaKind.Object || array.isNull()) {
return null;
}
Object a = ((HotSpotObjectConstantImpl) array).object();
if (!a.getClass().isArray() || index < 0 || index >= Array.getLength(a)) {
return null;
}
if (a instanceof Object[]) {
Object element = ((Object[]) a)[index];
return HotSpotObjectConstantImpl.forObject(element);
} else {
return JavaConstant.forBoxedPrimitive(Array.get(a, index));
}
}
示例8: canonicalizeBoxing
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
public static FloatingNode canonicalizeBoxing(BoxNode box, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection) {
ValueNode value = box.getValue();
if (value.isConstant()) {
JavaConstant sourceConstant = value.asJavaConstant();
if (sourceConstant.getJavaKind() != box.getBoxingKind() && sourceConstant.getJavaKind().isNumericInteger()) {
switch (box.getBoxingKind()) {
case Boolean:
sourceConstant = JavaConstant.forBoolean(sourceConstant.asLong() != 0L);
break;
case Byte:
sourceConstant = JavaConstant.forByte((byte) sourceConstant.asLong());
break;
case Char:
sourceConstant = JavaConstant.forChar((char) sourceConstant.asLong());
break;
case Short:
sourceConstant = JavaConstant.forShort((short) sourceConstant.asLong());
break;
}
}
JavaConstant boxedConstant = constantReflection.boxPrimitive(sourceConstant);
if (boxedConstant != null && sourceConstant.getJavaKind() == box.getBoxingKind()) {
return ConstantNode.forConstant(boxedConstant, metaAccess, box.graph());
}
}
return null;
}
示例9: readArrayLengthTest
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Test
public void readArrayLengthTest() {
for (ConstantValue cv : constants()) {
JavaConstant c = cv.value;
Integer actual = constantReflection.readArrayLength(c);
if (c.getJavaKind() != JavaKind.Object || c.isNull() || !cv.boxed.getClass().isArray()) {
assertNull(actual);
} else {
assertNotNull(actual);
int actualInt = actual;
assertEquals(Array.getLength(cv.boxed), actualInt);
}
}
}
示例10: forConstant
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
public static Stamp forConstant(JavaConstant value, MetaAccessProvider metaAccess) {
if (value.getJavaKind() == JavaKind.Object) {
ResolvedJavaType type = value.isNull() ? null : metaAccess.lookupJavaType(value);
return new ObjectStamp(type, value.isNonNull(), value.isNonNull(), value.isNull());
} else {
return forConstant(value);
}
}
示例11: isLogicalConstant
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
private static boolean isLogicalConstant(JavaConstant constValue) {
switch (constValue.getJavaKind()) {
case Int:
return AArch64MacroAssembler.isLogicalImmediate(constValue.asInt());
case Long:
return AArch64MacroAssembler.isLogicalImmediate(constValue.asLong());
default:
return false;
}
}
示例12: isArithmeticConstant
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
protected static boolean isArithmeticConstant(JavaConstant constValue) {
switch (constValue.getJavaKind()) {
case Int:
case Long:
return AArch64MacroAssembler.isArithmeticImmediate(constValue.asLong());
case Object:
return constValue.isNull();
default:
return false;
}
}
示例13: canInlineConstant
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Override
public boolean canInlineConstant(Constant con) {
if (con instanceof JavaConstant) {
JavaConstant c = (JavaConstant) con;
switch (c.getJavaKind()) {
case Long:
return NumUtil.isInt(c.asLong());
case Object:
return c.isNull();
default:
return true;
}
}
return false;
}
示例14: canStoreConstant
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
/**
* Checks whether the supplied constant can be used without loading it into a register for store
* operations, i.e., on the right hand side of a memory access.
*
* @param c The constant to check.
* @return True if the constant can be used directly, false if the constant needs to be in a
* register.
*/
protected static final boolean canStoreConstant(JavaConstant c) {
// there is no immediate move of 64-bit constants on Intel
switch (c.getJavaKind()) {
case Long:
return NumUtil.isInt(c.asLong());
case Double:
return false;
case Object:
return c.isNull();
default:
return true;
}
}
示例15: lookupJavaTypeConstantTest
import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Test
public void lookupJavaTypeConstantTest() {
for (ConstantValue cv : constants()) {
JavaConstant c = cv.value;
if (c.getJavaKind() == JavaKind.Object && !c.isNull()) {
Object o = cv.boxed;
ResolvedJavaType type = metaAccess.lookupJavaType(c);
assertNotNull(type);
assertTrue(type.equals(metaAccess.lookupJavaType(o.getClass())));
} else {
assertEquals(metaAccess.lookupJavaType(c), null);
}
}
}