Fix init/shutdown of v8js_globals.

The mutex/map/stack constructor/destructors weren't being properly called.
Fix ZTS errors in v8js_convert.cc.
Store tsrm_ls in php_v8js_ctx.

This avoids the need to ever do a (slow) TSRMLS_FETCH().
Merge pull request #65 from cscott/zts-fix

ZTS fixes
Merge pull request #66 from cscott/mem-leaks

Fix init/shutdown of v8js_globals.
Don't manually call destructors on v8js_globals.

v8js_globals is declared at the beginning of v8js.cc and hence
it's constructors and destructors are run automatically.
Merge pull request #68 from stesie/fix-double-free

Don't manually call destructors on v8js_globals.
Initialize v8js_globals manually only if ZTS is enabled.

If ZTS is disabled, the v8js_globals instance is declared right
in the BSS and hence automatically initialized by C++ compiler.
Most of the variables are just zeroed.

If ZTS is enabled however, v8js_globals just points to a freshly
allocated, unitialized piece of memory, hence we need to
initialize all fields on our own.  Likewise on shutdown we have to
run the destructors manually.
Trigger garbage collection within Isolate::Scope

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.
Delete global PHP object on shutdown

Deleting the global object implicitly deletes all the properties,
i.e. PHP objects we previously attached to it (and for which we
increased the reference counter).

Since the following idle notifications trigger the weak callbacks,
the references on the PHP objects are finally decreased.
Merge pull request #67 from stesie/fix-garbage-collection

Fix garbage collection
Merge pull request #69 from stesie/fix-global-zts-init

Initialize v8js_globals manually only if ZTS is enabled.
Document rules for initialization/cleanup of ZTS globals.

Transfer stesie's comment from the c3512587acf2f6aeeb80d7cc753f08a784c4c86b
commit message so that future additions to v8js_globals maintain the
proper ZTS behavior.
Fix a bunch of memory leaks.

Found by compiling PHP with --enable-debug.
Fix memory leak: The get_properties handler owns the returned hashtable.
Fix double-pop of timer_ctx (and efree from wrong thread).

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.
Don't leak if PHP constructor is called from JavaScript.

Register the weak reference callback to deref and do memory limit
accounting for wrapped PHP objects created from within JavaScript.
Fix memory leak in zend_read_property; also pass correct scope object.
Make PHP object accessors typesafe using V8::AccessorSignature.

This ensures that if you copy the accessor to another object you can't
trigger a segfault.
Free php_v8js_accessor_ctx when we are done with it.