private CodeTree createFastPathTryCatchRewriteException(SpecializationData specialization, ExecutableTypeData forType, LocalContext currentValues, CodeTree execution) { if (specialization.getExceptions().isEmpty()) { return execution; } CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); builder.startTryBlock(); builder.tree(execution); TypeMirror[] exceptionTypes = new TypeMirror[specialization.getExceptions().size()]; for (int i = 0; i < exceptionTypes.length; i++) { exceptionTypes[i] = specialization.getExceptions().get(i).getJavaClass(); } builder.end().startCatchBlock(exceptionTypes, "ex"); builder.startStatement().tree(accessParent(excludedFieldName(specialization))).string(" = true").end(); builder.tree(createCallRemove("threw rewrite exception", forType, currentValues)); builder.end(); return builder.build(); }
private CodeTree createCatchRewriteException(CodeTreeBuilder parent, SpecializationData specialization, ExecutableTypeData forType, FrameState frameState, CodeTree execution, NodeExecutionMode mode) { if (specialization.getExceptions().isEmpty()) { return execution; } CodeTreeBuilder builder = parent.create(); builder.startTryBlock(); builder.tree(execution); boolean nonSlowPath = false; TypeMirror[] exceptionTypes = new TypeMirror[specialization.getExceptions().size()]; for (int i = 0; i < exceptionTypes.length; i++) { TypeMirror type = specialization.getExceptions().get(i).getJavaClass(); if (!ElementUtils.isAssignable(type, context.getType(SlowPathException.class)) && !ElementUtils.isAssignable(type, context.getType(ArithmeticException.class))) { nonSlowPath = true; } exceptionTypes[i] = type; } builder.end().startCatchBlock(exceptionTypes, "ex"); if (nonSlowPath) { builder.tree(createTransferToInterpreterAndInvalidate()); } else { builder.lineComment("implicit transferToInterpreterAndInvalidate()"); } builder.tree(createExcludeThis(builder, frameState, forType, specialization, mode)); builder.end(); return builder.build(); }
builder.startTryBlock(); builder.tree(delegateBuilder.build()); builder.end().startCatchBlock(context.getType(UnexpectedResultException.class), "ex"); if (isVoid(type.getReturnType())) { builder.returnStatement();
builder.statement("break"); if (wrappedExecute.getThrownTypes().contains(context.getType(UnexpectedResultException.class))) { builder.end().startCatchBlock(context.getType(UnexpectedResultException.class), "e"); builder.startStatement().string(VAR_RETURN_CALLED).string(" = true").end(); builder.startStatement().startCall(FIELD_PROBE, METHOD_ON_RETURN_VALUE).string(frameParameterName).string("e.getResult()").end().end(); builder.startThrow().string("e").end(); builder.end().startCatchBlock(context.getType(Throwable.class), "t"); CodeTreeBuilder callExOrUnwind = builder.create(); callExOrUnwind.startCall(FIELD_PROBE, METHOD_ON_RETURN_EXCEPTIONAL_OR_UNWIND).string(frameParameterName).string("t").string(VAR_RETURN_CALLED).end();
builder.end().startCatchBlock(getType(InvalidAssumptionException.class), "ae"); builder.startReturn(); List<String> assumptionIds = new ArrayList<>();
private CodeTree createAssignExecuteChild(FrameState originalFrameState, FrameState frameState, CodeTreeBuilder parent, NodeExecutionData execution, ExecutableTypeData forType, LocalVariable targetValue) { CodeTreeBuilder builder = parent.create(); ChildExecutionResult executeChild = createExecuteChild(builder, originalFrameState, frameState, execution, targetValue); builder.tree(createTryExecuteChild(targetValue, executeChild.code, true, executeChild.throwsUnexpectedResult)); builder.end(); if (executeChild.throwsUnexpectedResult) { builder.startCatchBlock(getType(UnexpectedResultException.class), "ex"); FrameState slowPathFrameState = originalFrameState.copy(); slowPathFrameState.setValue(execution, targetValue.makeGeneric(context).accessWith(CodeTreeBuilder.singleString("ex.getResult()"))); ExecutableTypeData delegateType = node.getGenericExecutableType(forType); boolean found = false; for (NodeExecutionData otherExecution : node.getChildExecutions()) { if (found) { LocalVariable childEvaluatedValue = slowPathFrameState.createValue(otherExecution, genericType); builder.tree(createAssignExecuteChild(slowPathFrameState.copy(), slowPathFrameState, builder, otherExecution, delegateType, childEvaluatedValue)); slowPathFrameState.setValue(otherExecution, childEvaluatedValue); } else { // skip forward already evaluated found = execution == otherExecution; } } builder.tree(createCallExecuteAndSpecialize(forType, slowPathFrameState)); builder.end(); } return builder.build(); }
builder.startTryBlock(); builder.tree(returnBuilder.build()); builder.end().startCatchBlock(context.getType(UnexpectedResultException.class), "ex"); if (!isVoid(source.getReturnType())) { builder.startReturn().tree(cast(context.getType(Object.class), source.getReturnType(), CodeTreeBuilder.singleString("ex.getResult()"))).end();
builder.startCatchBlock(getType(UnexpectedResultException.class), "ex"); LocalContext slowPathValues = currentValues.copy(); slowPathValues.setValue(execution, targetValue.makeGeneric(context).accessWith(CodeTreeBuilder.singleString("ex.getResult()")));
builder.tree(executePolymorphic); builder.end(); builder.startCatchBlock(getType(UnexpectedResultException.class), "ex"); builder.startStatement().tree(accessParent(profileField)).string(" = ").typeLiteral(genericType).end(); builder.startReturn().string("ex.getResult()").end();