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

Unified Diff: test/cctest/test-heap.cc

Issue 1300333003: Introduce SharedFunctionInfo::Iterator and Script::Iterator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index f0ba4c1c04d429d55ce00f06c29e61381697d2e6..48ec24b3581d090bf1b8c1ea4042c1393679ee0a 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -6440,5 +6440,67 @@ TEST(ContextMeasure) {
CHECK_LE(measure.Size(), size_upper_limit);
}
+
+TEST(ScriptIterator) {
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Isolate* isolate = CcTest::i_isolate();
+ Heap* heap = CcTest::heap();
+ LocalContext context;
+
+ heap->CollectAllGarbage();
+
+ int script_count = 0;
+ {
+ HeapIterator it(heap);
+ for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) {
+ if (obj->IsScript()) script_count++;
+ }
+ }
+
+ {
+ Script::Iterator iterator(isolate);
+ while (iterator.Next()) script_count--;
+ }
+
+ CHECK_EQ(0, script_count);
+}
+
+
+TEST(SharedFunctionInfoIterator) {
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Isolate* isolate = CcTest::i_isolate();
+ Heap* heap = CcTest::heap();
+ LocalContext context;
+
+ heap->CollectAllGarbage();
+ heap->CollectAllGarbage();
+
+ int sfi_count = 0;
+ {
+ HeapIterator it(heap);
+ for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) {
+ if (!obj->IsSharedFunctionInfo()) continue;
+ // Shared function infos without a script (API functions or C++ builtins)
+ // are not returned by the iterator because they are not created from a
+ // script. They are not interesting for type feedback vector anyways.
+ SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj);
+ if (shared->script()->IsUndefined()) {
+ CHECK_EQ(0, shared->feedback_vector()->ICSlots());
+ } else {
+ sfi_count++;
+ }
+ }
+ }
+
+ {
+ SharedFunctionInfo::Iterator iterator(isolate);
+ while (iterator.Next()) sfi_count--;
+ }
+
+ CHECK_EQ(0, sfi_count);
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698