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


Java JavaConstant.asLong方法代码示例

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


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

示例1: 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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:SPARCAssembler.java

示例2: emitShift

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
private Variable emitShift(AMD64Shift op, OperandSize size, Value a, Value b) {
    Variable result = getLIRGen().newVariable(LIRKind.combine(a, b).changeType(a.getPlatformKind()));
    AllocatableValue input = getLIRGen().asAllocatable(a);
    if (isJavaConstant(b)) {
        JavaConstant c = asJavaConstant(b);
        if (c.asLong() == 1) {
            getLIRGen().append(new AMD64Unary.MOp(op.m1Op, size, result, input));
        } else {
            /*
             * c is implicitly masked to 5 or 6 bits by the CPU, so casting it to (int) is
             * always correct, even without the NumUtil.is32bit() test.
             */
            getLIRGen().append(new AMD64Binary.ConstOp(op.miOp, size, result, input, (int) c.asLong()));
        }
    } else {
        getLIRGen().emitMove(RCX_I, b);
        getLIRGen().append(new AMD64ShiftOp(op.mcOp, size, result, input, RCX_I));
    }
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:AMD64ArithmeticLIRGenerator.java

示例3: isBoxCached

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
/**
 * Check if the constant is a boxed value that is guaranteed to be cached by the platform.
 * Otherwise the generated code might be the only reference to the boxed value and since object
 * references from nmethods are weak this can cause GC problems.
 *
 * @param source
 * @return true if the box is cached
 */
private static boolean isBoxCached(JavaConstant source) {
    switch (source.getJavaKind()) {
        case Boolean:
            return true;
        case Char:
            return source.asInt() <= 127;
        case Byte:
        case Short:
        case Int:
            return source.asInt() >= -128 && source.asInt() <= 127;
        case Long:
            return source.asLong() >= -128 && source.asLong() <= 127;
        case Float:
        case Double:
            return false;
        default:
            throw new IllegalArgumentException("unexpected kind " + source.getJavaKind());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:HotSpotConstantReflectionProvider.java

示例4: canonical

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
@Override
public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {
    if (forValue.isConstant()) {
        JavaConstant c = forValue.asJavaConstant();
        if (c.asLong() != 0) {
            return ConstantNode.forInt(forValue.getStackKind() == JavaKind.Int ? scan(c.asInt()) : scan(c.asLong()));
        }
    }
    return this;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:BitScanReverseNode.java

示例5: tryFold

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
public static ValueNode tryFold(ValueNode value) {
    if (value.isConstant()) {
        JavaConstant c = value.asJavaConstant();
        if (c.asLong() != 0) {
            return ConstantNode.forInt(value.getStackKind() == JavaKind.Int ? scan(c.asInt()) : scan(c.asLong()));
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:BitScanForwardNode.java

示例6: forConstant

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
public static Stamp forConstant(JavaConstant value) {
    JavaKind kind = value.getJavaKind();
    switch (kind) {
        case Boolean:
        case Byte:
        case Char:
        case Short:
        case Int:
        case Long:
            long mask = value.asLong() & CodeUtil.mask(kind.getBitCount());
            return forInteger(kind.getStackKind(), value.asLong(), value.asLong(), mask, mask);
        case Float:
            return forFloat(kind, value.asFloat(), value.asFloat(), !Float.isNaN(value.asFloat()));
        case Double:
            return forFloat(kind, value.asDouble(), value.asDouble(), !Double.isNaN(value.asDouble()));
        case Illegal:
            return forKind(JavaKind.Illegal);
        case Object:
            if (value.isNull()) {
                return alwaysNull();
            } else {
                return objectNonNull();
            }
        default:
            throw new GraalError("unexpected kind: %s", kind);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:StampFactory.java

示例7: improveConstDisp

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
private static ValueNode improveConstDisp(AMD64AddressNode address, ValueNode original, JavaConstant c, ValueNode other, int shift) {
    if (c.getJavaKind().isNumericInteger()) {
        long disp = address.getDisplacement();
        disp += c.asLong() << shift;
        if (NumUtil.isInt(disp)) {
            address.setDisplacement((int) disp);
            return other;
        }
    }
    return original;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:AMD64AddressLowering.java

示例8: asLong

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
private static long asLong(JavaConstant value) {
    JavaKind kind = value.getJavaKind();
    switch (kind) {
        case Byte:
        case Short:
        case Char:
        case Int:
            return value.asInt();
        case Long:
            return value.asLong();
        default:
            throw new IllegalArgumentException("not an integer kind: " + kind);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:HotSpotCounterOp.java

示例9: const2reg

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
public static void const2reg(CompilationResultBuilder crb, AMD64MacroAssembler masm, Register result, JavaConstant input) {
    /*
     * Note: we use the kind of the input operand (and not the kind of the result operand)
     * because they don't match in all cases. For example, an object constant can be loaded to a
     * long register when unsafe casts occurred (e.g., for a write barrier where arithmetic
     * operations are then performed on the pointer).
     */
    switch (input.getJavaKind().getStackKind()) {
        case Int:
            // Do not optimize with an XOR as this instruction may be between
            // a CMP and a Jcc in which case the XOR will modify the condition
            // flags and interfere with the Jcc.
            masm.movl(result, input.asInt());

            break;
        case Long:
            // Do not optimize with an XOR as this instruction may be between
            // a CMP and a Jcc in which case the XOR will modify the condition
            // flags and interfere with the Jcc.
            if (input.asLong() == (int) input.asLong()) {
                // Sign extended to long
                masm.movslq(result, (int) input.asLong());
            } else if ((input.asLong() & 0xFFFFFFFFL) == input.asLong()) {
                // Zero extended to long
                masm.movl(result, (int) input.asLong());
            } else {
                masm.movq(result, input.asLong());
            }
            break;
        case Float:
            // This is *not* the same as 'constant == 0.0f' in the case where constant is -0.0f
            if (Float.floatToRawIntBits(input.asFloat()) == Float.floatToRawIntBits(0.0f)) {
                masm.xorps(result, result);
            } else {
                masm.movflt(result, (AMD64Address) crb.asFloatConstRef(input));
            }
            break;
        case Double:
            // This is *not* the same as 'constant == 0.0d' in the case where constant is -0.0d
            if (Double.doubleToRawLongBits(input.asDouble()) == Double.doubleToRawLongBits(0.0d)) {
                masm.xorpd(result, result);
            } else {
                masm.movdbl(result, (AMD64Address) crb.asDoubleConstRef(input));
            }
            break;
        case Object:
            // Do not optimize with an XOR as this instruction may be between
            // a CMP and a Jcc in which case the XOR will modify the condition
            // flags and interfere with the Jcc.
            if (input.isNull()) {
                masm.movq(result, 0x0L);
            } else if (crb.target.inlineObjects) {
                crb.recordInlineDataInCode(input);
                masm.movq(result, 0xDEADDEADDEADDEADL);
            } else {
                masm.movq(result, (AMD64Address) crb.recordDataReferenceInCode(input, 0));
            }
            break;
        default:
            throw GraalError.shouldNotReachHere();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:63,代码来源:AMD64Move.java

示例10: forIntegerBits

import jdk.vm.ci.meta.JavaConstant; //导入方法依赖的package包/类
private static ConstantNode forIntegerBits(int bits, JavaConstant constant, StructuredGraph graph) {
    long value = constant.asLong();
    long bounds = CodeUtil.signExtend(value, bits);
    return unique(graph, new ConstantNode(constant, StampFactory.forInteger(bits, bounds, bounds)));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:ConstantNode.java


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