Ticket #150 (closed bug: fixed)

Opened 13 years ago

Last modified 11 years ago

load_bytecode, loadlib, and HLL

Reported by: tene Owned by:
Priority: normal Milestone:
Component: hll_interop Version:
Severity: medium Keywords:
Cc: coke, NotFound Language:
Patch status: Platform:

Description (last modified by coke) (diff)

This works fine:

    # demo.pir
    .sub main :main
        load_bytecode 'perl6.pbc'
    .end

This fails, due to Perl6Str not existing

    # demo.pir
    .HLL 'foo'
    .sub main :main
        load_bytecode 'perl6.pbc'
    .end

The runtime version using the 'loadlib' op can work, kind of.

Adding this to perl6.pir doesn't help:

    # perl6.pir
    .HLL 'parrot'
    .sub '' :anon :load :init :immediate
        $P0 = loadlib 'perl6_group'
        $P0 = loadlib 'perl6_ops'
    .end

Adding that same code to the example does work:

    # demo.pir
    .HLL 'parrot'
    .sub '' :anon :load :init :immediate
        $P0 = loadlib 'perl6_group'
        $P0 = loadlib 'perl6_ops'
    .end
    .HLL 'foo'
    .sub main :main
        load_bytecode 'perl6.pbc'
    .end

This rather complicates attempts to use rakudo from another HLL.

I did a little bit of digging, and found this:

.loadlib is handled by do_loadlib in imcparser.c, which is:

    /* imcparser.c */
    do_loadlib(PARROT_INTERP, ARGIN(const char *lib))
    {
        ASSERT_ARGS(do_loadlib);
        STRING * const s = string_unescape_cstring(interp, lib + 1, '"', NULL);
        PMC    *ignored  = Parrot_load_lib(interp, s, NULL);
        UNUSED(ignored);
        Parrot_register_HLL_lib(interp, s);
    }

The loadlib op is handled by 'op loadlib' in core.ops:

    /* core.ops */
    inline op loadlib(out PMC, in STR) {
        $1 = Parrot_load_lib(interp, $2, NULL);
    }

You'll notice that the op version doesn't call Parrot_register_HLL_lib, but adding that to 'op loadlib' doesn't help. That's as far as I got in investigating this issue.

Attachments

loadbytecode.patch Download (1.8 KB) - added by NotFound 12 years ago.
Load bytecode and dynpmc libs in 'parrot' HLL context

Change History

Changed 13 years ago by coke

  • description modified (diff)

Changed 13 years ago by coke

Note that this snippet:

.HLL 'foo'
.loadlib 'perl6_group'
.sub main :main
  load_bytecode 'perl6.pbc'
.end

Completes without error.

Changed 13 years ago by NotFound

Don't know if it will solve any problem, but this works;

#demo.pir

.sub loadpbc
    load_bytecode 'perl6.pbc'
.end

.HLL 'foo'

.sub main :main
    loadpbc()
.end

Changed 13 years ago by japhb

  • component changed from none to hll_interop

Changed 12 years ago by NotFound

Load bytecode and dynpmc libs in 'parrot' HLL context

Changed 12 years ago by NotFound

The attached patch makes loading of bytecode and dynop files independent on the context from they are called, that seems to fix the problem.

Will be better to check it with a lot of HLL before committing.

Changed 12 years ago by NotFound

After some rethinking, I committed in r41115, the change is simpler enough to easily revert if it causes any trouble.

Changed 11 years ago by jkeenan

  • cc coke, NotFound added

A commit was made for this ticket 13 months ago and we appear to have survived.

Can we close the ticket?

Thank you very much.

kid51

Changed 11 years ago by NotFound

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

13 months? Time flies. Closing.

Note: See TracTickets for help on using tickets.