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

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

Issue 1156463002: Pass GC flags to incremental marker and start incremental marking with (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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/cctest.h ('k') | no next file » | 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 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 "function mkbar () { return new (new Function(\"\")) (); }" 2122 "function mkbar () { return new (new Function(\"\")) (); }"
2123 "function f (x) { return (x instanceof foo); }" 2123 "function f (x) { return (x instanceof foo); }"
2124 "function g () { f(mkbar()); }" 2124 "function g () { f(mkbar()); }"
2125 "f(new foo()); f(new foo());" 2125 "f(new foo()); f(new foo());"
2126 "%OptimizeFunctionOnNextCall(f);" 2126 "%OptimizeFunctionOnNextCall(f);"
2127 "f(new foo()); g();"); 2127 "f(new foo()); g();");
2128 } 2128 }
2129 2129
2130 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 2130 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
2131 marking->Abort(); 2131 marking->Abort();
2132 marking->Start(); 2132 marking->Start(Heap::kNoGCFlags);
2133 2133
2134 Handle<JSFunction> f = 2134 Handle<JSFunction> f =
2135 v8::Utils::OpenHandle( 2135 v8::Utils::OpenHandle(
2136 *v8::Handle<v8::Function>::Cast( 2136 *v8::Handle<v8::Function>::Cast(
2137 CcTest::global()->Get(v8_str("f")))); 2137 CcTest::global()->Get(v8_str("f"))));
2138 2138
2139 CHECK(f->IsOptimized()); 2139 CHECK(f->IsOptimized());
2140 2140
2141 while (!Marking::IsBlack(Marking::MarkBitFrom(f->code())) && 2141 while (!Marking::IsBlack(Marking::MarkBitFrom(f->code())) &&
2142 !marking->IsStopped()) { 2142 !marking->IsStopped()) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 "f();"); 2248 "f();");
2249 } 2249 }
2250 Handle<JSFunction> f = 2250 Handle<JSFunction> f =
2251 v8::Utils::OpenHandle( 2251 v8::Utils::OpenHandle(
2252 *v8::Handle<v8::Function>::Cast( 2252 *v8::Handle<v8::Function>::Cast(
2253 CcTest::global()->Get(v8_str("f")))); 2253 CcTest::global()->Get(v8_str("f"))));
2254 CHECK(f->IsOptimized()); 2254 CHECK(f->IsOptimized());
2255 2255
2256 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 2256 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
2257 marking->Abort(); 2257 marking->Abort();
2258 marking->Start(); 2258 marking->Start(Heap::kNoGCFlags);
2259 // The following calls will increment CcTest::heap()->global_ic_age(). 2259 // The following calls will increment CcTest::heap()->global_ic_age().
2260 CcTest::isolate()->ContextDisposedNotification(); 2260 CcTest::isolate()->ContextDisposedNotification();
2261 SimulateIncrementalMarking(CcTest::heap()); 2261 SimulateIncrementalMarking(CcTest::heap());
2262 CcTest::heap()->CollectAllGarbage(); 2262 CcTest::heap()->CollectAllGarbage();
2263 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); 2263 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age());
2264 CHECK_EQ(0, f->shared()->opt_count()); 2264 CHECK_EQ(0, f->shared()->opt_count());
2265 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); 2265 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2266 } 2266 }
2267 2267
2268 2268
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); 2306 CHECK_EQ(0, f->shared()->code()->profiler_ticks());
2307 } 2307 }
2308 2308
2309 2309
2310 TEST(IdleNotificationFinishMarking) { 2310 TEST(IdleNotificationFinishMarking) {
2311 i::FLAG_allow_natives_syntax = true; 2311 i::FLAG_allow_natives_syntax = true;
2312 CcTest::InitializeVM(); 2312 CcTest::InitializeVM();
2313 SimulateFullSpace(CcTest::heap()->old_space()); 2313 SimulateFullSpace(CcTest::heap()->old_space());
2314 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 2314 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
2315 marking->Abort(); 2315 marking->Abort();
2316 marking->Start(); 2316 marking->Start(Heap::kNoGCFlags);
2317 2317
2318 CHECK_EQ(CcTest::heap()->gc_count(), 0); 2318 CHECK_EQ(CcTest::heap()->gc_count(), 0);
2319 2319
2320 // TODO(hpayer): We cannot write proper unit test right now for heap. 2320 // TODO(hpayer): We cannot write proper unit test right now for heap.
2321 // The ideal test would call kMaxIdleMarkingDelayCounter to test the 2321 // The ideal test would call kMaxIdleMarkingDelayCounter to test the
2322 // marking delay counter. 2322 // marking delay counter.
2323 2323
2324 // Perform a huge incremental marking step but don't complete marking. 2324 // Perform a huge incremental marking step but don't complete marking.
2325 intptr_t bytes_processed = 0; 2325 intptr_t bytes_processed = 0;
2326 do { 2326 do {
(...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after
4116 4116
4117 TEST(IncrementalMarkingStepMakesBigProgressWithLargeObjects) { 4117 TEST(IncrementalMarkingStepMakesBigProgressWithLargeObjects) {
4118 CcTest::InitializeVM(); 4118 CcTest::InitializeVM();
4119 v8::HandleScope scope(CcTest::isolate()); 4119 v8::HandleScope scope(CcTest::isolate());
4120 CompileRun("function f(n) {" 4120 CompileRun("function f(n) {"
4121 " var a = new Array(n);" 4121 " var a = new Array(n);"
4122 " for (var i = 0; i < n; i += 100) a[i] = i;" 4122 " for (var i = 0; i < n; i += 100) a[i] = i;"
4123 "};" 4123 "};"
4124 "f(10 * 1024 * 1024);"); 4124 "f(10 * 1024 * 1024);");
4125 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 4125 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
4126 if (marking->IsStopped()) marking->Start(); 4126 if (marking->IsStopped()) marking->Start(Heap::kNoGCFlags);
4127 // This big step should be sufficient to mark the whole array. 4127 // This big step should be sufficient to mark the whole array.
4128 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 4128 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
4129 DCHECK(marking->IsComplete() || 4129 DCHECK(marking->IsComplete() ||
4130 marking->IsReadyToOverApproximateWeakClosure()); 4130 marking->IsReadyToOverApproximateWeakClosure());
4131 } 4131 }
4132 4132
4133 4133
4134 TEST(DisableInlineAllocation) { 4134 TEST(DisableInlineAllocation) {
4135 i::FLAG_allow_natives_syntax = true; 4135 i::FLAG_allow_natives_syntax = true;
4136 CcTest::InitializeVM(); 4136 CcTest::InitializeVM();
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
4844 Handle<FixedArray> survivor = factory->NewFixedArray(1, NOT_TENURED); 4844 Handle<FixedArray> survivor = factory->NewFixedArray(1, NOT_TENURED);
4845 Handle<WeakCell> weak_cells[N]; 4845 Handle<WeakCell> weak_cells[N];
4846 4846
4847 for (int i = 0; i < N; i++) { 4847 for (int i = 0; i < N; i++) {
4848 HandleScope inner_scope(isolate); 4848 HandleScope inner_scope(isolate);
4849 Handle<HeapObject> value = 4849 Handle<HeapObject> value =
4850 i == 0 ? survivor : factory->NewFixedArray(1, NOT_TENURED); 4850 i == 0 ? survivor : factory->NewFixedArray(1, NOT_TENURED);
4851 Handle<WeakCell> weak_cell = factory->NewWeakCell(value); 4851 Handle<WeakCell> weak_cell = factory->NewWeakCell(value);
4852 CHECK(weak_cell->value()->IsFixedArray()); 4852 CHECK(weak_cell->value()->IsFixedArray());
4853 IncrementalMarking* marking = heap->incremental_marking(); 4853 IncrementalMarking* marking = heap->incremental_marking();
4854 if (marking->IsStopped()) marking->Start(); 4854 if (marking->IsStopped()) marking->Start(Heap::kNoGCFlags);
4855 marking->Step(128, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 4855 marking->Step(128, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
4856 heap->CollectGarbage(NEW_SPACE); 4856 heap->CollectGarbage(NEW_SPACE);
4857 CHECK(weak_cell->value()->IsFixedArray()); 4857 CHECK(weak_cell->value()->IsFixedArray());
4858 weak_cells[i] = inner_scope.CloseAndEscape(weak_cell); 4858 weak_cells[i] = inner_scope.CloseAndEscape(weak_cell);
4859 } 4859 }
4860 heap->CollectAllGarbage(); 4860 heap->CollectAllGarbage();
4861 CHECK_EQ(*survivor, weak_cells[0]->value()); 4861 CHECK_EQ(*survivor, weak_cells[0]->value());
4862 for (int i = 1; i < N; i++) { 4862 for (int i = 1; i < N; i++) {
4863 CHECK(weak_cells[i]->cleared()); 4863 CHECK(weak_cells[i]->cleared());
4864 } 4864 }
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
5112 // Ensure that the object allocated where we need it. 5112 // Ensure that the object allocated where we need it.
5113 Page* page = Page::FromAddress(o->address()); 5113 Page* page = Page::FromAddress(o->address());
5114 CHECK_EQ(desired_offset, page->Offset(o->address())); 5114 CHECK_EQ(desired_offset, page->Offset(o->address()));
5115 5115
5116 // Now we have an object right at the end of the page. 5116 // Now we have an object right at the end of the page.
5117 5117
5118 // Enable incremental marking to trigger actions in Heap::AdjustLiveBytes() 5118 // Enable incremental marking to trigger actions in Heap::AdjustLiveBytes()
5119 // that would cause crash. 5119 // that would cause crash.
5120 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 5120 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
5121 marking->Abort(); 5121 marking->Abort();
5122 marking->Start(); 5122 marking->Start(Heap::kNoGCFlags);
5123 CHECK(marking->IsMarking()); 5123 CHECK(marking->IsMarking());
5124 5124
5125 // Now everything is set up for crashing in JSObject::MigrateFastToFast() 5125 // Now everything is set up for crashing in JSObject::MigrateFastToFast()
5126 // when it calls heap->AdjustLiveBytes(...). 5126 // when it calls heap->AdjustLiveBytes(...).
5127 JSObject::MigrateToMap(o, map2); 5127 JSObject::MigrateToMap(o, map2);
5128 } 5128 }
5129 5129
5130 5130
5131 TEST(Regress3631) { 5131 TEST(Regress3631) {
5132 i::FLAG_expose_gc = true; 5132 i::FLAG_expose_gc = true;
5133 CcTest::InitializeVM(); 5133 CcTest::InitializeVM();
5134 v8::HandleScope scope(CcTest::isolate()); 5134 v8::HandleScope scope(CcTest::isolate());
5135 Isolate* isolate = CcTest::i_isolate(); 5135 Isolate* isolate = CcTest::i_isolate();
5136 Heap* heap = isolate->heap(); 5136 Heap* heap = isolate->heap();
5137 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); 5137 IncrementalMarking* marking = CcTest::heap()->incremental_marking();
5138 v8::Local<v8::Value> result = CompileRun( 5138 v8::Local<v8::Value> result = CompileRun(
5139 "var weak_map = new WeakMap();" 5139 "var weak_map = new WeakMap();"
5140 "var future_keys = [];" 5140 "var future_keys = [];"
5141 "for (var i = 0; i < 50; i++) {" 5141 "for (var i = 0; i < 50; i++) {"
5142 " var key = {'k' : i + 0.1};" 5142 " var key = {'k' : i + 0.1};"
5143 " weak_map.set(key, 1);" 5143 " weak_map.set(key, 1);"
5144 " future_keys.push({'x' : i + 0.2});" 5144 " future_keys.push({'x' : i + 0.2});"
5145 "}" 5145 "}"
5146 "weak_map"); 5146 "weak_map");
5147 if (marking->IsStopped()) { 5147 if (marking->IsStopped()) {
5148 marking->Start(); 5148 marking->Start(Heap::kNoGCFlags);
5149 } 5149 }
5150 // Incrementally mark the backing store. 5150 // Incrementally mark the backing store.
5151 Handle<JSObject> obj = 5151 Handle<JSObject> obj =
5152 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); 5152 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result));
5153 Handle<JSWeakCollection> weak_map(reinterpret_cast<JSWeakCollection*>(*obj)); 5153 Handle<JSWeakCollection> weak_map(reinterpret_cast<JSWeakCollection*>(*obj));
5154 while (!Marking::IsBlack( 5154 while (!Marking::IsBlack(
5155 Marking::MarkBitFrom(HeapObject::cast(weak_map->table()))) && 5155 Marking::MarkBitFrom(HeapObject::cast(weak_map->table()))) &&
5156 !marking->IsStopped()) { 5156 !marking->IsStopped()) {
5157 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 5157 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
5158 } 5158 }
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
5551 size_t counter2 = 2000; 5551 size_t counter2 = 2000;
5552 tracer->SampleNewSpaceAllocation(time2, counter2); 5552 tracer->SampleNewSpaceAllocation(time2, counter2);
5553 size_t bytes = tracer->NewSpaceAllocatedBytesInLast(1000); 5553 size_t bytes = tracer->NewSpaceAllocatedBytesInLast(1000);
5554 CHECK_EQ(0, bytes); 5554 CHECK_EQ(0, bytes);
5555 int time3 = 1000; 5555 int time3 = 1000;
5556 size_t counter3 = 30000; 5556 size_t counter3 = 30000;
5557 tracer->SampleNewSpaceAllocation(time3, counter3); 5557 tracer->SampleNewSpaceAllocation(time3, counter3);
5558 bytes = tracer->NewSpaceAllocatedBytesInLast(100); 5558 bytes = tracer->NewSpaceAllocatedBytesInLast(100);
5559 CHECK_EQ((counter3 - counter1) * 100 / (time3 - time1), bytes); 5559 CHECK_EQ((counter3 - counter1) * 100 / (time3 - time1), bytes);
5560 } 5560 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698