|
37 | 37 | #define COMP_SETCOMP 2 |
38 | 38 | #define COMP_DICTCOMP 3 |
39 | 39 |
|
40 | | -/* A soft limit for stack use, to avoid excessive |
41 | | - * memory use for large constants, etc. |
42 | | - * |
43 | | - * The value 30 is plucked out of thin air. |
44 | | - * Code that could use more stack than this is |
45 | | - * rare, so the exact value is unimportant. |
46 | | - */ |
47 | | -#define STACK_USE_GUIDELINE 30 |
48 | | - |
49 | 40 | #undef SUCCESS |
50 | 41 | #undef ERROR |
51 | 42 | #define SUCCESS 0 |
@@ -3209,7 +3200,7 @@ starunpack_helper_impl(compiler *c, location loc, |
3209 | 3200 | int build, int add, int extend, int tuple) |
3210 | 3201 | { |
3211 | 3202 | Py_ssize_t n = asdl_seq_LEN(elts); |
3212 | | - int big = n + pushed + (injected_arg ? 1 : 0) > STACK_USE_GUIDELINE; |
| 3203 | + int big = n + pushed + (injected_arg ? 1 : 0) > _PY_STACK_USE_GUIDELINE; |
3213 | 3204 | int seen_star = 0; |
3214 | 3205 | for (Py_ssize_t i = 0; i < n; i++) { |
3215 | 3206 | expr_ty elt = asdl_seq_GET(elts, i); |
@@ -3364,7 +3355,7 @@ static int |
3364 | 3355 | codegen_subdict(compiler *c, expr_ty e, Py_ssize_t begin, Py_ssize_t end) |
3365 | 3356 | { |
3366 | 3357 | Py_ssize_t i, n = end - begin; |
3367 | | - int big = n*2 > STACK_USE_GUIDELINE; |
| 3358 | + int big = n*2 > _PY_STACK_USE_GUIDELINE; |
3368 | 3359 | location loc = LOC(e); |
3369 | 3360 | if (big) { |
3370 | 3361 | ADDOP_I(c, loc, BUILD_MAP, 0); |
@@ -3411,7 +3402,7 @@ codegen_dict(compiler *c, expr_ty e) |
3411 | 3402 | ADDOP_I(c, loc, DICT_UPDATE, 1); |
3412 | 3403 | } |
3413 | 3404 | else { |
3414 | | - if (elements*2 > STACK_USE_GUIDELINE) { |
| 3405 | + if (elements*2 > _PY_STACK_USE_GUIDELINE) { |
3415 | 3406 | RETURN_IF_ERROR(codegen_subdict(c, e, i - elements, i + 1)); |
3416 | 3407 | if (have_dict) { |
3417 | 3408 | ADDOP_I(c, loc, DICT_UPDATE, 1); |
@@ -3752,7 +3743,7 @@ maybe_optimize_method_call(compiler *c, expr_ty e) |
3752 | 3743 | /* Check that there aren't too many arguments */ |
3753 | 3744 | argsl = asdl_seq_LEN(args); |
3754 | 3745 | kwdsl = asdl_seq_LEN(kwds); |
3755 | | - if (argsl + kwdsl + (kwdsl != 0) >= STACK_USE_GUIDELINE) { |
| 3746 | + if (argsl + kwdsl + (kwdsl != 0) >= _PY_STACK_USE_GUIDELINE) { |
3756 | 3747 | return 0; |
3757 | 3748 | } |
3758 | 3749 | /* Check that there are no *varargs types of arguments. */ |
@@ -3849,7 +3840,7 @@ codegen_joined_str(compiler *c, expr_ty e) |
3849 | 3840 | { |
3850 | 3841 | location loc = LOC(e); |
3851 | 3842 | Py_ssize_t value_count = asdl_seq_LEN(e->v.JoinedStr.values); |
3852 | | - if (value_count > STACK_USE_GUIDELINE) { |
| 3843 | + if (value_count > _PY_STACK_USE_GUIDELINE) { |
3853 | 3844 | _Py_DECLARE_STR(empty, ""); |
3854 | 3845 | ADDOP_LOAD_CONST_NEW(c, loc, Py_NewRef(&_Py_STR(empty))); |
3855 | 3846 | ADDOP_NAME(c, loc, LOAD_METHOD, &_Py_ID(join), names); |
@@ -3928,7 +3919,7 @@ codegen_subkwargs(compiler *c, location loc, |
3928 | 3919 | Py_ssize_t i, n = end - begin; |
3929 | 3920 | keyword_ty kw; |
3930 | 3921 | assert(n > 0); |
3931 | | - int big = n*2 > STACK_USE_GUIDELINE; |
| 3922 | + int big = n*2 > _PY_STACK_USE_GUIDELINE; |
3932 | 3923 | if (big) { |
3933 | 3924 | ADDOP_I(c, NO_LOCATION, BUILD_MAP, 0); |
3934 | 3925 | } |
@@ -3981,7 +3972,7 @@ codegen_call_helper_impl(compiler *c, location loc, |
3981 | 3972 | nelts = asdl_seq_LEN(args); |
3982 | 3973 | nkwelts = asdl_seq_LEN(keywords); |
3983 | 3974 |
|
3984 | | - if (nelts + nkwelts*2 > STACK_USE_GUIDELINE) { |
| 3975 | + if (nelts + nkwelts*2 > _PY_STACK_USE_GUIDELINE) { |
3985 | 3976 | goto ex_call; |
3986 | 3977 | } |
3987 | 3978 | for (i = 0; i < nelts; i++) { |
|
0 commit comments