Reviewers: jochen (slow),
Description:
Fix memory leak in natives-external.
(Discovered when landing crrev.com/959693002)
[email protected]
BUG=
Please review this at https://codereview.chromium.org/960883003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+18, -0 lines):
M src/api.cc
M src/natives.h
M src/natives-external.cc
M src/snapshot-empty.cc
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
238c66835d1af1e10c6338f9e3b403a4c19e14fb..daf72e8efa7dc0f8d19af4907c2b8d74a60c3e4f
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -5214,6 +5214,9 @@ void v8::V8::SetArrayBufferAllocator(
bool v8::V8::Dispose() {
i::V8::TearDown();
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ i::DisposeNatives();
+#endif
return true;
}
Index: src/natives-external.cc
diff --git a/src/natives-external.cc b/src/natives-external.cc
index
e601808fe8182055683d32133081b36e46c9938f..109f9c5f47bfe14cf25a69365502ac1ef7993df7
100644
--- a/src/natives-external.cc
+++ b/src/natives-external.cc
@@ -132,6 +132,10 @@ class NativesHolder {
DCHECK(store);
holder_ = store;
}
+ static void Dispose() {
+ DCHECK(holder_);
+ delete holder_;
+ }
private:
static NativesStore* holder_;
@@ -157,6 +161,15 @@ void SetNativesFromFile(StartupData* natives_blob) {
}
+/**
+ * Release memory allocated by SetNativesFromFile.
+ */
+void DisposeNatives() {
+ NativesHolder<CORE>::Dispose();
+ NativesHolder<EXPERIMENTAL>::Dispose();
+}
+
+
// Implement NativesCollection<T> bsaed on NativesHolder + NativesStore.
//
// (The callers expect a purely static interface, since this is how the
Index: src/natives.h
diff --git a/src/natives.h b/src/natives.h
index
7ce7213edf9623d44f6e86c226013d09aaf0b91a..bec7128a1216ab0f16db245029733b4d697bf200
100644
--- a/src/natives.h
+++ b/src/natives.h
@@ -40,6 +40,7 @@ typedef NativesCollection<EXPERIMENTAL>
ExperimentalNatives;
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
// Used for reading the natives at runtime. Implementation in
natives-empty.cc
void SetNativesFromFile(StartupData* natives_blob);
+void DisposeNatives();
#endif
} } // namespace v8::internal
Index: src/snapshot-empty.cc
diff --git a/src/snapshot-empty.cc b/src/snapshot-empty.cc
index
add878fc1af3b35daa16d1fcb4aa5498a392ab30..9817b2b83b768418a46a2d73de242ff3e2245384
100644
--- a/src/snapshot-empty.cc
+++ b/src/snapshot-empty.cc
@@ -19,6 +19,7 @@ namespace internal {
// below. This happens when compiling the mksnapshot utility.
void SetNativesFromFile(StartupData* data) { CHECK(false); }
void SetSnapshotFromFile(StartupData* data) { CHECK(false); }
+void DisposeNatives() {}
#endif // V8_USE_EXTERNAL_STARTUP_DATA
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.