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

Side by Side Diff: test/cctest/test-heap.cc

Issue 1268333004: Introduce object visitor to estimate the size of a native context. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix compare Created 5 years, 4 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 | « test/cctest/test-api.cc ('k') | tools/gyp/v8.gyp » ('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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 #include <utility> 29 #include <utility>
30 30
31 #include "src/v8.h" 31 #include "src/v8.h"
32 32
33 #include "src/compilation-cache.h" 33 #include "src/compilation-cache.h"
34 #include "src/context-measure.h"
34 #include "src/deoptimizer.h" 35 #include "src/deoptimizer.h"
35 #include "src/execution.h" 36 #include "src/execution.h"
36 #include "src/factory.h" 37 #include "src/factory.h"
37 #include "src/global-handles.h" 38 #include "src/global-handles.h"
38 #include "src/ic/ic.h" 39 #include "src/ic/ic.h"
39 #include "src/macro-assembler.h" 40 #include "src/macro-assembler.h"
40 #include "src/snapshot/snapshot.h" 41 #include "src/snapshot/snapshot.h"
41 #include "test/cctest/cctest.h" 42 #include "test/cctest/cctest.h"
42 43
43 using namespace v8::internal; 44 using namespace v8::internal;
(...skipping 6217 matching lines...) Expand 10 before | Expand all | Expand 10 after
6261 array->address(), 6262 array->address(),
6262 array->address() + array->Size()); 6263 array->address() + array->Size());
6263 CHECK(reinterpret_cast<void*>(buffer->Get(1)) == 6264 CHECK(reinterpret_cast<void*>(buffer->Get(1)) ==
6264 HeapObject::RawField(heap->empty_fixed_array(), 6265 HeapObject::RawField(heap->empty_fixed_array(),
6265 FixedArrayBase::kLengthOffset)); 6266 FixedArrayBase::kLengthOffset));
6266 CHECK(reinterpret_cast<void*>(buffer->Get(2)) == 6267 CHECK(reinterpret_cast<void*>(buffer->Get(2)) ==
6267 HeapObject::RawField(heap->empty_fixed_array(), 6268 HeapObject::RawField(heap->empty_fixed_array(),
6268 FixedArrayBase::kLengthOffset)); 6269 FixedArrayBase::kLengthOffset));
6269 delete buffer; 6270 delete buffer;
6270 } 6271 }
6272
6273
6274 TEST(ContextMeasure) {
6275 CcTest::InitializeVM();
6276 v8::HandleScope scope(CcTest::isolate());
6277 Isolate* isolate = CcTest::i_isolate();
6278 LocalContext context;
6279
6280 int size_upper_limit = 0;
6281 int count_upper_limit = 0;
6282 HeapIterator it(CcTest::heap());
6283 for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) {
6284 size_upper_limit += obj->Size();
6285 count_upper_limit++;
6286 }
6287
6288 ContextMeasure measure(*isolate->native_context());
6289
6290 PrintF("Context size : %d bytes\n", measure.Size());
6291 PrintF("Context object count: %d\n", measure.Count());
6292
6293 CHECK_LE(1000, measure.Count());
6294 CHECK_LE(50000, measure.Size());
6295
6296 CHECK_LE(measure.Count(), count_upper_limit);
6297 CHECK_LE(measure.Size(), size_upper_limit);
6298 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698