@Override protected NewInstanceTypeFlow createNewArrayTypeFlow(NewArrayNode node, AnalysisType type, BytecodeLocation allocationLabel) { if (node instanceof NewPinnedArrayNode) { return new PinnedNewInstanceTypeFlow((Inflation) bb, node, type, allocationLabel); } return super.createNewArrayTypeFlow(node, type, allocationLabel); }
@Override protected NewInstanceTypeFlow createNewInstanceTypeFlow(NewInstanceNode node, AnalysisType type, BytecodeLocation allocationLabel) { if (node instanceof NewPinnedInstanceNode) { return new PinnedNewInstanceTypeFlow((Inflation) bb, node, type, allocationLabel); } return super.createNewInstanceTypeFlow(node, type, allocationLabel); }
public MethodTypeFlowBuilder createMethodTypeFlowBuilder(BigBang bb, MethodTypeFlow methodFlow) { return new MethodTypeFlowBuilder(bb, methodFlow); }
processNewInstance((NewInstanceNode) n, state); } else if (n instanceof DynamicNewInstanceNode) { DynamicNewInstanceNode node = (DynamicNewInstanceNode) n; Object key = uniqueKey(node); BytecodeLocation allocationLabel = bb.analysisPolicy().createAllocationSite(bb, key, method); TypeFlowBuilder<DynamicNewInstanceTypeFlow> dynamicNewInstanceBuilder = TypeFlowBuilder.create(bb, node, DynamicNewInstanceTypeFlow.class, () -> { processNewArray((NewArrayNode) n, state); } else if (n instanceof DynamicNewArrayNode) { DynamicNewArrayNode node = (DynamicNewArrayNode) n; Object key = uniqueKey(node); BytecodeLocation allocationLabel = bb.analysisPolicy().createAllocationSite(bb, key, method); Object key = uniqueKey(node); BytecodeLocation allocationLabel = bb.analysisPolicy().createAllocationSite(bb, key, method); TypeFlowBuilder<NewInstanceTypeFlow> newArrayBuilder = TypeFlowBuilder.create(bb, node, NewInstanceTypeFlow.class, () -> { checkUnsafeOffset(node.object(), node.offset()); checkUnsafeOffset(node.object(), node.offset()); checkUnsafeOffset(node.object(), node.offset()); checkUnsafeOffset(node.object(), node.offset()); checkUnsafeOffset(node.object(), node.offset()); if (node.object().getStackKind() == JavaKind.Object && node.newValue().getStackKind() == JavaKind.Object) {
protected void processNewInstance(NewInstanceNode node, TypeFlowsOfNodes state) { AnalysisType type = (AnalysisType) node.instanceClass(); assert type.isInstantiated(); Object key = uniqueKey(node); BytecodeLocation allocationLabel = bb.analysisPolicy().createAllocationSite(bb, key, method); TypeFlowBuilder<?> newInstanceBuilder = TypeFlowBuilder.create(bb, node, NewInstanceTypeFlow.class, () -> { NewInstanceTypeFlow newInstance = createNewInstanceTypeFlow(node, type, allocationLabel); /* Instance fields of a new object are initialized to null state in AnalysisField. */ methodFlow.addAllocation(newInstance); return newInstance; }); state.add(node, newInstanceBuilder); }
protected void processNewArray(NewArrayNode node, TypeFlowsOfNodes state) { AnalysisType type = ((AnalysisType) node.elementType()).getArrayClass(); assert type.isInstantiated(); Object key = uniqueKey(node); BytecodeLocation allocationLabel = bb.analysisPolicy().createAllocationSite(bb, key, method); TypeFlowBuilder<?> newArrayBuilder = TypeFlowBuilder.create(bb, node, NewInstanceTypeFlow.class, () -> { NewInstanceTypeFlow newArray = createNewArrayTypeFlow(node, type, allocationLabel); methodFlow.addAllocation(newArray); return newArray; }); state.add(node, newArrayBuilder); }
if (!parse()) { return; Object key = uniqueKey(node); BytecodeLocation boxSite = bb.analysisPolicy().createAllocationSite(bb, key, methodFlow.getMethod()); AnalysisType type = (AnalysisType) StampTool.typeOrNull(node); if (n instanceof InstanceOfNode) { InstanceOfNode instanceOf = (InstanceOfNode) n; markFieldsUsedInComparison(instanceOf.getValue()); } else if (n instanceof ObjectEqualsNode) { ObjectEqualsNode compareNode = (ObjectEqualsNode) n; markFieldsUsedInComparison(compareNode.getX()); markFieldsUsedInComparison(compareNode.getY());
@Override public void registerUsedElements() { super.registerUsedElements(); for (Node n : graph.getNodes()) { if (n instanceof ConstantNode) { ConstantNode cn = (ConstantNode) n; if (cn.hasUsages() && cn.asJavaConstant().getJavaKind() == JavaKind.Object && cn.asJavaConstant().isNonNull()) { /* * Constants that are embedded into graphs via constant folding of static fields * have already been replaced. But constants embedded manually by graph builder * plugins, or class constants that come directly from constant bytecodes, are * not replaced. We verify here that the object replacer would not replace such * objects. * * But more importantly, some object replacers also perform actions like forcing * eager initialization of fields. We need to make sure that these object * replacers really see all objects that are embedded into compiled code. */ Object value = SubstrateObjectConstant.asObject(cn.asJavaConstant()); Object replaced = bb.getUniverse().replaceObject(value); if (value != replaced) { throw GraalError.shouldNotReachHere("Missed object replacement during graph building: " + value + " (" + value.getClass() + ") != " + replaced + " (" + replaced.getClass() + ")"); } } } } }
private synchronized void doParse(BigBang bb, InvokeTypeFlow reason) { if (!methodParsed) { parsingReason = reason; try { MethodTypeFlowBuilder builder = bb.createMethodTypeFlowBuilder(bb, this); builder.apply(); graphRef = builder.graph; } catch (BytecodeParserError ex) { /* Rewrite some bytecode parsing errors as unsupported features. */ if (ex.getCause() instanceof UnsupportedFeatureException) { Throwable cause = ex; if (ex.getCause().getCause() != null) { cause = ex.getCause(); } String message = cause.getMessage(); bb.getUnsupportedFeatures().addMessage(method.format("%H.%n(%p)"), method, message, ex.context(), cause.getCause()); } else { /* Wrap all other errors as parsing errors. */ throw AnalysisError.parsingError(method, ex); } } catch (Throwable t) { /* Wrap all other errors as parsing errors. */ throw AnalysisError.parsingError(method, t); } originalMethodFlows.linearizeGraph(); bb.numParsedGraphs.incrementAndGet(); returnedParameter = computeReturnedParamter(); methodParsed = true; } }
registerUsedElements(); registerUsedElements(); } catch (Throwable e) { throw debug.handle(e);