mirror of
https://github.com/postgres/postgres.git
synced 2025-08-19 23:22:23 +03:00
Replace EEOP_DONE with special steps for return/no return
Knowing when the side-effects of an expression is the intended result of the execution, rather than the returnvalue, is important for being able generate more efficient JITed code. This replaces EEOP_DONE with two new steps: EEOP_DONE_RETURN and EEOP_DONE_NO_RETURN. Expressions which return a value should use the former step; expressions used for their side-effects which don't return value should use the latter. Author: Andres Freund <andres@anarazel.de> Co-authored-by: Daniel Gustafsson <daniel@yesql.se> Reviewed-by: Andreas Karlsson <andreas@proxel.se> Discussion: https://postgr.es/m/415721CE-7D2E-4B74-B5D9-1950083BA03E@yesql.se Discussion: https://postgr.es/m/20191023163849.sosqbfs5yenocez3@alap3.anarazel.de
This commit is contained in:
@@ -246,7 +246,8 @@ ExecReadyInterpretedExpr(ExprState *state)
|
||||
|
||||
/* Simple validity checks on expression */
|
||||
Assert(state->steps_len >= 1);
|
||||
Assert(state->steps[state->steps_len - 1].opcode == EEOP_DONE);
|
||||
Assert(state->steps[state->steps_len - 1].opcode == EEOP_DONE_RETURN ||
|
||||
state->steps[state->steps_len - 1].opcode == EEOP_DONE_NO_RETURN);
|
||||
|
||||
/*
|
||||
* Don't perform redundant initialization. This is unreachable in current
|
||||
@@ -469,7 +470,8 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
*/
|
||||
#if defined(EEO_USE_COMPUTED_GOTO)
|
||||
static const void *const dispatch_table[] = {
|
||||
&&CASE_EEOP_DONE,
|
||||
&&CASE_EEOP_DONE_RETURN,
|
||||
&&CASE_EEOP_DONE_NO_RETURN,
|
||||
&&CASE_EEOP_INNER_FETCHSOME,
|
||||
&&CASE_EEOP_OUTER_FETCHSOME,
|
||||
&&CASE_EEOP_SCAN_FETCHSOME,
|
||||
@@ -612,9 +614,16 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
|
||||
EEO_SWITCH()
|
||||
{
|
||||
EEO_CASE(EEOP_DONE)
|
||||
EEO_CASE(EEOP_DONE_RETURN)
|
||||
{
|
||||
goto out;
|
||||
*isnull = state->resnull;
|
||||
return state->resvalue;
|
||||
}
|
||||
|
||||
EEO_CASE(EEOP_DONE_NO_RETURN)
|
||||
{
|
||||
Assert(isnull == NULL);
|
||||
return (Datum) 0;
|
||||
}
|
||||
|
||||
EEO_CASE(EEOP_INNER_FETCHSOME)
|
||||
@@ -2188,13 +2197,13 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
{
|
||||
/* unreachable */
|
||||
Assert(false);
|
||||
goto out;
|
||||
goto out_error;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
*isnull = state->resnull;
|
||||
return state->resvalue;
|
||||
out_error:
|
||||
pg_unreachable();
|
||||
return (Datum) 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user