Skip to content

Commit 888684b

Browse files
committed
use v8::Global instead of v8::Persistent
1 parent 73e684f commit 888684b

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

v8js_class.cc

+10-10
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extern const zend_function_entry v8js_methods[];
5353
typedef struct _v8js_script {
5454
char *name;
5555
v8js_ctx *ctx;
56-
v8::Persistent<v8::Script, v8::CopyablePersistentTraits<v8::Script>> *script;
56+
v8::Global<v8::Script> *script;
5757
} v8js_script;
5858

5959
static void v8js_script_free(v8js_script *res);
@@ -95,11 +95,11 @@ static void v8js_free_storage(zend_object *object) /* {{{ */
9595
}
9696

9797
c->object_name.Reset();
98-
c->object_name.~Persistent();
98+
c->object_name.~Global();
9999
c->global_template.Reset();
100-
c->global_template.~Persistent();
100+
c->global_template.~Global();
101101
c->array_tmpl.Reset();
102-
c->array_tmpl.~Persistent();
102+
c->array_tmpl.~Global();
103103

104104
/* Clear persistent call_impl & method_tmpls templates */
105105
for (std::map<v8js_function_tmpl_t *, v8js_function_tmpl_t>::iterator it = c->call_impls.begin();
@@ -133,7 +133,7 @@ static void v8js_free_storage(zend_object *object) /* {{{ */
133133
if (!c->context.IsEmpty()) {
134134
c->context.Reset();
135135
}
136-
c->context.~Persistent();
136+
c->context.~Global();
137137

138138
/* Dispose yet undisposed weak refs */
139139
for (std::map<zend_object *, v8js_persistent_obj_t>::iterator it = c->weak_objects.begin();
@@ -208,10 +208,10 @@ static zend_object* v8js_new(zend_class_entry *ce) /* {{{ */
208208

209209
c->std.handlers = &v8js_object_handlers;
210210

211-
new(&c->object_name) v8::Persistent<v8::String>();
212-
new(&c->context) v8::Persistent<v8::Context>();
213-
new(&c->global_template) v8::Persistent<v8::FunctionTemplate>();
214-
new(&c->array_tmpl) v8::Persistent<v8::FunctionTemplate>();
211+
new(&c->object_name) v8::Global<v8::String>();
212+
new(&c->context) v8::Global<v8::Context>();
213+
new(&c->global_template) v8::Global<v8::FunctionTemplate>();
214+
new(&c->array_tmpl) v8::Global<v8::FunctionTemplate>();
215215

216216
new(&c->modules_stack) std::vector<char*>();
217217
new(&c->modules_loaded) std::map<char *, v8js_persistent_value_t, cmp_str>;
@@ -541,7 +541,7 @@ static void v8js_compile_script(zval *this_ptr, const zend_string *str, const ze
541541
return;
542542
}
543543
res = (v8js_script *)emalloc(sizeof(v8js_script));
544-
res->script = new v8::Persistent<v8::Script, v8::CopyablePersistentTraits<v8::Script>>(c->isolate, script.ToLocalChecked());
544+
res->script = new v8::Global<v8::Script>(c->isolate, script.ToLocalChecked());
545545

546546
v8::String::Utf8Value _sname(isolate, sname);
547547
res->name = estrndup(ToCString(_sname), _sname.length());

v8js_class.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818

1919
/* Abbreviate long type names */
20-
typedef v8::Persistent<v8::FunctionTemplate, v8::CopyablePersistentTraits<v8::FunctionTemplate> > v8js_function_tmpl_t;
21-
typedef v8::Persistent<v8::ObjectTemplate, v8::CopyablePersistentTraits<v8::ObjectTemplate> > v8js_object_tmpl_t;
22-
typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > v8js_persistent_obj_t;
23-
typedef v8::Persistent<v8::Value, v8::CopyablePersistentTraits<v8::Value> > v8js_persistent_value_t;
20+
typedef v8::Global<v8::FunctionTemplate> v8js_function_tmpl_t;
21+
typedef v8::Global<v8::ObjectTemplate> v8js_object_tmpl_t;
22+
typedef v8::Global<v8::Object> v8js_persistent_obj_t;
23+
typedef v8::Global<v8::Value> v8js_persistent_value_t;
2424

2525
/* Forward declarations */
2626
struct v8js_v8object;
@@ -35,8 +35,8 @@ struct cmp_str {
3535

3636
/* {{{ Context container */
3737
struct v8js_ctx {
38-
v8::Persistent<v8::String> object_name;
39-
v8::Persistent<v8::Context> context;
38+
v8::Global<v8::String> object_name;
39+
v8::Global<v8::Context> context;
4040
int in_execution;
4141
v8::Isolate *isolate;
4242

v8js_methods.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ V8JS_METHOD(require)
405405

406406
// If we have already loaded and cached this module then use it
407407
if (c->modules_loaded.count(normalised_module_id) > 0) {
408-
v8::Persistent<v8::Value> newobj;
408+
v8::Global<v8::Value> newobj;
409409
newobj.Reset(isolate, c->modules_loaded[normalised_module_id]);
410410

411411
// TODO store v8::Global in c->modules_loaded directly!?

v8js_v8object_class.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ static zend_object *v8js_v8object_new(zend_class_entry *ce) /* {{{ */
537537

538538
zend_object_std_init(&c->std, ce);
539539
c->std.handlers = &v8js_v8object_handlers;
540-
new (&c->v8obj) v8::Persistent<v8::Value>();
540+
new (&c->v8obj) v8::Global<v8::Value>();
541541

542542
return &c->std;
543543
}
@@ -624,7 +624,7 @@ static zend_object *v8js_v8generator_new(zend_class_entry *ce) /* {{{ */
624624

625625
zend_object_std_init(&c->v8obj.std, ce);
626626
c->v8obj.std.handlers = &v8js_v8generator_handlers;
627-
new (&c->v8obj.v8obj) v8::Persistent<v8::Value>();
627+
new (&c->v8obj.v8obj) v8::Global<v8::Value>();
628628

629629
return &c->v8obj.std;
630630
}

v8js_v8object_class.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* {{{ Object container */
1818
struct v8js_v8object {
19-
v8::Persistent<v8::Value> v8obj;
19+
v8::Global<v8::Value> v8obj;
2020
int flags;
2121
struct v8js_ctx *ctx;
2222
HashTable *properties;

0 commit comments

Comments
 (0)