Chromium Code Reviews| 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 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2364 static void WeakPointerCallback(v8::Isolate* isolate, | 2364 static void WeakPointerCallback(v8::Isolate* isolate, |
| 2365 Persistent<Value> handle, | 2365 Persistent<Value> handle, |
| 2366 void* id) { | 2366 void* id) { |
| 2367 WeakCallCounter* counter = reinterpret_cast<WeakCallCounter*>(id); | 2367 WeakCallCounter* counter = reinterpret_cast<WeakCallCounter*>(id); |
| 2368 CHECK_EQ(1234, counter->id()); | 2368 CHECK_EQ(1234, counter->id()); |
| 2369 counter->increment(); | 2369 counter->increment(); |
| 2370 handle.Dispose(isolate); | 2370 handle.Dispose(isolate); |
| 2371 } | 2371 } |
| 2372 | 2372 |
| 2373 | 2373 |
| 2374 THREADED_TEST(ApiObjectGroups) { | 2374 THREADED_TEST(OldApiObjectGroups) { |
| 2375 LocalContext env; | 2375 LocalContext env; |
| 2376 v8::Isolate* iso = env->GetIsolate(); | 2376 v8::Isolate* iso = env->GetIsolate(); |
| 2377 HandleScope scope(iso); | 2377 HandleScope scope(iso); |
| 2378 | 2378 |
| 2379 Persistent<Object> g1s1; | 2379 Persistent<Object> g1s1; |
| 2380 Persistent<Object> g1s2; | 2380 Persistent<Object> g1s2; |
| 2381 Persistent<Object> g1c1; | 2381 Persistent<Object> g1c1; |
| 2382 Persistent<Object> g2s1; | 2382 Persistent<Object> g2s1; |
| 2383 Persistent<Object> g2s2; | 2383 Persistent<Object> g2s2; |
| 2384 Persistent<Object> g2c1; | 2384 Persistent<Object> g2c1; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2450 | 2450 |
| 2451 // And now make children weak again and collect them. | 2451 // And now make children weak again and collect them. |
| 2452 g1c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2452 g1c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
| 2453 g2c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2453 g2c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
| 2454 | 2454 |
| 2455 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 2455 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
| 2456 CHECK_EQ(7, counter.NumberOfWeakCalls()); | 2456 CHECK_EQ(7, counter.NumberOfWeakCalls()); |
| 2457 } | 2457 } |
| 2458 | 2458 |
| 2459 | 2459 |
| 2460 THREADED_TEST(ApiObjectGroupsCycle) { | 2460 THREADED_TEST(ApiObjectGroups) { |
| 2461 LocalContext env; | 2461 LocalContext env; |
| 2462 v8::Isolate* iso = env->GetIsolate(); | 2462 v8::Isolate* iso = env->GetIsolate(); |
| 2463 HandleScope scope(iso); | 2463 HandleScope scope(iso); |
| 2464 | |
| 2465 Persistent<Object> g1s1; | |
| 2466 Persistent<Object> g1s2; | |
| 2467 Persistent<Object> g1c1; | |
| 2468 Persistent<Object> g2s1; | |
| 2469 Persistent<Object> g2s2; | |
| 2470 Persistent<Object> g2c1; | |
| 2471 | |
| 2472 WeakCallCounter counter(1234); | |
| 2473 | |
| 2474 { | |
| 2475 HandleScope scope(iso); | |
| 2476 g1s1 = Persistent<Object>::New(iso, Object::New()); | |
| 2477 g1s2 = Persistent<Object>::New(iso, Object::New()); | |
| 2478 g1c1 = Persistent<Object>::New(iso, Object::New()); | |
| 2479 g1s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2480 g1s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2481 g1c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2482 | |
| 2483 g2s1 = Persistent<Object>::New(iso, Object::New()); | |
| 2484 g2s2 = Persistent<Object>::New(iso, Object::New()); | |
| 2485 g2c1 = Persistent<Object>::New(iso, Object::New()); | |
| 2486 g2s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2487 g2s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2488 g2c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2489 } | |
| 2490 | |
| 2491 Persistent<Object> root = Persistent<Object>::New(iso, g1s1); // make a root. | |
| 2492 | |
| 2493 // Connect group 1 and 2, make a cycle. | |
| 2494 CHECK(g1s2->Set(0, g2s2)); | |
| 2495 CHECK(g2s1->Set(0, g1s1)); | |
| 2496 | |
| 2497 { | |
| 2498 Persistent<Value> g1_children[] = { g1c1 }; | |
| 2499 Persistent<Value> g2_children[] = { g2c1 }; | |
| 2500 V8::SetObjectGroupId(iso, g1s1, v8::UniqueId(1)); | |
|
Sven Panne
2013/04/10 10:58:52
Style nit: Use "using".
marja
2013/04/10 13:14:51
Done.
| |
| 2501 V8::SetObjectGroupId(iso, g1s2, v8::UniqueId(1)); | |
| 2502 V8::AddImplicitReferences(g1s1, g1_children, 1); | |
| 2503 V8::SetObjectGroupId(iso, g2s1, v8::UniqueId(2)); | |
| 2504 V8::SetObjectGroupId(iso, g2s2, v8::UniqueId(2)); | |
| 2505 V8::AddImplicitReferences(g2s2, g2_children, 1); | |
| 2506 } | |
| 2507 // Do a single full GC, ensure incremental marking is stopped. | |
| 2508 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | |
|
Sven Panne
2013/04/10 10:58:52
Use iso->heap() instead of HEAP here and below.
marja
2013/04/10 13:14:51
Done.
| |
| 2509 | |
| 2510 // All object should be alive. | |
| 2511 CHECK_EQ(0, counter.NumberOfWeakCalls()); | |
| 2512 | |
| 2513 // Weaken the root. | |
| 2514 root.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2515 // But make children strong roots---all the objects (except for children) | |
| 2516 // should be collectable now. | |
| 2517 g1c1.ClearWeak(iso); | |
| 2518 g2c1.ClearWeak(iso); | |
| 2519 | |
| 2520 // Groups are deleted, rebuild groups. | |
| 2521 { | |
| 2522 Persistent<Value> g1_children[] = { g1c1 }; | |
| 2523 Persistent<Value> g2_children[] = { g2c1 }; | |
| 2524 V8::SetObjectGroupId(iso, g1s1, v8::UniqueId(1)); | |
| 2525 V8::SetObjectGroupId(iso, g1s2, v8::UniqueId(1)); | |
| 2526 V8::AddImplicitReferences(g1s1, g1_children, 1); | |
| 2527 V8::SetObjectGroupId(iso, g2s1, v8::UniqueId(2)); | |
| 2528 V8::SetObjectGroupId(iso, g2s2, v8::UniqueId(2)); | |
| 2529 V8::AddImplicitReferences(g2s2, g2_children, 1); | |
| 2530 } | |
| 2531 | |
| 2532 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | |
| 2533 | |
| 2534 // All objects should be gone. 5 global handles in total. | |
| 2535 CHECK_EQ(5, counter.NumberOfWeakCalls()); | |
| 2536 | |
| 2537 // And now make children weak again and collect them. | |
| 2538 g1c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2539 g2c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2540 | |
| 2541 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | |
| 2542 CHECK_EQ(7, counter.NumberOfWeakCalls()); | |
| 2543 } | |
| 2544 | |
| 2545 | |
| 2546 THREADED_TEST(OldApiObjectGroupsCycle) { | |
| 2547 LocalContext env; | |
| 2548 v8::Isolate* iso = env->GetIsolate(); | |
| 2549 HandleScope scope(iso); | |
| 2464 | 2550 |
| 2465 WeakCallCounter counter(1234); | 2551 WeakCallCounter counter(1234); |
| 2466 | 2552 |
| 2467 Persistent<Object> g1s1; | 2553 Persistent<Object> g1s1; |
| 2468 Persistent<Object> g1s2; | 2554 Persistent<Object> g1s2; |
| 2469 Persistent<Object> g2s1; | 2555 Persistent<Object> g2s1; |
| 2470 Persistent<Object> g2s2; | 2556 Persistent<Object> g2s2; |
| 2471 Persistent<Object> g3s1; | 2557 Persistent<Object> g3s1; |
| 2472 Persistent<Object> g3s2; | 2558 Persistent<Object> g3s2; |
| 2473 Persistent<Object> g4s1; | 2559 Persistent<Object> g4s1; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2556 V8::AddImplicitReferences(g4s1, g4_children, 1); | 2642 V8::AddImplicitReferences(g4s1, g4_children, 1); |
| 2557 } | 2643 } |
| 2558 | 2644 |
| 2559 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 2645 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
| 2560 | 2646 |
| 2561 // All objects should be gone. 9 global handles in total. | 2647 // All objects should be gone. 9 global handles in total. |
| 2562 CHECK_EQ(9, counter.NumberOfWeakCalls()); | 2648 CHECK_EQ(9, counter.NumberOfWeakCalls()); |
| 2563 } | 2649 } |
| 2564 | 2650 |
| 2565 | 2651 |
| 2652 THREADED_TEST(ApiObjectGroupsCycle) { | |
| 2653 LocalContext env; | |
| 2654 v8::Isolate* iso = env->GetIsolate(); | |
| 2655 HandleScope scope(iso); | |
| 2656 | |
| 2657 WeakCallCounter counter(1234); | |
| 2658 | |
| 2659 Persistent<Object> g1s1; | |
| 2660 Persistent<Object> g1s2; | |
| 2661 Persistent<Object> g2s1; | |
| 2662 Persistent<Object> g2s2; | |
| 2663 Persistent<Object> g3s1; | |
| 2664 Persistent<Object> g3s2; | |
| 2665 Persistent<Object> g4s1; | |
| 2666 Persistent<Object> g4s2; | |
| 2667 | |
| 2668 { | |
| 2669 HandleScope scope(iso); | |
| 2670 g1s1 = Persistent<Object>::New(iso, Object::New()); | |
| 2671 g1s2 = Persistent<Object>::New(iso, Object::New()); | |
| 2672 g1s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2673 g1s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2674 CHECK(g1s1.IsWeak(iso)); | |
| 2675 CHECK(g1s2.IsWeak(iso)); | |
| 2676 | |
| 2677 g2s1 = Persistent<Object>::New(iso, Object::New()); | |
| 2678 g2s2 = Persistent<Object>::New(iso, Object::New()); | |
| 2679 g2s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2680 g2s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2681 CHECK(g2s1.IsWeak(iso)); | |
| 2682 CHECK(g2s2.IsWeak(iso)); | |
| 2683 | |
| 2684 g3s1 = Persistent<Object>::New(iso, Object::New()); | |
| 2685 g3s2 = Persistent<Object>::New(iso, Object::New()); | |
| 2686 g3s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2687 g3s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2688 CHECK(g3s1.IsWeak(iso)); | |
| 2689 CHECK(g3s2.IsWeak(iso)); | |
| 2690 | |
| 2691 g4s1 = Persistent<Object>::New(iso, Object::New()); | |
| 2692 g4s2 = Persistent<Object>::New(iso, Object::New()); | |
| 2693 g4s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2694 g4s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2695 CHECK(g4s1.IsWeak(iso)); | |
| 2696 CHECK(g4s2.IsWeak(iso)); | |
| 2697 } | |
| 2698 | |
| 2699 Persistent<Object> root = Persistent<Object>::New(iso, g1s1); // make a root. | |
| 2700 | |
| 2701 // Connect groups. We're building the following cycle: | |
| 2702 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other | |
| 2703 // groups. | |
| 2704 { | |
| 2705 Persistent<Value> g1_children[] = { g2s1 }; | |
| 2706 Persistent<Value> g2_children[] = { g3s1 }; | |
| 2707 Persistent<Value> g3_children[] = { g4s1 }; | |
| 2708 Persistent<Value> g4_children[] = { g1s1 }; | |
| 2709 V8::SetObjectGroupId(iso, g1s1, v8::UniqueId(1)); | |
| 2710 V8::SetObjectGroupId(iso, g1s2, v8::UniqueId(1)); | |
| 2711 V8::AddImplicitReferences(g1s1, g1_children, 1); | |
| 2712 V8::SetObjectGroupId(iso, g2s1, v8::UniqueId(2)); | |
| 2713 V8::SetObjectGroupId(iso, g2s2, v8::UniqueId(2)); | |
| 2714 V8::AddImplicitReferences(g2s1, g2_children, 1); | |
| 2715 V8::SetObjectGroupId(iso, g3s1, v8::UniqueId(3)); | |
| 2716 V8::SetObjectGroupId(iso, g3s2, v8::UniqueId(3)); | |
| 2717 V8::AddImplicitReferences(g3s1, g3_children, 1); | |
| 2718 V8::SetObjectGroupId(iso, g4s1, v8::UniqueId(4)); | |
| 2719 V8::SetObjectGroupId(iso, g4s2, v8::UniqueId(4)); | |
| 2720 V8::AddImplicitReferences(g4s1, g4_children, 1); | |
| 2721 } | |
| 2722 // Do a single full GC | |
| 2723 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | |
| 2724 | |
| 2725 // All object should be alive. | |
| 2726 CHECK_EQ(0, counter.NumberOfWeakCalls()); | |
| 2727 | |
| 2728 // Weaken the root. | |
| 2729 root.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2730 | |
| 2731 // Groups are deleted, rebuild groups. | |
| 2732 { | |
| 2733 Persistent<Value> g1_children[] = { g2s1 }; | |
| 2734 Persistent<Value> g2_children[] = { g3s1 }; | |
| 2735 Persistent<Value> g3_children[] = { g4s1 }; | |
| 2736 Persistent<Value> g4_children[] = { g1s1 }; | |
| 2737 V8::SetObjectGroupId(iso, g1s1, v8::UniqueId(1)); | |
| 2738 V8::SetObjectGroupId(iso, g1s2, v8::UniqueId(1)); | |
| 2739 V8::AddImplicitReferences(g1s1, g1_children, 1); | |
| 2740 V8::SetObjectGroupId(iso, g2s1, v8::UniqueId(2)); | |
| 2741 V8::SetObjectGroupId(iso, g2s2, v8::UniqueId(2)); | |
| 2742 V8::AddImplicitReferences(g2s1, g2_children, 1); | |
| 2743 V8::SetObjectGroupId(iso, g3s1, v8::UniqueId(3)); | |
| 2744 V8::SetObjectGroupId(iso, g3s2, v8::UniqueId(3)); | |
| 2745 V8::AddImplicitReferences(g3s1, g3_children, 1); | |
| 2746 V8::SetObjectGroupId(iso, g4s1, v8::UniqueId(4)); | |
| 2747 V8::SetObjectGroupId(iso, g4s2, v8::UniqueId(4)); | |
| 2748 V8::AddImplicitReferences(g4s1, g4_children, 1); | |
| 2749 } | |
| 2750 | |
| 2751 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | |
| 2752 | |
| 2753 // All objects should be gone. 9 global handles in total. | |
| 2754 CHECK_EQ(9, counter.NumberOfWeakCalls()); | |
| 2755 } | |
| 2756 | |
| 2757 | |
| 2566 // TODO(mstarzinger): This should be a THREADED_TEST but causes failures | 2758 // TODO(mstarzinger): This should be a THREADED_TEST but causes failures |
| 2567 // on the buildbots, so was made non-threaded for the time being. | 2759 // on the buildbots, so was made non-threaded for the time being. |
| 2568 TEST(ApiObjectGroupsCycleForScavenger) { | 2760 TEST(OldApiObjectGroupsCycleForScavenger) { |
| 2569 i::FLAG_stress_compaction = false; | 2761 i::FLAG_stress_compaction = false; |
| 2570 i::FLAG_gc_global = false; | 2762 i::FLAG_gc_global = false; |
| 2571 LocalContext env; | 2763 LocalContext env; |
| 2572 v8::Isolate* iso = env->GetIsolate(); | 2764 v8::Isolate* iso = env->GetIsolate(); |
| 2573 HandleScope scope(iso); | 2765 HandleScope scope(iso); |
| 2574 | 2766 |
| 2575 WeakCallCounter counter(1234); | 2767 WeakCallCounter counter(1234); |
| 2576 | 2768 |
| 2577 Persistent<Object> g1s1; | 2769 Persistent<Object> g1s1; |
| 2578 Persistent<Object> g1s2; | 2770 Persistent<Object> g1s2; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2653 g3s1->Set(v8_str("x"), g1s1); | 2845 g3s1->Set(v8_str("x"), g1s1); |
| 2654 } | 2846 } |
| 2655 | 2847 |
| 2656 HEAP->CollectGarbage(i::NEW_SPACE); | 2848 HEAP->CollectGarbage(i::NEW_SPACE); |
| 2657 | 2849 |
| 2658 // All objects should be gone. 7 global handles in total. | 2850 // All objects should be gone. 7 global handles in total. |
| 2659 CHECK_EQ(7, counter.NumberOfWeakCalls()); | 2851 CHECK_EQ(7, counter.NumberOfWeakCalls()); |
| 2660 } | 2852 } |
| 2661 | 2853 |
| 2662 | 2854 |
| 2855 // TODO(mstarzinger): This should be a THREADED_TEST but causes failures | |
| 2856 // on the buildbots, so was made non-threaded for the time being. | |
| 2857 TEST(ApiObjectGroupsCycleForScavenger) { | |
| 2858 i::FLAG_stress_compaction = false; | |
| 2859 i::FLAG_gc_global = false; | |
| 2860 LocalContext env; | |
| 2861 v8::Isolate* iso = env->GetIsolate(); | |
| 2862 HandleScope scope(iso); | |
| 2863 | |
| 2864 WeakCallCounter counter(1234); | |
| 2865 | |
| 2866 Persistent<Object> g1s1; | |
| 2867 Persistent<Object> g1s2; | |
| 2868 Persistent<Object> g2s1; | |
| 2869 Persistent<Object> g2s2; | |
| 2870 Persistent<Object> g3s1; | |
| 2871 Persistent<Object> g3s2; | |
| 2872 | |
| 2873 { | |
| 2874 HandleScope scope(iso); | |
| 2875 g1s1 = Persistent<Object>::New(iso, Object::New()); | |
| 2876 g1s2 = Persistent<Object>::New(iso, Object::New()); | |
| 2877 g1s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2878 g1s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2879 | |
| 2880 g2s1 = Persistent<Object>::New(iso, Object::New()); | |
| 2881 g2s2 = Persistent<Object>::New(iso, Object::New()); | |
| 2882 g2s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2883 g2s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2884 | |
| 2885 g3s1 = Persistent<Object>::New(iso, Object::New()); | |
| 2886 g3s2 = Persistent<Object>::New(iso, Object::New()); | |
| 2887 g3s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2888 g3s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2889 } | |
| 2890 | |
| 2891 // Make a root. | |
| 2892 Persistent<Object> root = Persistent<Object>::New(iso, g1s1); | |
| 2893 root.MarkPartiallyDependent(iso); | |
| 2894 | |
| 2895 // Connect groups. We're building the following cycle: | |
| 2896 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other | |
| 2897 // groups. | |
| 2898 { | |
| 2899 g1s1.MarkPartiallyDependent(iso); | |
| 2900 g1s2.MarkPartiallyDependent(iso); | |
| 2901 g2s1.MarkPartiallyDependent(iso); | |
| 2902 g2s2.MarkPartiallyDependent(iso); | |
| 2903 g3s1.MarkPartiallyDependent(iso); | |
| 2904 g3s2.MarkPartiallyDependent(iso); | |
| 2905 V8::SetObjectGroupId(iso, g1s1, v8::UniqueId(1)); | |
| 2906 V8::SetObjectGroupId(iso, g1s2, v8::UniqueId(1)); | |
| 2907 g1s1->Set(v8_str("x"), g2s1); | |
| 2908 V8::SetObjectGroupId(iso, g2s1, v8::UniqueId(2)); | |
| 2909 V8::SetObjectGroupId(iso, g2s2, v8::UniqueId(2)); | |
| 2910 g2s1->Set(v8_str("x"), g3s1); | |
| 2911 V8::SetObjectGroupId(iso, g3s1, v8::UniqueId(3)); | |
| 2912 V8::SetObjectGroupId(iso, g3s2, v8::UniqueId(3)); | |
| 2913 g3s1->Set(v8_str("x"), g1s1); | |
| 2914 } | |
| 2915 | |
| 2916 HEAP->CollectGarbage(i::NEW_SPACE); | |
| 2917 | |
| 2918 // All objects should be alive. | |
| 2919 CHECK_EQ(0, counter.NumberOfWeakCalls()); | |
| 2920 | |
| 2921 // Weaken the root. | |
| 2922 root.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2923 root.MarkPartiallyDependent(iso); | |
| 2924 | |
| 2925 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 2926 // Groups are deleted, rebuild groups. | |
| 2927 { | |
| 2928 g1s1.MarkPartiallyDependent(isolate); | |
| 2929 g1s2.MarkPartiallyDependent(isolate); | |
| 2930 g2s1.MarkPartiallyDependent(isolate); | |
| 2931 g2s2.MarkPartiallyDependent(isolate); | |
| 2932 g3s1.MarkPartiallyDependent(isolate); | |
| 2933 g3s2.MarkPartiallyDependent(isolate); | |
| 2934 V8::SetObjectGroupId(iso, g1s1, v8::UniqueId(1)); | |
| 2935 V8::SetObjectGroupId(iso, g1s2, v8::UniqueId(1)); | |
| 2936 g1s1->Set(v8_str("x"), g2s1); | |
| 2937 V8::SetObjectGroupId(iso, g2s1, v8::UniqueId(2)); | |
| 2938 V8::SetObjectGroupId(iso, g2s2, v8::UniqueId(2)); | |
| 2939 g2s1->Set(v8_str("x"), g3s1); | |
| 2940 V8::SetObjectGroupId(iso, g3s1, v8::UniqueId(3)); | |
| 2941 V8::SetObjectGroupId(iso, g3s2, v8::UniqueId(3)); | |
| 2942 g3s1->Set(v8_str("x"), g1s1); | |
| 2943 } | |
| 2944 | |
| 2945 HEAP->CollectGarbage(i::NEW_SPACE); | |
| 2946 | |
| 2947 // All objects should be gone. 7 global handles in total. | |
| 2948 CHECK_EQ(7, counter.NumberOfWeakCalls()); | |
| 2949 } | |
| 2950 | |
| 2951 | |
| 2663 THREADED_TEST(ScriptException) { | 2952 THREADED_TEST(ScriptException) { |
| 2664 LocalContext env; | 2953 LocalContext env; |
| 2665 v8::HandleScope scope(env->GetIsolate()); | 2954 v8::HandleScope scope(env->GetIsolate()); |
| 2666 Local<Script> script = Script::Compile(v8_str("throw 'panama!';")); | 2955 Local<Script> script = Script::Compile(v8_str("throw 'panama!';")); |
| 2667 v8::TryCatch try_catch; | 2956 v8::TryCatch try_catch; |
| 2668 Local<Value> result = script->Run(); | 2957 Local<Value> result = script->Run(); |
| 2669 CHECK(result.IsEmpty()); | 2958 CHECK(result.IsEmpty()); |
| 2670 CHECK(try_catch.HasCaught()); | 2959 CHECK(try_catch.HasCaught()); |
| 2671 String::AsciiValue exception_value(try_catch.Exception()); | 2960 String::AsciiValue exception_value(try_catch.Exception()); |
| 2672 CHECK_EQ(*exception_value, "panama!"); | 2961 CHECK_EQ(*exception_value, "panama!"); |
| (...skipping 15647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 18320 i::Semaphore* sem_; | 18609 i::Semaphore* sem_; |
| 18321 volatile int sem_value_; | 18610 volatile int sem_value_; |
| 18322 }; | 18611 }; |
| 18323 | 18612 |
| 18324 | 18613 |
| 18325 THREADED_TEST(SemaphoreInterruption) { | 18614 THREADED_TEST(SemaphoreInterruption) { |
| 18326 ThreadInterruptTest().RunTest(); | 18615 ThreadInterruptTest().RunTest(); |
| 18327 } | 18616 } |
| 18328 | 18617 |
| 18329 #endif // WIN32 | 18618 #endif // WIN32 |
| OLD | NEW |