Dan Sugalski <[EMAIL PROTECTED]> wrote:
> At 11:16 AM +0100 11/2/04, Leopold Toetsch wrote:

> I was thinking something a bit more primitive. Since we can treat the
> call chain as an array, we could do:

>     $S0 = insert_opname_here [0; 'subname'] # Get the current sub name
>     $S1 = insert_opname_here [1; 'subname'] # Get the caller's sub name
>     $P1 = insert_opname_here [2; 'pad'] # Get grandparent's pad

> We could do the same thing with continuation objects -- access them
> as an array and pull parts out, which'd work fine.

We don't have opcodes with a keyed on nothing syntax. So 2nd idea:

  $P2 = getinterp              # this exists

  $P0 = $P2['current_sub']     # aka P0
  $P1 = $P2['current_cont']    # formerly P1
  $P0 = $P2['current_sub', 1]  # caller's info
  $P1 = $P2['current_cont', 1]

  $S0 = $P0                    # subname := get_string

>>I think having methods is ok for that. It's in no way time critical to
>>warrant opcodes.

> The one downside to methods is that we need an object, which means
> that we've got to instantiate the current continuation.

Not really, We can hang these methods off the interpreter too.

> ... I'm not sure I'd want to go with
> methods here, though -- there's a reasonable chance that the method
> code might mess up some of the environmental info in the traceback.

That's an argument. OTOH you can't override NCI methods on plain PMCs.
The chance of disruption is low.

>>When and in which run loop do we update the C<current_pc>[1] ? Only,
>>when warnings are enabled or always?

> We should always be able to get a sane value out of it. If that means
> with the JIT that we have to play some interesting games with line
> number metadata sections or something, well... that's OK. It doesn't
> have to be cheap, just doable.

Ok. I presume "line number" is both HLL and PIR line numbers. To be able
to create a precise traceback, we've to update the program counter in
the interpreter context, so that we know, what we are executing.

Metadata is basically not the problem. We have that for PASM albeit it's
not too exact always.

What is the granularity of updating the PC? E.g. when we have:

   a = func(b, c)

this translates to several PASM instructions. Alone setting I0..I4 for
call and return are 10. For a traceback, we'd need one PC update only.

OTOH when we have:

   add P0, P1

it could be an overridden method call, which would need updating the PC.

We could of course just say, that's not our problem: the HLL is
responsible for emitting

  setline n
  setfile "file"

opcodes.

leo

Reply via email to