Skip to content

Commit 059e050

Browse files
committed
Merge remote-tracking branch 'origin/master' into php7
2 parents 3085db6 + f73abfa commit 059e050

File tree

9 files changed

+102
-30
lines changed

9 files changed

+102
-30
lines changed

README.Linux.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ sudo cp -R include/* /usr/include
3838
echo -e "create /usr/lib/libv8_libplatform.a\naddlib out/native/obj.target/tools/gyp/libv8_libplatform.a\nsave\nend" | sudo ar -M
3939
```
4040

41+
Then add `extension=v8js.so` to your php.ini file. If you have a separate configuration for CLI, add it there also.
42+
4143
* If the V8 library is newer than 4.4.9.1 you need to pass `snapshot=off` to
4244
`make`, otherwise the V8 library will not be usable
4345
(see V8 [Issue 4192](https://code.google.com/p/v8/issues/detail?id=4192))

README.MacOS.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ V8Js on MacOS
33

44
Installation of V8Js on MacOS is pretty much straight forward.
55

6-
First of all you need a pretty fresh installation of v8 library.
7-
If you have brew around, just `brew install v8` and you should be done.
6+
If you have [brew](https://brew.sh) around, just `brew install
7+
php56-v8js` (or `php54-v8js` / `php55-v8js` depending on your PHP
8+
version) and you should be done. This will install a recent version
9+
of V8 along with this extension.
10+
811
Otherwise you need to compile latest v8 manually.
912

1013
Compile latest v8

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Minimum requirements
2424
V8 implements ECMAScript as specified in ECMA-262, 5th edition.
2525
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.
2626

27+
V8 releases are published rather quickly and the V8 team usually provides security support
28+
for the version line shipped with the Chrome browser (stable channel) and newer (only).
29+
For a version overview see https://omahaproxy.appspot.com/.
30+
2731
- PHP 7.0.0+
2832

2933
This embedded implementation of the V8 engine uses thread locking so it works with ZTS enabled.

config.m4

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,32 @@ if test "$PHP_V8JS" != "no"; then
4646
CPPFLAGS=$old_CPPFLAGS
4747
]);
4848

49-
AC_CACHE_CHECK(how to disable c++11 narrowing warning, ac_cv_v8_narrowing, [
49+
AC_CACHE_CHECK(how to allow c++11 narrowing, ac_cv_v8_narrowing, [
5050
ac_cv_v8_narrowing=""
5151
old_CXXFLAGS=$CXXFLAGS
5252
AC_LANG_PUSH([C++])
53-
CXXFLAGS="-Wno-c++11-narrowing"
54-
AC_TRY_RUN([int main() { unsigned int a[1] = { -1 }; (void) a; return 0; }],[ac_cv_v8_narrowing="-Wno-c++11-narrowing"],[],[])
53+
CXXFLAGS="-std="$ac_cv_v8_cstd
54+
AC_TRY_RUN([int main() {
55+
struct { unsigned int x; } foo = {-1};
56+
(void) foo;
57+
return 0;
58+
}], [ ac_cv_v8_narrowing="" ], [
59+
CXXFLAGS="-Wno-c++11-narrowing -std="$ac_cv_v8_cstd
60+
AC_TRY_RUN([int main() {
61+
struct { unsigned int x; } foo = {-1};
62+
(void) foo;
63+
return 0;
64+
}], [ ac_cv_v8_narrowing="-Wno-c++11-narrowing" ], [
65+
CXXFLAGS="-Wno-narrowing -std="$ac_cv_v8_cstd
66+
AC_TRY_RUN([int main() {
67+
struct { unsigned int x; } foo = {-1};
68+
(void) foo;
69+
return 0;
70+
}], [ ac_cv_v8_narrowing="-Wno-narrowing" ], [
71+
AC_MSG_ERROR([cannot compile with narrowing])
72+
], [])
73+
], [])
74+
], [])
5575
AC_LANG_POP([C++])
5676
CXXFLAGS=$old_CXXFLAGS
5777
]);

package.xml

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,25 @@
1616
<email>stesie@php.net</email>
1717
<active>yes</active>
1818
</lead>
19-
<date>2015-09-26</date>
20-
<time>12:31:47</time>
19+
<date>2015-10-11</date>
20+
<time>21:59:47</time>
2121
<version>
22-
<release>0.2.6</release>
23-
<api>0.2.6</api>
22+
<release>0.3.0</release>
23+
<api>0.3.0</api>
2424
</version>
2525
<stability>
26-
<release>beta</release>
27-
<api>beta</api>
26+
<release>stable</release>
27+
<api>stable</api>
2828
</stability>
2929
<license uri="http://www.php.net/license">The MIT License (MIT)</license>
3030
<notes>
31-
- Fix reference counting issue on PHP-&gt;JS-&gt;PHP exception propagation
31+
- Fix multi-threading with pthreads extension
32+
- Remove v8 debug agent support (which is unsupported by V8 since 3.28.4)
3233
</notes>
3334
<contents>
3435
<dir baseinstalldir="/" name="/">
3536
<file baseinstalldir="/" md5sum="9532b5359069afc8bdccb5e01c288493" name="js/json-template.js" role="data" />
3637
<file baseinstalldir="/" md5sum="a490e5a575deeceab9872035fbe74eb1" name="js/jstparser.js" role="data" />
37-
<file baseinstalldir="/" md5sum="f1143e3f74042890b6f1a5abce86a3c3" name="samples/debug_callback_line_processor.php" role="php" />
38-
<file baseinstalldir="/" md5sum="a352c90590b7e13bad41b3c77928c84c" name="samples/debug_line_processor.php" role="php" />
3938
<file baseinstalldir="/" md5sum="ddbae43f7979c5fe082e08ff4f2e8765" name="samples/dlopen.supp" role="src" />
4039
<file baseinstalldir="/" md5sum="045e094122747e8e71f02ffc1ba88d4a" name="samples/test_call.php" role="php" />
4140
<file baseinstalldir="/" md5sum="87cb416c6bc17d657abbbf314a41ff85" name="samples/test_callback.php" role="php" />
@@ -150,6 +149,7 @@
150149
<file baseinstalldir="/" md5sum="4dd56ff553d5a79c2157848d51a7bd52" name="tests/property_visibility.phpt" role="test" />
151150
<file baseinstalldir="/" md5sum="b1b46869cf9db29d38c50964a9fea8f7" name="tests/property_visibility__get.phpt" role="test" />
152151
<file baseinstalldir="/" md5sum="76bdcf96941321e372516413f65c8576" name="tests/property_visibility__set.phpt" role="test" />
152+
<file baseinstalldir="/" md5sum="794b8e67cad67f72a5c0786b9ba72547" name="tests/pthreads_001.phpt" role="test" />
153153
<file baseinstalldir="/" md5sum="5a97aad8f07d8a9a67882b614e956c72" name="tests/regression_121.phpt" role="test" />
154154
<file baseinstalldir="/" md5sum="3b256c85a054b728a37b3429d4157f02" name="tests/return_value.phpt" role="test" />
155155
<file baseinstalldir="/" md5sum="1a9c261661b08cfc6879f7f427b9f0de" name="tests/serialize_001.phpt" role="test" />
@@ -171,38 +171,36 @@
171171
<file baseinstalldir="/" md5sum="35ce3816ae00e697fca26142c46e0c79" name="tests/v8_write_property.phpt" role="test" />
172172
<file baseinstalldir="/" md5sum="ae504a63e5ff800e3aa7d529835d0e8e" name="tests/variable_passing.phpt" role="test" />
173173
<file baseinstalldir="/" md5sum="1bd7738aeeb5cf80d80561554f59f2ed" name="tests/var_dump.phpt" role="test" />
174-
<file baseinstalldir="/" md5sum="63c4b2873ccc935571ae7fbb1baeab7b" name="config.m4" role="src" />
175-
<file baseinstalldir="/" md5sum="987d834d2edc84ead98dc1fddba2ad73" name="config.w32" role="src" />
174+
<file baseinstalldir="/" md5sum="8d1bdd18cc65d7328876dffca99cf0a9" name="config.m4" role="src" />
175+
<file baseinstalldir="/" md5sum="dd848985051c6e0db6e8037d5b9529da" name="config.w32" role="src" />
176176
<file baseinstalldir="/" md5sum="cea72666538d5b0b80a64ccdbda24919" name="CREDITS" role="doc" />
177177
<file baseinstalldir="/" md5sum="9f5b5f41204bcde55d9df87d5a970b30" name="LICENSE" role="doc" />
178-
<file baseinstalldir="/" md5sum="25260e0bc3111b01f700fad13544d6a9" name="Makefile.frag" role="src" />
178+
<file baseinstalldir="/" md5sum="679b9046688ed6f60969415b182b1cac" name="Makefile.frag" role="src" />
179179
<file baseinstalldir="/" md5sum="31e331386def7ce98943694151c0d5cb" name="Makefile.travis" role="src" />
180180
<file baseinstalldir="/" md5sum="0e23fa6446e52a3b1cff8b18a6e0bd79" name="php_v8js.h" role="src" />
181-
<file baseinstalldir="/" md5sum="0d986531818b0e31633f2db3a242afb7" name="php_v8js_macros.h" role="src" />
181+
<file baseinstalldir="/" md5sum="2d42ed24043ef4a6ab4bccdbda45eb89" name="php_v8js_macros.h" role="src" />
182182
<file baseinstalldir="/" md5sum="ec19e63ca9310bfc4dc4dbd357c779ae" name="README.Linux.md" role="doc" />
183183
<file baseinstalldir="/" md5sum="4a65a3f9995d325a2c2ccb23224ea503" name="README.MacOS.md" role="doc" />
184-
<file baseinstalldir="/" md5sum="177459a9628e3c8c31b305f20c970f8d" name="README.md" role="doc" />
184+
<file baseinstalldir="/" md5sum="b390530f1587c71e605806601a7f13eb" name="README.md" role="doc" />
185185
<file baseinstalldir="/" md5sum="9839870e001306943797003e8828d855" name="README.Win32.md" role="doc" />
186186
<file baseinstalldir="/" md5sum="542f52c54898f33ac53b173970cba305" name="test.php" role="php" />
187187
<file baseinstalldir="/" md5sum="65294fadb5ed766094b1f587fc20ad37" name="TODO" role="doc" />
188-
<file baseinstalldir="/" md5sum="cc54d77b4d0044d7b143989f2dc12b94" name="v8js.cc" role="src" />
188+
<file baseinstalldir="/" md5sum="16c060e49d1b2c477531758e1de4850e" name="v8js.cc" role="src" />
189189
<file baseinstalldir="/" md5sum="358c628b2627319e40fd7e5092f19872" name="v8js_array_access.cc" role="src" />
190190
<file baseinstalldir="/" md5sum="7baf3fe5b77d1374b39a1d8332e05df4" name="v8js_array_access.h" role="src" />
191-
<file baseinstalldir="/" md5sum="6c213918edf4f46ac630498e92bb99f6" name="v8js_class.cc" role="src" />
191+
<file baseinstalldir="/" md5sum="aa4bae42383773d1f769f44e0a28e484" name="v8js_class.cc" role="src" />
192192
<file baseinstalldir="/" md5sum="444a6fda6259076cd2a419cf59ab2c42" name="v8js_class.h" role="src" />
193193
<file baseinstalldir="/" md5sum="88b49988a5ef55edbd7ba085e7857f64" name="v8js_commonjs.cc" role="src" />
194194
<file baseinstalldir="/" md5sum="32a5d1a65f64ec37ec294f496fc11ff1" name="v8js_commonjs.h" role="src" />
195195
<file baseinstalldir="/" md5sum="c061344705c42fb705bffb2959fc1001" name="v8js_convert.cc" role="src" />
196-
<file baseinstalldir="/" md5sum="ede2cf80141b1831c7e7ab50dc57236f" name="v8js_debug.cc" role="src" />
197-
<file baseinstalldir="/" md5sum="cbdb6ed29c9ece278aa2aeab75dbe61f" name="v8js_debug.h" role="src" />
198196
<file baseinstalldir="/" md5sum="40b66c44650a8127618c7fc48bf4b0b2" name="v8js_exceptions.cc" role="src" />
199197
<file baseinstalldir="/" md5sum="9d13bf5f413c2d76664670e847e1a801" name="v8js_exceptions.h" role="src" />
200198
<file baseinstalldir="/" md5sum="9f3ad8c136cdc3ebc2bdf993491f9ad8" name="v8js_methods.cc" role="src" />
201199
<file baseinstalldir="/" md5sum="d688b8eb822736d49f7282d22546d6bc" name="v8js_object_export.cc" role="src" />
202200
<file baseinstalldir="/" md5sum="281fb591fbebc3d23e04196cdb3ec64a" name="v8js_object_export.h" role="src" />
203201
<file baseinstalldir="/" md5sum="d96c0e1eeaf1693813236f7e5da61e09" name="v8js_timer.cc" role="src" />
204202
<file baseinstalldir="/" md5sum="49f609c8cea6033f2ad1e6c9c829a571" name="v8js_timer.h" role="src" />
205-
<file baseinstalldir="/" md5sum="b3ba6b76f92683c55b45bce351af887e" name="v8js_v8.cc" role="src" />
203+
<file baseinstalldir="/" md5sum="6cde5b068dfce9026a3b43c5232d6b1c" name="v8js_v8.cc" role="src" />
206204
<file baseinstalldir="/" md5sum="0c4829d52ff46116c381b1b66ec27541" name="v8js_v8.h" role="src" />
207205
<file baseinstalldir="/" md5sum="82908f4e741755efa2aedfb486945a40" name="v8js_v8object_class.cc" role="src" />
208206
<file baseinstalldir="/" md5sum="8a80d71ff40dfa833d3b58ac94475a9f" name="v8js_v8object_class.h" role="src" />
@@ -427,5 +425,21 @@
427425
- Fix reference counting issue on PHP-&gt;JS-&gt;PHP exception propagation
428426
</notes>
429427
</release>
428+
<release>
429+
<version>
430+
<release>0.3.0</release>
431+
<api>0.3.0</api>
432+
</version>
433+
<stability>
434+
<release>stable</release>
435+
<api>stable</api>
436+
</stability>
437+
<date>2015-10-11</date>
438+
<license uri="http://www.php.net/license">The MIT License (MIT)</license>
439+
<notes>
440+
- Fix multi-threading with pthreads extension
441+
- Remove v8 debug agent support (which is unsupported by V8 since 3.28.4)
442+
</notes>
443+
</release>
430444
</changelog>
431445
</package>

php_v8js_macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern "C" {
5252
#endif
5353

5454
/* V8Js Version */
55-
#define PHP_V8JS_VERSION "0.2.6"
55+
#define PHP_V8JS_VERSION "0.3.0"
5656

5757
/* Hidden field name used to link JS wrappers with underlying PHP object */
5858
#define PHPJS_OBJECT_KEY "phpjs::object"

tests/function_properties.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Test V8::executeString() : Set property on function
3+
--SKIPIF--
4+
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
8+
$v8 = new V8Js();
9+
10+
$JS = <<< EOT
11+
(function(exports) {
12+
// begin module code
13+
exports.hello = function() { return 'hello'; };
14+
// end module code
15+
return exports;
16+
})({})
17+
EOT;
18+
19+
$exports = $v8->executeString($JS, 'basic.js');
20+
$exports->hello->foo = "bar";
21+
$v8->func = $exports->hello;
22+
23+
$v8->executeString('print(PHP.func.foo + "\n");');
24+
25+
?>
26+
===EOF===
27+
--EXPECT--
28+
bar
29+
===EOF===

v8js_methods.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static void v8js_dumper(v8::Isolate *isolate, v8::Local<v8::Value> var, int leve
138138
V8JS_GET_CLASS_NAME(cname, object);
139139
int hash = object->GetIdentityHash();
140140

141-
if (var->IsFunction())
141+
if (var->IsFunction() && strcmp(ToCString(cname), "Closure") != 0)
142142
{
143143
v8::String::Utf8Value csource(object->ToString());
144144
php_printf("object(Closure)#%d {\n%*c%s\n", hash, level * 2 + 2, ' ', ToCString(csource));

v8js_v8object_class.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static int v8js_v8object_has_property(zval *object, zval *member, int has_set_ex
6363
V8JS_CTX_PROLOGUE_EX(obj->ctx, retval);
6464
v8::Local<v8::Value> v8obj = v8::Local<v8::Value>::New(isolate, obj->v8obj);
6565

66-
if (Z_TYPE_P(member) == IS_STRING && v8obj->IsObject() && !v8obj->IsFunction())
66+
if (Z_TYPE_P(member) == IS_STRING && v8obj->IsObject())
6767
{
6868

6969
v8::Local<v8::Object> jsObj = v8obj->ToObject();
@@ -122,7 +122,7 @@ static zval *v8js_v8object_read_property(zval *object, zval *member, int type, v
122122
V8JS_CTX_PROLOGUE_EX(obj->ctx, retval);
123123
v8::Local<v8::Value> v8obj = v8::Local<v8::Value>::New(isolate, obj->v8obj);
124124

125-
if (Z_TYPE_P(member) == IS_STRING && v8obj->IsObject() && !v8obj->IsFunction())
125+
if (Z_TYPE_P(member) == IS_STRING && v8obj->IsObject())
126126
{
127127

128128
v8::Local<v8::Object> jsObj = v8obj->ToObject();
@@ -156,7 +156,7 @@ static void v8js_v8object_write_property(zval *object, zval *member, zval *value
156156
V8JS_CTX_PROLOGUE(obj->ctx);
157157
v8::Local<v8::Value> v8obj = v8::Local<v8::Value>::New(isolate, obj->v8obj);
158158

159-
if (v8obj->IsObject() && !v8obj->IsFunction()) {
159+
if (v8obj->IsObject()) {
160160
v8obj->ToObject()->ForceSet(V8JS_SYML(Z_STRVAL_P(member), Z_STRLEN_P(member)), zval_to_v8js(value, isolate TSRMLS_CC));
161161
}
162162
}
@@ -175,7 +175,7 @@ static void v8js_v8object_unset_property(zval *object, zval *member, void **cach
175175
V8JS_CTX_PROLOGUE(obj->ctx);
176176
v8::Local<v8::Value> v8obj = v8::Local<v8::Value>::New(isolate, obj->v8obj);
177177

178-
if (v8obj->IsObject() && !v8obj->IsFunction()) {
178+
if (v8obj->IsObject()) {
179179
v8obj->ToObject()->Delete(V8JS_SYML(Z_STRVAL_P(member), Z_STRLEN_P(member)));
180180
}
181181
}

0 commit comments

Comments
 (0)