Source:
public BytecodeNode generateExpression(Signature signature, BytecodeGeneratorContext generatorContext, Type returnType, List<RowExpression> arguments) { Scope scope = generatorContext.getScope(); RowExpression first = arguments.get(0); RowExpression second = arguments.get(1); if (first.getType().getJavaType() == void.class) { return new BytecodeBlock() .comment("NULLIF(NULL, *) = NULL") .append(generatorContext.generate(first)); } LabelNode notMatch = new LabelNode("notMatch"); Variable firstValue = scope.createTempVariable(first.getType().getJavaType()); BytecodeBlock block = new BytecodeBlock() .comment("check if first arg is null") .append(generatorContext.generate(first)) .append(BytecodeUtils.ifWasNullPopAndGoto(scope, notMatch, void.class)) .dup(first.getType().getJavaType()) .putVariable(firstValue); Type firstType = first.getType(); Type secondType = second.getType(); Signature equalsSignature = generatorContext.getRegistry().resolveOperator(OperatorType.EQUAL, ImmutableList.of(firstType, secondType)); ScalarFunctionImplementation equalsFunction = generatorContext.getRegistry().getScalarFunctionImplementation(equalsSignature); BytecodeNode equalsCall = generatorContext.generateCall( equalsSignature.getName(), equalsFunction, ImmutableList.of( cast(generatorContext, firstValue, firstType, equalsSignature.getArgumentTypes().get(0)), cast(generatorContext, generatorContext.generate(second), secondType, equalsSignature.getArgumentTypes().get(1)))); BytecodeBlock conditionBlock = new BytecodeBlock() .append(equalsCall) .append(BytecodeUtils.ifWasNullClearPopAndGoto(scope, notMatch, void.class, boolean.class)); BytecodeBlock trueBlock = new BytecodeBlock() .append(generatorContext.wasNull().set(constantTrue())) .pop(first.getType().getJavaType()) .pushJavaDefault(first.getType().getJavaType()); block.append(new IfStatement() .condition(conditionBlock) .ifTrue(trueBlock) .ifFalse(notMatch)); return block; }

Target:
public BytecodeNode generateExpression(Signature signature, BytecodeGeneratorContext generatorContext, Type returnType, List<RowExpression> arguments) { Scope scope = generatorContext.getScope(); RowExpression first = arguments.get(0); RowExpression second = arguments.get(1); if (first.getType().getJavaType() == void.class) { return new BytecodeBlock() .comment("NULLIF(NULL, *) = NULL") .append(generatorContext.generate(first)); } LabelNode notMatch = new LabelNode("notMatch"); Variable firstValue = scope.createTempVariable(first.getType().getJavaType()); BytecodeBlock block = new BytecodeBlock() .comment("check if first arg is null") .append(generatorContext.generate(first)) .append(ifWasNullPopAndGoto(scope, notMatch, void.class)) .dup(first.getType().getJavaType()) .putVariable(firstValue); Type firstType = first.getType(); Type secondType = second.getType(); Signature equalsSignature = generatorContext.getRegistry().resolveOperator(OperatorType.EQUAL, ImmutableList.of(firstType, secondType)); ScalarFunctionImplementation equalsFunction = generatorContext.getRegistry().getScalarFunctionImplementation(equalsSignature); BytecodeNode equalsCall = generatorContext.generateCall( equalsSignature.getName(), equalsFunction, ImmutableList.of( cast(generatorContext, firstValue, firstType, equalsSignature.getArgumentTypes().get(0)), cast(generatorContext, generatorContext.generate(second), secondType, equalsSignature.getArgumentTypes().get(1)))); BytecodeBlock conditionBlock = new BytecodeBlock() .append(equalsCall) .append(BytecodeUtils.ifWasNullClearPopAndGoto(scope, notMatch, void.class, boolean.class)); BytecodeBlock trueBlock = new BytecodeBlock() .append(generatorContext.wasNull().set(constantTrue())) .pop(first.getType().getJavaType()) .pushJavaDefault(first.getType().getJavaType()); block.append(new IfStatement() .condition(conditionBlock) .ifTrue(trueBlock) .ifFalse(notMatch)); return block; }