The PIR subroutine call syntax

_f()

expands (besides other instructions) to something like:

  newsub P0, .Sub, _f
  invokecc

I've now hacked together this sequence:
1) a new opcode (in dynoplibs/myops.ops for quick testing)

op pmc_const(out PMC, inlabelconst INT) {
    $1 = PCONST($2)->u.key;
    goto NEXT();
}

2) The call:
  loadlib P10, "myops_ops"
  pmc_const P0, 3
  ...
  invokecc

(The constant number #3 is known to imcc when generating the const table entry - actuall it would ne more like pmc_const P0, _f)

So *if* all is as static as in this code, and the Sub PMC isn't abused by different callers (e.g. by attaching properties or such), then this scheme would safe the C<newsub> operation, i.e. the construction of a new PMC.

Comments welcome,
leo



Reply via email to