Valgrind cleanliness, part 3: Delete elements accessors on exit.

This fixes 15 leaks, returning 132 bytes of lost memory.

As an additional bonus, elements accessors initialization has bee simplified a bit.

Review URL: https://chromiumcodereview.appspot.com/9836109

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11154 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 057371da
......@@ -1326,18 +1326,8 @@ ElementsAccessor* ElementsAccessor::ForArray(FixedArrayBase* array) {
void ElementsAccessor::InitializeOncePerProcess() {
static struct ConcreteElementsAccessors {
#define ACCESSOR_STRUCT(Class, Kind, Store) Class* Kind##_handler;
ELEMENTS_LIST(ACCESSOR_STRUCT)
#undef ACCESSOR_STRUCT
} element_accessors = {
#define ACCESSOR_INIT(Class, Kind, Store) new Class(#Kind),
ELEMENTS_LIST(ACCESSOR_INIT)
#undef ACCESSOR_INIT
};
static ElementsAccessor* accessor_array[] = {
#define ACCESSOR_ARRAY(Class, Kind, Store) element_accessors.Kind##_handler,
#define ACCESSOR_ARRAY(Class, Kind, Store) new Class(#Kind),
ELEMENTS_LIST(ACCESSOR_ARRAY)
#undef ACCESSOR_ARRAY
};
......@@ -1349,6 +1339,14 @@ void ElementsAccessor::InitializeOncePerProcess() {
}
void ElementsAccessor::TearDown() {
#define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind];
ELEMENTS_LIST(ACCESSOR_DELETE)
#undef ACCESSOR_DELETE
elements_accessors_ = NULL;
}
template <typename ElementsAccessorSubclass, typename ElementsKindTraits>
MaybeObject* ElementsAccessorBase<ElementsAccessorSubclass,
ElementsKindTraits>::
......
......@@ -131,6 +131,7 @@ class ElementsAccessor {
static ElementsAccessor* ForArray(FixedArrayBase* array);
static void InitializeOncePerProcess();
static void TearDown();
protected:
friend class NonStrictArgumentsElementsAccessor;
......
......@@ -104,6 +104,8 @@ void V8::TearDown() {
if (!has_been_set_up_ || has_been_disposed_) return;
ElementsAccessor::TearDown();
isolate->TearDown();
delete isolate;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment