Search in sources :

Example 31 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class HexCodeFileDisassemblerProvider method disassemble.

private static String disassemble(CodeCacheProvider codeCache, CompilationResult compResult, InstalledCode installedCode) {
    TargetDescription target = codeCache.getTarget();
    RegisterConfig regConfig = codeCache.getRegisterConfig();
    byte[] code = installedCode == null ? Arrays.copyOf(compResult.getTargetCode(), compResult.getTargetCodeSize()) : installedCode.getCode();
    if (code == null) {
        // Method was deoptimized/invalidated
        return "";
    }
    long start = installedCode == null ? 0L : installedCode.getStart();
    HexCodeFile hcf = new HexCodeFile(code, start, target.arch.getName(), target.wordSize * 8);
    if (compResult != null) {
        HexCodeFile.addAnnotations(hcf, compResult.getAnnotations());
        addExceptionHandlersComment(compResult, hcf);
        Register fp = regConfig.getFrameRegister();
        RefMapFormatter slotFormatter = new DefaultRefMapFormatter(target.wordSize, fp, 0);
        for (Infopoint infopoint : compResult.getInfopoints()) {
            if (infopoint instanceof Call) {
                Call call = (Call) infopoint;
                if (call.debugInfo != null) {
                    hcf.addComment(call.pcOffset + call.size, CodeUtil.append(new StringBuilder(100), call.debugInfo, slotFormatter).toString());
                }
                addOperandComment(hcf, call.pcOffset, "{" + codeCache.getTargetName(call) + "}");
            } else {
                if (infopoint.debugInfo != null) {
                    hcf.addComment(infopoint.pcOffset, CodeUtil.append(new StringBuilder(100), infopoint.debugInfo, slotFormatter).toString());
                }
                addOperandComment(hcf, infopoint.pcOffset, "{infopoint: " + infopoint.reason + "}");
            }
        }
        for (DataPatch site : compResult.getDataPatches()) {
            hcf.addOperandComment(site.pcOffset, "{" + site.reference.toString() + "}");
        }
        for (Mark mark : compResult.getMarks()) {
            hcf.addComment(mark.pcOffset, codeCache.getMarkName(mark));
        }
    }
    String hcfEmbeddedString = hcf.toEmbeddedString();
    return HexCodeFileDisTool.tryDisassemble(hcfEmbeddedString);
}
Also used : DefaultRefMapFormatter(jdk.vm.ci.code.CodeUtil.DefaultRefMapFormatter) RefMapFormatter(jdk.vm.ci.code.CodeUtil.RefMapFormatter) RegisterConfig(jdk.vm.ci.code.RegisterConfig) Call(jdk.vm.ci.code.site.Call) TargetDescription(jdk.vm.ci.code.TargetDescription) Mark(jdk.vm.ci.code.site.Mark) Infopoint(jdk.vm.ci.code.site.Infopoint) DataPatch(jdk.vm.ci.code.site.DataPatch) Register(jdk.vm.ci.code.Register) DefaultRefMapFormatter(jdk.vm.ci.code.CodeUtil.DefaultRefMapFormatter)

Example 32 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class RawStructureLayoutPlanner method computeSize.

private void computeSize(StructFieldInfo info) {
    AccessorInfo ainfo = info.getAccessorInfo();
    /**
     * Resolve field size using the declared type in its accessors. Note that the field offsets
     * are not calculated before visiting all StructFieldInfos and collecting all field types.
     */
    ResolvedJavaMethod accessor = (ResolvedJavaMethod) ainfo.getAnnotatedElement();
    ResolvedJavaType fieldType;
    if (ainfo.getAccessorKind() == AccessorKind.GETTER) {
        fieldType = (ResolvedJavaType) accessor.getSignature().getReturnType(null);
    } else if (ainfo.getAccessorKind() == AccessorKind.SETTER) {
        fieldType = (ResolvedJavaType) accessor.getSignature().getParameterType(ainfo.valueParameterNumber(false), null);
    } else {
        throw shouldNotReachHere("Unexpected accessor kind " + ainfo.getAccessorKind());
    }
    TargetDescription target = nativeLibs.getTarget();
    int declaredSize = target.arch.getPlatformKind(fieldType.getJavaKind()).getSizeInBytes();
    info.getSizeInfo().setProperty(declaredSize);
    if (info.getKind() == ElementKind.INTEGER) {
        info.getSignednessInfo().setProperty(nativeLibs.isSigned(fieldType) ? SignednessValue.SIGNED : SignednessValue.UNSIGNED);
    }
}
Also used : TargetDescription(jdk.vm.ci.code.TargetDescription) AccessorInfo(com.oracle.svm.hosted.c.info.AccessorInfo) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 33 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class AArch64MacroAssemblerTest method createTarget.

private static TargetDescription createTarget() {
    final int stackFrameAlignment = 16;
    final int implicitNullCheckLimit = 4096;
    final boolean inlineObjects = true;
    Architecture arch = new AArch64(computeFeatures(), computeFlags());
    return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects);
}
Also used : AArch64(jdk.vm.ci.aarch64.AArch64) Architecture(jdk.vm.ci.code.Architecture) TargetDescription(jdk.vm.ci.code.TargetDescription)

Example 34 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class AArch64MacroAssemblerTest method setupEnvironment.

@Before
public void setupEnvironment() {
    TargetDescription target = createTarget();
    masm = new AArch64MacroAssembler(target);
    asm = new TestProtectedAssembler(target);
    base = AArch64.r10;
    index = AArch64.r13;
    scratch = AArch64.r15;
}
Also used : AArch64MacroAssembler(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler) TargetDescription(jdk.vm.ci.code.TargetDescription) Before(org.junit.Before)

Example 35 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class BitOpsTest method lzcntqMemTest.

@Test
public void lzcntqMemTest() {
    if (lzcntSupported) {
        CodeGenTest test = new CodeGenTest() {

            @Override
            public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
                AMD64Assembler asm = new AMD64Assembler(target);
                Register ret = registerConfig.getReturnRegister(JavaKind.Int);
                try {
                    Field f = LongField.class.getDeclaredField("x");
                    AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) UNSAFE.objectFieldOffset(f));
                    LZCNT.emit(asm, QWORD, ret, arg);
                    asm.ret(0);
                    return asm.close(true);
                } catch (Exception e) {
                    throw new RuntimeException("exception while trying to generate field access:", e);
                }
            }
        };
        assertReturn("longFieldStub", test, 63, new LongField(1));
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterConfig(jdk.vm.ci.code.RegisterConfig) Field(java.lang.reflect.Field) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) AMD64Assembler(org.graalvm.compiler.asm.amd64.AMD64Assembler) TargetDescription(jdk.vm.ci.code.TargetDescription) CompilationResult(org.graalvm.compiler.code.CompilationResult) AMD64Address(org.graalvm.compiler.asm.amd64.AMD64Address) Test(org.junit.Test) AssemblerTest(org.graalvm.compiler.asm.test.AssemblerTest)

Aggregations

TargetDescription (jdk.vm.ci.code.TargetDescription)41 CallingConvention (jdk.vm.ci.code.CallingConvention)14 Register (jdk.vm.ci.code.Register)14 RegisterConfig (jdk.vm.ci.code.RegisterConfig)12 AssemblerTest (org.graalvm.compiler.asm.test.AssemblerTest)11 CompilationResult (org.graalvm.compiler.code.CompilationResult)11 Test (org.junit.Test)11 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)10 AMD64Assembler (org.graalvm.compiler.asm.amd64.AMD64Assembler)10 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)8 GraalHotSpotVMConfig (org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)7 LIRKind (org.graalvm.compiler.core.common.LIRKind)6 AMD64Address (org.graalvm.compiler.asm.amd64.AMD64Address)5 Field (java.lang.reflect.Field)4 BytecodeProvider (org.graalvm.compiler.bytecode.BytecodeProvider)4 Value (jdk.vm.ci.meta.Value)3 AMD64MacroAssembler (org.graalvm.compiler.asm.amd64.AMD64MacroAssembler)3 HotSpotRegistersProvider (org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider)3 RegisterValue (jdk.vm.ci.code.RegisterValue)2 DataSectionReference (jdk.vm.ci.code.site.DataSectionReference)2