If there's magic, it was an unintentional invocation. =-) If I was managing my own registers, I'd expect to have to save things - but since I'm always (I think) using .locals or the $I<foo> syntax, I'd expect IMCC to do the saving, since I have no way of knowing /which/ registers it's using for me. Unless, as you say, I should be doing an explicit, limited save/restore. It's this expectation that I was trying to gauge as unreasonable or not.

Attached, find the definition for __var_subst, and the one function it calls, __cmd_set (and the one macro /that/ includes, debug.)

(There are some commented out calls to _dumper (for printing out the contents of aggegrate PMCs), but the trouncing occurs without them.)


Attachment: var_subst.imc
Description: Binary data


Attachment: set.imc
Description: Binary data


Attachment: debug.imc
Description: Binary data






On Sunday, January 25, 2004, at 02:28 AM, Luke Palmer wrote:

Will Coleda writes:
I'm trying to track down a problem with a PerlArray that is getting
modified on me.

I have a snippet of code like:

  typeof $S12, tcl_words
  $I12 = tcl_words
  print "TYPEOF: "
  print $S12
  print "\n"
  print "SIZEOF: "
  print $I12
  print "\n"
  (var_start_at,var_length,var_replace_str) =
__var_subst(var_current_word)
  typeof $S12, tcl_words
  $I12 = tcl_words
  print "TYPEOF: "
  print $S12
  print "\n"
  print "SIZEOF: "
  print $I12
  print "\n"

Which is displaying:

TYPEOF: PerlArray
SIZEOF: 7
TYPEOF: PerlArray
SIZEOF: 1

if I do a saveall/restoreall around the call to __var_subst, then I get
the expected:

TYPEOF: PerlArray
SIZEOF: 7
TYPEOF: PerlArray
SIZEOF: 7

But then my return values are trounced.

Is this a bug, or just a misunderstanding on my part?

It looks okay to me, but that depends on what __var_subst actually does.
Any continuation magic could make this choke. What if you try a
savetop/restoretop instead? I'm not sure if that works, because I'm not
sure whether IMCC moves return values into high registers after a call.
Or you could use the user stack to save your return values.

Of course these are temporary fixes.  I'd like to see the code of
__var_subst, and perhaps a few functions that it in turn calls, if any.

Luke


--
Will "Coke" Coleda will at coleda dot com

Reply via email to