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 2525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2536 V8::AddImplicitReferences(g3s1, g3_children, 1); | 2536 V8::AddImplicitReferences(g3s1, g3_children, 1); |
2537 } | 2537 } |
2538 | 2538 |
2539 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 2539 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
2540 | 2540 |
2541 // All objects should be gone. 7 global handles in total. | 2541 // All objects should be gone. 7 global handles in total. |
2542 CHECK_EQ(7, counter.NumberOfWeakCalls()); | 2542 CHECK_EQ(7, counter.NumberOfWeakCalls()); |
2543 } | 2543 } |
2544 | 2544 |
2545 | 2545 |
| 2546 THREADED_TEST(ApiObjectGroupsCycleForScavenger) { |
| 2547 HandleScope scope; |
| 2548 LocalContext env; |
| 2549 |
| 2550 WeakCallCounter counter(1234); |
| 2551 |
| 2552 Persistent<Object> g1s1; |
| 2553 Persistent<Object> g1s2; |
| 2554 Persistent<Object> g2s1; |
| 2555 Persistent<Object> g2s2; |
| 2556 Persistent<Object> g3s1; |
| 2557 Persistent<Object> g3s2; |
| 2558 |
| 2559 { |
| 2560 HandleScope scope; |
| 2561 g1s1 = Persistent<Object>::New(Object::New()); |
| 2562 g1s2 = Persistent<Object>::New(Object::New()); |
| 2563 g1s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
| 2564 g1s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
| 2565 |
| 2566 g2s1 = Persistent<Object>::New(Object::New()); |
| 2567 g2s2 = Persistent<Object>::New(Object::New()); |
| 2568 g2s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
| 2569 g2s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
| 2570 |
| 2571 g3s1 = Persistent<Object>::New(Object::New()); |
| 2572 g3s2 = Persistent<Object>::New(Object::New()); |
| 2573 g3s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
| 2574 g3s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
| 2575 } |
| 2576 |
| 2577 // Make a root. |
| 2578 Persistent<Object> root = Persistent<Object>::New(g1s1); |
| 2579 root.MarkPartiallyDependent(); |
| 2580 |
| 2581 // Connect groups. We're building the following cycle: |
| 2582 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other |
| 2583 // groups. |
| 2584 { |
| 2585 g1s1.MarkPartiallyDependent(); |
| 2586 g1s2.MarkPartiallyDependent(); |
| 2587 g2s1.MarkPartiallyDependent(); |
| 2588 g2s2.MarkPartiallyDependent(); |
| 2589 g3s1.MarkPartiallyDependent(); |
| 2590 g3s2.MarkPartiallyDependent(); |
| 2591 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; |
| 2592 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; |
| 2593 Persistent<Value> g3_objects[] = { g3s1, g3s2 }; |
| 2594 V8::AddObjectGroup(g1_objects, 2); |
| 2595 g1s1->Set(v8_str("x"), g2s1); |
| 2596 V8::AddObjectGroup(g2_objects, 2); |
| 2597 g2s1->Set(v8_str("x"), g3s1); |
| 2598 V8::AddObjectGroup(g3_objects, 2); |
| 2599 g3s1->Set(v8_str("x"), g1s1); |
| 2600 } |
| 2601 |
| 2602 HEAP->CollectGarbage(i::NEW_SPACE); |
| 2603 |
| 2604 // All objects should be alive. |
| 2605 CHECK_EQ(0, counter.NumberOfWeakCalls()); |
| 2606 |
| 2607 // Weaken the root. |
| 2608 root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
| 2609 root.MarkPartiallyDependent(); |
| 2610 |
| 2611 // Groups are deleted, rebuild groups. |
| 2612 { |
| 2613 g1s1.MarkPartiallyDependent(); |
| 2614 g1s2.MarkPartiallyDependent(); |
| 2615 g2s1.MarkPartiallyDependent(); |
| 2616 g2s2.MarkPartiallyDependent(); |
| 2617 g3s1.MarkPartiallyDependent(); |
| 2618 g3s2.MarkPartiallyDependent(); |
| 2619 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; |
| 2620 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; |
| 2621 Persistent<Value> g3_objects[] = { g3s1, g3s2 }; |
| 2622 V8::AddObjectGroup(g1_objects, 2); |
| 2623 g1s1->Set(v8_str("x"), g2s1); |
| 2624 V8::AddObjectGroup(g2_objects, 2); |
| 2625 g2s1->Set(v8_str("x"), g3s1); |
| 2626 V8::AddObjectGroup(g3_objects, 2); |
| 2627 g3s1->Set(v8_str("x"), g1s1); |
| 2628 } |
| 2629 |
| 2630 HEAP->CollectGarbage(i::NEW_SPACE); |
| 2631 |
| 2632 // All objects should be gone. 7 global handles in total. |
| 2633 CHECK_EQ(7, counter.NumberOfWeakCalls()); |
| 2634 } |
| 2635 |
| 2636 |
2546 THREADED_TEST(ScriptException) { | 2637 THREADED_TEST(ScriptException) { |
2547 v8::HandleScope scope; | 2638 v8::HandleScope scope; |
2548 LocalContext env; | 2639 LocalContext env; |
2549 Local<Script> script = Script::Compile(v8_str("throw 'panama!';")); | 2640 Local<Script> script = Script::Compile(v8_str("throw 'panama!';")); |
2550 v8::TryCatch try_catch; | 2641 v8::TryCatch try_catch; |
2551 Local<Value> result = script->Run(); | 2642 Local<Value> result = script->Run(); |
2552 CHECK(result.IsEmpty()); | 2643 CHECK(result.IsEmpty()); |
2553 CHECK(try_catch.HasCaught()); | 2644 CHECK(try_catch.HasCaught()); |
2554 String::AsciiValue exception_value(try_catch.Exception()); | 2645 String::AsciiValue exception_value(try_catch.Exception()); |
2555 CHECK_EQ(*exception_value, "panama!"); | 2646 CHECK_EQ(*exception_value, "panama!"); |
(...skipping 15328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17884 | 17975 |
17885 i::Semaphore* sem_; | 17976 i::Semaphore* sem_; |
17886 volatile int sem_value_; | 17977 volatile int sem_value_; |
17887 }; | 17978 }; |
17888 | 17979 |
17889 | 17980 |
17890 THREADED_TEST(SemaphoreInterruption) { | 17981 THREADED_TEST(SemaphoreInterruption) { |
17891 ThreadInterruptTest().RunTest(); | 17982 ThreadInterruptTest().RunTest(); |
17892 } | 17983 } |
17893 #endif // WIN32 | 17984 #endif // WIN32 |
OLD | NEW |