0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-09-19 22:25:19 +00:00
Commit Graph

191 Commits

Author SHA1 Message Date
Patrick Reilly
8a51e0bc81 Merge pull request #67 from stesie/fix-garbage-collection
Fix garbage collection
2013-10-26 18:21:14 -07:00
Stefan Siegl
68a579f3ae 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.
2013-10-27 00:41:47 +02:00
Stefan Siegl
18b129b128 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.
2013-10-27 00:41:47 +02:00
Stefan Siegl
5c1c68b045 Merge pull request #68 from stesie/fix-double-free
Don't manually call destructors on v8js_globals.
2013-10-26 14:59:33 -07:00
Stefan Siegl
16934c2254 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.
2013-10-26 23:57:49 +02:00
Patrick Reilly
1906a8e6b6 Merge pull request #66 from cscott/mem-leaks
Fix init/shutdown of v8js_globals.
2013-10-26 14:26:34 -07:00
Patrick Reilly
b2a92e5be1 Merge pull request #65 from cscott/zts-fix
ZTS fixes
2013-10-26 14:25:30 -07:00
C. Scott Ananian
39cc821f91 Store tsrm_ls in php_v8js_ctx.
This avoids the need to ever do a (slow) TSRMLS_FETCH().
2013-10-26 02:07:12 -04:00
C. Scott Ananian
011e517cfe Fix ZTS errors in v8js_convert.cc. 2013-10-26 02:07:00 -04:00
C. Scott Ananian
527e636b25 Fix init/shutdown of v8js_globals.
The mutex/map/stack constructor/destructors weren't being properly called.
2013-10-26 02:04:57 -04:00
Patrick Reilly
e2a8186ad6 Merge pull request #63 from cscott/travis-fix
Travis config update: Partial fix for issue #56.
2013-10-25 14:49:43 -07:00
C. Scott Ananian
0948795d36 Travis config update: Partial fix for issue #56. 2013-10-25 17:43:36 -04:00
Patrick Reilly
e73a9434db Merge pull request #62 from cscott/issue-25
Fix property and method calls on PHP native objects.
2013-10-25 14:42:22 -07:00
Patrick Reilly
ed8fd24f69 Merge pull request #61 from cscott/misc-cleanup
A week's worth of cleanup
2013-10-25 14:41:33 -07:00
C. Scott Ananian
303f3f52b5 Refactor template cache into php_v8js_ctx.
Reduce map lookups by adding internal object field pointing to function
template.  Use hidden field to allow easy unwrapping of PHP objects.
2013-10-25 17:40:51 -04:00
C. Scott Ananian
c341511b36 PHP 5.3 compatibility fixes. 2013-10-25 17:40:51 -04:00
C. Scott Ananian
f6a6d1e4b5 Rework JavaScript wrapper for PHP objects.
Use the NamedPropertyHandler feature of v8 to wrap accesses to PHP properties
and methods from JavaScript.  This enables us to support property
set/delete/query.

The `in` and `delete` operators in JavaScript work like the `isset()` and
`unset()` functions in PHP.  In particular, a PHP property with a null
value will not be `in` the JavaScript object. (This holds when enumerating
all properties of an object as well.)

Because JavaScript has a single namespace for both properties and methods,
we allow the use of the `__call` method on a PHP object (even if the
PHP class does not natively define the `__call` magic function) in order
to unambiguously invoke a method.  Similarly, you can prefix a property
name with `$` to unambiguously access the property. (When enumerating all
properties, properties are `$`-prefixed in order to ensure they are not
conflated with method names.)
2013-10-25 16:47:15 -04:00
C. Scott Ananian
0adefa5048 Add a test for issue 25 (native properties) 2013-10-25 16:47:15 -04:00
C. Scott Ananian
44c329b953 Add a test of PHP magic functions. 2013-10-25 16:47:15 -04:00
C. Scott Ananian
52d8946b89 Add isolate parameter to V8JS_* macros.
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.
2013-10-25 16:46:07 -04:00
C. Scott Ananian
27a140c9fb Bug fixes for JavaScript var_dump implementation (make it match PHP). 2013-10-25 14:18:56 -04:00
C. Scott Ananian
c725a80674 Handle NULL in global.var_dump(). 2013-10-25 14:18:56 -04:00
C. Scott Ananian
0e1c6ef5e9 Clean up allocation/deallocation of php_v8js_ctx.
Use the constructor and destructor functions (don't just cross our fingers
and hope that zeroing out memory will work).
2013-10-25 14:18:50 -04:00
C. Scott Ananian
49632054a4 Cleanup: remove some warnings when compiled with -Wunused 2013-10-25 14:17:40 -04:00
C. Scott Ananian
abadda147c Don't rethrow outer exception if report_uncaught is false.
This would cause the exception to stick around and the next time JavaScript
is executed, this exception would be (anomalously) thrown.
2013-10-25 14:17:40 -04:00
C. Scott Ananian
2516e76ff8 Unwrap PHP objects when passing them back from JavaScript to PHP. 2013-10-25 14:17:40 -04:00
Patrick Reilly
6de3e901fa Merge pull request #60 from stesie/fix-v8object-rewrap
Don't re-wrap PHP objects from V8 to V8Object
2013-10-22 10:51:56 -07:00
Stefan Siegl
bd9483080d Don't re-wrap PHP objects from V8 to V8Object 2013-10-21 20:00:58 +02:00
Patrick Reilly
0051c77700 Merge pull request #58 from stesie/fix-tsrm
TSRM/ZTS fixes.
2013-10-21 03:21:41 -07:00
Stefan Siegl
61eee4cbd6 TSRM/ZTS fixes. 2013-10-19 23:04:35 +00:00
Patrick Reilly
f31c44e524 Merge pull request #57 from stesie/call-object_properties_init
More fixes on handling of derived V8Js objects and property export
2013-10-18 23:37:43 -07:00
Stefan Siegl
8eb5721c35 Copy default_properties to new object (PHP 5.3) 2013-10-19 02:52:19 +02:00
Stefan Siegl
683ac347c7 Test export of undeclared properties in derived classes 2013-10-19 02:36:19 +02:00
Stefan Siegl
c77cdf4b6f Export initially initialized public properties to V8
Before a property was exported to V8 if it was assigned a value
during normal code execution.  However if the value was assigned
(hard coded) on class level it wasn't exported.
2013-10-19 02:36:19 +02:00
Stefan Siegl
257233be51 Make php_v8js_write_property export only public properties
Before a property would have been exported, even if a derived
class declared it either private or protected.
2013-10-19 02:22:13 +02:00
Stefan Siegl
b888cfce0d Add test on protected & private properties on derived classes 2013-10-19 02:17:10 +02:00
Stefan Siegl
1f8b605585 Add test on initially initialized properties on V8Js object. 2013-10-19 02:15:37 +02:00
Stefan Siegl
645b0df999 Add test from issue #54 2013-10-18 23:57:26 +02:00
Patrick Reilly
40d9e3e4f2 Merge pull request #55 from stesie/call-object_properties_init
Call object_properties_init on newly created V8Js object.
2013-10-18 04:44:10 -07:00
Stefan Siegl
d6a4a3c960 Call object_properties_init on newly created V8Js object. 2013-10-17 23:32:16 +02:00
Patrick Reilly
17381525f1 Merge pull request #53 from stesie/v8-debug
Add V8 debugging support
2013-10-13 12:28:58 -07:00
Stefan Siegl
3f049d3b91 Unlock isolate on JS->PHP transition. 2013-10-13 11:36:57 +02:00
Stefan Siegl
d69f2be50a Add v8 debug support 2013-10-13 11:36:57 +02:00
Patrick Reilly
ab35dcc96b Merge pull request #52 from cscott/travis
Support g++-4.6 and travis CI server.
2013-10-13 00:26:31 -07:00
Patrick Reilly
b021bbefab Merge pull request #51 from cscott/typesafe-func
Make JavaScript function wrappers typesafe.
2013-10-13 00:26:08 -07:00
C. Scott Ananian
d75fc4a142 Hookup Travis continous integration test server. 2013-10-12 01:19:14 -04:00
C. Scott Ananian
d416d9b59b Support g++-4.6 in configuration script.
gcc 4.6 doesn't have the -std=c++11 option, it uses the not-yet-finalized
-std=c++0x option.  Use whichever is found to be appropriate at configure
time.
2013-10-12 01:19:14 -04:00
C. Scott Ananian
f85675f169 Make JavaScript function wrappers typesafe.
Use the v8::Signature parameter to FunctionTemplate::New to guarantee that
the info->Holder() is of the proper type when `php_v8js_php_callback` is
invoked.

Add test case demonstrating the segfault (which is now prevented).
2013-10-11 23:28:21 -04:00
Patrick Reilly
0319b74250 Merge pull request #50 from stesie/fix-test-for-php53
Make test PHP 5.3 compatible
2013-10-07 09:05:42 -07:00
Stefan Siegl
4f3cbd412b Make test PHP 5.3 compatible 2013-10-07 14:55:01 +02:00