On Tue, Sep 2, 2014 at 5:12 PM, enormouspenguin <[email protected]> wrote:
> I was just playing around with V8 Stack Trace API and came up with the
> following stupid code:
>
> [snip]
>
> Is that expected behavior? And if so, could anyone please explain it? I
> think it involve some kind of optimization that V8 does because different
> versions of node print different outputs.

It's a V8 bug, I've grappled with it before.  And you're right, it's
an issue (sort of) with the optimizer.

The second argument to Error.captureStackTrace() is the "stack top"
function, the function whose stack frame capturing starts at.
Everything at or above the stack top frame is filtered, everything
below it is captured.

What happens in your test is that V8 misses the stack top when there
is an exit frame on the stack (a call into the C++ run-time) from
self-optimizing JS code.  You can work around it in JS like this:

  function printST(x) {
    // Put another printST frame on the stack.
    if (x !== 42) return printST(42);
    // ...
  }

I wrote a patch some time ago that adds raw_frame->is_exit() checks in
the right places but as I wasn't sure whether my approach was sound
and I didn't have time to go through multiple review rounds, I never
sent it upstream.  You know what the score is now, you're welcome to
give it a try.  :-)

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAHQurc-vYnPfPvy4JX2%2BAfYrvLv7P9VWt-bNkPVD0tLiXt03DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to