@@ -1075,12 +1075,35 @@ static int
1075
1075
stack_effect (int opcode , int oparg , int jump )
1076
1076
{
1077
1077
if (0 <= opcode && opcode < 256 ) {
1078
- int popped = _PyOpcode_num_popped (opcode , oparg , jump );
1079
- int pushed = _PyOpcode_num_pushed (opcode , oparg , jump );
1078
+ int popped , pushed ;
1079
+ if (jump > 0 ) {
1080
+ popped = _PyOpcode_num_popped (opcode , oparg , true);
1081
+ pushed = _PyOpcode_num_pushed (opcode , oparg , true);
1082
+ }
1083
+ else {
1084
+ popped = _PyOpcode_num_popped (opcode , oparg , false);
1085
+ pushed = _PyOpcode_num_pushed (opcode , oparg , false);
1086
+ }
1080
1087
if (popped < 0 || pushed < 0 ) {
1081
1088
return PY_INVALID_STACK_EFFECT ;
1082
1089
}
1083
- return pushed - popped ;
1090
+ if (jump >= 0 ) {
1091
+ return pushed - popped ;
1092
+ }
1093
+ if (jump < 0 ) {
1094
+ // Compute max(pushed - popped, alt_pushed - alt_popped)
1095
+ int alt_popped = _PyOpcode_num_popped (opcode , oparg , true);
1096
+ int alt_pushed = _PyOpcode_num_pushed (opcode , oparg , true);
1097
+ if (alt_popped < 0 || alt_pushed < 0 ) {
1098
+ return PY_INVALID_STACK_EFFECT ;
1099
+ }
1100
+ int diff = pushed - popped ;
1101
+ int alt_diff = alt_pushed - alt_popped ;
1102
+ if (alt_diff > diff ) {
1103
+ return alt_diff ;
1104
+ }
1105
+ return diff ;
1106
+ }
1084
1107
}
1085
1108
1086
1109
// Pseudo ops
0 commit comments