Taneli Leppa
7ee8d69470
Added V8Js::clearPendingException().
2014-11-17 10:45:35 +02:00
Stefan Siegl
6ee72b6f0a
Use concurrency::wait on Windows to sleep.
...
The chrono + sleep_for implementation seems not to work,
due to bugs in chrono header file. And after all sleep_for
calculates a time_point for sleep_until, which calculates
the delta again and finally passes the number of
milliseconds to concurrency::wait ...
2014-11-14 00:08:30 +01:00
Stefan Siegl
449d66ca01
Don't force garbage collection on shutdown.
...
Doing so causes crashes on Windows and isn't needed anymore
anyways, since we have started tracking weak references
meanwhile.
2014-11-14 00:05:58 +01:00
Stefan Siegl
d03641254d
Use alloca for variable-size array on stack
2014-11-13 01:21:15 +01:00
Stefan Siegl
83a17b5e6a
libplatform stuff not needed on Windows
2014-11-13 00:31:26 +01:00
Stefan Siegl
c339d51924
Drop old-age PHP_V8_API_VERSION #ifdef
2014-10-19 12:20:10 +00:00
Stefan Siegl
f6310f9994
Get rid of V8JS_NEW macro.
2014-10-19 11:58:21 +00:00
Stefan Siegl
16af153c3e
Merge branch 'cscott/issue-64' (ctx_lifecycle test).
...
Test adapted to current behaviour of V8Js, that the situation is
properly handled, but not by keeping objects valid, but by
invalidating all of them.
2014-10-18 20:28:06 +00:00
Stefan Siegl
7d13c75073
efree resource memory
2014-09-20 22:52:48 +02:00
Stefan Siegl
d8a6467903
TSRM/ZTS fixes
2014-09-20 22:52:47 +02:00
Stefan Siegl
47b433efe8
Restore clean unwind state after unwinding.
2014-09-20 18:42:09 +00:00
Stefan Siegl
c91f96a439
Merge pull request #108 from stesie/fix-commonjs-module-reuse
...
Fix module caching, closes #107
2014-09-20 15:05:31 +02:00
Stefan Siegl
11f7311ab8
Use php_v8js_compile_script for checkString.
2014-09-20 12:22:56 +00:00
Stefan Siegl
9cb3711c66
Merge remote-tracking branch 'rosmo/compile-script-201409', closes #95
2014-09-20 12:22:31 +00:00
Stefan Siegl
eda74908cc
Fix module caching, closes #107
...
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.
2014-09-19 22:36:27 +00:00
Stefan Siegl
06371e4126
Include libplatform.h only for v8 >= 3.29.36
2014-09-17 16:47:33 +02:00
Stefan Siegl
14600d3be3
Initialize v8 platform as needed
...
See http://comments.gmane.org/gmane.comp.lang.javascript.v8.general/8029
for more information.
2014-09-17 00:45:24 +02:00
Taneli Leppa
200c16c30e
Fixed script destructor and free resource struct when done.
2014-09-16 17:11:13 +03:00
Taneli Leppa
de8b0666a6
Some changes to how V8 contexts are managed.
2014-09-16 17:10:18 +03:00
Taneli Leppa
7310c93c1e
Deprecate V8Js::checkString() in favour of compileString() and add tests.
2014-09-16 17:10:15 +03:00
Taneli Leppa
bd7d649d90
Added new functions V8Js::compileString() and V8Js::executeScript().
...
Conflicts:
php_v8js_macros.h
2014-09-16 17:09:58 +03:00
Stefan Siegl
ebcb6dc211
Keep track of V8Object/V8Function instances
...
Disallow access to these once the V8Js object has been destroyed.
2014-08-11 03:11:02 +02:00
Stefan Siegl
a72a180596
Keep a list of disposed isolates and make sure not to use disposed isolates.
2014-08-10 23:48:54 +02:00
Stefan Siegl
133ad4a7b5
Merge remote-tracking branch 'rosmo/dispose-isolate'
2014-08-10 22:13:47 +02:00
Stefan Siegl
137a6732c6
IdleNotification is on Isolate now
2014-08-10 13:36:07 +02:00
Stefan Siegl
e25e5264f6
Make compatible with V8 3.28.23, fixes #99
2014-08-10 11:57:20 +02:00
Taneli Leppa
dbe477fc8e
Exit current isolate on fatal V8 error.
2014-07-01 10:48:06 +03:00
Taneli Leppa
03728d8bbd
Dispose isolate when freeing V8Js object.
2014-07-01 09:20:45 +03:00
Stefan Siegl
847ac7677c
Initialize V8JSG(old_error_handler) on ZTS, refs #94
2014-05-23 00:06:28 +02:00
Stefan Siegl
659c0fb601
Code folding marks and comments
2014-04-13 22:59:35 +02:00
Stefan Siegl
35d8b815f8
Store error message and re-throw with original type & message
2014-04-13 21:46:31 +02:00
Stefan Siegl
dfd8a1f386
Use V8JSG instead of global variable.
2014-04-12 09:22:58 +02:00
Stefan Siegl
a49fa8ce02
Unwind V8 execution context on fatal error, refs #87
...
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.
2014-04-12 00:02:43 +02:00
Stefan Siegl
c866e67313
Call INIT_ZVAL on stack-allocated zval
2014-04-11 20:15:51 +02:00
Stefan Siegl
0355a95c78
Fix strdup+getenv behaviour; multi api version support, closes #86
2014-03-22 19:09:53 +01:00
Stefan Siegl
ddbef50ea6
Merge remote-tracking branch 'rosmo/master'
2014-03-22 18:44:13 +01:00
Stefan Siegl
1186e7951f
Make compatible with V8 3.25.12, fixes #88
2014-03-22 17:58:38 +01:00
Stefan Siegl
bc86ce9e44
Clear persistent cells with weak references correctly, refs #88
2014-03-22 17:41:00 +01:00
Stefan Siegl
4c64bc4ad9
Make compatible with V8 3.24.10, fixes #83
2014-03-22 00:07:53 +01:00
Taneli Leppa
da53c90f88
Added new "v8js.use_date" ini setting to convert PHP DateTime objects to Javascript Date objects
...
when set as V8JS object properties.
2014-03-20 16:06:18 +02:00
Taneli Leppa
0a85d27ee7
V8 needs to be notified when timezone changes. Keep track of timezone changes and notify it.
...
Also added a test.
2014-03-20 11:20:59 +02:00
Taneli Leppa
dd20670546
When passing objects from JS to PHP with mixed keys, some of the keys
...
might get lost or "re-indexed". This fixes it and adds two tests.
2014-03-20 10:35:05 +02:00
Taneli Leppa
54621e18f3
Added checkString() method for checking Javascript syntax.
2014-03-19 17:00:28 +02:00
Stefan Siegl
1e773dd4a8
Make compatible with V8 3.23.8 (and below)
2013-12-21 20:54:55 +01:00
Stefan Siegl
69290b5779
Fix build against libv8 3.24.5
2013-12-21 01:18:08 +01: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
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
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
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
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
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
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
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
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
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
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
Stefan Siegl
bd9483080d
Don't re-wrap PHP objects from V8 to V8Object
2013-10-21 20:00:58 +02:00
Stefan Siegl
61eee4cbd6
TSRM/ZTS fixes.
2013-10-19 23:04:35 +00:00
Stefan Siegl
8eb5721c35
Copy default_properties to new object (PHP 5.3)
2013-10-19 02:52: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
d6a4a3c960
Call object_properties_init on newly created V8Js object.
2013-10-17 23:32:16 +02:00
Anatol Belski
c0290d4a17
fix version macros name
2013-10-15 17:42:02 +02:00
Stefan Siegl
d69f2be50a
Add v8 debug support
2013-10-13 11:36:57 +02:00
C. Scott Ananian
035e6faa8b
Implement property_exists()/isset()/empty() on wrapped JavaScript objects.
...
Fixes issue #32 .
2013-10-05 11:56:42 -04:00
Stefan Siegl
12e5e01920
Remove Locker from timer thread
2013-10-03 16:57:18 +02:00
Stefan Siegl
619231913c
Adapt to new v8::Persistent API, support V8 >= 3.21.12
2013-10-03 16:27:04 +02:00
Stefan Siegl
f90650d630
Create temporary HandleScope to get & call methods likewise, closes #33
2013-10-03 01:15:51 +02:00
Stefan Siegl
1f4caaeead
Create temporary HandleScope while reading properties
2013-10-03 01:05:03 +02:00
Stefan Siegl
662e491e1f
Pass back v8 functions, don't re-wrap
2013-10-03 00:34:50 +02:00
Anatol Belski
35685ed96c
TSRM fixes
2013-09-28 21:49:58 +02:00
Patrick Reilly
dc1475a3ad
updated package for beta release and switch license to MIT
2013-09-28 10:17:33 -07:00
Stefan Siegl
ffa42cdfaf
Replaced deprecated v8 api calls with newer equivalents
2013-07-08 00:58:19 +02:00
Stefan Siegl
6eeb6fe9d6
Use v8::Isolate version of v8::Context::New
2013-07-07 22:36:56 +02:00
Stefan Siegl
a951b82a40
Use persistent context + Dispose
2013-06-10 16:57:56 +02:00
Stefan Siegl
6106f46d4c
Remove leaked temp_context allocation
2013-06-08 01:44:13 +02:00
Patrick Reilly
98638c78db
fix for format '%d' expects argument of type 'int', but argument 2 has type 'size_t {aka long unsigned int}' [-Wformat]
2013-05-16 16:59:41 -07:00
Patrick Reilly
6f44220328
fix merge conflict
2013-05-09 15:55:30 -07:00
Simon Best
ef8620f0c2
Fix to start timer thread when there is a memory limit but no time limit.
2013-04-14 12:23:39 +01:00
Simon Best
e778b6d7af
Fix for SetFatalErrorHandler. This needs to be called for every context isolate.
2013-04-14 11:19:50 +01:00
Simon Best
8d8c671aa0
V8 isolates need to be passed into all variable accessor and conversion functions.
2013-04-14 00:36:05 +01:00
Simon Best
8ae7606338
Refactor CommonJS modules functionality to store state in the extension globals and context as appropriate.
2013-04-13 00:00:27 +01:00
Simon Best
46e509c0a9
Use the PHP memory management functions emalloc and efree.
2013-04-12 16:49:07 +01:00
Simon Best
147b743d4c
Removed v8::V8::Dispose call because it was causing SIGTRAPs in some exit scenarios. This is probably due to using the debug version of V8, but the documentation states that it's not necessary to call this anyway.
2013-04-11 22:57:25 +01:00
Simon Best
93df3411d9
Merged CommonJS modules functionality.
2013-04-11 17:15:55 +01:00
Simon Best
e05f811954
Renamed V8JsException to V8JsScriptException and added V8JsTimeLimitException and V8JsMemoryLimitException classes.
2013-04-11 00:23:47 +01:00
Simon Best
9d9ad831b8
Implemented memory limit checking. Increased stability for V8 execution isolates.
2013-04-11 00:08:05 +01:00
Simon Best
15dc9e157b
Script timeout thread to forcefully terminate the current thread of V8 execution in the corresponding isolate.
...
Note that threads are implemented using std::thread which is only available in C++0x. The relevant compile flags have been added but compiler support has not been tested and is therefore not guaranteed.
2013-04-09 22:52:42 +01:00
Simon Best
84baa7614a
First working version of CommonJS modules.
2013-03-24 16:27:13 +00:00
Patrick Reilly
5811659e88
add new version number
2013-03-21 14:41:31 -07:00
Patrick Reilly
dfbd5f0c0c
Fixed build in 5.4+
2012-07-06 17:12:53 -07:00
Dylan Arnold
157fe13c0e
Fixes to build in PHP 5.4.3
2012-05-10 22:47:39 +12:00