0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-24 05:21:51 +00:00
Commit Graph

870 Commits

Author SHA1 Message Date
Patrick Reilly
98d535b8b1 Merge pull request #82 from stesie/fix-ftbfs-v8-3.24.5
Fix build against V8 >= 3.24.4
2013-12-29 00:21:38 -08:00
Stefan Siegl
985307dc91 Update README, removed build badge, require V8 3.22.3
GitHub now caches the build badge image if it is served via HTTP.
However the Jenkins box has no SSL certificate, hence I had to remove
the badge.
2013-12-21 20:54:55 +01:00
Stefan Siegl
8858bf5f27 Make compatible with V8 3.23.2 (and below) 2013-12-21 20:54:55 +01:00
Stefan Siegl
1e773dd4a8 Make compatible with V8 3.23.8 (and below) 2013-12-21 20:54:55 +01:00
Stefan Siegl
e20e5098c7 Make compatible with V8 3.23.11 (and below) 2013-12-21 19:56:28 +01:00
Stefan Siegl
69290b5779 Fix build against libv8 3.24.5 2013-12-21 01:18:08 +01:00
Patrick Reilly
e68d7073de Merge pull request #77 from cscott/minor-fixes
A pair of minor fixes
2013-10-30 11:45:03 -07:00
Patrick Reilly
5f0cd045e2 Merge pull request #76 from cscott/issue-75
Protect against direct invocation of `new V8Object` and `new V8Function`
2013-10-30 11:44:33 -07:00
C. Scott Ananian
30497766a3 Fix test cases which hard coded the object identity of returned objects. 2013-10-29 15:38:27 -04:00
C. Scott Ananian
7c5817c931 Remove unnecessary TSRMLS_FETCH from php_v8js_weak_object_callback. 2013-10-29 15:38:18 -04:00
C. Scott Ananian
2fe87a4cbc Protect against direct invocation of new V8Object and new V8Function.
This fixes issue #75.
2013-10-29 15:37:04 -04:00
Patrick Reilly
6eeafc0f83 Merge pull request #74 from cscott/dtor-simple
Simplify php_v8js_weak_object_callback.
2013-10-27 10:32:14 -07:00
Patrick Reilly
38837af243 Merge pull request #73 from cscott/a-few-more-leaks
Fix leak in v8 named property setter; clean up v8 named property getter.
2013-10-27 10:31:24 -07:00
C. Scott Ananian
892c654c8c Simplify php_v8js_weak_object_callback.
This also fixes a leak in the `object_dom` testcase, where the DOM extension
returns an object with refcnt 1 but object_store refcnt 2, causing
READY_TO_DESTROY to return false.  Don't try to be fancy, just use the
standard PHP destructor.
2013-10-27 12:39:02 -04:00
C. Scott Ananian
1976e35b9a Fix leak in v8 named property setter; clean up v8 named property getter.
zend_update_property does not own the value after the call; we need to
do the deref ourself.  Tweaks to the getter based on a better understanding
of the zend_read_property API.
2013-10-27 12:36:54 -04:00
Patrick Reilly
a730ddeb67 Merge pull request #70 from cscott/travis-fix-3
More memory leak and safety fixes; fix travis configuration.
2013-10-27 04:18:34 -07:00
C. Scott Ananian
99a1d54e9e Travis config update: compile against minimum supported v8 and most recent v8. 2013-10-27 02:49:24 -04:00
C. Scott Ananian
673d178ce7 Travis config update: fix for issue #56.
Test against php 5.3, 5.4, and 5.5 -- which incidentally works around
the 'make test always succeeds' bug in php 5.3 and 5.4
(https://bugs.php.net/bug.php?id=60285).

('make test' may always succeed, but we still test against 5.3 and 5.4 to
ensure that we build correctly w/o errors on these php versions.)
2013-10-27 02:49:24 -04:00
C. Scott Ananian
24257b54af Free php_v8js_accessor_ctx when we are done with it. 2013-10-27 02:49:24 -04:00
C. Scott Ananian
3f77a5a356 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.
2013-10-27 02:49:24 -04:00
C. Scott Ananian
879d1d54a2 Fix memory leak in zend_read_property; also pass correct scope object. 2013-10-27 02:49:24 -04:00
C. Scott Ananian
1c3a919ae8 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.
2013-10-27 02:49:23 -04:00
C. Scott Ananian
57348c5f7d 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.
2013-10-27 02:48:52 -04:00
C. Scott Ananian
dba6322812 Fix memory leak: The get_properties handler owns the returned hashtable. 2013-10-26 23:14:39 -04:00
C. Scott Ananian
b4d560dd52 Fix a bunch of memory leaks.
Found by compiling PHP with --enable-debug.
2013-10-26 23:14:39 -04:00
C. Scott Ananian
7cdcb5f45e Document rules for initialization/cleanup of ZTS globals.
Transfer stesie's comment from the c3512587ac
commit message so that future additions to v8js_globals maintain the
proper ZTS behavior.
2013-10-26 23:14:39 -04:00
Patrick Reilly
ae2ad9967d Merge pull request #69 from stesie/fix-global-zts-init
Initialize v8js_globals manually only if ZTS is enabled.
2013-10-26 18:21:25 -07:00
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
c3512587ac 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.
2013-10-27 00:29:50 +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