Skip to content

Commit 9afd1a9

Browse files
authored
Merge pull request #490 from stesie/issue-489
Support V8 10.5
2 parents dd536bc + 26de750 commit 9afd1a9

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

config.m4

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ if test "$PHP_V8JS" != "no"; then
3939

4040

4141
AC_CACHE_CHECK(for C standard version, ac_cv_v8_cstd, [
42-
ac_cv_v8_cstd="c++14"
42+
ac_cv_v8_cstd="c++17"
4343
old_CPPFLAGS=$CPPFLAGS
4444
AC_LANG_PUSH([C++])
4545
CPPFLAGS="-std="$ac_cv_v8_cstd
46-
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],[],[ac_cv_v8_cstd="c++1y"],[])
46+
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],[],[
47+
ac_cv_v8_cstd="c++14"
48+
CPPFLAGS="-std="$ac_cv_v8_cstd
49+
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],[],[ ac_cv_v8_cstd="c++1y" ],[])
50+
],[])
4751
AC_LANG_POP([C++])
4852
CPPFLAGS=$old_CPPFLAGS
4953
]);
@@ -173,6 +177,24 @@ int main ()
173177
V8_SEARCH_BLOB([snapshot_blob.bin], [PHP_V8_SNAPSHOT_BLOB_PATH])
174178

175179

180+
dnl
181+
dnl Check for v8::V8::InitializeSandbox
182+
dnl
183+
AC_CACHE_CHECK([for v8::V8::InitializeSandbox], ac_cv_has_initialize_sandbox, [
184+
AC_LINK_IFELSE([AC_LANG_PROGRAM([
185+
#define V8_ENABLE_SANDBOX 1
186+
#include <v8.h>
187+
], [ v8::V8::InitializeSandbox(); ])], [
188+
ac_cv_has_initialize_sandbox=yes
189+
], [
190+
ac_cv_has_initialize_sandbox=no
191+
])
192+
])
193+
if test "x$ac_cv_has_initialize_sandbox" = "xyes"; then
194+
AC_DEFINE([V8_HAS_INITIALIZE_SANDBOX], [1],
195+
[Define if V8::InitializeSandbox must be called.])
196+
fi
197+
176198
dnl
177199
dnl Check for v8::ArrayBuffer::Allocator::NewDefaultAllocator
178200
dnl

v8js_main.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ static PHP_MSHUTDOWN_FUNCTION(v8js)
162162

163163
if(v8_initialized) {
164164
v8::V8::Dispose();
165+
#if PHP_V8_API_VERSION >= 10000000
166+
v8::V8::DisposePlatform();
167+
#else
165168
v8::V8::ShutdownPlatform();
169+
#endif
166170
// @fixme call virtual destructor somehow
167171
//delete v8js_process_globals.v8_platform;
168172
}

v8js_v8.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ void v8js_v8_init() /* {{{ */
7171
v8js_process_globals.v8_platform = v8::platform::NewDefaultPlatform();
7272
v8::V8::InitializePlatform(v8js_process_globals.v8_platform.get());
7373

74+
#ifdef V8_HAS_INITIALIZE_SANDBOX
75+
v8::V8::InitializeSandbox();
76+
#endif
77+
7478
/* Set V8 command line flags (must be done before V8::Initialize()!) */
7579
if (v8js_process_globals.v8_flags) {
7680
size_t flags_len = strlen(v8js_process_globals.v8_flags);

v8js_variables.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void v8js_register_accessors(std::vector<v8js_accessor_ctx*> *accessor_list, v8:
8080
ctx->isolate = isolate;
8181

8282
/* Set the variable fetch callback for given symbol on named property */
83-
php_obj->SetAccessor(V8JS_STRL(ZSTR_VAL(property_name), static_cast<int>(ZSTR_LEN(property_name))), v8js_fetch_php_variable, NULL, v8::External::New(isolate, ctx), v8::PROHIBITS_OVERWRITING, v8::ReadOnly, v8::AccessorSignature::New(isolate, php_obj_t));
83+
php_obj->SetAccessor(V8JS_STRL(ZSTR_VAL(property_name), static_cast<int>(ZSTR_LEN(property_name))), v8js_fetch_php_variable, NULL, v8::External::New(isolate, ctx), v8::PROHIBITS_OVERWRITING, v8::ReadOnly);
8484

8585
/* record the context so we can free it later */
8686
accessor_list->push_back(ctx);

0 commit comments

Comments
 (0)