Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Cannot declare pseudo-package GLOBAL" on mips #2563

Closed
robertlemmen opened this issue Dec 23, 2018 · 7 comments
Closed

"Cannot declare pseudo-package GLOBAL" on mips #2563

robertlemmen opened this issue Dec 23, 2018 · 7 comments
Labels
BLOCKER Preventing the next release of rakudo, or just needing attention before the release

Comments

@robertlemmen
Copy link

on big-endian mips, a 2018.12 rakudo build fails with this:

/usr/bin/moar --libpath="blib" --libpath="/usr/lib/nqp/lib" --libpath="/usr/share/nqp/lib" perl6.moarvm --nqp-lib=blib --setting=NULL --ll-exception --optimize=3 --target=mbc --stagestats --output=CORE.setting.moarvm gen/moar/CORE.setting
Stage start      :   0.000
Stage parse      : Cannot declare pseudo-package GLOBAL
   at src/Perl6/World.nqp:4288  (blib/Perl6/World.moarvm:type_name_parts)
 from gen/moar/Perl6-Actions.nqp:6251  (blib/Perl6/Actions.moarvm:term:sym<name>)
 from gen/moar/stage2/QRegex.nqp:1597  (/usr/share/nqp/lib/QRegex.moarvm:!cursor_pass)
 from gen/moar/Perl6-Grammar.nqp:3122  (blib/Perl6/Grammar.moarvm:term:sym<name>)
 from gen/moar/stage2/QRegex.nqp:1689  (/usr/share/nqp/lib/QRegex.moarvm:!protoregex)
 from gen/moar/Perl6-Grammar.nqp:3599  (blib/Perl6/Grammar.moarvm:termish)
 from gen/moar/stage2/NQPHLL.nqp:993  (/usr/share/nqp/lib/NQPHLL.moarvm:EXPR)
 from gen/moar/Perl6-Grammar.nqp:3639  (blib/Perl6/Grammar.moarvm:EXPR)
 from <unknown>:1  (blib/Perl6/Grammar.moarvm:arglist)
 from <unknown>:1  (blib/Perl6/Grammar.moarvm:semiarglist)

More details at https://buildd.debian.org/status/fetch.php?pkg=rakudo&arch=mips&ver=2018.12-1&stamp=1545513729&raw=0

I guess this is a moar bug rather than rakudo, but filing it here because the investigation most likely starts here.

Please let me know how I can help investigate

@niner
Copy link
Collaborator

niner commented Dec 23, 2018

Turns out, this seems to be a spesh bug. With MVM_SPESH_DISABLE=1 stage parse completes in just 1734s in my PowerPC VM. Without I get the exact same error as shown above.

@niner
Copy link
Collaborator

niner commented Dec 23, 2018

Luckily compilation of Telemetry.pm6 fails with a rather similar error message which made it possible to use jit-bisect to get at the failing spesh frame:

Specialization of '!cursor_fail' (cuid: 89)

Before:
Spesh of '!cursor_fail' (cuid: 89, file: gen/moar/stage2/QRegex.nqp:1602)

  BB 0 (0xb4c00b20):
    line: 1602 (pc 0)
    Instructions:
      no_op           
    Successors: 1
    Predecessors: 
    Dominance children: 1

  BB 1 (0xb4c00b78):
    line: 1602 (pc 0)
    Instructions:
      null              r0(1)
      null              r1(1)
      null              r3(1)
      null              r4(1)
      null              r5(1)
      null              r6(1)
      null              r7(1)
      checkarity      liti16(1), liti16(1)
      param_rp_o        r0(2), liti16(0)
      paramnamesused  
      [Annotation: INS Deopt One (idx 0 -> pc 20; line 1603)]
      [Annotation: Logged (bytecode offset 14)]
      [Annotation: Line Number: gen/moar/stage2/QRegex.nqp:1602]
      decont            r1(2),   r0(2)
    Successors: 2
    Predecessors: 0
    Dominance children: 2

  BB 2 (0xb4c00bb8):
    line: 1603 (pc 20)
    Instructions:
      const_s           r2(1), lits($?CLASS)
      [Annotation: Logged (bytecode offset 28)]
      getlexperinvtype_o   r3(2),   r2(1)
      null              r4(2)
      bindattr_o        r1(2),   r3(2), lits($!match),   r4(2), liti16(-1)
      [Annotation: INS Deopt One (idx 1 -> pc 58; line 1604)]
      [Annotation: Logged (bytecode offset 52)]
      decont            r3(3),   r0(2)
    Successors: 3
    Predecessors: 1
    Dominance children: 3

  BB 3 (0xb4c00bf8):
    line: 1604 (pc 58)
    Instructions:
      const_s           r2(2), lits($?CLASS)
      [Annotation: Logged (bytecode offset 66)]
      getlexperinvtype_o   r1(3),   r2(2)
      null              r5(2)
      bindattr_o        r3(3),   r1(3), lits($!bstack),   r5(2), liti16(-1)
      [Annotation: INS Deopt One (idx 2 -> pc 96; line 1605)]
      [Annotation: Logged (bytecode offset 90)]
      decont            r1(4),   r0(2)
    Successors: 4
    Predecessors: 2
    Dominance children: 4

  BB 4 (0xb4c00c38):
    line: 1605 (pc 96)
    Instructions:
      const_s           r2(3), lits($?CLASS)
      [Annotation: Logged (bytecode offset 104)]
      getlexperinvtype_o   r3(4),   r2(3)
      null              r6(2)
      bindattr_o        r1(4),   r3(4), lits($!cstack),   r6(2), liti16(-1)
      [Annotation: INS Deopt One (idx 3 -> pc 134; line 1606)]
      [Annotation: Logged (bytecode offset 128)]
      decont            r3(5),   r0(2)
    Successors: 5
    Predecessors: 3
    Dominance children: 5

  BB 5 (0xb4c00c78):
    line: 1606 (pc 134)
    Instructions:
      const_s           r2(4), lits($?CLASS)
      [Annotation: Logged (bytecode offset 142)]
      getlexperinvtype_o   r1(5),   r2(4)
      null              r7(2)
      bindattr_o        r3(5),   r1(5), lits($!regexsub),   r7(2), liti16(-1)
      [Annotation: INS Deopt One (idx 4 -> pc 172; line 1607)]
      [Annotation: Logged (bytecode offset 166)]
      decont            r1(6),   r0(2)
    Successors: 6
    Predecessors: 4
    Dominance children: 6

  BB 6 (0xb4c00cb8):
    line: 1607 (pc 172)
    Instructions:
      const_s           r2(5), lits($?CLASS)
      [Annotation: Logged (bytecode offset 180)]
      getlexperinvtype_o   r3(6),   r2(5)
      const_i64_16      r8(1), liti16(-3)
      bindattr_i        r1(6),   r3(6), lits($!pos),   r8(1), liti16(-1)
      return_i          r8(1)
    Successors: 
    Predecessors: 5
    Dominance children: 


Frame size: 388 bytes
After:
Spesh of '!cursor_fail' (cuid: 89, file: gen/moar/stage2/QRegex.nqp:1602)
Callsite 0xffd3c98 (1 args, 1 pos)
Positional flags: obj

  BB 0 (0xb4c00b20):
    line: 1602 (pc 0)
    Instructions:
      no_op           
    Successors: 1
    Predecessors: 
    Dominance children: 1

  BB 1 (0xb4c00b78):
    line: 1602 (pc 0)
    Instructions:
      sp_getarg_o       r0(2), liti16(0)
      [Annotation: INS Deopt One (idx 0 -> pc 20; line 1603)]
      [Annotation: Logged (bytecode offset 14)]
      [Annotation: Line Number: gen/moar/stage2/QRegex.nqp:1602]
      set               r1(2),   r0(2)
      null              r4(2)
      sp_p6obind_o      r1(2), liti16(68),   r4(2)  # bindattr_o of '$!match' in NQPMatch
      [Annotation: INS Deopt One (idx 1 -> pc 58; line 1604)]
      [Annotation: Logged (bytecode offset 52)]
      set               r3(3),   r0(2)
      null              r5(2)
      sp_p6obind_o      r3(3), liti16(48),   r5(2)  # bindattr_o of '$!bstack' in NQPMatch
      [Annotation: INS Deopt One (idx 2 -> pc 96; line 1605)]
      [Annotation: Logged (bytecode offset 90)]
      set               r1(4),   r0(2)
      null              r6(2)
      sp_p6obind_o      r1(4), liti16(52),   r6(2)  # bindattr_o of '$!cstack' in NQPMatch
      [Annotation: INS Deopt One (idx 3 -> pc 134; line 1606)]
      [Annotation: Logged (bytecode offset 128)]
      set               r3(5),   r0(2)
      null              r7(2)
      sp_p6obind_o      r3(5), liti16(56),   r7(2)  # bindattr_o of '$!regexsub' in NQPMatch
      [Annotation: INS Deopt One (idx 4 -> pc 172; line 1607)]
      [Annotation: Logged (bytecode offset 166)]
      set               r1(6),   r0(2)
      const_i64_16      r8(1), liti16(-3)
      sp_p6obind_i      r1(6), liti16(24),   r8(1)  # bindattr_i of '$!pos' in NQPMatch
      return_i          r8(1)
    Successors: 
    Predecessors: 0
    Dominance children: 2


Facts:
      r0(0): usages=0, flags=0    
      r0(1): usages=0, flags=0     DeadWriter
      r0(2): usages=5, flags=9     KnTyp Concr (type: NQPMatch)

      r1(0): usages=0, flags=0    
      r1(1): usages=0, flags=0     DeadWriter
      r1(2): usages=1, flags=9     KnTyp Concr (type: NQPMatch)
      r1(3): usages=0, flags=19    KnTyp KnVal TyObj DeadWriter (type: NQPMatch)
      r1(4): usages=1, flags=9     KnTyp Concr (type: NQPMatch)
      r1(5): usages=0, flags=19    KnTyp KnVal TyObj DeadWriter (type: NQPMatch)
      r1(6): usages=1, flags=9     KnTyp Concr (type: NQPMatch)

      r2(0): usages=0, flags=0    
      r2(1): usages=0, flags=2     KnVal DeadWriter
      r2(2): usages=0, flags=2     KnVal DeadWriter
      r2(3): usages=0, flags=2     KnVal DeadWriter
      r2(4): usages=0, flags=2     KnVal DeadWriter
      r2(5): usages=0, flags=2     KnVal DeadWriter

      r3(0): usages=0, flags=0    
      r3(1): usages=0, flags=0     DeadWriter
      r3(2): usages=0, flags=19    KnTyp KnVal TyObj DeadWriter (type: NQPMatch)
      r3(3): usages=1, flags=9     KnTyp Concr (type: NQPMatch)
      r3(4): usages=0, flags=19    KnTyp KnVal TyObj DeadWriter (type: NQPMatch)
      r3(5): usages=1, flags=9     KnTyp Concr (type: NQPMatch)
      r3(6): usages=0, flags=19    KnTyp KnVal TyObj DeadWriter (type: NQPMatch)

      r4(0): usages=0, flags=0    
      r4(1): usages=0, flags=0     DeadWriter
      r4(2): usages=1, flags=0    

      r5(0): usages=0, flags=0    
      r5(1): usages=0, flags=0     DeadWriter
      r5(2): usages=1, flags=0    

      r6(0): usages=0, flags=0    
      r6(1): usages=0, flags=0     DeadWriter
      r6(2): usages=1, flags=0    

      r7(0): usages=0, flags=0    
      r7(1): usages=0, flags=0     DeadWriter
      r7(2): usages=1, flags=0    

      r8(0): usages=0, flags=0    
      r8(1): usages=2, flags=2     KnVal


Spesh slots:
    0 = Type Object (NQPMatch)

Frame size: 158 bytes
Specialization took 257us (total 806us)

========

Latest guard tree for '!cursor_fail' (cuid: 89, file: gen/moar/stage2/QRegex.nqp:1602)

0: CALLSITE 0xffd3c98 | Y: 1, N: 0
1: LOAD ARG 0 | Y: 2
2: STABLE CONC Perl6::Grammar | Y: 3, N: 4
3: RESULT 0
4: STABLE CONC NQPMatch | Y: 5, N: 0
5: RESULT 1

========

@AlexDaniel AlexDaniel added the BLOCKER Preventing the next release of rakudo, or just needing attention before the release label Dec 24, 2018
@jnthn
Copy link
Member

jnthn commented Dec 28, 2018

@niner Looking at the sp_p6obind_o offset arguments, I assume this is a 32-bit platform?

@niner
Copy link
Collaborator

niner commented Dec 28, 2018

It is indeed!
In case you didn't backlog: in the meantime I've found that the error in Telemetry.pm6 is not the same as the one about GLOBAL during settings compilation.

The Telemetry.pm6 failure can be worked around by removing the eliminate_unused_log_guards call from MVM_spesh_optimize, while the settings failure goes away when I remove optimize_decont(tc, g, bb, ins)

@jnthn
Copy link
Member

jnthn commented Dec 28, 2018

Not following too closely, no; enjoying a little time off. :-) I wonder how those two could be sensitive to endianness, and if we're maybe messing up a 32-bit vs. 16-bit operand somewhere... Could try commenting out various paths in optimize_decont to see if one of them is obviously to blame.

@niner
Copy link
Collaborator

niner commented Dec 28, 2018

It's apparently this copy_facts: https://github.com/MoarVM/MoarVM/blob/master/src/spesh/optimize.c#L574
Which makes me think, that it's not optimize_decont at all but some later optimization.

@niner
Copy link
Collaborator

niner commented Dec 29, 2018

Looks like I was right. It was indeed a big endian issue and it was in optimize_istrue_isfalse. Fixed with MoarVM/MoarVM@c5bc342

@niner niner closed this as completed Dec 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLOCKER Preventing the next release of rakudo, or just needing attention before the release
Projects
None yet
Development

No branches or pull requests

4 participants