use of jdk.vm.ci.code.TargetDescription in project graal by oracle.
the class SizeAndSignednessVerifier method checkSizeAndSignedness.
private void checkSizeAndSignedness(SizableInfo sizableInfo, ResolvedJavaType type, ResolvedJavaMethod method, boolean isReturn) {
TargetDescription target = nativeLibs.getTarget();
int declaredSize = target.arch.getPlatformKind(type.getJavaKind()).getSizeInBytes();
int actualSize = sizableInfo.getSizeInfo().getProperty();
if (declaredSize != actualSize) {
Class<? extends Annotation> supressionAnnotation = (declaredSize > actualSize) ^ isReturn ? AllowNarrowingCast.class : AllowWideningCast.class;
if (method.getAnnotation(supressionAnnotation) == null) {
nativeLibs.addError("Type " + type.toJavaName(false) + " has a size of " + declaredSize + " bytes, but accessed C value has a size of " + actualSize + " bytes; to suppress this error, use the annotation @" + supressionAnnotation.getSimpleName(), method);
}
}
checkSignedness(sizableInfo.isUnsigned(), type, method);
}
use of jdk.vm.ci.code.TargetDescription in project graal by oracle.
the class QueryResultParser method visitConstantInfo.
@Override
protected void visitConstantInfo(ConstantInfo constantInfo) {
TargetDescription target = nativeLibs.getTarget();
switch(constantInfo.getKind()) {
case INTEGER:
parseIntegerProperty(constantInfo.getSizeInfo());
parseSignedness(constantInfo.getSignednessInfo());
parseIntegerConstantValue(constantInfo.getValueInfo());
/*
* From the point of view of the C compiler, plain #define constants have the type
* int and therefore size 4. But sometimes we want to access such values as short or
* byte to avoid casts. Check the actual value of the constant, and if it fits the
* declared type of the constant, then change the actual size to the declared size.
*/
ResolvedJavaMethod method = (ResolvedJavaMethod) constantInfo.getAnnotatedElement();
ResolvedJavaType returnType = (ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass());
JavaKind returnKind = returnType.getJavaKind();
if (returnKind == JavaKind.Object) {
returnKind = target.wordJavaKind;
}
int declaredSize = target.arch.getPlatformKind(returnKind).getSizeInBytes();
int actualSize = constantInfo.getSizeInfo().getProperty();
if (declaredSize != actualSize) {
long value = (long) constantInfo.getValueInfo().getProperty();
if (value >= returnKind.getMinValue() && value <= returnKind.getMaxValue()) {
constantInfo.getSizeInfo().setProperty(declaredSize);
}
}
break;
case POINTER:
parseIntegerProperty(constantInfo.getSizeInfo());
parseIntegerConstantValue(constantInfo.getValueInfo());
break;
case FLOAT:
parseIntegerProperty(constantInfo.getSizeInfo());
parseFloatValue(constantInfo.getValueInfo());
break;
case STRING:
parseStringValue(constantInfo.getValueInfo());
break;
case BYTEARRAY:
parseByteArrayValue(constantInfo.getValueInfo());
break;
default:
throw shouldNotReachHere();
}
}
use of jdk.vm.ci.code.TargetDescription in project graal by oracle.
the class SPARCHotSpotCounterOp method emitCode.
@Override
public void emitCode(CompilationResultBuilder crb) {
SPARCMacroAssembler masm = (SPARCMacroAssembler) crb.asm;
TargetDescription target = crb.target;
// address for counters array
SPARCAddress countersArrayAddr = new SPARCAddress(thread, config.jvmciCountersThreadOffset);
try (ScratchRegister scratch = masm.getScratchRegister()) {
Register countersArrayReg = scratch.getRegister();
// load counters array
masm.ldx(countersArrayAddr, countersArrayReg);
IncrementEmitter emitter = new IncrementEmitter(countersArrayReg, masm);
forEachCounter(emitter, target);
}
}
use of jdk.vm.ci.code.TargetDescription in project graal by oracle.
the class SPARCHotSpotForeignCallsProvider method initialize.
@Override
public void initialize(HotSpotProviders providers, OptionValues options) {
GraalHotSpotVMConfig config = runtime.getVMConfig();
TargetDescription target = providers.getCodeCache().getTarget();
PlatformKind word = target.arch.getWordKind();
// The calling convention for the exception handler stub is (only?) defined in
// TemplateInterpreterGenerator::generate_throw_exception()
// in templateInterpreter_sparc.cpp around line 1925
RegisterValue outgoingException = o0.asValue(LIRKind.fromJavaKind(target.arch, JavaKind.Object));
RegisterValue outgoingExceptionPc = o1.asValue(LIRKind.value(word));
RegisterValue incomingException = i0.asValue(LIRKind.fromJavaKind(target.arch, JavaKind.Object));
RegisterValue incomingExceptionPc = i1.asValue(LIRKind.value(word));
CallingConvention outgoingExceptionCc = new CallingConvention(0, ILLEGAL, outgoingException, outgoingExceptionPc);
CallingConvention incomingExceptionCc = new CallingConvention(0, ILLEGAL, incomingException, incomingExceptionPc);
register(new HotSpotForeignCallLinkageImpl(EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF_NOFP, outgoingExceptionCc, incomingExceptionCc, NOT_REEXECUTABLE, any()));
register(new HotSpotForeignCallLinkageImpl(EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF_NOFP, outgoingExceptionCc, incomingExceptionCc, NOT_REEXECUTABLE, any()));
if (config.useCRC32Intrinsics) {
// This stub does callee saving
registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
}
if (config.useCRC32CIntrinsics) {
registerForeignCall(UPDATE_BYTES_CRC32C, config.updateBytesCRC32C, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
}
super.initialize(providers, options);
}
use of jdk.vm.ci.code.TargetDescription in project graal by oracle.
the class SPARCHotSpotBackendFactory method createBackend.
@Override
public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, CompilerConfiguration compilerConfiguration, HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotBackend host) {
assert host == null;
GraalHotSpotVMConfig config = runtime.getVMConfig();
JVMCIBackend jvmci = jvmciRuntime.getHostJVMCIBackend();
HotSpotRegistersProvider registers = createRegisters();
HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) jvmci.getMetaAccess();
HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmci.getCodeCache();
TargetDescription target = codeCache.getTarget();
HotSpotConstantReflectionProvider constantReflection = (HotSpotConstantReflectionProvider) jvmci.getConstantReflection();
HotSpotConstantFieldProvider constantFieldProvider = new HotSpotGraalConstantFieldProvider(config, metaAccess);
Value[] nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(config, codeCache.getRegisterConfig());
HotSpotWordTypes wordTypes = new HotSpotWordTypes(metaAccess, target.wordJavaKind);
HotSpotForeignCallsProvider foreignCalls = new SPARCHotSpotForeignCallsProvider(jvmciRuntime, runtime, metaAccess, codeCache, wordTypes, nativeABICallerSaveRegisters);
LoweringProvider lowerer = createLowerer(runtime, metaAccess, foreignCalls, registers, constantReflection, target);
HotSpotStampProvider stampProvider = new HotSpotStampProvider();
Providers p = new Providers(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, null, stampProvider);
HotSpotSnippetReflectionProvider snippetReflection = new HotSpotSnippetReflectionProvider(runtime, constantReflection, wordTypes);
BytecodeProvider bytecodeProvider = new ClassfileBytecodeProvider(metaAccess, snippetReflection);
HotSpotReplacementsImpl replacements = new HotSpotReplacementsImpl(runtime.getOptions(), p, snippetReflection, bytecodeProvider, target);
Plugins plugins = createGraphBuilderPlugins(compilerConfiguration, config, metaAccess, constantReflection, foreignCalls, lowerer, stampProvider, snippetReflection, replacements, wordTypes);
replacements.setGraphBuilderPlugins(plugins);
HotSpotSuitesProvider suites = createSuites(config, runtime, compilerConfiguration, plugins, replacements);
HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, replacements, suites, registers, snippetReflection, wordTypes, plugins);
return createBackend(config, runtime, providers);
}
Aggregations