diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2020-04-19 22:51:05 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-05-06 07:44:04 +0300 |
commit | 86fdaa745572a3bec4370ac7bd05d18e6bf64c01 (patch) | |
tree | 45890dbc713ad29edd830fd2aa17f592909ccbb7 /src/env.cc | |
parent | f446b2058dcfaf9d4e2f6bdfe555bc4437f41acf (diff) |
src: retrieve binding data from the context
Instead of passing them through the data bound to function
templates, store references to them in a list embedded inside
the context.
This makes the function templates more context-independent,
and makes it possible to embed binding data in non-main contexts.
Co-authored-by: Anna Henningsen <anna@addaleax.net>
PR-URL: https://github.com/nodejs/node/pull/33139
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/env.cc')
-rw-r--r-- | src/env.cc | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/env.cc b/src/env.cc index f966bfba1ee..3efa5c3b9c9 100644 --- a/src/env.cc +++ b/src/env.cc @@ -261,29 +261,17 @@ void TrackingTraceStateObserver::UpdateTraceCategoryState() { USE(cb->Call(env_->context(), Undefined(isolate), arraysize(args), args)); } -class NoBindingData : public BaseObject { - public: - NoBindingData(Environment* env, Local<Object> obj) : BaseObject(env, obj) {} - - SET_NO_MEMORY_INFO() - SET_MEMORY_INFO_NAME(NoBindingData) - SET_SELF_SIZE(NoBindingData) -}; - void Environment::CreateProperties() { HandleScope handle_scope(isolate_); Local<Context> ctx = context(); + { Context::Scope context_scope(ctx); Local<FunctionTemplate> templ = FunctionTemplate::New(isolate()); templ->InstanceTemplate()->SetInternalFieldCount( BaseObject::kInternalFieldCount); - set_as_callback_data_template(templ); - Local<Object> obj = MakeBindingCallbackData<NoBindingData>() - .ToLocalChecked(); - set_as_callback_data(obj); - set_current_callback_data(obj); + set_binding_data_ctor_template(templ); } // Store primordials setup by the per-context script in the environment. @@ -674,6 +662,8 @@ void Environment::RunCleanup() { started_cleanup_ = true; TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment), "RunCleanup", this); + bindings_.clear(); + initial_base_object_count_ = 0; CleanupHandles(); while (!cleanup_hooks_.empty()) { |