Splits longish v8js.cc file into pieces. It used to contain the
definitions of all V8Js exception classes, the V8Js class itself as
well as the V8Object/V8Function classes... besides the module setup
code itself.
This change factors out all exception class definitions into a
seperate pair of files (v8js_exceptions.*).
The V8Js class definition itself is moved to v8js_class.* pair,
with the v8 init & call code moved to v8js_v8.* pair
and the watchdog timer to v8js_timer.* pair.
The V8Object/V8Function code was moved to v8js_v8object_class.*
pair, not differentiating between the two like before.
Use v8::Persistent handle to keep module instances around.
Objects cannot be shared between isolates anyhow, hence moved
modules_loaded map from global V8JSG structure to php_v8js_ctx.
Besides fixes a use-after-free on normalised_module_id.
This is yet a first hack to prove applicability. Currently
unwind environment is held in a global variable, i.e. solution
is neither thread safe nor reentrant yet.
The timer_ctx was being popped & freed in terminate_execution, from the
timer thread (not the main thread), and then popped again in the main
thread when execution was aborted. Do all pop/free work in main thread.
Also, remember to pop the timer_ctx when just a memory limit is set.
Before the idle notifications to V8 were sent without a special
Isolate entered, which results in V8 using it's default isolate
(which we don't use at all). Hence those were pretty useless
anyways (if they were called, which was unlikely).
Besides V8 seems to not trigger the weak object callbacks if
the isolate is destroyed, hence the PHP objects we add-ref'ed
before will leak.
Therefore this removes the previous idle notification logic
and forces garbage collection from the V8Js object destructor.
This avoids unnecessary calls to Isolate::GetCurrent() in the implementation.
By standardizing on the V8JS_SYM and V8JS_STR macros we also standardize on
UTF-8 encoding for v8 strings.