Skip to content

Instantly share code, notes, and snippets.

@ab5tract
Last active April 4, 2024 19:39
Show Gist options
  • Save ab5tract/972c29df4a980823c71af9c30bbb223e to your computer and use it in GitHub Desktop.
Save ab5tract/972c29df4a980823c71af9c30bbb223e to your computer and use it in GitHub Desktop.
`@a is item` trait for parameters -- QAST output for analysis
### Diffed output between runs where the optimizer is kept from changing call to callstatic
125c125
< │ │ - Sub|5532807842296
---
> │ │ - Sub|4737970457080
128c128
< │ │ - Array|5532807732616
---
> │ │ - Array|4737970347400
297c297
< │ │ │ - QAST::Op(call &dd) <wanted> :statement_id<2> dd @a
---
> │ │ │ - QAST::Op(callstatic &dd) <wanted> :statement_id<2> dd @a
301c301
< │ │ │ - QAST::Op(call &dd) <wanted> :statement_id<2> dd @a
---
> │ │ │ - QAST::Op(callstatic &dd) <wanted> :statement_id<2> dd @a
305c305
< │ │ - Sub|5532807842296
---
> │ │ - Sub|4737970457080
308c308
< │ │ - Array|5532807732616
---
> │ │ - Array|4737970347400
334c334
< │ │ - QAST::Op(call &q) <sunk> :statement_id<4> q($[5,6])
---
> │ │ - QAST::Op(callstatic &q) <sunk> :statement_id<4> q($[5,6])
336c336
< │ │ - QAST::Op(call &circumfix:<[ ]>) <wanted> [5,6]
---
> │ │ - QAST::Op(callstatic &circumfix:<[ ]>) <wanted> [5,6]
340c340
< │ │ - QAST::Op(call &q) <sunk> :statement_id<4> q($[5,6])
---
> │ │ - QAST::Op(callstatic &q) <sunk> :statement_id<4> q($[5,6])
342c342
< │ │ - QAST::Op(call &circumfix:<[ ]>) <wanted> [5,6]
---
> │ │ - QAST::Op(callstatic &circumfix:<[ ]>) <wanted> [5,6]
346c346,349
< $[5, 6]
---
> Parameter '@a' only accepts an itemized argument
> in sub q at -e line 1
> in block <unit> at -e line 1
>
method optimize before
- QAST::CompUnit :W<?> :UNIT<?> :CAN_LOWER_TOPIC<?>
[pre_deserialize]
- QAST::Stmt
- QAST::Stmt
- QAST::Op(loadbytecode)
- QAST::VM
[moar]
- QAST::SVal(ModuleLoader.moarvm)
[jvm]
- QAST::SVal(ModuleLoader.class)
[js]
- QAST::SVal(ModuleLoader)
- QAST::Op(callmethod load_module)
- QAST::Op(gethllsym)
- QAST::SVal(nqp)
- QAST::SVal(ModuleLoader)
- QAST::SVal(Perl6::ModuleLoader)
- QAST::Op(forceouterctx)
- QAST::BVal(3)
- QAST::Op(callmethod load_setting)
- QAST::Op(getcurhllsym)
- QAST::SVal(ModuleLoader)
- QAST::SVal(CORE.d)
[post_deserialize]
- QAST::Stmts
- QAST::Op(bind)
- QAST::Var(attribute $!do)
- QAST::WVal(Sub)
- QAST::WVal(Code)
- QAST::BVal(1)
- QAST::Stmts
- QAST::Op(bind)
- QAST::Var(attribute $!do)
- QAST::WVal(Block)
- QAST::WVal(Code)
- QAST::BVal(2)
- QAST::Op(ifnull)
- QAST::Op(getcurhllsym)
- QAST::SVal(GLOBAL)
- QAST::Op(bindcurhllsym)
- QAST::SVal(GLOBAL)
- QAST::WVal(GLOBAL)
[load]
- QAST::Op(call)
- QAST::BVal(3)
[children]
- QAST::Block(:name(<unit-outer>) :cuid(3)) :in_stmt_mod<?> sub q(@a is item) { dd @a }; q $[5,6];
│ - QAST::Var(local __args__ :decl(param))
│ - QAST::Stmts sub q(@a is item) { dd @a }; q $[5,6];
│ - QAST::Op(bind)
│ - QAST::Var(lexical RakuAST :decl(var))
│ - QAST::Op(callmethod new)
│ - QAST::Var(lexical Failure)
│ - QAST::Op(callmethod new)
│ - QAST::WVal(X::Experimental)
│ - QAST::SVal+{QAST::SpecialArg}(RakuAST :named<feature>)
│ - QAST::SVal+{QAST::SpecialArg}(rakuast :named<use>)
│ - QAST::Op(call)
│ - QAST::Block(:name(<unit>) :cuid(2) :blocktype(declaration_static)) :outer<?> :in_stmt_mod<?> :code_object<?> :IN_DECL<mainline>
│ │ - QAST::Stmts sub q(@a is item) { dd @a }; q $[5,6];
│ │ - QAST::Var(lexical $¢ :decl(contvar))
│ │ - QAST::Var(lexical $! :decl(contvar))
│ │ - QAST::Var(lexical $/ :decl(contvar))
│ │ - QAST::Var(lexical $_ :decl(contvar))
│ │ - QAST::Var(lexical GLOBALish :decl(static))
│ │ - QAST::Var(lexical EXPORT :decl(static))
│ │ - QAST::Var(lexical $?PACKAGE :decl(static))
│ │ - QAST::Var(lexical ::?PACKAGE :decl(static))
│ │ - QAST::Var(lexical $=finish :decl(static))
│ │ - QAST::Stmt
│ │ - QAST::Block(:name(q) :cuid(1) :blocktype(declaration_static)) <wanted> :statement_id<1> :signatured<?> :outer<?> :in_stmt_mod<?> :count<?> :code_object<?> :IN_DECL<sub> { dd @a }
│ │ │ - QAST::Stmts
│ │ │ - QAST::Var(lexical $¢ :decl(contvar))
│ │ │ - QAST::Var(lexical $! :decl(contvar))
│ │ │ - QAST::Var(lexical $/ :decl(contvar))
│ │ │ - QAST::Var(lexical $_ :decl(contvar))
│ │ │ - QAST::Var(lexical @a :decl(var))
│ │ │ - QAST::Var(local __lowered_param__1 :decl(param))
│ │ │ - QAST::Op(bind)
│ │ │ - QAST::Var(local __lowered_param__1)
│ │ │ - QAST::Op(hllize)
│ │ │ - QAST::Var(local __lowered_param__1)
│ │ │ - QAST::Op(bind)
│ │ │ - QAST::Var(local __lowered_param_decont__1 :decl(var))
│ │ │ - QAST::Op(decont)
│ │ │ - QAST::Var(local __lowered_param__1)
│ │ │ - QAST::Op(if)
│ │ │ - QAST::Op(istype_nd)
│ │ │ - QAST::Var(local __lowered_param_decont__1)
│ │ │ - QAST::WVal(PositionalBindFailover)
│ │ │ - QAST::Op(bind)
│ │ │ - QAST::Var(local __lowered_param_decont__1)
│ │ │ - QAST::Op(decont)
│ │ │ - QAST::Op(bind)
│ │ │ - QAST::Var(local __lowered_param__1)
│ │ │ - QAST::Op(callmethod cache)
│ │ │ - QAST::Var(local __lowered_param_decont__1)
│ │ │ - QAST::ParamTypeCheck
│ │ │ - QAST::Op(istype_nd)
│ │ │ - QAST::Var(local __lowered_param_decont__1)
│ │ │ - QAST::WVal(Positional)
│ │ │ - QAST::ParamTypeCheck
│ │ │ - QAST::Op(istype_nd)
│ │ │ - QAST::Var(local __lowered_param__1)
│ │ │ - QAST::WVal(Scalar)
│ │ │ - QAST::Op(bind)
│ │ │ - QAST::Var(lexical @a)
│ │ │ - QAST::Op(decont)
│ │ │ - QAST::Var(local __lowered_param__1)
│ │ │ - QAST::Op(p6typecheckrv)
│ │ │ - QAST::Op(p6decontrv)
│ │ │ - QAST::WVal(Sub)
│ │ │ - QAST::Stmts <wanted> dd @a
│ │ │ - QAST::Stmt <wanted final> dd @a
│ │ │ - QAST::Want <wanted>
│ │ │ - QAST::Op(call &dd) <wanted> :statement_id<2> dd @a
│ │ │ - QAST::Var(lexical @a) <wanted> @a
│ │ │ - v
│ │ │ - QAST::Op(p6sink)
│ │ │ - QAST::Op(call &dd) <wanted> :statement_id<2> dd @a
│ │ │ - QAST::Var(lexical @a) <wanted> @a
│ │ │ - QAST::WVal(Sub)
│ │ │ - QAST::WVal(Nil)
│ │ - QAST::Var(lexical &q :decl(static))
│ │ [value]
│ │ - Sub|2977370786296
│ │ - QAST::Var(lexical $=pod :decl(static))
│ │ [value]
│ │ - Array|2977365761528
│ │ - QAST::Var(lexical !UNIT_MARKER :decl(static))
│ │ - QAST::Stmts
│ │ - QAST::Op(bind)
│ │ - QAST::Var(local ctxsave :decl(var))
│ │ - QAST::Var(contextual $*CTXSAVE)
│ │ - QAST::Op(unless)
│ │ - QAST::Op(isnull)
│ │ - QAST::Var(local ctxsave)
│ │ - QAST::Op(if)
│ │ - QAST::Op(can)
│ │ - QAST::Var(local ctxsave)
│ │ - QAST::SVal(ctxsave)
│ │ - QAST::Op(callmethod ctxsave)
│ │ - QAST::Var(local ctxsave)
│ │ - QAST::Stmts
│ │ - QAST::WVal(Array)
│ │ - QAST::Stmts <sunk> sub q(@a is item) { dd @a }; q $[5,6];
│ │ - QAST::Want <sunk> sub q(@a is item) { dd @a }
│ │ - QAST::Op(p6capturelex) :statement_id<1> :sink_ast<?> :past_block<?> :code_object<?>
│ │ - QAST::Op(callmethod clone)
│ │ - QAST::WVal(Sub :cuid(1)) :past_block<?> :code_object<?>
│ │ - v
│ │ - QAST::Op(null)
│ │ - QAST::Stmt <sunk final> q $[5,6]
│ │ - QAST::Want <sunk>
│ │ - QAST::Op(call &q) <sunk> :statement_id<4> q $[5,6]
│ │ - QAST::Op(callmethod item) <wanted>
│ │ - QAST::Op(call &circumfix:<[ ]>) <wanted> [5,6]
│ │ - QAST::Stmts <wanted> 5,6
│ │ - QAST::Op(call &infix:<,>) :statement_id<5> ,
│ │ - QAST::Want <wanted> 5
│ │ - QAST::WVal(Int)
│ │ - Ii
│ │ - QAST::IVal(5) 5
│ │ - QAST::Want <wanted> 6
│ │ - QAST::WVal(Int)
│ │ - Ii
│ │ - QAST::IVal(6) 6
│ │ - v
│ │ - QAST::Op(p6sink)
│ │ - QAST::Op(call &q) <sunk> :statement_id<4> q $[5,6]
│ │ - QAST::Op(callmethod item) <wanted>
│ │ - QAST::Op(call &circumfix:<[ ]>) <wanted> [5,6]
│ │ - QAST::Stmts <wanted> 5,6
│ │ - QAST::Op(call &infix:<,>) :statement_id<5> ,
│ │ - QAST::Want <wanted> 5
│ │ - QAST::WVal(Int)
│ │ - Ii
│ │ - QAST::IVal(5) 5
│ │ - QAST::Want <wanted> 6
│ │ - QAST::WVal(Int)
│ │ - Ii
│ │ - QAST::IVal(6) 6
│ │ - QAST::WVal(Nil)
method optimize after
- QAST::CompUnit :W<?> :UNIT<?> :CAN_LOWER_TOPIC<?>
[pre_deserialize]
- QAST::Stmt
- QAST::Stmt
- QAST::Op(loadbytecode)
- QAST::VM
[moar]
- QAST::SVal(ModuleLoader.moarvm)
[jvm]
- QAST::SVal(ModuleLoader.class)
[js]
- QAST::SVal(ModuleLoader)
- QAST::Op(callmethod load_module)
- QAST::Op(gethllsym)
- QAST::SVal(nqp)
- QAST::SVal(ModuleLoader)
- QAST::SVal(Perl6::ModuleLoader)
- QAST::Op(forceouterctx)
- QAST::BVal(3)
- QAST::Op(callmethod load_setting)
- QAST::Op(getcurhllsym)
- QAST::SVal(ModuleLoader)
- QAST::SVal(CORE.d)
[post_deserialize]
- QAST::Stmts
- QAST::Op(bind)
- QAST::Var(attribute $!do)
- QAST::WVal(Sub)
- QAST::WVal(Code)
- QAST::BVal(1)
- QAST::Stmts
- QAST::Op(bind)
- QAST::Var(attribute $!do)
- QAST::WVal(Block)
- QAST::WVal(Code)
- QAST::BVal(2)
- QAST::Op(ifnull)
- QAST::Op(getcurhllsym)
- QAST::SVal(GLOBAL)
- QAST::Op(bindcurhllsym)
- QAST::SVal(GLOBAL)
- QAST::WVal(GLOBAL)
[load]
- QAST::Op(call)
- QAST::BVal(3)
[children]
- QAST::Block(:name(<unit-outer>) :cuid(3)) :in_stmt_mod<?> sub q(@a is item) { dd @a }; q $[5,6];
│ - QAST::Var(local __args__ :decl(param))
│ - QAST::Stmts sub q(@a is item) { dd @a }; q $[5,6];
│ - QAST::Op(bind)
│ - QAST::Var(lexical RakuAST :decl(var))
│ - QAST::Op(callmethod new)
│ - QAST::Var(lexical Failure)
│ - QAST::Op(callmethod new)
│ - QAST::WVal(X::Experimental)
│ - QAST::SVal+{QAST::SpecialArg}(RakuAST :named<feature>)
│ - QAST::SVal+{QAST::SpecialArg}(rakuast :named<use>)
│ - QAST::Op(call)
│ - QAST::Block(:name(<unit>) :cuid(2) :blocktype(declaration_static)) :outer<?> :in_stmt_mod<?> :code_object<?> :IN_DECL<mainline>
│ │ - QAST::Stmts sub q(@a is item) { dd @a }; q $[5,6];
│ │ - QAST::Var(lexical $¢ :decl(contvar))
│ │ - QAST::Var(lexical $! :decl(contvar))
│ │ - QAST::Var(lexical $/ :decl(contvar))
│ │ - QAST::Op(null)
│ │ - QAST::Var(lexical GLOBALish :decl(static))
│ │ - QAST::Var(lexical EXPORT :decl(static))
│ │ - QAST::Var(lexical $?PACKAGE :decl(static))
│ │ - QAST::Var(lexical ::?PACKAGE :decl(static))
│ │ - QAST::Var(lexical $=finish :decl(static))
│ │ - QAST::Stmt
│ │ - QAST::Block(:name(q) :cuid(1) :blocktype(declaration_static)) <wanted> :statement_id<1> :signatured<?> :outer<?> :in_stmt_mod<?> :count<?> :code_object<?> :IN_DECL<sub> { dd @a }
│ │ │ - QAST::Stmts
│ │ │ - QAST::Var(lexical @a :decl(static))
│ │ │ - QAST::Var(lexical $¢ :decl(contvar))
│ │ │ - QAST::Var(lexical $! :decl(contvar))
│ │ │ - QAST::Var(lexical $/ :decl(contvar))
│ │ │ - QAST::Op(null)
│ │ │ - QAST::Var(local __lowered_lex_1 :decl(var))
│ │ │ - QAST::Var(local __lowered_param__1 :decl(param))
│ │ │ - QAST::Op(bind)
│ │ │ - QAST::Var(local __lowered_param__1)
│ │ │ - QAST::Op(hllize)
│ │ │ - QAST::Var(local __lowered_param__1)
│ │ │ - QAST::Op(bind)
│ │ │ - QAST::Var(local __lowered_param_decont__1 :decl(var))
│ │ │ - QAST::Op(decont)
│ │ │ - QAST::Var(local __lowered_param__1)
│ │ │ - QAST::Op(if)
│ │ │ - QAST::Op(istype_nd)
│ │ │ - QAST::Var(local __lowered_param_decont__1)
│ │ │ - QAST::WVal(PositionalBindFailover)
│ │ │ - QAST::Op(bind)
│ │ │ - QAST::Var(local __lowered_param_decont__1)
│ │ │ - QAST::Op(decont)
│ │ │ - QAST::Op(bind)
│ │ │ - QAST::Var(local __lowered_param__1)
│ │ │ - QAST::Op(callmethod cache)
│ │ │ - QAST::Var(local __lowered_param_decont__1)
│ │ │ - QAST::ParamTypeCheck
│ │ │ - QAST::Op(istype_nd)
│ │ │ - QAST::Var(local __lowered_param_decont__1)
│ │ │ - QAST::WVal(Positional)
│ │ │ - QAST::ParamTypeCheck
│ │ │ - QAST::Op(istype_nd)
│ │ │ - QAST::Var(local __lowered_param__1)
│ │ │ - QAST::WVal(Scalar)
│ │ │ - QAST::Op(bind)
│ │ │ - QAST::Var(local __lowered_lex_1)
│ │ │ - QAST::Op(decont)
│ │ │ - QAST::Var(local __lowered_param__1)
│ │ │ - QAST::Op(p6decontrv)
│ │ │ - QAST::WVal(Sub)
│ │ │ - QAST::Stmt <wanted final> dd @a
│ │ │ - QAST::Want <wanted>
│ │ │ - QAST::Op(callstatic &dd) <wanted> :statement_id<2> dd @a
│ │ │ - QAST::Var(local __lowered_lex_1) <wanted> @a
│ │ │ - v
│ │ │ - QAST::Op(p6sink)
│ │ │ - QAST::Op(callstatic &dd) <wanted> :statement_id<2> dd @a
│ │ │ - QAST::Var(local __lowered_lex_1) <wanted> @a
│ │ - QAST::Var(lexical &q :decl(static))
│ │ [value]
│ │ - Sub|2977370786296
│ │ - QAST::Var(lexical $=pod :decl(static))
│ │ [value]
│ │ - Array|2977365761528
│ │ - QAST::Var(lexical !UNIT_MARKER :decl(static))
│ │ - QAST::Stmts
│ │ - QAST::Op(bind)
│ │ - QAST::Var(local ctxsave :decl(var))
│ │ - QAST::Var(contextual $*CTXSAVE)
│ │ - QAST::Op(unless)
│ │ - QAST::Op(isnull)
│ │ - QAST::Var(local ctxsave)
│ │ - QAST::Op(if)
│ │ - QAST::Op(can)
│ │ - QAST::Var(local ctxsave)
│ │ - QAST::SVal(ctxsave)
│ │ - QAST::Op(callmethod ctxsave)
│ │ - QAST::Var(local ctxsave)
│ │ - QAST::Stmts
│ │ - QAST::WVal(Array)
│ │ - QAST::Stmts <sunk> sub q(@a is item) { dd @a }; q $[5,6];
│ │ - QAST::Want <sunk> sub q(@a is item) { dd @a }
│ │ - QAST::Op(p6capturelex) :statement_id<1> :sink_ast<?> :past_block<?> :code_object<?>
│ │ - QAST::Op(callmethod clone)
│ │ - QAST::WVal(Sub :cuid(1)) :past_block<?> :code_object<?>
│ │ - v
│ │ - QAST::Op(null)
│ │ - QAST::Stmt <sunk final> q $[5,6]
│ │ - QAST::Want <sunk>
│ │ - QAST::Op(callstatic &q) <sunk> :statement_id<4> q $[5,6]
│ │ - QAST::Op(callmethod item) <wanted>
│ │ - QAST::Op(callstatic &circumfix:<[ ]>) <wanted> [5,6]
│ │ - QAST::WVal(List)
│ │ - v
│ │ - QAST::Op(p6sink)
│ │ - QAST::Op(callstatic &q) <sunk> :statement_id<4> q $[5,6]
│ │ - QAST::Op(callmethod item) <wanted>
│ │ - QAST::Op(callstatic &circumfix:<[ ]>) <wanted> [5,6]
│ │ - QAST::WVal(List)
│ │ - QAST::WVal(Nil)
Parameter '@a' only accepts an itemized argument
in sub q at -e line 1
in block <unit> at -e line 1
@ab5tract
Copy link
Author

ab5tract commented Apr 4, 2024

Here is what a run looks like qith --optimize=off:

~/c/r/z/d/rakudo (is-item)
> ./rakudo-m --optimize=off -e 'sub q(@a is item) { dd @a }; q $[5,6];'
[5, 6]
~/c/r/z/d/rakudo (is-item)
> ./rakudo-m --optimize=off -e 'sub q(@a is item) { dd @a }; q [5,6];'
Parameter '@a' only accepts an itemized argument

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