OLD | NEW |
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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 h1 = global_handles->Create(*i); | 426 h1 = global_handles->Create(*i); |
427 h2 = global_handles->Create(*u); | 427 h2 = global_handles->Create(*u); |
428 } | 428 } |
429 | 429 |
430 std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234); | 430 std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234); |
431 GlobalHandles::MakeWeak(h2.location(), | 431 GlobalHandles::MakeWeak(h2.location(), |
432 reinterpret_cast<void*>(&handle_and_id), | 432 reinterpret_cast<void*>(&handle_and_id), |
433 &TestWeakGlobalHandleCallback); | 433 &TestWeakGlobalHandleCallback); |
434 | 434 |
435 // Scavenge treats weak pointers as normal roots. | 435 // Scavenge treats weak pointers as normal roots. |
436 heap->PerformScavenge(); | 436 heap->CollectGarbage(NEW_SPACE); |
437 | 437 |
438 CHECK((*h1)->IsString()); | 438 CHECK((*h1)->IsString()); |
439 CHECK((*h2)->IsHeapNumber()); | 439 CHECK((*h2)->IsHeapNumber()); |
440 | 440 |
441 CHECK(!WeakPointerCleared); | 441 CHECK(!WeakPointerCleared); |
442 CHECK(!global_handles->IsNearDeath(h2.location())); | 442 CHECK(!global_handles->IsNearDeath(h2.location())); |
443 CHECK(!global_handles->IsNearDeath(h1.location())); | 443 CHECK(!global_handles->IsNearDeath(h1.location())); |
444 | 444 |
445 GlobalHandles::Destroy(h1.location()); | 445 GlobalHandles::Destroy(h1.location()); |
446 GlobalHandles::Destroy(h2.location()); | 446 GlobalHandles::Destroy(h2.location()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 Handle<Object> i = factory->NewStringFromAscii(CStrVector("fisk")); | 511 Handle<Object> i = factory->NewStringFromAscii(CStrVector("fisk")); |
512 h = global_handles->Create(*i); | 512 h = global_handles->Create(*i); |
513 } | 513 } |
514 | 514 |
515 std::pair<Handle<Object>*, int> handle_and_id(&h, 1234); | 515 std::pair<Handle<Object>*, int> handle_and_id(&h, 1234); |
516 GlobalHandles::MakeWeak(h.location(), | 516 GlobalHandles::MakeWeak(h.location(), |
517 reinterpret_cast<void*>(&handle_and_id), | 517 reinterpret_cast<void*>(&handle_and_id), |
518 &TestWeakGlobalHandleCallback); | 518 &TestWeakGlobalHandleCallback); |
519 | 519 |
520 // Scanvenge does not recognize weak reference. | 520 // Scanvenge does not recognize weak reference. |
521 heap->PerformScavenge(); | 521 heap->CollectGarbage(NEW_SPACE); |
522 | 522 |
523 CHECK(!WeakPointerCleared); | 523 CHECK(!WeakPointerCleared); |
524 | 524 |
525 // Mark-compact treats weak reference properly. | 525 // Mark-compact treats weak reference properly. |
526 heap->CollectGarbage(OLD_POINTER_SPACE); | 526 heap->CollectGarbage(OLD_POINTER_SPACE); |
527 | 527 |
528 CHECK(WeakPointerCleared); | 528 CHECK(WeakPointerCleared); |
529 } | 529 } |
530 | 530 |
531 | 531 |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 CompileRun("f4()"); | 1429 CompileRun("f4()"); |
1430 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); | 1430 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); |
1431 CompileRun("f5()"); | 1431 CompileRun("f5()"); |
1432 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i])); | 1432 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i])); |
1433 | 1433 |
1434 // Remove function f1, and | 1434 // Remove function f1, and |
1435 CompileRun("f1=null"); | 1435 CompileRun("f1=null"); |
1436 | 1436 |
1437 // Scavenge treats these references as strong. | 1437 // Scavenge treats these references as strong. |
1438 for (int j = 0; j < 10; j++) { | 1438 for (int j = 0; j < 10; j++) { |
1439 CcTest::heap()->PerformScavenge(); | 1439 CcTest::heap()->CollectGarbage(NEW_SPACE); |
1440 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i])); | 1440 CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i])); |
1441 } | 1441 } |
1442 | 1442 |
1443 // Mark compact handles the weak references. | 1443 // Mark compact handles the weak references. |
1444 isolate->compilation_cache()->Clear(); | 1444 isolate->compilation_cache()->Clear(); |
1445 heap->CollectAllGarbage(Heap::kNoGCFlags); | 1445 heap->CollectAllGarbage(Heap::kNoGCFlags); |
1446 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); | 1446 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); |
1447 | 1447 |
1448 // Get rid of f3 and f5 in the same way. | 1448 // Get rid of f3 and f5 in the same way. |
1449 CompileRun("f3=null"); | 1449 CompileRun("f3=null"); |
1450 for (int j = 0; j < 10; j++) { | 1450 for (int j = 0; j < 10; j++) { |
1451 CcTest::heap()->PerformScavenge(); | 1451 CcTest::heap()->CollectGarbage(NEW_SPACE); |
1452 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); | 1452 CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); |
1453 } | 1453 } |
1454 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 1454 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
1455 CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i])); | 1455 CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i])); |
1456 CompileRun("f5=null"); | 1456 CompileRun("f5=null"); |
1457 for (int j = 0; j < 10; j++) { | 1457 for (int j = 0; j < 10; j++) { |
1458 CcTest::heap()->PerformScavenge(); | 1458 CcTest::heap()->CollectGarbage(NEW_SPACE); |
1459 CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i])); | 1459 CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i])); |
1460 } | 1460 } |
1461 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 1461 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
1462 CHECK_EQ(opt ? 2 : 0, CountOptimizedUserFunctions(ctx[i])); | 1462 CHECK_EQ(opt ? 2 : 0, CountOptimizedUserFunctions(ctx[i])); |
1463 | 1463 |
1464 ctx[i]->Exit(); | 1464 ctx[i]->Exit(); |
1465 } | 1465 } |
1466 | 1466 |
1467 // Force compilation cache cleanup. | 1467 // Force compilation cache cleanup. |
1468 CcTest::heap()->NotifyContextDisposed(); | 1468 CcTest::heap()->NotifyContextDisposed(); |
1469 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 1469 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
1470 | 1470 |
1471 // Dispose the native contexts one by one. | 1471 // Dispose the native contexts one by one. |
1472 for (int i = 0; i < kNumTestContexts; i++) { | 1472 for (int i = 0; i < kNumTestContexts; i++) { |
1473 // TODO(dcarney): is there a better way to do this? | 1473 // TODO(dcarney): is there a better way to do this? |
1474 i::Object** unsafe = reinterpret_cast<i::Object**>(*ctx[i]); | 1474 i::Object** unsafe = reinterpret_cast<i::Object**>(*ctx[i]); |
1475 *unsafe = CcTest::heap()->undefined_value(); | 1475 *unsafe = CcTest::heap()->undefined_value(); |
1476 ctx[i].Clear(); | 1476 ctx[i].Clear(); |
1477 | 1477 |
1478 // Scavenge treats these references as strong. | 1478 // Scavenge treats these references as strong. |
1479 for (int j = 0; j < 10; j++) { | 1479 for (int j = 0; j < 10; j++) { |
1480 CcTest::heap()->PerformScavenge(); | 1480 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
1481 CHECK_EQ(kNumTestContexts - i, CountNativeContexts()); | 1481 CHECK_EQ(kNumTestContexts - i, CountNativeContexts()); |
1482 } | 1482 } |
1483 | 1483 |
1484 // Mark compact handles the weak references. | 1484 // Mark compact handles the weak references. |
1485 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 1485 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
1486 CHECK_EQ(kNumTestContexts - i - 1, CountNativeContexts()); | 1486 CHECK_EQ(kNumTestContexts - i - 1, CountNativeContexts()); |
1487 } | 1487 } |
1488 | 1488 |
1489 CHECK_EQ(0, CountNativeContexts()); | 1489 CHECK_EQ(0, CountNativeContexts()); |
1490 } | 1490 } |
(...skipping 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3681 code = scope.CloseAndEscape(Handle<Code>(bar->code())); | 3681 code = scope.CloseAndEscape(Handle<Code>(bar->code())); |
3682 } | 3682 } |
3683 | 3683 |
3684 // Now make sure that a gc should get rid of the function | 3684 // Now make sure that a gc should get rid of the function |
3685 for (int i = 0; i < 4; i++) { | 3685 for (int i = 0; i < 4; i++) { |
3686 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3686 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
3687 } | 3687 } |
3688 | 3688 |
3689 ASSERT(code->marked_for_deoptimization()); | 3689 ASSERT(code->marked_for_deoptimization()); |
3690 } | 3690 } |
OLD | NEW |