Skip to content

Commit ac79f99

Browse files
committed
first stab at PERL_RC_STACK support (don't you love #ifdef?)
1 parent 355df89 commit ac79f99

File tree

1 file changed

+108
-38
lines changed

1 file changed

+108
-38
lines changed

Parameters.xs

Lines changed: 108 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,9 @@ static SV *call_from_curstash(pTHX_ Sentinel sen, SV *sv, SV **args, size_t narg
707707
SV *r;
708708
COP curcop_with_stash;
709709
I32 want;
710-
dSP;
710+
#ifndef PERL_RC_STACK
711+
dSP;
712+
#endif
711713

712714
assert(sv != NULL);
713715

@@ -719,17 +721,31 @@ static SV *call_from_curstash(pTHX_ Sentinel sen, SV *sv, SV **args, size_t narg
719721
ENTER;
720722
SAVETMPS;
721723

722-
PUSHMARK(SP);
724+
#ifdef PERL_RC_STACK
725+
PUSHMARK(PL_stack_sp);
726+
#else
727+
PUSHMARK(SP);
728+
#endif
723729
if (!args) {
724730
flags |= G_NOARGS;
725731
} else {
726732
size_t i;
727-
EXTEND(SP, (SSize_t)nargs);
733+
#ifdef PERL_RC_STACK
734+
rpp_extend(nargs);
735+
#else
736+
EXTEND(SP, (SSize_t)nargs);
737+
#endif
728738
for (i = 0; i < nargs; i++) {
729-
PUSHs(args[i]);
739+
#ifdef PERL_RC_STACK
740+
rpp_push_1(args[i]);
741+
#else
742+
PUSHs(args[i]);
743+
#endif
730744
}
731745
}
732-
PUTBACK;
746+
#ifndef PERL_RC_STACK
747+
PUTBACK;
748+
#endif
733749

734750
assert(PL_curcop == &PL_compiling);
735751
curcop_with_stash = PL_compiling;
@@ -742,9 +758,13 @@ static SV *call_from_curstash(pTHX_ Sentinel sen, SV *sv, SV **args, size_t narg
742758
r = NULL;
743759
} else {
744760
assert(want == G_SCALAR);
745-
SPAGAIN;
746-
r = sentinel_mortalize(sen, SvREFCNT_inc(POPs));
747-
PUTBACK;
761+
#ifdef PERL_RC_STACK
762+
r = sentinel_mortalize(sen, rpp_pop_1_norc());
763+
#else
764+
SPAGAIN;
765+
r = sentinel_mortalize(sen, SvREFCNT_inc(POPs));
766+
PUTBACK;
767+
#endif
748768
}
749769

750770
FREETMPS;
@@ -1355,34 +1375,58 @@ static PADOFFSET parse_param(
13551375
}
13561376

13571377
static void register_info(pTHX_ UV key, SV *declarator, const ParamSpec *ps) {
1358-
dSP;
1378+
#ifndef PERL_RC_STACK
1379+
dSP;
1380+
#endif
13591381

13601382
ENTER;
13611383
SAVETMPS;
13621384

1363-
PUSHMARK(SP);
1364-
EXTEND(SP, 9);
1385+
#ifdef PERL_RC_STACK
1386+
PUSHMARK(PL_stack_sp);
1387+
rpp_extend(9);
1388+
#else
1389+
PUSHMARK(SP);
1390+
EXTEND(SP, 9);
1391+
#endif
13651392

13661393
/* 0 */ {
1367-
mPUSHu(key);
1394+
#ifdef PERL_RC_STACK
1395+
rpp_push_1_norc(newSVuv(key));
1396+
#else
1397+
mPUSHu(key);
1398+
#endif
13681399
}
13691400
/* 1 */ {
13701401
STRLEN n;
13711402
char *p = SvPV(declarator, n);
13721403
char *q = memchr(p, ' ', n);
13731404
SV *tmp = newSVpvn_utf8(p, q ? (size_t)(q - p) : n, SvUTF8(declarator));
1374-
mPUSHs(tmp);
1405+
#ifdef PERL_RC_STACK
1406+
rpp_push_1_norc(tmp);
1407+
#else
1408+
mPUSHs(tmp);
1409+
#endif
13751410
}
13761411
/* 2 */ {
1377-
mPUSHu(ps->shift);
1412+
#ifdef PERL_RC_STACK
1413+
rpp_push_1_norc(newSVuv(ps->shift));
1414+
#else
1415+
mPUSHu(ps->shift);
1416+
#endif
13781417
}
13791418
/* 3 */ {
13801419
size_t i, lim;
13811420
AV *av;
13821421

1383-
lim = ps->positional_required.used;
1384-
13851422
av = newAV();
1423+
#ifdef PERL_RC_STACK
1424+
rpp_push_1_norc(newRV_noinc((SV *)av));
1425+
#else
1426+
mPUSHs(newRV_noinc((SV *)av));
1427+
#endif
1428+
1429+
lim = ps->positional_required.used;
13861430
if (lim) {
13871431
av_extend(av, (lim - 1) * 2);
13881432
for (i = 0; i < lim; i++) {
@@ -1391,16 +1435,19 @@ static void register_info(pTHX_ UV key, SV *declarator, const ParamSpec *ps) {
13911435
av_push(av, cur->type ? SvREFCNT_inc_simple_NN(cur->type) : &PL_sv_undef);
13921436
}
13931437
}
1394-
1395-
mPUSHs(newRV_noinc((SV *)av));
13961438
}
13971439
/* 4 */ {
13981440
size_t i, lim;
13991441
AV *av;
14001442

1401-
lim = ps->positional_optional.used;
1402-
14031443
av = newAV();
1444+
#ifdef PERL_RC_STACK
1445+
rpp_push_1_norc(newRV_noinc((SV *)av));
1446+
#else
1447+
mPUSHs(newRV_noinc((SV *)av));
1448+
#endif
1449+
1450+
lim = ps->positional_optional.used;
14041451
if (lim) {
14051452
av_extend(av, (lim - 1) * 2);
14061453
for (i = 0; i < lim; i++) {
@@ -1409,16 +1456,19 @@ static void register_info(pTHX_ UV key, SV *declarator, const ParamSpec *ps) {
14091456
av_push(av, cur->type ? SvREFCNT_inc_simple_NN(cur->type) : &PL_sv_undef);
14101457
}
14111458
}
1412-
1413-
mPUSHs(newRV_noinc((SV *)av));
14141459
}
14151460
/* 5 */ {
14161461
size_t i, lim;
14171462
AV *av;
14181463

1419-
lim = ps->named_required.used;
1420-
14211464
av = newAV();
1465+
#ifdef PERL_RC_STACK
1466+
rpp_push_1_norc(newRV_noinc((SV *)av));
1467+
#else
1468+
mPUSHs(newRV_noinc((SV *)av));
1469+
#endif
1470+
1471+
lim = ps->named_required.used;
14221472
if (lim) {
14231473
av_extend(av, (lim - 1) * 2);
14241474
for (i = 0; i < lim; i++) {
@@ -1427,16 +1477,19 @@ static void register_info(pTHX_ UV key, SV *declarator, const ParamSpec *ps) {
14271477
av_push(av, cur->type ? SvREFCNT_inc_simple_NN(cur->type) : &PL_sv_undef);
14281478
}
14291479
}
1430-
1431-
mPUSHs(newRV_noinc((SV *)av));
14321480
}
14331481
/* 6 */ {
14341482
size_t i, lim;
14351483
AV *av;
14361484

1437-
lim = ps->named_optional.used;
1438-
14391485
av = newAV();
1486+
#ifdef PERL_RC_STACK
1487+
rpp_push_1_norc(newRV_noinc((SV *)av));
1488+
#else
1489+
mPUSHs(newRV_noinc((SV *)av));
1490+
#endif
1491+
1492+
lim = ps->named_optional.used;
14401493
if (lim) {
14411494
av_extend(av, (lim - 1) * 2);
14421495
for (i = 0; i < lim; i++) {
@@ -1445,23 +1498,41 @@ static void register_info(pTHX_ UV key, SV *declarator, const ParamSpec *ps) {
14451498
av_push(av, cur->type ? SvREFCNT_inc_simple_NN(cur->type) : &PL_sv_undef);
14461499
}
14471500
}
1448-
1449-
mPUSHs(newRV_noinc((SV *)av));
14501501
}
14511502
/* 7, 8 */ {
14521503
if (ps->slurpy.name) {
1453-
PUSHs(ps->slurpy.name);
1504+
#ifdef PERL_RC_STACK
1505+
rpp_push_1(ps->slurpy.name);
1506+
#else
1507+
PUSHs(ps->slurpy.name);
1508+
#endif
14541509
if (ps->slurpy.type) {
1455-
PUSHs(ps->slurpy.type);
1510+
#ifdef PERL_RC_STACK
1511+
rpp_push_1(ps->slurpy.type);
1512+
#else
1513+
PUSHs(ps->slurpy.type);
1514+
#endif
14561515
} else {
1457-
PUSHmortal;
1516+
#ifdef PERL_RC_STACK
1517+
rpp_push_1_norc(newSV(0));
1518+
#else
1519+
PUSHmortal;
1520+
#endif
14581521
}
14591522
} else {
1460-
PUSHmortal;
1461-
PUSHmortal;
1523+
#ifdef PERL_RC_STACK
1524+
rpp_push_1_norc(newSV(0));
1525+
rpp_push_1_norc(newSV(0));
1526+
#else
1527+
PUSHmortal;
1528+
PUSHmortal;
1529+
#endif
14621530
}
14631531
}
1464-
PUTBACK;
1532+
1533+
#ifndef PERL_RC_STACK
1534+
PUTBACK;
1535+
#endif
14651536

14661537
call_pv(MY_PKG "::_register_info", G_VOID);
14671538

@@ -2468,9 +2539,8 @@ static int kw_flags_enter(pTHX_ Sentinel **ppsen, const char *kw_ptr, STRLEN kw_
24682539
sv = *psv;
24692540
if (!SvROK(sv)) {
24702541
/* something is wrong: $^H{'Function::Parameters/config'} has turned into a string */
2471-
dSP;
24722542

2473-
PUSHMARK(SP);
2543+
PUSHMARK(PL_stack_sp);
24742544
call_pv(MY_PKG "::_warn_config_not_a_reference", G_VOID);
24752545

24762546
/* don't warn twice within the same scope */

0 commit comments

Comments
 (0)