Ticket #1505 (closed bug: fixed)

Opened 12 years ago

Last modified 12 years ago

:anon vtable overrides don't work in PIR

Reported by: moritz Owned by: whiteknight
Priority: normal Milestone:
Component: core Version: 2.1.0
Severity: medium Keywords:
Cc: Language: perl6
Patch status: Platform: linux


.namespace [ 'Foo' ]

.sub '__onload' :anon :init
    $P0 = newclass "Foo"

.sub '' :vtable('get_string') :method :anon

.sub main :main
    $P0 = new 'Foo'
    $S0 = $P0
    print $S0
    print "\n"

This prints

get_string() not implemented in class 'Foo'
current instr.: 'parrot;Foo;main' pc 16 (foo.pir:15)

but just prints "works" if you remove the :anon.

I know of no good reason why a method that overrides a vtable method has to have a name.

Currently it prevents us from fixing this bug in Rakudo:  http://rt.perl.org/rt3/Ticket/Display.html?id=73112

Change History

Changed 12 years ago by whiteknight

  • owner set to whiteknight

As a quick note, here's the codepath that these things should be taking in IMCC. I've been tracing it out a little and think I know what things are bad,but haven't had time for a fix. In my tests I removed the :method flag. The result is the same but fewer branches are taken in the code to reduce debugging time.

  • sub enters compilers/imcc/pbc.c:add_const_pmc_sub.
  • On line 1410, gets vtable_index of 76. I don't know if this number is correct, but seems plausible.
  • On line 1447 calls Parrot_store_sub_in_namespace. At this point, here is the sub PMC data according to GDB:
    (gdb) p * sub
    $3 = {seg = 0x80f6580, start_offs = 6, end_offs = 13, HLL_id = 0, namespace_name = 0x80e7a68, 
      namespace_stash = 0x0, name = 0x807f27c, method_name = 0x80c5cdc, ns_entry_name = 0x807f27c, 
      subid = 0x807f27c, vtable_index = 76, multi_signature = 0x0, n_regs_used = {0, 0, 0, 1}, 
      lex_info = 0x0, outer_sub = 0x0, eval_pmc = 0x0, ctx = 0x0, comp_flags = 0, arg_info = 0x0, 
      outer_ctx = 0x0}
  • Sub enters src/global.c:Parrot_store_sub_in_namespace.
  • On line 816, there is a test for the sub being anon. The vtable in question fails this test. On line 820, the sub would be passed to Parrot_store_global_n, which it looks like will perform the rest of the magic.

So I think in that Parrot_store_sub_in_namespace function we need to add a condition where the sub can be :anon if it is also :vtable, and then continue in that direction. I will do testing tonight if nobody beats me to it.

Changed 12 years ago by whiteknight

  • status changed from new to closed
  • resolution set to fixed

I've committed a fix in r44833. All tests appear to pass, so I'm closing the ticket. If this solution does not satisfy the needs of Rakudo or is found to cause other problems, we can reopen the ticket.

Changed 12 years ago by whiteknight

...and test case committed in r44837.

Note: See TracTickets for help on using tickets.