This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Correctly preserve the stack on an implicit break.
authorVincent Pit <perl@profvince.com>
Sat, 25 Jun 2011 21:36:50 +0000 (23:36 +0200)
committerVincent Pit <perl@profvince.com>
Sat, 25 Jun 2011 22:16:29 +0000 (00:16 +0200)
commitc08f093b3e154c428f604f89f7feb633e6c97869
tree5b3818b4c6011f1249a3d2a749bdc79fae6586a8
parentf02ea43cac371ecb59188f9654a0d99fd54db862
Correctly preserve the stack on an implicit break.

Perl generates a 'break' op with the special flag set at the end of every
'when' block. This makes it difficult to handle both the case of an
implicit break, where the stack has to be preserved, and the case of an
explicit break, which must obliterate the stack, with the same pp function.
Stack handling should naturally occur in 'leavewhen', but it is effectively
called only when the block issues a 'continue'.

In order to preserve the stack, we change the respective roles of 'break',
'continue' and 'leavewhen' ops :
- Special 'break' ops are no longer generated for implicit breaks. Just as
before, they give the control back to the 'leavegiven' op.
- 'continue' ops now directly forward to the op *following* the 'leavewhen'
op of the current 'when' block.
- 'leavewhen' is now only called at the natural end of a 'when' block.
It adjusts the stack to make sure returned values survive the temp cleanup,
then issues a 'next' or go to the current 'leavegiven' depending on whether
it is enclosed in a for loop or a given block.

This fixes [perl #93548].
dist/B-Deparse/Deparse.pm
op.c
op.h
pp_ctl.c
t/op/switch.t