On Aug 6, 2006, at 4:08 PM, Leopold Toetsch wrote:

Am Sonntag, 6. August 2006 19:03 schrieb Will Coleda:
we get a 9K line PIR sub. Running this through parrot dies after
about 2.5m on an runtime error on one of the tests.

Great progress. While Parrot shouldn't die or - in the long run - take really long to compile that, you could work a bit on the compiler in the meantime.


I just wanted to make sure I mentioned the error here because I knew someone would try to run this and get the error: I think there's a ticket opened for this particular error already...

Here's a snippet from near the end of the code:

start_1559:
dynamic_1559:
   .local pmc command
     $P1566 = new .String
     $P1566 = 'foreach'

# why create a new String here - the line below clearly shows, that the
compiler wants to call '&foreach'.

This should be moved down to the unknown section below - if the .sub isn't found at runtime, we need to dispatch the name to the unknown handler. So this string needs to be here, but it's in the wrong spot. I'll fix that.


     push_eh invalid_1559
     command = get_hll_global  '&foreach'

# why '&foreach' the tcl name is 'foreach' - just install that sym in the runtime namespace and use it. Why the 'get_hll_global'? You are setting up an
exception frame anyway. Why not just compile to:


Because tcl allows both [foo] and $foo. So we (internally) adopted the sigils to keep these two things segregated. We could have two separate namespaces for them, but the thought was that this is a better choice for interoperability.

  push_eh invalid_xyz
      $P1565 = 'for_each'($P1560, $P1561, $P1563)
  clear_eh
  ...


I suppose we could have the exception handler check to see if the exception was due to a missing sub, and unknown() if so, or rethrow if not. That might work, though I'd be curious if parrot did this lookup at each invocation or somehow cached it.

invalid_1559:
   .local pmc interactive
   interactive = get_root_global ['tcl'], '$tcl_interactive'

# you might cache that once - it's probably used in zillion of places


This is a user visible variable that could theoretically change anywhere, so any caching scheme has to take that into account.

   unless interactive goto err_command1559
   .local pmc unk
   unk=find_global '&unknown'

# same here and just do ...

  'unknown'(...)

... call it instead of ...

   unk($P1566, $P1560, $P1561, $P1563)

my 2 c
leo


I'll investigate just using the '&foreach'() syntax in both cases, and there's probably some wins there.

A lot of the compilation at this point is naive - we don't bother to do optimizations with constant strings, for example: constants, command interpolation, variable interpolation - all these end up naively in a PMC register that we can than manipulate uniformly. We can for sure be more aggressive about this sort of thing, though.

Another thing that I'm considering is a custom op library for this sort of dispatch. Let it handle things at the C level - which might not be too much faster/slower at execution time, but would be a plus during compilation.

We could probably replace the entire section above with:

tcl_dispatch $P1566, $P1560, $P1561, $P1563

and have it do all the heavy lifting.

Thanks for the feedback, I'll incorporate what I can!

--
Will "Coke" Coleda
[EMAIL PROTECTED]


Reply via email to