当前位置: 首页>>代码示例>>Java>>正文


Java JavaConstant.forInt方法代码示例

本文整理汇总了Java中jdk.vm.ci.meta.JavaConstant.forInt方法的典型用法代码示例。如果您正苦于以下问题:Java JavaConstant.forInt方法的具体用法?Java JavaConstant.forInt怎么用?Java JavaConstant.forInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jdk.vm.ci.meta.JavaConstant的用法示例。


在下文中一共展示了JavaConstant.forInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: emitCCall

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Override
public void emitCCall(long address, CallingConvention nativeCallingConvention, Value[] args, int numberOfFloatingPointArguments) {
    Value[] argLocations = new Value[args.length];
    getResult().getFrameMapBuilder().callsMethod(nativeCallingConvention);
    // TODO(mg): in case a native function uses floating point varargs, the ABI requires that
    // RAX contains the length of the varargs
    PrimitiveConstant intConst = JavaConstant.forInt(numberOfFloatingPointArguments);
    AllocatableValue numberOfFloatingPointArgumentsRegister = AMD64.rax.asValue(LIRKind.value(AMD64Kind.DWORD));
    emitMoveConstant(numberOfFloatingPointArgumentsRegister, intConst);
    for (int i = 0; i < args.length; i++) {
        Value arg = args[i];
        AllocatableValue loc = nativeCallingConvention.getArgument(i);
        emitMove(loc, arg);
        argLocations[i] = loc;
    }
    Value ptr = emitLoadConstant(LIRKind.value(AMD64Kind.QWORD), JavaConstant.forLong(address));
    append(new AMD64CCall(nativeCallingConvention.getReturn(), ptr, numberOfFloatingPointArgumentsRegister, argLocations));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:AMD64HotSpotLIRGenerator.java

示例2: deserialize

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Override
public SerializableConstant deserialize(ByteBuffer buffer) {
    switch (getBits()) {
        case 1:
            return JavaConstant.forBoolean(buffer.get() != 0);
        case 8:
            return JavaConstant.forByte(buffer.get());
        case 16:
            return JavaConstant.forShort(buffer.getShort());
        case 32:
            return JavaConstant.forInt(buffer.getInt());
        case 64:
            return JavaConstant.forLong(buffer.getLong());
        default:
            throw GraalError.shouldNotReachHere();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:IntegerStamp.java

示例3: asConstant

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Override
public JavaConstant asConstant() {
    if (lowerBound == upperBound) {
        switch (getBits()) {
            case 1:
                return JavaConstant.forBoolean(lowerBound != 0);
            case 8:
                return JavaConstant.forByte((byte) lowerBound);
            case 16:
                return JavaConstant.forShort((short) lowerBound);
            case 32:
                return JavaConstant.forInt((int) lowerBound);
            case 64:
                return JavaConstant.forLong(lowerBound);
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:IntegerStamp.java

示例4: zapValueForKind

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Override
protected JavaConstant zapValueForKind(PlatformKind kind) {
    long dead = 0xDEADDEADDEADDEADL;
    switch ((AArch64Kind) kind) {
        case BYTE:
            return JavaConstant.forByte((byte) dead);
        case WORD:
            return JavaConstant.forShort((short) dead);
        case DWORD:
            return JavaConstant.forInt((int) dead);
        case QWORD:
            return JavaConstant.forLong(dead);
        case SINGLE:
            return JavaConstant.forFloat(Float.intBitsToFloat((int) dead));
        case DOUBLE:
            return JavaConstant.forDouble(Double.longBitsToDouble(dead));
        default:
            throw GraalError.shouldNotReachHere();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:AArch64LIRGenerator.java

示例5: zapValueForKind

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Override
protected JavaConstant zapValueForKind(PlatformKind kind) {
    long dead = 0xDEADDEADDEADDEADL;
    switch ((AMD64Kind) kind) {
        case BYTE:
            return JavaConstant.forByte((byte) dead);
        case WORD:
            return JavaConstant.forShort((short) dead);
        case DWORD:
            return JavaConstant.forInt((int) dead);
        case QWORD:
            return JavaConstant.forLong(dead);
        case SINGLE:
            return JavaConstant.forFloat(Float.intBitsToFloat((int) dead));
        default:
            // we don't support vector types, so just zap with double for all of them
            return JavaConstant.forDouble(Double.longBitsToDouble(dead));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:AMD64LIRGenerator.java

示例6: testImplies

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Test
public void testImplies() {
    Random rand = new Random(13);
    for (Condition c1 : Condition.values()) {
        for (Condition c2 : Condition.values()) {
            boolean implies = c1.implies(c2);
            if (implies) {
                for (int i = 0; i < 1000; i++) {
                    JavaConstant a = JavaConstant.forInt(rand.nextInt());
                    JavaConstant b = JavaConstant.forInt(i < 100 ? a.asInt() : rand.nextInt());
                    boolean result1 = c1.foldCondition(a, b, null, false);
                    boolean result2 = c2.foldCondition(a, b, null, false);
                    if (result1) {
                        assertTrue(result2);
                    }
                }
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ConditionTest.java

示例7: testJoin

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Test
public void testJoin() {
    Random rand = new Random(13);
    for (Condition c1 : Condition.values()) {
        for (Condition c2 : Condition.values()) {
            Condition join = c1.join(c2);
            assertEquals(join, c2.join(c1));
            if (join != null) {
                for (int i = 0; i < 1000; i++) {
                    JavaConstant a = JavaConstant.forInt(rand.nextInt());
                    JavaConstant b = JavaConstant.forInt(i < 100 ? a.asInt() : rand.nextInt());
                    boolean result1 = c1.foldCondition(a, b, null, false);
                    boolean result2 = c2.foldCondition(a, b, null, false);
                    boolean resultJoin = join.foldCondition(a, b, null, false);
                    if (result1 && result2) {
                        assertTrue(resultJoin);
                    } else {
                        assertFalse(resultJoin);
                    }
                }
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:ConditionTest.java

示例8: readConstant

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
static final ClassfileConstant readConstant(DataInputStream stream) throws IOException {
    byte tag = stream.readByte();

    switch (tag) {
        case ClassfileConstant.CONSTANT_Class:
            return new ClassfileConstant.ClassRef(stream);
        case ClassfileConstant.CONSTANT_Fieldref:
            return new ClassfileConstant.FieldRef(stream);
        case ClassfileConstant.CONSTANT_Methodref:
            return new ClassfileConstant.MethodRef(stream);
        case ClassfileConstant.CONSTANT_InterfaceMethodref:
            return new ClassfileConstant.InterfaceMethodRef(stream);
        case ClassfileConstant.CONSTANT_String:
            return new ClassfileConstant.StringRef(stream);
        case ClassfileConstant.CONSTANT_Integer:
            return new ClassfileConstant.Primitive(tag, JavaConstant.forInt(stream.readInt()));
        case ClassfileConstant.CONSTANT_Float:
            return new ClassfileConstant.Primitive(tag, JavaConstant.forFloat(stream.readFloat()));
        case ClassfileConstant.CONSTANT_Long:
            return new ClassfileConstant.Primitive(tag, JavaConstant.forLong(stream.readLong()));
        case ClassfileConstant.CONSTANT_Double:
            return new ClassfileConstant.Primitive(tag, JavaConstant.forDouble(stream.readDouble()));
        case ClassfileConstant.CONSTANT_NameAndType:
            return new ClassfileConstant.NameAndType(stream);
        case ClassfileConstant.CONSTANT_Utf8:
            return new ClassfileConstant.Utf8(stream.readUTF());
        case ClassfileConstant.CONSTANT_MethodHandle:
            skipFully(stream, 3); // reference_kind, reference_index
            return new ClassfileConstant.Unsupported(tag, "CONSTANT_MethodHandle_info");
        case ClassfileConstant.CONSTANT_MethodType:
            skipFully(stream, 2); // descriptor_index
            return new ClassfileConstant.Unsupported(tag, "CONSTANT_MethodType_info");
        case ClassfileConstant.CONSTANT_InvokeDynamic:
            skipFully(stream, 4); // bootstrap_method_attr_index, name_and_type_index
            return new ClassfileConstant.Unsupported(tag, "CONSTANT_InvokeDynamic_info");
        default:
            throw new GraalError("Invalid constant pool tag: " + tag);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:ClassfileConstantPool.java

示例9: decodeDebugIdTest

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Test
public void decodeDebugIdTest() {
    for (int i = 0; i < VALID_ENCODED_VALUES.length; i++) {
        JavaConstant value = JavaConstant.forInt(VALID_ENCODED_VALUES[i]);
        assertEquals("Unexpected debugId", metaAccess.decodeDebugId(value), DEBUG_IDS[i]);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TestMetaAccessProvider.java

示例10: min32

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
private static void min32(CompareNode enode, ValueNode v) {
    Stamp s = v.stamp();
    if (s instanceof IntegerStamp) {
        int bits = ((IntegerStamp) s).getBits();
        if (bits != 32 && bits != 64) {
            if (bits <= 32) {
                bits = 32;
            } else {
                bits = 64;
            }
            ValueNode replacement;
            if (v instanceof ConstantNode) {
                JavaConstant newConst;
                if (bits == 32) {
                    newConst = JavaConstant.forInt(v.asJavaConstant().asInt());
                } else if (bits == 64) {
                    newConst = JavaConstant.forLong(v.asJavaConstant().asLong());
                } else {
                    throw GraalError.shouldNotReachHere();
                }
                long mask = CodeUtil.mask(bits);
                replacement = v.graph().addOrUnique(new ConstantNode(newConst, IntegerStamp.stampForMask(bits, newConst.asLong() & mask, newConst.asLong() & mask)));
            } else {
                replacement = v.graph().addOrUnique(new SignExtendNode(v, bits));
            }
            v.replaceAtUsages(replacement, x -> x == enode);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:SPARCIntegerCompareCanonicalizationPhase.java

示例11: testByte

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Test
public void testByte() {
    byte[] a = new byte[]{Byte.MIN_VALUE, Byte.MIN_VALUE + 1, -1, 0, 1, Byte.MAX_VALUE - 1, Byte.MAX_VALUE};
    for (byte i : a) {
        ConstantNode node = ConstantNode.forByte(i, graph);
        JavaConstant expected = JavaConstant.forInt(-i);
        assertEquals(expected, ArithmeticOpTable.forStamp(node.stamp()).getNeg().foldConstant(node.asConstant()));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:NegateNodeCanonicalizationTest.java

示例12: testChar

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Test
public void testChar() {
    char[] a = new char[]{Character.MIN_VALUE, Character.MIN_VALUE + 1, 0, 1, Character.MAX_VALUE - 1, Character.MAX_VALUE};
    for (char i : a) {
        ConstantNode node = ConstantNode.forChar(i, graph);
        JavaConstant expected = JavaConstant.forInt(-i);
        assertEquals(expected, ArithmeticOpTable.forStamp(node.stamp()).getNeg().foldConstant(node.asConstant()));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:NegateNodeCanonicalizationTest.java

示例13: decodeDeoptActionTest

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Test
public void decodeDeoptActionTest() {
    for (int encoded : VALID_ENCODED_VALUES) {
        JavaConstant value = JavaConstant.forInt(encoded);
        DeoptimizationAction action = metaAccess.decodeDeoptAction(value);
        assertEquals("Expected equal actions", action, DEOPT_ACTION);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:TestMetaAccessProvider.java

示例14: testInt

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Test
public void testInt() {
    int[] a = new int[]{Integer.MIN_VALUE, Integer.MIN_VALUE + 1, -1, 0, 1, Integer.MAX_VALUE - 1, Integer.MAX_VALUE};
    for (int i : a) {
        ConstantNode node = ConstantNode.forInt(i, graph);
        JavaConstant expected = JavaConstant.forInt(-i);
        assertEquals(expected, ArithmeticOpTable.forStamp(node.stamp()).getNeg().foldConstant(node.asConstant()));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:NegateNodeCanonicalizationTest.java

示例15: readPrimitiveConstant

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Override
public JavaConstant readPrimitiveConstant(JavaKind kind, Constant baseConstant, long initialDisplacement, int bits) {
    try {
        long rawValue = readRawValue(baseConstant, initialDisplacement, kind, bits);
        switch (kind) {
            case Boolean:
                return JavaConstant.forBoolean(rawValue != 0);
            case Byte:
                return JavaConstant.forByte((byte) rawValue);
            case Char:
                return JavaConstant.forChar((char) rawValue);
            case Short:
                return JavaConstant.forShort((short) rawValue);
            case Int:
                return JavaConstant.forInt((int) rawValue);
            case Long:
                return JavaConstant.forLong(rawValue);
            case Float:
                return JavaConstant.forFloat(Float.intBitsToFloat((int) rawValue));
            case Double:
                return JavaConstant.forDouble(Double.longBitsToDouble(rawValue));
            default:
                throw new IllegalArgumentException("Unsupported kind: " + kind);
        }
    } catch (NullPointerException e) {
        return null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:HotSpotMemoryAccessProviderImpl.java


注:本文中的jdk.vm.ci.meta.JavaConstant.forInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。