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

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

Issue 9608006: Add kAbortIncrementalMarkingMask flag for GC. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Ulan Degenbaev. Created 8 years, 9 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/runtime.cc ('k') | test/cctest/test-deoptimization.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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 &dispose_count)); 443 &dispose_count));
444 CHECK(success); 444 CHECK(success);
445 Local<Script> script = Script::Compile(source); 445 Local<Script> script = Script::Compile(source);
446 Local<Value> value = script->Run(); 446 Local<Value> value = script->Run();
447 CHECK(value->IsNumber()); 447 CHECK(value->IsNumber());
448 CHECK_EQ(7, value->Int32Value()); 448 CHECK_EQ(7, value->Int32Value());
449 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 449 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
450 CHECK_EQ(0, dispose_count); 450 CHECK_EQ(0, dispose_count);
451 } 451 }
452 i::Isolate::Current()->compilation_cache()->Clear(); 452 i::Isolate::Current()->compilation_cache()->Clear();
453 // TODO(1608): This should use kAbortIncrementalMarking. 453 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
454 HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
455 CHECK_EQ(1, dispose_count); 454 CHECK_EQ(1, dispose_count);
456 } 455 }
457 456
458 457
459 THREADED_TEST(ScriptMakingExternalAsciiString) { 458 THREADED_TEST(ScriptMakingExternalAsciiString) {
460 int dispose_count = 0; 459 int dispose_count = 0;
461 const char* c_source = "1 + 2 * 3"; 460 const char* c_source = "1 + 2 * 3";
462 { 461 {
463 v8::HandleScope scope; 462 v8::HandleScope scope;
464 LocalContext env; 463 LocalContext env;
465 Local<String> source = v8_str(c_source); 464 Local<String> source = v8_str(c_source);
466 // Trigger GCs so that the newly allocated string moves to old gen. 465 // Trigger GCs so that the newly allocated string moves to old gen.
467 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now 466 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
468 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now 467 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
469 bool success = source->MakeExternal( 468 bool success = source->MakeExternal(
470 new TestAsciiResource(i::StrDup(c_source), &dispose_count)); 469 new TestAsciiResource(i::StrDup(c_source), &dispose_count));
471 CHECK(success); 470 CHECK(success);
472 Local<Script> script = Script::Compile(source); 471 Local<Script> script = Script::Compile(source);
473 Local<Value> value = script->Run(); 472 Local<Value> value = script->Run();
474 CHECK(value->IsNumber()); 473 CHECK(value->IsNumber());
475 CHECK_EQ(7, value->Int32Value()); 474 CHECK_EQ(7, value->Int32Value());
476 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 475 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
477 CHECK_EQ(0, dispose_count); 476 CHECK_EQ(0, dispose_count);
478 } 477 }
479 i::Isolate::Current()->compilation_cache()->Clear(); 478 i::Isolate::Current()->compilation_cache()->Clear();
480 // TODO(1608): This should use kAbortIncrementalMarking. 479 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
481 HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
482 CHECK_EQ(1, dispose_count); 480 CHECK_EQ(1, dispose_count);
483 } 481 }
484 482
485 483
486 TEST(MakingExternalStringConditions) { 484 TEST(MakingExternalStringConditions) {
487 v8::HandleScope scope; 485 v8::HandleScope scope;
488 LocalContext env; 486 LocalContext env;
489 487
490 // Free some space in the new space so that we can check freshness. 488 // Free some space in the new space so that we can check freshness.
491 HEAP->CollectGarbage(i::NEW_SPACE); 489 HEAP->CollectGarbage(i::NEW_SPACE);
(...skipping 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 { 2244 {
2247 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; 2245 Persistent<Value> g1_objects[] = { g1s1, g1s2 };
2248 Persistent<Value> g1_children[] = { g1c1 }; 2246 Persistent<Value> g1_children[] = { g1c1 };
2249 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; 2247 Persistent<Value> g2_objects[] = { g2s1, g2s2 };
2250 Persistent<Value> g2_children[] = { g2c1 }; 2248 Persistent<Value> g2_children[] = { g2c1 };
2251 V8::AddObjectGroup(g1_objects, 2); 2249 V8::AddObjectGroup(g1_objects, 2);
2252 V8::AddImplicitReferences(g1s1, g1_children, 1); 2250 V8::AddImplicitReferences(g1s1, g1_children, 1);
2253 V8::AddObjectGroup(g2_objects, 2); 2251 V8::AddObjectGroup(g2_objects, 2);
2254 V8::AddImplicitReferences(g2s2, g2_children, 1); 2252 V8::AddImplicitReferences(g2s2, g2_children, 1);
2255 } 2253 }
2256 // Do a single full GC. Use kMakeHeapIterableMask to ensure that 2254 // Do a single full GC, ensure incremental marking is stopped.
2257 // incremental garbage collection is stopped. 2255 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
2258 HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
2259 2256
2260 // All object should be alive. 2257 // All object should be alive.
2261 CHECK_EQ(0, counter.NumberOfWeakCalls()); 2258 CHECK_EQ(0, counter.NumberOfWeakCalls());
2262 2259
2263 // Weaken the root. 2260 // Weaken the root.
2264 root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); 2261 root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
2265 // But make children strong roots---all the objects (except for children) 2262 // But make children strong roots---all the objects (except for children)
2266 // should be collectable now. 2263 // should be collectable now.
2267 g1c1.ClearWeak(); 2264 g1c1.ClearWeak();
2268 g2c1.ClearWeak(); 2265 g2c1.ClearWeak();
2269 2266
2270 // Groups are deleted, rebuild groups. 2267 // Groups are deleted, rebuild groups.
2271 { 2268 {
2272 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; 2269 Persistent<Value> g1_objects[] = { g1s1, g1s2 };
2273 Persistent<Value> g1_children[] = { g1c1 }; 2270 Persistent<Value> g1_children[] = { g1c1 };
2274 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; 2271 Persistent<Value> g2_objects[] = { g2s1, g2s2 };
2275 Persistent<Value> g2_children[] = { g2c1 }; 2272 Persistent<Value> g2_children[] = { g2c1 };
2276 V8::AddObjectGroup(g1_objects, 2); 2273 V8::AddObjectGroup(g1_objects, 2);
2277 V8::AddImplicitReferences(g1s1, g1_children, 1); 2274 V8::AddImplicitReferences(g1s1, g1_children, 1);
2278 V8::AddObjectGroup(g2_objects, 2); 2275 V8::AddObjectGroup(g2_objects, 2);
2279 V8::AddImplicitReferences(g2s2, g2_children, 1); 2276 V8::AddImplicitReferences(g2s2, g2_children, 1);
2280 } 2277 }
2281 2278
2282 HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); 2279 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
2283 2280
2284 // All objects should be gone. 5 global handles in total. 2281 // All objects should be gone. 5 global handles in total.
2285 CHECK_EQ(5, counter.NumberOfWeakCalls()); 2282 CHECK_EQ(5, counter.NumberOfWeakCalls());
2286 2283
2287 // And now make children weak again and collect them. 2284 // And now make children weak again and collect them.
2288 g1c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); 2285 g1c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
2289 g2c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); 2286 g2c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
2290 2287
2291 HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); 2288 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
2292 CHECK_EQ(7, counter.NumberOfWeakCalls()); 2289 CHECK_EQ(7, counter.NumberOfWeakCalls());
2293 } 2290 }
2294 2291
2295 2292
2296 THREADED_TEST(ApiObjectGroupsCycle) { 2293 THREADED_TEST(ApiObjectGroupsCycle) {
2297 HandleScope scope; 2294 HandleScope scope;
2298 LocalContext env; 2295 LocalContext env;
2299 2296
2300 WeakCallCounter counter(1234); 2297 WeakCallCounter counter(1234);
2301 2298
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2337 Persistent<Value> g3_objects[] = { g3s1, g3s2 }; 2334 Persistent<Value> g3_objects[] = { g3s1, g3s2 };
2338 Persistent<Value> g3_children[] = { g1s1 }; 2335 Persistent<Value> g3_children[] = { g1s1 };
2339 V8::AddObjectGroup(g1_objects, 2); 2336 V8::AddObjectGroup(g1_objects, 2);
2340 V8::AddImplicitReferences(g1s1, g1_children, 1); 2337 V8::AddImplicitReferences(g1s1, g1_children, 1);
2341 V8::AddObjectGroup(g2_objects, 2); 2338 V8::AddObjectGroup(g2_objects, 2);
2342 V8::AddImplicitReferences(g2s1, g2_children, 1); 2339 V8::AddImplicitReferences(g2s1, g2_children, 1);
2343 V8::AddObjectGroup(g3_objects, 2); 2340 V8::AddObjectGroup(g3_objects, 2);
2344 V8::AddImplicitReferences(g3s1, g3_children, 1); 2341 V8::AddImplicitReferences(g3s1, g3_children, 1);
2345 } 2342 }
2346 // Do a single full GC 2343 // Do a single full GC
2347 HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); 2344 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
2348 2345
2349 // All object should be alive. 2346 // All object should be alive.
2350 CHECK_EQ(0, counter.NumberOfWeakCalls()); 2347 CHECK_EQ(0, counter.NumberOfWeakCalls());
2351 2348
2352 // Weaken the root. 2349 // Weaken the root.
2353 root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); 2350 root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
2354 2351
2355 // Groups are deleted, rebuild groups. 2352 // Groups are deleted, rebuild groups.
2356 { 2353 {
2357 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; 2354 Persistent<Value> g1_objects[] = { g1s1, g1s2 };
2358 Persistent<Value> g1_children[] = { g2s1 }; 2355 Persistent<Value> g1_children[] = { g2s1 };
2359 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; 2356 Persistent<Value> g2_objects[] = { g2s1, g2s2 };
2360 Persistent<Value> g2_children[] = { g3s1 }; 2357 Persistent<Value> g2_children[] = { g3s1 };
2361 Persistent<Value> g3_objects[] = { g3s1, g3s2 }; 2358 Persistent<Value> g3_objects[] = { g3s1, g3s2 };
2362 Persistent<Value> g3_children[] = { g1s1 }; 2359 Persistent<Value> g3_children[] = { g1s1 };
2363 V8::AddObjectGroup(g1_objects, 2); 2360 V8::AddObjectGroup(g1_objects, 2);
2364 V8::AddImplicitReferences(g1s1, g1_children, 1); 2361 V8::AddImplicitReferences(g1s1, g1_children, 1);
2365 V8::AddObjectGroup(g2_objects, 2); 2362 V8::AddObjectGroup(g2_objects, 2);
2366 V8::AddImplicitReferences(g2s1, g2_children, 1); 2363 V8::AddImplicitReferences(g2s1, g2_children, 1);
2367 V8::AddObjectGroup(g3_objects, 2); 2364 V8::AddObjectGroup(g3_objects, 2);
2368 V8::AddImplicitReferences(g3s1, g3_children, 1); 2365 V8::AddImplicitReferences(g3s1, g3_children, 1);
2369 } 2366 }
2370 2367
2371 HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); 2368 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
2372 2369
2373 // All objects should be gone. 7 global handles in total. 2370 // All objects should be gone. 7 global handles in total.
2374 CHECK_EQ(7, counter.NumberOfWeakCalls()); 2371 CHECK_EQ(7, counter.NumberOfWeakCalls());
2375 } 2372 }
2376 2373
2377 2374
2378 THREADED_TEST(ScriptException) { 2375 THREADED_TEST(ScriptException) {
2379 v8::HandleScope scope; 2376 v8::HandleScope scope;
2380 LocalContext env; 2377 LocalContext env;
2381 Local<Script> script = Script::Compile(v8_str("throw 'panama!';")); 2378 Local<Script> script = Script::Compile(v8_str("throw 'panama!';"));
(...skipping 13782 matching lines...) Expand 10 before | Expand all | Expand 10 after
16164 16161
16165 TEST(SecondaryStubCache) { 16162 TEST(SecondaryStubCache) {
16166 StubCacheHelper(true); 16163 StubCacheHelper(true);
16167 } 16164 }
16168 16165
16169 16166
16170 TEST(PrimaryStubCache) { 16167 TEST(PrimaryStubCache) {
16171 StubCacheHelper(false); 16168 StubCacheHelper(false);
16172 } 16169 }
16173 16170
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-deoptimization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698