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


Java JavaConstant类代码示例

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


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

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

示例2: KindData

import jdk.vm.ci.meta.JavaConstant; //导入依赖的package包/类
KindData(JavaKind kind, Object testObject) {
    this.kind = kind;
    try {
        Class<?> c = testObject.getClass();
        instanceField = c.getDeclaredField(kind.getJavaName() + "Field");
        staticField = c.getDeclaredField(kind.getJavaName() + "StaticField");
        instanceField.setAccessible(true);
        staticField.setAccessible(true);
        instanceFieldOffset = UNSAFE.objectFieldOffset(instanceField);
        staticFieldOffset = UNSAFE.staticFieldOffset(staticField);
        instanceFieldValue = JavaConstant.forBoxedPrimitive(instanceField.get(testObject));
        staticFieldValue = JavaConstant.forBoxedPrimitive(staticField.get(null));
    } catch (Exception e) {
        throw new Error("TESTBUG for kind " + kind, e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:MemoryAccessProviderData.java

示例3: readFieldValue

import jdk.vm.ci.meta.JavaConstant; //导入依赖的package包/类
public JavaConstant readFieldValue(ResolvedJavaField field, JavaConstant receiver) {
    HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field;
    if (hotspotField.isStatic()) {
        HotSpotResolvedJavaType holder = (HotSpotResolvedJavaType) hotspotField.getDeclaringClass();
        if (holder.isInitialized()) {
            return memoryAccess.readFieldValue(hotspotField, holder.mirror());
        }
    } else {
        if (receiver.isNonNull()) {
            Object object = ((HotSpotObjectConstantImpl) receiver).object();
            if (hotspotField.isInObject(object)) {
                return memoryAccess.readFieldValue(hotspotField, object);
            }
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:HotSpotConstantReflectionProvider.java

示例4: tryConstantFold

import jdk.vm.ci.meta.JavaConstant; //导入依赖的package包/类
private static ValueNode tryConstantFold(ValueNode array, ValueNode index, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection) {
    if (array.isConstant() && !array.isNullConstant() && index.isConstant()) {
        JavaConstant arrayConstant = array.asJavaConstant();
        if (arrayConstant != null) {
            int stableDimension = ((ConstantNode) array).getStableDimension();
            if (stableDimension > 0) {
                JavaConstant constant = constantReflection.readArrayElement(arrayConstant, index.asJavaConstant().asInt());
                boolean isDefaultStable = ((ConstantNode) array).isDefaultStable();
                if (constant != null && (isDefaultStable || !constant.isDefaultForKind())) {
                    return ConstantNode.forConstant(constant, stableDimension - 1, isDefaultStable, metaAccess);
                }
            }
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:LoadIndexedNode.java

示例5: doubleTest

import jdk.vm.ci.meta.JavaConstant; //导入依赖的package包/类
@Test
public void doubleTest() {
    CodeGenTest test = new CodeGenTest() {

        @Override
        public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
            AMD64MacroAssembler asm = new AMD64MacroAssembler(target);
            Register ret = registerConfig.getReturnRegister(JavaKind.Double);
            Data data = new SerializableData(JavaConstant.forDouble(84.72), 8);
            DataSectionReference ref = compResult.getDataSection().insertData(data);
            compResult.recordDataPatch(asm.position(), ref);
            asm.movdbl(ret, asm.getPlaceholder(-1));
            asm.ret(0);
            return asm.close(true);
        }
    };
    assertReturn("doubleStub", test, 84.72);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:SimpleAssemblerTest.java

示例6: 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

示例7: tryUseTrappingNullCheck

import jdk.vm.ci.meta.JavaConstant; //导入依赖的package包/类
private static void tryUseTrappingNullCheck(AbstractDeoptimizeNode deopt, Node predecessor, DeoptimizationReason deoptimizationReason, JavaConstant speculation, long implicitNullCheckLimit) {
    if (deoptimizationReason != DeoptimizationReason.NullCheckException && deoptimizationReason != DeoptimizationReason.UnreachedCode) {
        return;
    }
    if (speculation != null && !speculation.equals(JavaConstant.NULL_POINTER)) {
        return;
    }
    if (predecessor instanceof AbstractMergeNode) {
        AbstractMergeNode merge = (AbstractMergeNode) predecessor;
        if (merge.phis().isEmpty()) {
            for (AbstractEndNode end : merge.cfgPredecessors().snapshot()) {
                checkPredecessor(deopt, end.predecessor(), deoptimizationReason, implicitNullCheckLimit);
            }
        }
    } else if (predecessor instanceof AbstractBeginNode) {
        checkPredecessor(deopt, predecessor, deoptimizationReason, implicitNullCheckLimit);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:UseTrappingNullChecksPhase.java

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

示例9: one

import jdk.vm.ci.meta.JavaConstant; //导入依赖的package包/类
/**
 * Returns the one value for a given numeric kind.
 */
public static JavaConstant one(JavaKind kind) {
    switch (kind) {
        case Boolean:
            return JavaConstant.TRUE;
        case Byte:
            return JavaConstant.forByte((byte) 1);
        case Char:
            return JavaConstant.forChar((char) 1);
        case Double:
            return JavaConstant.DOUBLE_1;
        case Float:
            return JavaConstant.FLOAT_1;
        case Int:
            return JavaConstant.INT_1;
        case Long:
            return JavaConstant.LONG_1;
        case Short:
            return JavaConstant.forShort((short) 1);
        default:
            throw new IllegalArgumentException(kind.toString());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:Util.java

示例10: 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

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

示例12: test1

import jdk.vm.ci.meta.JavaConstant; //导入依赖的package包/类
@Test
public void test1() {
    ResolvedJavaMethod method = getResolvedJavaMethod("parameterizedHashCode");
    StructuredGraph graph = parseForCompile(method);

    String s = "some string";
    int expected = s.hashCode();
    graph.getParameter(0).replaceAndDelete(asConstant(graph, s));

    compile(method, graph);

    FixedNode firstFixed = graph.start().next();
    Assert.assertThat(firstFixed, instanceOf(ReturnNode.class));

    ReturnNode ret = (ReturnNode) firstFixed;
    JavaConstant result = ret.result().asJavaConstant();
    if (result == null) {
        Assert.fail("result not constant: " + ret.result());
    } else {
        Assert.assertEquals("result", expected, result.asInt());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:StringHashConstantTest.java

示例13: testStringEquals

import jdk.vm.ci.meta.JavaConstant; //导入依赖的package包/类
private void testStringEquals(String s0, String s1) {
    ResolvedJavaMethod method = getResolvedJavaMethod("stringEquals");
    StructuredGraph graph = parseForCompile(method);

    graph.getParameter(0).replaceAndDelete(asConstant(graph, s0));
    graph.getParameter(1).replaceAndDelete(asConstant(graph, s1));

    compile(method, graph);

    FixedNode firstFixed = graph.start().next();
    Assert.assertThat(firstFixed, instanceOf(ReturnNode.class));

    ReturnNode ret = (ReturnNode) firstFixed;
    JavaConstant result = ret.result().asJavaConstant();
    if (result == null) {
        Assert.fail("result not constant: " + ret.result());
    } else {
        int expected = s0.equals(s1) ? 1 : 0;
        Assert.assertEquals("result", expected, result.asInt());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:StringEqualsConstantTest.java

示例14: genInvokeVirtual

import jdk.vm.ci.meta.JavaConstant; //导入依赖的package包/类
protected void genInvokeVirtual(JavaMethod target) {
    if (callTargetIsResolved(target)) {
        /*
         * Special handling for runtimes that rewrite an invocation of MethodHandle.invoke(...)
         * or MethodHandle.invokeExact(...) to a static adapter. HotSpot does this - see
         * https://wikis.oracle.com/display/HotSpotInternals/Method+handles +and+invokedynamic
         */
        boolean hasReceiver = !((ResolvedJavaMethod) target).isStatic();
        JavaConstant appendix = constantPool.lookupAppendix(stream.readCPI(), Bytecodes.INVOKEVIRTUAL);
        if (appendix != null) {
            frameState.push(JavaKind.Object, ConstantNode.forConstant(appendix, metaAccess, graph));
        }
        ValueNode[] args = frameState.popArguments(target.getSignature().getParameterCount(hasReceiver));
        if (hasReceiver) {
            appendInvoke(InvokeKind.Virtual, (ResolvedJavaMethod) target, args);
        } else {
            appendInvoke(InvokeKind.Static, (ResolvedJavaMethod) target, args);
        }
    } else {
        handleUnresolvedInvoke(target, InvokeKind.Virtual);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:BytecodeParser.java

示例15: createZapRegisters

import jdk.vm.ci.meta.JavaConstant; //导入依赖的package包/类
@Override
public SaveRegistersOp createZapRegisters() {
    Register[] zappedRegisters = getResult().getFrameMap().getRegisterConfig().getAllocatableRegisters().toArray();
    JavaConstant[] zapValues = new JavaConstant[zappedRegisters.length];
    for (int i = 0; i < zappedRegisters.length; i++) {
        PlatformKind kind = target().arch.getLargestStorableKind(zappedRegisters[i].getRegisterCategory());
        zapValues[i] = zapValueForKind(kind);
    }
    return createZapRegisters(zappedRegisters, zapValues);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:LIRGenerator.java


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