Reviewers: Mads Ager,
Description:
Add termination of the script to the bailout check.
Today, when V8::TerminateExecution() is called, the 'sticky' termination
exception (not unlike out-of-memory) is thrown and the current layer of JS
on
the stack exits. The next C++ layer on the stack is supposed not to re-enter
into JS but rather exit quickly (V8::IsExecutionTerminating() returns true
during stack unwind). The next JS layer exits because of the 'sticky'
termination exception, and so on. Finally, after all JS layers are off the
stack, the 'sticky' exception is cleared and the JS can be re-entered again.
The requirement to not reenter into JS from C++ layer while in the process
of
stack unwinding is though hard to implement correctly. Reentry may happen
when
parameters are converted (toString()) or when the properties are retrieved.
In
the complex embedder like Chrome, there are so many places where this can
happen
that using V8::IsExecutionTerminating() in all of them is hard to ensure.
Instead, it is possible to keep a flag and check for it in ON_BAILOUT macro
to
see if the reentry into JS should immediately return. This is what JSC is
doing
and it could make codepaths in WebKit similar and remove the need to pepper
the
code with checks in front of many code fragments that potentially call into
JS.
Here is a patch that tries to do that. I've run it through Golem and it
seems to
have no visible regression. It's my second patch for V8, I'm trying to
learn it
so I mostly look for educational feedback :-)
Please review this at http://codereview.chromium.org/2123005/show
Affected files:
M src/api.cc
M src/top.cc
M src/v8.h
M src/v8.cc
M test/cctest/test-thread-termination.cc
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev