Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support V8 10.5 #490

Merged
merged 6 commits into from
Jun 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions config.m4
Original file line number Diff line number Diff line change
@@ -39,11 +39,15 @@ if test "$PHP_V8JS" != "no"; then


AC_CACHE_CHECK(for C standard version, ac_cv_v8_cstd, [
ac_cv_v8_cstd="c++14"
ac_cv_v8_cstd="c++17"
old_CPPFLAGS=$CPPFLAGS
AC_LANG_PUSH([C++])
CPPFLAGS="-std="$ac_cv_v8_cstd
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],[],[ac_cv_v8_cstd="c++1y"],[])
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],[],[
ac_cv_v8_cstd="c++14"
CPPFLAGS="-std="$ac_cv_v8_cstd
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],[],[ ac_cv_v8_cstd="c++1y" ],[])
],[])
AC_LANG_POP([C++])
CPPFLAGS=$old_CPPFLAGS
]);
@@ -173,6 +177,24 @@ int main ()
V8_SEARCH_BLOB([snapshot_blob.bin], [PHP_V8_SNAPSHOT_BLOB_PATH])


dnl
dnl Check for v8::V8::InitializeSandbox
dnl
AC_CACHE_CHECK([for v8::V8::InitializeSandbox], ac_cv_has_initialize_sandbox, [
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#define V8_ENABLE_SANDBOX 1
#include <v8.h>
], [ v8::V8::InitializeSandbox(); ])], [
ac_cv_has_initialize_sandbox=yes
], [
ac_cv_has_initialize_sandbox=no
])
])
if test "x$ac_cv_has_initialize_sandbox" = "xyes"; then
AC_DEFINE([V8_HAS_INITIALIZE_SANDBOX], [1],
[Define if V8::InitializeSandbox must be called.])
fi

dnl
dnl Check for v8::ArrayBuffer::Allocator::NewDefaultAllocator
dnl
4 changes: 4 additions & 0 deletions v8js_main.cc
Original file line number Diff line number Diff line change
@@ -162,7 +162,11 @@ static PHP_MSHUTDOWN_FUNCTION(v8js)

if(v8_initialized) {
v8::V8::Dispose();
#if PHP_V8_API_VERSION >= 10000000
v8::V8::DisposePlatform();
#else
v8::V8::ShutdownPlatform();
#endif
// @fixme call virtual destructor somehow
//delete v8js_process_globals.v8_platform;
}
4 changes: 4 additions & 0 deletions v8js_v8.cc
Original file line number Diff line number Diff line change
@@ -71,6 +71,10 @@ void v8js_v8_init() /* {{{ */
v8js_process_globals.v8_platform = v8::platform::NewDefaultPlatform();
v8::V8::InitializePlatform(v8js_process_globals.v8_platform.get());

#ifdef V8_HAS_INITIALIZE_SANDBOX
v8::V8::InitializeSandbox();
#endif

/* Set V8 command line flags (must be done before V8::Initialize()!) */
if (v8js_process_globals.v8_flags) {
size_t flags_len = strlen(v8js_process_globals.v8_flags);
2 changes: 1 addition & 1 deletion v8js_variables.cc
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ void v8js_register_accessors(std::vector<v8js_accessor_ctx*> *accessor_list, v8:
ctx->isolate = isolate;

/* Set the variable fetch callback for given symbol on named property */
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));
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);

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