0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 14:01:53 +00:00

Move zend_try block into v8::Unlocker block

If the v8::Unlocker block is within the zend_try block, then
v8::~Unlocker (dtor) is not called and hence V8 doesn't
re-aquire the lock.

Besides before we re-entered the isolate within zend_try
and hence *before* taking the lock.
This commit is contained in:
Stefan Siegl 2015-12-31 23:42:01 +01:00
parent 362eb0b806
commit 2d9c831eeb
2 changed files with 25 additions and 24 deletions

View File

@ -354,27 +354,29 @@ V8JS_METHOD(require)
int call_result;
zval params[1];
zend_try {
{
isolate->Exit();
v8::Unlocker unlocker(isolate);
{
isolate->Exit();
v8::Unlocker unlocker(isolate);
zend_try {
ZVAL_STRING(&params[0], normalised_module_id);
call_result = call_user_function_ex(EG(function_table), NULL, &c->module_loader, &module_code, 1, params, 0, NULL TSRMLS_CC);
}
isolate->Enter();
if (call_result == FAILURE) {
info.GetReturnValue().Set(isolate->ThrowException(V8JS_SYM("Module loader callback failed")));
zend_catch {
v8js_terminate_execution(isolate);
V8JSG(fatal_error_abort) = 1;
}
zend_end_try();
}
zend_catch {
v8js_terminate_execution(isolate);
V8JSG(fatal_error_abort) = 1;
isolate->Enter();
if (V8JSG(fatal_error_abort)) {
call_result = FAILURE;
}
zend_end_try();
else if (call_result == FAILURE) {
info.GetReturnValue().Set(isolate->ThrowException(V8JS_SYM("Module loader callback failed")));
}
zval_dtor(&params[0]);

View File

@ -114,11 +114,11 @@ static void v8js_call_php_func(zend_object *object, zend_function *method_ptr, v
fci.no_separation = 1;
info.GetReturnValue().Set(V8JS_NULL);
zend_try {
{
isolate->Exit();
v8::Unlocker unlocker(isolate);
{
isolate->Exit();
v8::Unlocker unlocker(isolate);
zend_try {
/* zend_fcall_info_cache */
fcc.initialized = 1;
fcc.function_handler = method_ptr;
@ -128,14 +128,13 @@ static void v8js_call_php_func(zend_object *object, zend_function *method_ptr, v
zend_call_function(&fci, &fcc TSRMLS_CC);
}
isolate->Enter();
zend_catch {
v8js_terminate_execution(isolate);
V8JSG(fatal_error_abort) = 1;
}
zend_end_try();
}
zend_catch {
v8js_terminate_execution(isolate);
V8JSG(fatal_error_abort) = 1;
}
zend_end_try();
isolate->Enter();
failure:
/* Cleanup */