Skip to content

Loop/scope AST corner cases? #1

Description

@tsee

It seems there's a number of funky corner cases around blocks and loops where ASTification currently DWI don't Ms. Just so I don't have to shave yaks right now.

A few examples:

perl author_tools/jit_ast_dump.pl -c -e 'do{}'

segfaults.

perl author_tools/jit_ast_dump.pl -c -e 'foreach my $x (1..10) {1}'

gives a bare StatementSequence for the block.

perl author_tools/jit_ast_dump.pl -c -e 'my $x = 1; do{1}; $x = 1;'

Does not produce a single StatementSequence to hold it all:

----------------------------------------------
# StatementSequence
#   Statement (eval 13):1
#     Binop 'sassign' (
#       VD ($) = 1 : Any
#       C = (IV)1
#     )
----------------------------------------------
# StatementSequence
#   Statement (eval 13):1
#     Binop 'sassign' (
#       V ($) = 1 : Any
#       C = (IV)1
#     )
----------------------------------------------
# Block 'scope' (
#   'UnJITable subtree'
# )
----------------------------------------------
B::Concise::compile(CODE(0x1afcee0))
a  <1> leavesub[1 ref] K/REFC,1 ->(end)
-     <@> lineseq KP ->a
1        <;> nextstate(main 2 (eval 13):1) v:%,2048 ->2
4        <2> sassign vKS/2 ->5
2           <$> const[IV 1] s ->3
3           <0> padsv[$x:2,4] sRM*/LVINTRO ->4
5        <;> nextstate(main 4 (eval 13):1) v:%,2048 ->6
-        <1> null vK*/1 ->6
-           <@> scope vK ->-
-              <0> ex-nextstate v ->-
-              <0> ex-const v ->-
6        <;> nextstate(main 4 (eval 13):1) v:%,{,2048 ->7
9        <2> sassign sKS/2 ->a
7           <$> const[IV 1] s ->8
8           <0> padsv[$x:2,4] sRM* ->9

Activity

  1. mbarbon commented on Oct 7, 2013

    @mbarbon
    Collaborator

    Fixed the segfault on the first case, and the AST for the second case.

    While looking for a proper fix for cases 1 and 3, I found this snippet, and I'm not sure whether it handles the case of an empty do{}, so I can refactor it as part of the fix, or it handles another case entirely

        // empty list is not really a kid, don't include in child list
        delete kid_term;
        // FIXME segv on "perl author_tools/jit_ast_dump.pl -c -e '@x = () x 12'" since the OP_STUB is "important"
    
  2. tsee commented on Oct 8, 2013

    @tsee
    OwnerAuthor

    The FIXME is clearly another case.

    Funnily enough, I had a fix for do{} myself but failed to commit/push it before the train arrived.

    Rats.

    By the way: keyword plugin for "for" works as you say, but will require a complete rewrite of all the keyword plugin code we have so far.

  3. mbarbon commented on Oct 8, 2013

    @mbarbon
    Collaborator

    You mean for the segfault or for the 3rd case? In the latter case feel free to push it (I haven't finished the fix yet).

  4. tsee commented on Oct 8, 2013

    @tsee
    OwnerAuthor

    No, the do{} segv. That was a trivial fix, though, so no harm done.

    Curiously, my fix was to put an Empty into the block, whereas you chose not to ASTify it at all (according to my one-liner). Is that on purpose?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions