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);
}
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);
}
}
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);
}
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;
}
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));
}
}
Aggregations