use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class UniverseBuilder method buildHubs.
private void buildHubs() {
ReferenceMapEncoder referenceMapEncoder = new ReferenceMapEncoder();
Map<HostedType, ReferenceMapEncoder.Input> referenceMaps = new HashMap<>();
for (HostedType type : hUniverse.orderedTypes) {
ReferenceMapEncoder.Input referenceMap = createReferenceMap(type);
referenceMaps.put(type, referenceMap);
referenceMapEncoder.add(referenceMap);
}
ImageSingletons.lookup(DynamicHubSupport.class).setData(referenceMapEncoder.encodeAll(null));
ObjectLayout ol = ConfigurationValues.getObjectLayout();
for (HostedType type : hUniverse.orderedTypes) {
int layoutHelper;
int monitorOffset = 0;
int hashCodeOffset = 0;
if (type.isInstanceClass()) {
HostedInstanceClass instanceClass = (HostedInstanceClass) type;
if (instanceClass.isAbstract()) {
layoutHelper = LayoutEncoding.forAbstract();
} else if (HybridLayout.isHybrid(type)) {
HybridLayout<?> hybridLayout = new HybridLayout<>(instanceClass, ol);
JavaKind kind = hybridLayout.getArrayElementKind();
layoutHelper = LayoutEncoding.forArray(kind == JavaKind.Object, hybridLayout.getArrayBaseOffset(), ol.getArrayIndexShift(kind), ol.getAlignment());
} else {
layoutHelper = LayoutEncoding.forInstance(ConfigurationValues.getObjectLayout().alignUp(instanceClass.getInstanceSize()));
}
monitorOffset = instanceClass.getMonitorFieldOffset();
hashCodeOffset = instanceClass.getHashCodeFieldOffset();
} else if (type.isArray()) {
JavaKind kind = type.getComponentType().getStorageKind();
layoutHelper = LayoutEncoding.forArray(kind == JavaKind.Object, ol.getArrayBaseOffset(kind), ol.getArrayIndexShift(kind), ol.getAlignment());
hashCodeOffset = ol.getArrayHashCodeOffset();
} else if (type.isInterface()) {
layoutHelper = LayoutEncoding.forInterface();
} else if (type.isPrimitive()) {
layoutHelper = LayoutEncoding.forPrimitive();
} else {
throw shouldNotReachHere();
}
/*
* The vtable entry values are available only after the code cache layout is fixed, so
* leave them 0.
*/
CFunctionPointer[] vtable = new CFunctionPointer[type.vtable.length];
for (int idx = 0; idx < type.vtable.length; idx++) {
/*
* We install a CodePointer in the vtable; when generating relocation info, we will
* know these point into .text
*/
vtable[idx] = MethodPointer.factory(type.vtable[idx]);
}
// pointer maps in Dynamic Hub
ReferenceMapEncoder.Input referenceMap = referenceMaps.get(type);
assert referenceMap != null;
long referenceMapIndex = referenceMapEncoder.lookupEncoding(referenceMap);
DynamicHub hub = type.getHub();
hub.setData(layoutHelper, type.getTypeID(), monitorOffset, hashCodeOffset, type.getAssignableFromMatches(), type.instanceOfBits, vtable, referenceMapIndex, type.isInstantiated());
}
}
use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class BytecodeParser method genConditionalForIf.
private void genConditionalForIf(BciBlock trueBlock, LogicNode condition, int oldBci, int trueBlockInt, int falseBlockInt, boolean genReturn) {
ConstantNode trueValue = graph.unique(ConstantNode.forInt(trueBlockInt));
ConstantNode falseValue = graph.unique(ConstantNode.forInt(falseBlockInt));
ValueNode conditionalNode = ConditionalNode.create(condition, trueValue, falseValue, NodeView.DEFAULT);
if (conditionalNode.graph() == null) {
conditionalNode = graph.addOrUniqueWithInputs(conditionalNode);
}
if (genReturn) {
JavaKind returnKind = method.getSignature().getReturnKind().getStackKind();
this.genReturn(conditionalNode, returnKind);
} else {
frameState.push(JavaKind.Int, conditionalNode);
appendGoto(trueBlock.getSuccessor(0));
stream.setBCI(oldBci);
}
}
use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class BytecodeParser method appendInvoke.
protected Invoke appendInvoke(InvokeKind initialInvokeKind, ResolvedJavaMethod initialTargetMethod, ValueNode[] args) {
ResolvedJavaMethod targetMethod = initialTargetMethod;
InvokeKind invokeKind = initialInvokeKind;
if (initialInvokeKind.isIndirect()) {
ResolvedJavaType contextType = this.frameState.getMethod().getDeclaringClass();
ResolvedJavaMethod specialCallTarget = MethodCallTargetNode.findSpecialCallTarget(initialInvokeKind, args[0], initialTargetMethod, contextType);
if (specialCallTarget != null) {
invokeKind = InvokeKind.Special;
targetMethod = specialCallTarget;
}
}
JavaKind resultType = targetMethod.getSignature().getReturnKind();
if (!parsingIntrinsic() && DeoptALot.getValue(options)) {
append(new DeoptimizeNode(DeoptimizationAction.None, RuntimeConstraint));
frameState.pushReturn(resultType, ConstantNode.defaultForKind(resultType, graph));
return null;
}
JavaType returnType = targetMethod.getSignature().getReturnType(method.getDeclaringClass());
if (graphBuilderConfig.eagerResolving() || parsingIntrinsic()) {
returnType = returnType.resolve(targetMethod.getDeclaringClass());
}
if (invokeKind.hasReceiver()) {
args[0] = emitExplicitExceptions(args[0]);
}
if (initialInvokeKind == InvokeKind.Special && !targetMethod.isConstructor()) {
emitCheckForInvokeSuperSpecial(args);
}
InlineInfo inlineInfo = null;
try {
currentInvoke = new CurrentInvoke(args, invokeKind, returnType);
if (tryNodePluginForInvocation(args, targetMethod)) {
if (TraceParserPlugins.getValue(options)) {
traceWithContext("used node plugin for %s", targetMethod.format("%h.%n(%p)"));
}
return null;
}
if (invokeKind.hasReceiver() && args[0].isNullConstant()) {
append(new DeoptimizeNode(InvalidateRecompile, NullCheckException));
return null;
}
if (!invokeKind.isIndirect() || (UseGuardedIntrinsics.getValue(options) && !GeneratePIC.getValue(options))) {
if (tryInvocationPlugin(invokeKind, args, targetMethod, resultType, returnType)) {
if (TraceParserPlugins.getValue(options)) {
traceWithContext("used invocation plugin for %s", targetMethod.format("%h.%n(%p)"));
}
return null;
}
}
if (invokeKind.isDirect()) {
inlineInfo = tryInline(args, targetMethod);
if (inlineInfo == SUCCESSFULLY_INLINED) {
return null;
}
}
} finally {
currentInvoke = null;
}
int invokeBci = bci();
JavaTypeProfile profile = getProfileForInvoke(invokeKind);
ExceptionEdgeAction edgeAction = getActionForInvokeExceptionEdge(inlineInfo);
boolean partialIntrinsicExit = false;
if (intrinsicContext != null && intrinsicContext.isCallToOriginal(targetMethod)) {
partialIntrinsicExit = true;
ResolvedJavaMethod originalMethod = intrinsicContext.getOriginalMethod();
BytecodeParser intrinsicCallSiteParser = getNonIntrinsicAncestor();
if (intrinsicCallSiteParser != null) {
// When exiting a partial intrinsic, the invoke to the original
// must use the same context as the call to the intrinsic.
invokeBci = intrinsicCallSiteParser.bci();
profile = intrinsicCallSiteParser.getProfileForInvoke(invokeKind);
edgeAction = intrinsicCallSiteParser.getActionForInvokeExceptionEdge(inlineInfo);
} else {
// so the bci must be set to unknown, so that the inliner patches it later.
assert intrinsicContext.isPostParseInlined();
invokeBci = BytecodeFrame.UNKNOWN_BCI;
profile = null;
edgeAction = graph.method().getAnnotation(Snippet.class) == null ? ExceptionEdgeAction.INCLUDE_AND_HANDLE : ExceptionEdgeAction.OMIT;
}
if (originalMethod.isStatic()) {
invokeKind = InvokeKind.Static;
} else {
// The original call to the intrinsic must have been devirtualized
// otherwise we wouldn't be here.
invokeKind = InvokeKind.Special;
}
Signature sig = originalMethod.getSignature();
returnType = sig.getReturnType(method.getDeclaringClass());
resultType = sig.getReturnKind();
assert intrinsicContext.allowPartialIntrinsicArgumentMismatch() || checkPartialIntrinsicExit(intrinsicCallSiteParser == null ? null : intrinsicCallSiteParser.currentInvoke.args, args);
targetMethod = originalMethod;
}
Invoke invoke = createNonInlinedInvoke(edgeAction, invokeBci, args, targetMethod, invokeKind, resultType, returnType, profile);
if (partialIntrinsicExit) {
// This invoke must never be later inlined as it might select the intrinsic graph.
// Until there is a mechanism to guarantee that any late inlining will not select
// the intrinsic graph, prevent this invoke from being inlined.
invoke.setUseForInlining(false);
}
return invoke;
}
use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class ArrayCopyCallNode method updateAlignedDisjoint.
public void updateAlignedDisjoint() {
JavaKind componentKind = elementKind;
if (srcPos == destPos) {
// Can treat as disjoint
disjoint = true;
}
PrimitiveConstant constantSrc = (PrimitiveConstant) srcPos.stamp(NodeView.DEFAULT).asConstant();
PrimitiveConstant constantDst = (PrimitiveConstant) destPos.stamp(NodeView.DEFAULT).asConstant();
if (constantSrc != null && constantDst != null) {
if (!aligned) {
aligned = isHeapWordAligned(constantSrc, componentKind) && isHeapWordAligned(constantDst, componentKind);
}
if (constantSrc.asInt() >= constantDst.asInt()) {
// low to high copy so treat as disjoint
disjoint = true;
}
}
}
use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class FrameStateBuilder method initializeForMethodStart.
public void initializeForMethodStart(Assumptions assumptions, boolean eagerResolve, Plugins plugins) {
int javaIndex = 0;
int index = 0;
ResolvedJavaMethod method = getMethod();
ResolvedJavaType originalType = method.getDeclaringClass();
if (!method.isStatic()) {
// add the receiver
FloatingNode receiver = null;
StampPair receiverStamp = null;
if (plugins != null) {
receiverStamp = plugins.getOverridingStamp(tool, originalType, true);
}
if (receiverStamp == null) {
receiverStamp = StampFactory.forDeclaredType(assumptions, originalType, true);
}
if (plugins != null) {
for (ParameterPlugin plugin : plugins.getParameterPlugins()) {
receiver = plugin.interceptParameter(tool, index, receiverStamp);
if (receiver != null) {
break;
}
}
}
if (receiver == null) {
receiver = new ParameterNode(javaIndex, receiverStamp);
}
locals[javaIndex] = graph.addOrUniqueWithInputs(receiver);
javaIndex = 1;
index = 1;
}
Signature sig = method.getSignature();
int max = sig.getParameterCount(false);
ResolvedJavaType accessingClass = originalType;
for (int i = 0; i < max; i++) {
JavaType type = sig.getParameterType(i, accessingClass);
if (eagerResolve) {
type = type.resolve(accessingClass);
}
JavaKind kind = type.getJavaKind();
StampPair stamp = null;
if (plugins != null) {
stamp = plugins.getOverridingStamp(tool, type, false);
}
if (stamp == null) {
stamp = StampFactory.forDeclaredType(assumptions, type, false);
}
FloatingNode param = null;
if (plugins != null) {
for (ParameterPlugin plugin : plugins.getParameterPlugins()) {
param = plugin.interceptParameter(tool, index, stamp);
if (param != null) {
break;
}
}
}
if (param == null) {
param = new ParameterNode(index, stamp);
}
locals[javaIndex] = graph.addOrUniqueWithInputs(param);
javaIndex++;
if (kind.needsTwoSlots()) {
locals[javaIndex] = TWO_SLOT_MARKER;
javaIndex++;
}
index++;
}
}
Aggregations