Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: src/elements.cc

Issue 9836109: Valgrind cleanliness, part 3: Delete elements accessors on exit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/elements.h ('k') | src/v8.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 case EXTERNAL_PIXEL_ARRAY_TYPE: 1319 case EXTERNAL_PIXEL_ARRAY_TYPE:
1320 return elements_accessors_[EXTERNAL_PIXEL_ELEMENTS]; 1320 return elements_accessors_[EXTERNAL_PIXEL_ELEMENTS];
1321 default: 1321 default:
1322 UNREACHABLE(); 1322 UNREACHABLE();
1323 return NULL; 1323 return NULL;
1324 } 1324 }
1325 } 1325 }
1326 1326
1327 1327
1328 void ElementsAccessor::InitializeOncePerProcess() { 1328 void ElementsAccessor::InitializeOncePerProcess() {
1329 static struct ConcreteElementsAccessors {
1330 #define ACCESSOR_STRUCT(Class, Kind, Store) Class* Kind##_handler;
1331 ELEMENTS_LIST(ACCESSOR_STRUCT)
1332 #undef ACCESSOR_STRUCT
1333 } element_accessors = {
1334 #define ACCESSOR_INIT(Class, Kind, Store) new Class(#Kind),
1335 ELEMENTS_LIST(ACCESSOR_INIT)
1336 #undef ACCESSOR_INIT
1337 };
1338
1339 static ElementsAccessor* accessor_array[] = { 1329 static ElementsAccessor* accessor_array[] = {
1340 #define ACCESSOR_ARRAY(Class, Kind, Store) element_accessors.Kind##_handler, 1330 #define ACCESSOR_ARRAY(Class, Kind, Store) new Class(#Kind),
1341 ELEMENTS_LIST(ACCESSOR_ARRAY) 1331 ELEMENTS_LIST(ACCESSOR_ARRAY)
1342 #undef ACCESSOR_ARRAY 1332 #undef ACCESSOR_ARRAY
1343 }; 1333 };
1344 1334
1345 STATIC_ASSERT((sizeof(accessor_array) / sizeof(*accessor_array)) == 1335 STATIC_ASSERT((sizeof(accessor_array) / sizeof(*accessor_array)) ==
1346 kElementsKindCount); 1336 kElementsKindCount);
1347 1337
1348 elements_accessors_ = accessor_array; 1338 elements_accessors_ = accessor_array;
1349 } 1339 }
1350 1340
1351 1341
1342 void ElementsAccessor::TearDown() {
1343 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind];
1344 ELEMENTS_LIST(ACCESSOR_DELETE)
1345 #undef ACCESSOR_DELETE
1346 elements_accessors_ = NULL;
1347 }
1348
1349
1352 template <typename ElementsAccessorSubclass, typename ElementsKindTraits> 1350 template <typename ElementsAccessorSubclass, typename ElementsKindTraits>
1353 MaybeObject* ElementsAccessorBase<ElementsAccessorSubclass, 1351 MaybeObject* ElementsAccessorBase<ElementsAccessorSubclass,
1354 ElementsKindTraits>:: 1352 ElementsKindTraits>::
1355 SetLengthImpl(JSObject* obj, 1353 SetLengthImpl(JSObject* obj,
1356 Object* length, 1354 Object* length,
1357 typename ElementsKindTraits::BackingStore* backing_store) { 1355 typename ElementsKindTraits::BackingStore* backing_store) {
1358 JSArray* array = JSArray::cast(obj); 1356 JSArray* array = JSArray::cast(obj);
1359 1357
1360 // Fast case: The new length fits into a Smi. 1358 // Fast case: The new length fits into a Smi.
1361 MaybeObject* maybe_smi_length = length->ToSmi(); 1359 MaybeObject* maybe_smi_length = length->ToSmi();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; 1402 if (!maybe_obj->To(&new_backing_store)) return maybe_obj;
1405 new_backing_store->set(0, length); 1403 new_backing_store->set(0, length);
1406 { MaybeObject* result = array->SetContent(new_backing_store); 1404 { MaybeObject* result = array->SetContent(new_backing_store);
1407 if (result->IsFailure()) return result; 1405 if (result->IsFailure()) return result;
1408 } 1406 }
1409 return array; 1407 return array;
1410 } 1408 }
1411 1409
1412 1410
1413 } } // namespace v8::internal 1411 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/elements.h ('k') | src/v8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698