private void compileThis(QueryProfileRegistry queryProfiles, ImportedMlModels importedModels) {
        checkNameCollisions(getFunctions(), constants());
        ExpressionTransforms expressionTransforms = new ExpressionTransforms();

        Map<Reference, TensorType> featureTypes = featureTypes();
        // Function compiling first pass: compile inline functions without resolving other functions
        Map<String, RankingExpressionFunction> inlineFunctions =
                compileFunctions(this::getInlineFunctions, queryProfiles, featureTypes, importedModels, Map.of(), expressionTransforms);

        firstPhaseRanking = compile(this.getFirstPhase(), queryProfiles, featureTypes, importedModels, constants(), inlineFunctions, expressionTransforms);
        secondPhaseRanking = compile(this.getSecondPhase(), queryProfiles, featureTypes, importedModels, constants(), inlineFunctions, expressionTransforms);
        globalPhaseRanking = compile(this.getGlobalPhase(), queryProfiles, featureTypes, importedModels, constants(), inlineFunctions, expressionTransforms);

        // Function compiling second pass: compile all functions and insert previously compiled inline functions
        // TODO: This merges all functions from inherited profiles too and erases inheritance information. Not good.
        functions = compileFunctions(this::getFunctions, queryProfiles, featureTypes, importedModels, inlineFunctions, expressionTransforms);
        allFunctionsCached = null;

        var context = new RankProfileTransformContext(this,
                                                      queryProfiles,
                                                      featureTypes,
                                                      importedModels,
                                                      constants(),
                                                      inlineFunctions);
        var allNormalizers = getFeatureNormalizers();
        verifyNoNormalizers("first-phase expression", firstPhaseRanking, allNormalizers, context);
        verifyNoNormalizers("second-phase expression", secondPhaseRanking, allNormalizers, context);
        for (ReferenceNode mf : getMatchFeatures()) {
            verifyNoNormalizers("match-feature " + mf, mf, allNormalizers, context);
        }
        for (ReferenceNode sf : getSummaryFeatures()) {
            verifyNoNormalizers("summary-feature " + sf, sf, allNormalizers, context);
        }
        if (globalPhaseRanking != null) {
            var needInputs = new HashSet<String>();
            Set<String> userDeclaredMatchFeatures = new HashSet<>();
            for (ReferenceNode mf : getMatchFeatures()) {
                userDeclaredMatchFeatures.add(mf.toString());
            }
            var recorder = new InputRecorder(needInputs);
            recorder.alreadyMatchFeatures(userDeclaredMatchFeatures);
            recorder.addKnownNormalizers(allNormalizers.keySet());
            recorder.process(globalPhaseRanking.function().getBody(), context);
            for (var normalizerName : recorder.normalizersUsed()) {
                var normalizer = allNormalizers.get(normalizerName);
                var func = functions.get(normalizer.input());
                if (func != null) {
                    verifyNoNormalizers("normalizer input " + normalizer.input(), func, allNormalizers, context);
                    if (! userDeclaredMatchFeatures.contains(normalizer.input())) {
                        var subRecorder = new InputRecorder(needInputs);
                        subRecorder.alreadyMatchFeatures(userDeclaredMatchFeatures);
                        subRecorder.process(func.function().getBody(), context);
                    }
                } else {
                    needInputs.add(normalizer.input());
                }
            }
            List<FeatureList> addIfMissing = new ArrayList<>();
            for (String input : needInputs) {
                if (input.startsWith("constant(") || input.startsWith("query(")) {
                    continue;
                }
                try {
                    addIfMissing.add(new FeatureList(input));
                } catch (com.yahoo.searchlib.rankingexpression.parser.ParseException e) {
                    throw new IllegalArgumentException("invalid input in global-phase expression: "+input);
                }
            }
            addImplicitMatchFeatures(addIfMissing);
        }
    }
Returns a copy of this where the content is optimized for execution.
Compiled profiles should never be modified.
config-model/src/main/java/com/yahoo/schema/RankProfile.java