0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-23 04:51:53 +00:00
Commit Graph

51 Commits

Author SHA1 Message Date
Stefan Siegl
3108d3947d Fix output of var_dump on regexp (V8 > 4.8)
Newer V8 versions' toString() converts RegExp objects
just to [object RegExp] (instead of the actual regexp
as before).  Work-around by calling GetSource() on the
regexp and create former outhway that way.
2015-12-30 14:59:37 +01:00
Stefan Siegl
67a9de01bd Allow custom module normalisation 2015-12-06 13:55:13 +01:00
Stefan Siegl
f258980399 Accept empty string as module source
This might be perfectly valid, if you're using a third-party module,
which requires a module yet doesn't use it in the code paths hit
and hence you just want to stub it out.
2015-12-06 13:25:43 +01:00
Stefan Siegl
4853c6d17f Set script identifier as String, not Symbol
Otherwise long module identifiers might get cut off.
2015-12-06 13:23:14 +01:00
Stefan Siegl
bf58fe67c1 wrap module loading in zend_try/zend_catch, closes #178 2015-12-04 22:09:04 +01:00
Stefan Siegl
39fff2301e Use module id as JsFileName for V8
This way the information to V8JsScriptException instances are way
more clear since they contain the name of the module that caused
the exception.
2015-12-04 21:46:54 +01:00
Stefan Siegl
2f0b8e2873 Make var_dump command available to modules as well 2015-12-04 21:37:51 +01:00
Stefan Siegl
670554306a Fix tests/var_dump.phpt
Recent V8 versions (e.g. 4.8.253 or 4.9.19) consider
`IsFunction() = true` for Closure objects from PHP; but earlier
versions didn't.

This ensures consistent var_dump behaviour (sticking to the
behaviour with older V8 versions).
2015-11-28 15:27:35 +01:00
Stefan Siegl
187b97060f Stop JS execution on PHP exceptions, refs #144 2015-08-21 15:55:52 +02:00
Stefan Siegl
cedcac1318 skip useless estrdup/efree cycle
The garbage collector cannot free the object as it is allocated
on the local stack.
2015-08-01 19:45:21 +02:00
Stefan Siegl
2ce7e420a7 Fix use-after-free on module reuse 2015-08-01 18:11:39 +02:00
Stefan Siegl
3d89f0250d Provide key compare function for modules_loaded
Without the compare function std::map simply compares one
pointer to another.  However we need to compare the actual
strings.

Besides we must not efree normalised_module_id on return
of require method, since the pointer was added to
modules_loaded (and is valid until destruction of V8Js
class); instead it is now freed during V8Js object destruction.
2015-08-01 17:49:11 +02:00
Stefan Siegl
754d398ec9 Move v8js_commonjs.cc forward declarations in .h file 2015-08-01 17:09:48 +02:00
Stefan Siegl
72cb2da9ba Enter endless loop after V8::TerminateExecution call, fixes #135
The V8::TerminateExecution does *not* immediately terminate execution
as its name might suggest.  It just marks the given isolate as
"to terminate" and the execution thread checks - from time to time -
whether to terminate.  For v8 itself this is not problematic as
the call is thought to stop long-running scripts executed in the
browser context.

As v8js exposes this function to JavaScript with the exit() method,
this behaviour is confusing.  In order to stop code execution right
at the exit() call, v8js enters an endless loop and waits for v8
to terminate execution within it.
2015-07-25 17:42:32 +02:00
Stefan Siegl
5b4aaa64f1 More php_v8js_ prefix cleanup 2014-12-13 01:37:25 +01:00
Stefan Siegl
2954de2db5 Remove php_ prefix to struct & type names 2014-12-13 01:18:42 +01:00
Stefan Siegl
3efec8d428 Remove CVS $Id$ comment lines 2014-12-13 00:45:05 +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
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
a134129018 Use isolate version of V8::TerminateExecution, refs #92 2014-05-14 23:39:41 +02:00
Stefan Siegl
c54b49d2a6 Use PHPWRITE macro instead of php_output_write, refs #80
php_output_write is not available in PHP 5.3.
2014-03-23 00:54:15 +01:00
Stefan Siegl
fd801631b7 Add null-byte passing test, make var_dump null-byte safe, closes #80 2014-03-23 00:28:53 +01:00
Stefan Siegl
1186e7951f Make compatible with V8 3.25.12, fixes #88 2014-03-22 17:58:38 +01:00
Stefan Siegl
4c64bc4ad9 Make compatible with V8 3.24.10, fixes #83 2014-03-22 00:07:53 +01:00
Stefan Siegl
8858bf5f27 Make compatible with V8 3.23.2 (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
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
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
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
49632054a4 Cleanup: remove some warnings when compiled with -Wunused 2013-10-25 14:17:40 -04:00
Stefan Siegl
61eee4cbd6 TSRM/ZTS fixes. 2013-10-19 23:04:35 +00:00
Stefan Siegl
619231913c Adapt to new v8::Persistent API, support V8 >= 3.21.12 2013-10-03 16:27:04 +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
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
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
be0cd75c65 Improve compatibility with NodeJS-style module.exports and exports. This allows arbitrary types to be exported, not just properties of the exports object. 2013-03-26 00:09:21 +00:00
Simon Best
99878e2995 Support for relative and absolute module identifiers. 2013-03-25 00:02:13 +00:00
Simon Best
db50fc25d1 Removed spurious number from exception message. 2013-03-24 22:56:55 +00:00
Simon Best
cd20140774 Handle exceptions throw from module loader callback. 2013-03-24 22:53:31 +00:00
Simon Best
ff34a2ddda Normalisation of module identifier. 2013-03-24 22:27:46 +00:00
Simon Best
114eb9cbf6 Removed spurious line. 2013-03-24 20:43:51 +00:00
Simon Best
ff443f3bc7 Check for module cyclic dependencies. Throw proper V8 exceptions when the require method is not successful. 2013-03-24 19:08:54 +00:00
Simon Best
84baa7614a First working version of CommonJS modules. 2013-03-24 16:27:13 +00:00
Patrick Reilly
dfbd5f0c0c Fixed build in 5.4+ 2012-07-06 17:12:53 -07:00
Patrick Reilly
7593cbcc59 Update copyright information 2012-04-27 16:41:32 +00:00