Skip to content

Instantly share code, notes, and snippets.

@skids
Created February 18, 2016 04:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skids/0029ab3fe15e354f1378 to your computer and use it in GitHub Desktop.
Save skids/0029ab3fe15e354f1378 to your computer and use it in GitHub Desktop.
I knew I should have taken that left turn at Albequirky
So this is why I get lost in NQP/MoarVM.
Objective: figure out how to create a non-resumable subclass of Exception
Step 1: Look at Exception, notice "method resumable" checks $!ex at key 'resume' and "method resume" just calls nqp::resume
Step 2: Well, I could just override those, but what if the nqp op is called directly somewhere. Better investigate
Step 3: OK $!ex is made by calling "nqp::newexception". rgrep nqp tree for it
step 4: OK that's mapped to MoarVM "newexeception" op. Resist the urge to say "this goes to VM level too?!?"
since exceptions are pretty low level VM things. and I knew that would happen in this case.
Step 5: Look at NQP and MoarVM exception pods. Don't find anything about default init values or instatiation params there.
Step 6: grep for newexception. Note that it is specialized. Wonder how MVM_OP_sp_fastcreate works, decide
to put a pin in worrying about this codepath and lok at the interpreted one first.
Step 7: OK op newexception just finds boot_types.BOOTException and uses a generic initializer on it. Look for that.
Step 8: rest eyes. starting to glaze.
Step 9: Ok I guess that BootException just maps to MVM_REPR_ID_MVMException. Which is just 22.
Step 10: Figure out that that maps to a C type MVMException.
Step 11: OK, that has two null-if-not-resumable address pointers, one for jit jit_resume_label and one
for unjitted resume_addr. No C code that would implement a .resume that checks resumability.
Step 12: Wait what, where is $!ex.resume? Did we miss it in nqp? how does that become an nqp attribute?
Step 13: Find MVM_REPR_DEFAULT_GET_ATTRIBUTE, it's a die.
Step 14: Try:
$ perl6 -e 'Exception.new().resumable.say'
This type does not support associative operations
in block <unit> at -e line 1
Step 15: Well hell. I'm going to bed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment