From b29bb886bba30fd73a249751dbfd9fa220971c19 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Sun, 11 Oct 2015 22:00:33 +0200 Subject: [PATCH 1/7] Bump version to 0.3.0 --- package.xml | 52 ++++++++++++++++++++++++++++++----------------- php_v8js_macros.h | 2 +- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/package.xml b/package.xml index 701b25a..13873f9 100644 --- a/package.xml +++ b/package.xml @@ -16,26 +16,25 @@ stesie@php.net yes - 2015-09-26 - + 2015-10-11 + - 0.2.6 - 0.2.6 + 0.3.0 + 0.3.0 - beta - beta + stable + stable The MIT License (MIT) -- Fix reference counting issue on PHP->JS->PHP exception propagation +- Fix multi-threading with pthreads extension +- Remove v8 debug agent support (which is unsupported by V8 since 3.28.4) - - @@ -150,6 +149,7 @@ + @@ -171,30 +171,28 @@ - - + + - + - + - + - + - + - - @@ -202,7 +200,7 @@ - + @@ -427,5 +425,21 @@ - Fix reference counting issue on PHP->JS->PHP exception propagation + + + 0.3.0 + 0.3.0 + + + stable + stable + + 2015-10-11 + The MIT License (MIT) + +- Fix multi-threading with pthreads extension +- Remove v8 debug agent support (which is unsupported by V8 since 3.28.4) + + diff --git a/php_v8js_macros.h b/php_v8js_macros.h index e34a30e..cf8e465 100644 --- a/php_v8js_macros.h +++ b/php_v8js_macros.h @@ -53,7 +53,7 @@ extern "C" { #endif /* V8Js Version */ -#define PHP_V8JS_VERSION "0.2.6" +#define PHP_V8JS_VERSION "0.3.0" /* Hidden field name used to link JS wrappers with underlying PHP object */ #define PHPJS_OBJECT_KEY "phpjs::object" From 7805abfb183835c40f2857de98389492f0a876a3 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Sun, 18 Oct 2015 18:03:04 +0200 Subject: [PATCH 2/7] Improve -Wno-c++11-narrowing/-Wno-narrowing detection --- config.m4 | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/config.m4 b/config.m4 index e87a81e..1e3c488 100644 --- a/config.m4 +++ b/config.m4 @@ -46,12 +46,32 @@ if test "$PHP_V8JS" != "no"; then CPPFLAGS=$old_CPPFLAGS ]); - AC_CACHE_CHECK(how to disable c++11 narrowing warning, ac_cv_v8_narrowing, [ + AC_CACHE_CHECK(how to allow c++11 narrowing, ac_cv_v8_narrowing, [ ac_cv_v8_narrowing="" old_CXXFLAGS=$CXXFLAGS AC_LANG_PUSH([C++]) - CXXFLAGS="-Wno-c++11-narrowing" - AC_TRY_RUN([int main() { unsigned int a[1] = { -1 }; (void) a; return 0; }],[ac_cv_v8_narrowing="-Wno-c++11-narrowing"],[],[]) + CXXFLAGS="-std="$ac_cv_v8_cstd + AC_TRY_RUN([int main() { + struct { unsigned int x; } foo = {-1}; + (void) foo; + return 0; + }], [ ac_cv_v8_narrowing="" ], [ + CXXFLAGS="-Wno-c++11-narrowing -std="$ac_cv_v8_cstd + AC_TRY_RUN([int main() { + struct { unsigned int x; } foo = {-1}; + (void) foo; + return 0; + }], [ ac_cv_v8_narrowing="-Wno-c++11-narrowing" ], [ + CXXFLAGS="-Wno-narrowing -std="$ac_cv_v8_cstd + AC_TRY_RUN([int main() { + struct { unsigned int x; } foo = {-1}; + (void) foo; + return 0; + }], [ ac_cv_v8_narrowing="-Wno-narrowing" ], [ + AC_MSG_ERROR([cannot compile with narrowing]) + ], []) + ], []) + ], []) AC_LANG_POP([C++]) CXXFLAGS=$old_CXXFLAGS ]); From a58f944804cf3209eef687de68200776c1abda3b Mon Sep 17 00:00:00 2001 From: Matt Kynaston Date: Tue, 3 Nov 2015 17:35:30 +0000 Subject: [PATCH 3/7] Experiment to see if #172 is easy to fix --- tests/function_properties.phpt | 29 +++++++++++++++++++++++++++++ v8js_v8object_class.cc | 8 ++++---- 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 tests/function_properties.phpt diff --git a/tests/function_properties.phpt b/tests/function_properties.phpt new file mode 100644 index 0000000..ec30a85 --- /dev/null +++ b/tests/function_properties.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test V8::executeString() : Set property on function +--SKIPIF-- + +--FILE-- +executeString($JS, 'basic.js'); +$exports->hello->foo = "bar"; +$v8->func = $exports->hello; + +$v8->executeString('print(PHP.func.foo + "\n");'); + +?> +===EOF=== +--EXPECT-- +bar +===EOF=== diff --git a/v8js_v8object_class.cc b/v8js_v8object_class.cc index debabff..c51929d 100644 --- a/v8js_v8object_class.cc +++ b/v8js_v8object_class.cc @@ -63,7 +63,7 @@ static int v8js_v8object_has_property(zval *object, zval *member, int has_set_ex V8JS_CTX_PROLOGUE_EX(obj->ctx, retval); v8::Local v8obj = v8::Local::New(isolate, obj->v8obj); - if (Z_TYPE_P(member) == IS_STRING && v8obj->IsObject() && !v8obj->IsFunction()) + if (Z_TYPE_P(member) == IS_STRING && v8obj->IsObject()) { v8::Local jsObj = v8obj->ToObject(); @@ -123,7 +123,7 @@ static zval *v8js_v8object_read_property(zval *object, zval *member, int type ZE V8JS_CTX_PROLOGUE_EX(obj->ctx, retval); v8::Local v8obj = v8::Local::New(isolate, obj->v8obj); - if (Z_TYPE_P(member) == IS_STRING && v8obj->IsObject() && !v8obj->IsFunction()) + if (Z_TYPE_P(member) == IS_STRING && v8obj->IsObject()) { v8::Local jsObj = v8obj->ToObject(); @@ -166,7 +166,7 @@ static void v8js_v8object_write_property(zval *object, zval *member, zval *value V8JS_CTX_PROLOGUE(obj->ctx); v8::Local v8obj = v8::Local::New(isolate, obj->v8obj); - if (v8obj->IsObject() && !v8obj->IsFunction()) { + if (v8obj->IsObject()) { v8obj->ToObject()->ForceSet(V8JS_SYML(Z_STRVAL_P(member), Z_STRLEN_P(member)), zval_to_v8js(value, isolate TSRMLS_CC)); } } @@ -185,7 +185,7 @@ static void v8js_v8object_unset_property(zval *object, zval *member ZEND_HASH_KE V8JS_CTX_PROLOGUE(obj->ctx); v8::Local v8obj = v8::Local::New(isolate, obj->v8obj); - if (v8obj->IsObject() && !v8obj->IsFunction()) { + if (v8obj->IsObject()) { v8obj->ToObject()->Delete(V8JS_SYML(Z_STRVAL_P(member), Z_STRLEN_P(member))); } } From 1642ce48ba6e7c5e3b758c5ba32924db71ca2599 Mon Sep 17 00:00:00 2001 From: Alexander Hofstede Date: Fri, 20 Nov 2015 22:51:18 +0700 Subject: [PATCH 4/7] Update README.Linux.md Added a note about adding the extension to PHP config, especially for CLI, which needs to be configured separately in some PHP7 installs. --- README.Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.Linux.md b/README.Linux.md index 2cd6b2c..e85c261 100644 --- a/README.Linux.md +++ b/README.Linux.md @@ -38,6 +38,8 @@ sudo cp -R include/* /usr/include echo -e "create /usr/lib/libv8_libplatform.a\naddlib out/native/obj.target/tools/gyp/libv8_libplatform.a\nsave\nend" | sudo ar -M ``` +Then add `extension=v8js.so` to your php.ini file. If you have a separate configuration for CLI, add it there also. + * If the V8 library is newer than 4.4.9.1 you need to pass `snapshot=off` to `make`, otherwise the V8 library will not be usable (see V8 [Issue 4192](https://code.google.com/p/v8/issues/detail?id=4192)) From ff172f48ceb6952ca8a0abfd2392eb4bf7592839 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Fri, 20 Nov 2015 18:55:26 +0100 Subject: [PATCH 5/7] Add link to omahaproxy --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index d48a40e..8cf45a3 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,10 @@ Minimum requirements V8 implements ECMAScript as specified in ECMA-262, 5th edition. This extension makes use of V8 isolates to ensure separation between multiple V8Js instances and uses the new isolate-based mechanism to throw exceptions, hence the need for 3.24.6 or above. + V8 releases are published rather quickly and the V8 team usually provides security support + for the version line shipped with the Chrome browser (stable channel) and newer (only). + For a version overview see https://omahaproxy.appspot.com/. + - PHP 5.3.3+ This embedded implementation of the V8 engine uses thread locking so it works with ZTS enabled. From e5ee35a30ed384098a3c4175a19eafb9af9bbca6 Mon Sep 17 00:00:00 2001 From: Matt Kynaston Date: Fri, 20 Nov 2015 18:19:23 +0000 Subject: [PATCH 6/7] Updated README.MacOS to recommend installing extension via brew --- README.MacOS.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.MacOS.md b/README.MacOS.md index 65a6e7e..a0f35d9 100644 --- a/README.MacOS.md +++ b/README.MacOS.md @@ -3,8 +3,11 @@ V8Js on MacOS Installation of V8Js on MacOS is pretty much straight forward. -First of all you need a pretty fresh installation of v8 library. -If you have brew around, just `brew install v8` and you should be done. +If you have [brew](https://brew.sh) around, just `brew install +php56-v8js` (or `php54-v8js` / `php55-v8js` depending on your PHP +version) and you should be done. This will install a recent version +of V8 along with this extension. + Otherwise you need to compile latest v8 manually. Compile latest v8 From 670554306a3c2f6ef813d5c0caa961f4033901a4 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Sat, 28 Nov 2015 15:18:38 +0100 Subject: [PATCH 7/7] 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). --- v8js_methods.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v8js_methods.cc b/v8js_methods.cc index 722736b..c16eda5 100644 --- a/v8js_methods.cc +++ b/v8js_methods.cc @@ -138,7 +138,7 @@ static void v8js_dumper(v8::Isolate *isolate, v8::Local var, int leve V8JS_GET_CLASS_NAME(cname, object); int hash = object->GetIdentityHash(); - if (var->IsFunction()) + if (var->IsFunction() && strcmp(ToCString(cname), "Closure") != 0) { v8::String::Utf8Value csource(object->ToString()); php_printf("object(Closure)#%d {\n%*c%s\n", hash, level * 2 + 2, ' ', ToCString(csource));