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

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapTest.cpp

Issue 1650123002: Keep (Heap)TerminatedArray in a consistent state while building. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add assert Created 4 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/TerminatedArrayBuilder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 4325 matching lines...) Expand 10 before | Expand all | Expand 10 after
4336 IntWrapper::s_destructorCalls = 0; 4336 IntWrapper::s_destructorCalls = 0;
4337 4337
4338 HeapTerminatedArray<TerminatedArrayItem>* arr = 0; 4338 HeapTerminatedArray<TerminatedArrayItem>* arr = 0;
4339 4339
4340 const size_t prefixSize = 4; 4340 const size_t prefixSize = 4;
4341 const size_t suffixSize = 4; 4341 const size_t suffixSize = 4;
4342 4342
4343 { 4343 {
4344 HeapTerminatedArrayBuilder<TerminatedArrayItem> builder(arr); 4344 HeapTerminatedArrayBuilder<TerminatedArrayItem> builder(arr);
4345 builder.grow(prefixSize); 4345 builder.grow(prefixSize);
4346 conservativelyCollectGarbage();
4346 for (size_t i = 0; i < prefixSize; i++) 4347 for (size_t i = 0; i < prefixSize; i++)
4347 builder.append(TerminatedArrayItem(IntWrapper::create(i))); 4348 builder.append(TerminatedArrayItem(IntWrapper::create(i)));
4348 arr = builder.release(); 4349 arr = builder.release();
4349 } 4350 }
4350 4351
4351 conservativelyCollectGarbage(); 4352 conservativelyCollectGarbage();
4352 EXPECT_EQ(0, IntWrapper::s_destructorCalls); 4353 EXPECT_EQ(0, IntWrapper::s_destructorCalls);
4353 EXPECT_EQ(prefixSize, arr->size()); 4354 EXPECT_EQ(prefixSize, arr->size());
4354 for (size_t i = 0; i < prefixSize; i++) 4355 for (size_t i = 0; i < prefixSize; i++)
4355 EXPECT_EQ(i, static_cast<size_t>(arr->at(i).payload()->value())); 4356 EXPECT_EQ(i, static_cast<size_t>(arr->at(i).payload()->value()));
(...skipping 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after
6524 EXPECT_EQ(1u, vector2.size()); 6525 EXPECT_EQ(1u, vector2.size());
6525 // TODO(Oilpan): when Vector.h's contiguous container support no longer disables 6526 // TODO(Oilpan): when Vector.h's contiguous container support no longer disables
6526 // Vector<>s with inline capacity, remove. 6527 // Vector<>s with inline capacity, remove.
6527 #if !defined(ANNOTATE_CONTIGUOUS_CONTAINER) 6528 #if !defined(ANNOTATE_CONTIGUOUS_CONTAINER)
6528 EXPECT_EQ(16u, vector1.capacity()); 6529 EXPECT_EQ(16u, vector1.capacity());
6529 EXPECT_EQ(16u, vector2.capacity()); 6530 EXPECT_EQ(16u, vector2.capacity());
6530 #endif 6531 #endif
6531 } 6532 }
6532 6533
6533 } // namespace blink 6534 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/TerminatedArrayBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698