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