diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-07-20 19:35:24 +0200 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-07-22 11:55:25 -0700 |
commit | 89e4b36e62978f54b2e33b4bce8197072dbe8af1 (patch) | |
tree | dc43dc3491aac3ddc3977612d4fb8f772e7a9592 /src/env.cc | |
parent | 31178994140676417a4ee7d30e7f7e57e73c6873 (diff) | |
download | android-node-v8-89e4b36e62978f54b2e33b4bce8197072dbe8af1.tar.gz android-node-v8-89e4b36e62978f54b2e33b4bce8197072dbe8af1.tar.bz2 android-node-v8-89e4b36e62978f54b2e33b4bce8197072dbe8af1.zip |
src: make `CompiledFnEntry` a `BaseObject`
In particular:
- Move the class definition to the relevant header file,
i.e. `node_contextify.h`.
- Make sure that class instances are destroyed on
`Environment` teardown.
- Make instances of the key object traceable in heap dumps. This is
particularly relevant here because our C++ script → map key mapping
could introduce memory leaks when the import function metadata refers
back to the script in some way.
Refs: https://github.com/nodejs/node/pull/28671
PR-URL: https://github.com/nodejs/node/pull/28782
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/env.cc')
-rw-r--r-- | src/env.cc | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/src/env.cc b/src/env.cc index 38d5796f54..bb78a0c1f3 100644 --- a/src/env.cc +++ b/src/env.cc @@ -39,7 +39,6 @@ using v8::NewStringType; using v8::Number; using v8::Object; using v8::Private; -using v8::ScriptOrModule; using v8::SnapshotCreator; using v8::StackTrace; using v8::String; @@ -47,7 +46,6 @@ using v8::Symbol; using v8::TracingController; using v8::Undefined; using v8::Value; -using v8::WeakCallbackInfo; using worker::Worker; int const Environment::kNodeContextTag = 0x6e6f64; @@ -387,24 +385,6 @@ Environment::Environment(IsolateData* isolate_data, CreateProperties(); } -static void WeakCallbackCompiledFn( - const WeakCallbackInfo<CompiledFnEntry>& data) { - CompiledFnEntry* entry = data.GetParameter(); - entry->env->id_to_function_map.erase(entry->id); - delete entry; -} - -CompiledFnEntry::CompiledFnEntry(Environment* env, - uint32_t id, - Local<ScriptOrModule> script) - : env(env), - id(id), - cache_key(env->isolate(), Object::New(env->isolate())), - script(env->isolate(), script) { - this->script.SetWeak( - this, WeakCallbackCompiledFn, v8::WeakCallbackType::kParameter); -} - Environment::~Environment() { isolate()->GetHeapProfiler()->RemoveBuildEmbedderGraphCallback( BuildEmbedderGraph, this); |