Postgresql source code (113) simple analysis of expression JIT calculation

Related
“Postgresql source code (85) query execution – expression parser analysis (how to execute select 1 + 1)”
“Postgresql source code (113) simple analysis of expression JIT calculation”

1 Common expression calculation

Ordinary expression calculation occurs in the optimizer preprocess_expression. All functions that can be calculated will be calculated first and the values will be added to the plan.

#0 ExecInterpExpr (state=0x16188b8, econtext=0x1618df8, isnull=0x7ffcbbb1b6af) at execExprInterp.c:508
#1 0x000000000072b06f in ExecInterpExprStillValid (state=0x16188b8, econtext=0x1618df8, isNull=0x7ffcbbb1b6af) at execExprInterp.c:1870
#2 0x00000000008abc53 in ExecEvalExprSwitchContext (state=0x16188b8, econtext=0x1618df8, isNull=0x7ffcbbb1b6af) at ../../../../src/include/executor/executor.h:355
#3 0x00000000008b33d5 in evaluate_expr (expr=0x15524d8, result_type=23, result_typmod=-1, result_collation=0) at clauses.c:4902
#4 0x00000000008b26f8 in evaluate_function (funcid=177, result_type=23, result_typmod=-1, result_collid=0, input_collid=0, args=0x1552438, funcvariadic=false,
    func_tuple=0x7f8ed3ebc3f8, context=0x7ffcbbb1ccb0) at clauses.c:4409
#5 0x00000000008b1a47 in simplify_function (funcid=177, result_type=23, result_typmod=-1, result_collid=0, input_collid=0, args_p=0x7ffcbbb1b8c8, funcvariadic=false,
    process_args=true, allow_non_const=true, context=0x7ffcbbb1ccb0) at clauses.c:3997
#6 0x00000000008af028 in eval_const_expressions_mutator (node=0x1521488, context=0x7ffcbbb1ccb0) at clauses.c:2551
#7 0x00000000007e7ed9 in expression_tree_mutator_impl (node=0x15214d8, mutator=0x8ae95b <eval_const_expressions_mutator>, context=0x7ffcbbb1ccb0) at nodeFuncs.c:3298
#8 0x00000000008b13ec in eval_const_expressions_mutator (node=0x15214d8, context=0x7ffcbbb1ccb0) at clauses.c:3616
#9 0x00000000007e82e4 in expression_tree_mutator_impl (node=0x1521528, mutator=0x8ae95b <eval_const_expressions_mutator>, context=0x7ffcbbb1ccb0) at nodeFuncs.c:3384
#10 0x00000000008b13ec in eval_const_expressions_mutator (node=0x1521528, context=0x7ffcbbb1ccb0) at clauses.c:3616
#11 0x00000000008ae720 in eval_const_expressions (root=0x1521648, node=0x1521528) at clauses.c:2183
#12 0x0000000000885d2a in preprocess_expression (root=0x1521648, expr=0x1521528, kind=1) at planner.c:1144
#13 0x0000000000885173 in subquery_planner (glob=0x1520e08, parse=0x1520f18, parent_root=0x0, hasRecursion=false, tuple_fraction=0) at planner.c:811
#14 0x0000000000884293 in standard_planner (parse=0x1520f18, query_string=0x151fe78 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at planner.c:413
#15 0x000000000088403a in planner (parse=0x1520f18, query_string=0x151fe78 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at planner.c:281
#16 0x00000000009b5ec0 in pg_plan_query (querytree=0x1520f18, query_string=0x151fe78 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at postgres.c:904
#17 0x00000000009b600c in pg_plan_queries (querytrees=0x15215f8, query_string=0x151fe78 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at postgres.c:996
#18 0x00000000009b638c in exec_simple_query (query_string=0x151fe78 "select 1000 + abs(-10000) + 100;") at postgres.c:1193
#19 0x00000000009bab95 in PostgresMain (dbname=0x15572f8 "postgres", username=0x151bad8 "mingjie") at postgres.c:4637
#20 0x00000000008f1d6d in BackendRun (port=0x154db80) at postmaster.c:4464
#21 0x00000000008f1706 in BackendStartup (port=0x154db80) at postmaster.c:4192
#22 0x00000000008edfd1 in ServerLoop () at postmaster.c:1782
#23 0x00000000008ed9a1 in PostmasterMain (argc=1, argv=0x1519a80) at postmaster.c:1466
#24 0x00000000007b8201 in main (argc=1, argv=0x1519a80) at main.c:198

1.1 Calculationselect 1000 + abs(-10000) + 100;

select 1000 + abs(-10000) + 100;

Query Tree

Optimizer processing: ExecInterpExpr procedure

1.1.1 The first step is to calculate abs(-10000)

ExecInterpExpr

(gdb) p *state
$6 = {type = T_ExprState,
  flags = 6 '\006',
  resnull = false, resvalue = 0, resultslot = 0x0,
  steps = 0x16189e8,
  evalfunc = 0x7288a3 <ExecInterpExpr>,
  expr = 0x15522f8, → points to FuncExpr above
  evalfunc_private = 0x7288a3 <ExecInterpExpr>,
  steps_len = 2,
  steps_alloc = 16,
  parent = 0x0,
  ext_params = 0x0,
  innermost_caseval = 0x0,
  innermost_casenull = 0x0,
  innermost_domainval = 0x0,
  innermost_domainnull = 0x0}

Let’s look at step 0 first, where to jump to
Step one: EEOP_FUNCEXPR_STRICT
Step 2: EEOP_DONE

(gdb) p/x state->steps[0]->opcode
$23 = 0x72914f
(gdb) p/x state->steps[1]->opcode
$30 = 0x72893a

(gdb) p reverse_dispatch_table
$24 = {
...
{opcode = 0x72893a <ExecInterpExpr + 151>, op = EEOP_DONE},
{opcode = 0x72914f <ExecInterpExpr + 2220>, op = EEOP_FUNCEXPR_STRICT}
...
}

Data required for the current branch

(gdb) p state->steps[0]->d.func
$14 = {finfo = 0x1618948, fcinfo_data = 0x1618998, fn_addr = 0xa51c5d <int4abs>, nargs = 1}

Enter the branch to work and calculate the abs(-10000) result

EEO_CASE(EEOP_FUNCEXPR_STRICT)
{<!-- -->
FunctionCallInfo fcinfo = op->d.func.fcinfo_data;
NullableDatum *args = fcinfo->args;
int nargs = op->d.func.nargs;
Datum d;

/* strict function, so check for NULL args */
for (int argno = 0; argno < nargs; argno + + )
{<!-- -->
if (args[argno].isnull)
{<!-- -->
*op->resnull = true;
goto strictfail;
}
}
fcinfo->isnull = false;
d = op->d.func.fn_addr(fcinfo); // Call the function with the function address to get the result
*op->resvalue = d;
*op->resnull = fcinfo->isnull;

strictfail:
EEO_NEXT();
}

(For the memory below, please refer to “Postgresql Source Code (85) Query Execution – Expression Parser Analysis (How to Execute Select 1 + 1)”)
Recall the process of expression calculation of ExecInterpExpr function. The core is this op, which is step. This ExprEvalStep structure is passed in as the data in the core structure when executing ExecInterpExpr. It is specifically saved in ExprState→steps. This is a piece of data. Each element represents a calculation, and the current calculation memory is recorded by the ExprEvalStep structure:

1.1.2 The second step is to calculate 1000 + 10000

Same as above. Note that the steps_len in the first step above and now are both 2, that is, they are both calculated once.

That is to say, each calculation occurs after the function node is discovered when eval_const_expressions_mutator traverses the tree.

(gdb) p *state
$31 = {type = T_ExprState,
  flags = 6 '\006',
  resnull = false,
  resvalue = 0,
  resultslot = 0x0,
  steps = 0x16189e8,
  evalfunc = 0x7288a3 <ExecInterpExpr>,
  expr = 0x1552398, // FuncExpr->args = {Const{1000}, Const{10000}}
  evalfunc_private = 0x7288a3 <ExecInterpExpr>,
  steps_len = 2,
  steps_alloc = 16,
  parent = 0x0,
  ext_params = 0x0,
  innermost_caseval = 0x0,
  innermost_casenull = 0x0,
  innermost_domainval = 0x0,
  innermost_domainnull = 0x0}

1.1.3 The third step is to calculate 11000 + 100

Same as above

2 JIT expression calculation

2.1 Calculationselect 1000 + abs(-10000) + 100;

Enter jit stack jit_compile_expr for the first time, state→expr = (FuncExpr) means abs(-10000)

Because it is not a parent expression, the calculation will not continue.

#0 jit_compile_expr (state=0x1deae18) at jit.c:180
#1 0x000000000071fa6b in ExecReadyExpr (state=0x1deae18) at execExpr.c:874
#2 0x000000000071e60b in ExecInitExpr (node=0x1dfabb8, parent=0x0) at execExpr.c:152
#3 0x00000000008b3395 in evaluate_expr (expr=0x1dfabb8, result_type=23, result_typmod=-1, result_collation=0) at clauses.c:4892
#4 0x00000000008b26f8 in evaluate_function (funcid=1397, result_type=23, result_typmod=-1, result_collid=0, input_collid=0, args=0x1dfab68, funcvariadic=false, func_tuple=0x7fd9588871a8, context=0x7ffdd8867f2 0) at clauses.c:4409
#5 0x00000000008b1a47 in simplify_function (funcid=1397, result_type=23, result_typmod=-1, result_collid=0, input_collid=0, args_p=0x7ffdd8865960, funcvariadic=false, process_args=true, allow_non_const=true, context=0x7ffdd8867f 20) at clauses. c:3997
#6 0x00000000008aee93 in eval_const_expressions_mutator (node=0x1cf92e8, context=0x7ffdd8867f20) at clauses.c:2503
#7 0x00000000007e82e4 in expression_tree_mutator_impl (node=0x1cf9338, mutator=0x8ae95b <eval_const_expressions_mutator>, context=0x7ffdd8867f20) at nodeFuncs.c:3384
#8 0x00000000008b1a05 in simplify_function (funcid=177, result_type=23, result_typmod=-1, result_collid=0, input_collid=0, args_p=0x7ffdd8866248, funcvariadic=false, process_args=true, allow_non_const=true, context=0x7ffdd8867f2 0) at clauses. c:3988
#9 0x00000000008af028 in eval_const_expressions_mutator (node=0x1cf9388, context=0x7ffdd8867f20) at clauses.c:2551
#10 0x00000000007e82e4 in expression_tree_mutator_impl (node=0x1cf9428, mutator=0x8ae95b <eval_const_expressions_mutator>, context=0x7ffdd8867f20) at nodeFuncs.c:3384
#11 0x00000000008b1a05 in simplify_function (funcid=177, result_type=23, result_typmod=-1, result_collid=0, input_collid=0, args_p=0x7ffdd8866b38, funcvariadic=false, process_args=true, allow_non_const=true, context=0x7ffdd8867f 20) at clauses. c:3988
#12 0x00000000008af028 in eval_const_expressions_mutator (node=0x1cf9478, context=0x7ffdd8867f20) at clauses.c:2551
#13 0x00000000007e7ed9 in expression_tree_mutator_impl (node=0x1cf94c8, mutator=0x8ae95b <eval_const_expressions_mutator>, context=0x7ffdd8867f20) at nodeFuncs.c:3298
#14 0x00000000008b13ec in eval_const_expressions_mutator (node=0x1cf94c8, context=0x7ffdd8867f20) at clauses.c:3616
#15 0x00000000007e82e4 in expression_tree_mutator_impl (node=0x1cf9518, mutator=0x8ae95b <eval_const_expressions_mutator>, context=0x7ffdd8867f20) at nodeFuncs.c:3384
#16 0x00000000008b13ec in eval_const_expressions_mutator (node=0x1cf9518, context=0x7ffdd8867f20) at clauses.c:3616
#17 0x00000000008ae720 in eval_const_expressions (root=0x1cf9638, node=0x1cf9518) at clauses.c:2183
#18 0x0000000000885d2a in preprocess_expression (root=0x1cf9638, expr=0x1cf9518, kind=1) at planner.c:1144
#19 0x0000000000885173 in subquery_planner (glob=0x1cf8df8, parse=0x1cf8f08, parent_root=0x0, hasRecursion=false, tuple_fraction=0) at planner.c:811
#20 0x0000000000884293 in standard_planner (parse=0x1cf8f08, query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at planner.c:413
#21 0x000000000088403a in planner (parse=0x1cf8f08, query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at planner.c:281
#22 0x00000000009b5ec0 in pg_plan_query (querytree=0x1cf8f08, query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at postgres.c:904
#23 0x00000000009b600c in pg_plan_queries (querytrees=0x1cf95e8, query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at postgres.c:996
#24 0x00000000009b638c in exec_simple_query (query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;") at postgres.c:1193
#25 0x00000000009bab95 in PostgresMain (dbname=0x1d2f2e8 "postgres", username=0x1cf3ac8 "mingjie") at postgres.c:4637
#26 0x00000000008f1d6d in BackendRun (port=0x1d25b70) at postmaster.c:4464
#27 0x00000000008f1706 in BackendStartup (port=0x1d25b70) at postmaster.c:4192
#28 0x00000000008edfd1 in ServerLoop () at postmaster.c:1782
#29 0x00000000008ed9a1 in PostmasterMain (argc=1, argv=0x1cf1a70) at postmaster.c:1466
#30 0x00000000007b8201 in main (argc=1, argv=0x1cf1a70) at main.c:198
Enter jit stack jit_compile_expr for the second time, state→expr = (FuncExpr) means 1000 + 10000

Because it is not a parent expression, the calculation will not continue.

#0 jit_compile_expr (state=0x1deae18) at jit.c:165
#1 0x000000000071fa6b in ExecReadyExpr (state=0x1deae18) at execExpr.c:874
#2 0x000000000071e60b in ExecInitExpr (node=0x1dfac58, parent=0x0) at execExpr.c:152
#3 0x00000000008b3395 in evaluate_expr (expr=0x1dfac58, result_type=23, result_typmod=-1, result_collation=0) at clauses.c:4892
#4 0x00000000008b26f8 in evaluate_function (funcid=177, result_type=23, result_typmod=-1, result_collid=0, input_collid=0, args=0x1dfaac8, funcvariadic=false, func_tuple=0x7fd9588876b8, context=0x7ffdd8867f20) at clauses.c:4409
#5 0x00000000008b1a47 in simplify_function (funcid=177, result_type=23, result_typmod=-1, result_collid=0, input_collid=0, args_p=0x7ffdd8866248, funcvariadic=false, process_args=true, allow_non_const=true, context=0x7ffdd8867f2 0) at clauses. c:3997
#6 0x00000000008af028 in eval_const_expressions_mutator (node=0x1cf9388, context=0x7ffdd8867f20) at clauses.c:2551
#7 0x00000000007e82e4 in expression_tree_mutator_impl (node=0x1cf9428, mutator=0x8ae95b <eval_const_expressions_mutator>, context=0x7ffdd8867f20) at nodeFuncs.c:3384
#8 0x00000000008b1a05 in simplify_function (funcid=177, result_type=23, result_typmod=-1, result_collid=0, input_collid=0, args_p=0x7ffdd8866b38, funcvariadic=false, process_args=true, allow_non_const=true, context=0x7ffdd8867f2 0) at clauses. c:3988
#9 0x00000000008af028 in eval_const_expressions_mutator (node=0x1cf9478, context=0x7ffdd8867f20) at clauses.c:2551
#10 0x00000000007e7ed9 in expression_tree_mutator_impl (node=0x1cf94c8, mutator=0x8ae95b <eval_const_expressions_mutator>, context=0x7ffdd8867f20) at nodeFuncs.c:3298
#11 0x00000000008b13ec in eval_const_expressions_mutator (node=0x1cf94c8, context=0x7ffdd8867f20) at clauses.c:3616
#12 0x00000000007e82e4 in expression_tree_mutator_impl (node=0x1cf9518, mutator=0x8ae95b <eval_const_expressions_mutator>, context=0x7ffdd8867f20) at nodeFuncs.c:3384
#13 0x00000000008b13ec in eval_const_expressions_mutator (node=0x1cf9518, context=0x7ffdd8867f20) at clauses.c:3616
#14 0x00000000008ae720 in eval_const_expressions (root=0x1cf9638, node=0x1cf9518) at clauses.c:2183
#15 0x0000000000885d2a in preprocess_expression (root=0x1cf9638, expr=0x1cf9518, kind=1) at planner.c:1144
#16 0x0000000000885173 in subquery_planner (glob=0x1cf8df8, parse=0x1cf8f08, parent_root=0x0, hasRecursion=false, tuple_fraction=0) at planner.c:811
#17 0x0000000000884293 in standard_planner (parse=0x1cf8f08, query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at planner.c:413
#18 0x000000000088403a in planner (parse=0x1cf8f08, query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at planner.c:281
#19 0x00000000009b5ec0 in pg_plan_query (querytree=0x1cf8f08, query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at postgres.c:904
#20 0x00000000009b600c in pg_plan_queries (querytrees=0x1cf95e8, query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at postgres.c:996
#21 0x00000000009b638c in exec_simple_query (query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;") at postgres.c:1193
#22 0x00000000009bab95 in PostgresMain (dbname=0x1d2f2e8 "postgres", username=0x1cf3ac8 "mingjie") at postgres.c:4637
#23 0x00000000008f1d6d in BackendRun (port=0x1d25b70) at postmaster.c:4464
#24 0x00000000008f1706 in BackendStartup (port=0x1d25b70) at postmaster.c:4192
#25 0x00000000008edfd1 in ServerLoop () at postmaster.c:1782
#26 0x00000000008ed9a1 in PostmasterMain (argc=1, argv=0x1cf1a70) at postmaster.c:1466
#27 0x00000000007b8201 in main (argc=1, argv=0x1cf1a70) at main.c:198
Enter jit stack jit_compile_expr for the third time, state→expr = (FuncExpr) means 11000 + 100

Because it is not a parent expression, the calculation will not continue.

#0 jit_compile_expr (state=0x1deae18) at jit.c:165
#1 0x000000000071fa6b in ExecReadyExpr (state=0x1deae18) at execExpr.c:874
#2 0x000000000071e60b in ExecInitExpr (node=0x1dfad98, parent=0x0) at execExpr.c:152
#3 0x00000000008b3395 in evaluate_expr (expr=0x1dfad98, result_type=23, result_typmod=-1, result_collation=0) at clauses.c:4892
#4 0x00000000008b26f8 in evaluate_function (funcid=177, result_type=23, result_typmod=-1, result_collid=0, input_collid=0, args=0x1dfacf8, funcvariadic=false, func_tuple=0x7fd9588876b8, context=0x7ffdd8867f20) at clauses.c:4409
#5 0x00000000008b1a47 in simplify_function (funcid=177, result_type=23, result_typmod=-1, result_collid=0, input_collid=0, args_p=0x7ffdd8866b38, funcvariadic=false, process_args=true, allow_non_const=true, context=0x7ffdd8867f2 0) at clauses. c:3997
#6 0x00000000008af028 in eval_const_expressions_mutator (node=0x1cf9478, context=0x7ffdd8867f20) at clauses.c:2551
#7 0x00000000007e7ed9 in expression_tree_mutator_impl (node=0x1cf94c8, mutator=0x8ae95b <eval_const_expressions_mutator>, context=0x7ffdd8867f20) at nodeFuncs.c:3298
#8 0x00000000008b13ec in eval_const_expressions_mutator (node=0x1cf94c8, context=0x7ffdd8867f20) at clauses.c:3616
#9 0x00000000007e82e4 in expression_tree_mutator_impl (node=0x1cf9518, mutator=0x8ae95b <eval_const_expressions_mutator>, context=0x7ffdd8867f20) at nodeFuncs.c:3384
#10 0x00000000008b13ec in eval_const_expressions_mutator (node=0x1cf9518, context=0x7ffdd8867f20) at clauses.c:3616
#11 0x00000000008ae720 in eval_const_expressions (root=0x1cf9638, node=0x1cf9518) at clauses.c:2183
#12 0x0000000000885d2a in preprocess_expression (root=0x1cf9638, expr=0x1cf9518, kind=1) at planner.c:1144
#13 0x0000000000885173 in subquery_planner (glob=0x1cf8df8, parse=0x1cf8f08, parent_root=0x0, hasRecursion=false, tuple_fraction=0) at planner.c:811
#14 0x0000000000884293 in standard_planner (parse=0x1cf8f08, query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at planner.c:413
#15 0x000000000088403a in planner (parse=0x1cf8f08, query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at planner.c:281
#16 0x00000000009b5ec0 in pg_plan_query (querytree=0x1cf8f08, query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at postgres.c:904
#17 0x00000000009b600c in pg_plan_queries (querytrees=0x1cf95e8, query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;", cursorOptions=2048, boundParams=0x0) at postgres.c:996
#18 0x00000000009b638c in exec_simple_query (query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;") at postgres.c:1193
#19 0x00000000009bab95 in PostgresMain (dbname=0x1d2f2e8 "postgres", username=0x1cf3ac8 "mingjie") at postgres.c:4637
#20 0x00000000008f1d6d in BackendRun (port=0x1d25b70) at postmaster.c:4464
#21 0x00000000008f1706 in BackendStartup (port=0x1d25b70) at postmaster.c:4192
#22 0x00000000008edfd1 in ServerLoop () at postmaster.c:1782
#23 0x00000000008ed9a1 in PostmasterMain (argc=1, argv=0x1cf1a70) at postmaster.c:1466
#24 0x00000000007b8201 in main (argc=1, argv=0x1cf1a70) at main.c:198
Enter jit stack jit_compile_expr for the fourth time, state→expr = (List) record TargetEntry

TargetEntry expr record result 11100

{ xpr = {type = T_TargetEntry},
  expr = Const{constvalue = 11100} ,
  resno = 1,
  resname = 0xcbfb88 "?column?",
  ressortgroupref = 0,
  resorigtbl = 0,
  resorigcol = 0,
  resjunk = false}

Enter jit_compile_expr→llvm_compile_expr to start compiling expressions

#0 llvm_compile_expr (state=0x1deb218) at llvmjit_expr.c:80
#1 0x0000000000bd3698 in jit_compile_expr (state=0x1deb218) at jit.c:177
#2 0x000000000071fa6b in ExecReadyExpr (state=0x1deb218) at execExpr.c:874
#3 0x000000000071eecb in ExecBuildProjectionInfo (targetList=0x1dfb890, econtext=0x1deaf40, slot=0x1deb130, parent=0x1deae30, inputDesc=0x0) at execExpr.c:479
#4 0x0000000000749d1b in ExecAssignProjectionInfo (planstate=0x1deae30, inputDesc=0x0) at execUtils.c:547
#5 0x00000000007827d0 in ExecInitResult (node=0x1dfb7b0, estate=0x1deac08, eflags=32) at nodeResult.c:221
#6 0x00000000007403d1 in ExecInitNode (node=0x1dfb7b0, estate=0x1deac08, eflags=32) at execProcnode.c:167
#7 0x0000000000735daf in InitPlan (queryDesc=0x1d1fb98, eflags=32) at execMain.c:968
#8 0x0000000000734c85 in standard_ExecutorStart (queryDesc=0x1d1fb98, eflags=32) at execMain.c:266
#9 0x00000000007349fa in ExecutorStart (queryDesc=0x1d1fb98, eflags=0) at execMain.c:145
#10 0x00000000009bc3dc in PortalStart (portal=0x1da1368, params=0x0, eflags=0, snapshot=0x0) at pquery.c:517
#11 0x00000000009b6419 in exec_simple_query (query_string=0x1cf7e68 "select 1000 + abs(-10000) + 100;") at postgres.c:1235
#12 0x00000000009bab95 in PostgresMain (dbname=0x1d2f2e8 "postgres", username=0x1cf3ac8 "mingjie") at postgres.c:4637
#13 0x00000000008f1d6d in BackendRun (port=0x1d25b70) at postmaster.c:4464
#14 0x00000000008f1706 in BackendStartup (port=0x1d25b70) at postmaster.c:4192
#15 0x00000000008edfd1 in ServerLoop () at postmaster.c:1782
#16 0x00000000008ed9a1 in PostmasterMain (argc=1, argv=0x1cf1a70) at postmaster.c:1466
#17 0x00000000007b8201 in main (argc=1, argv=0x1cf1a70) at main.c:198

The llvm_compile_expr function is strictly calculated based on the ExecInterpExpr expression from a functional point of view. For example, the result of calculating the function expression is the EEOP_FUNCEXPR_STRICT branch:

4 Use cases

set max_parallel_workers_per_gather to 0;
set jit_expressions to on;
set jit_tuple_deforming to on;
set jit_above_cost to 0;
set jit_inline_above_cost to 0;
set jit_optimize_above_cost to 0;
explain analyze select abs(-10000) + 1000 + 100;
select 1000 + abs(-10000) + 100;