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

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

Issue 11369131: Implement MarkIndependent(Isolate*) and MarkPartiallyDependent(Isolate*) (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « src/api.cc ('k') | no next file » | 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 2590 matching lines...) Expand 10 before | Expand all | Expand 10 after
2601 2601
2602 HEAP->CollectGarbage(i::NEW_SPACE); 2602 HEAP->CollectGarbage(i::NEW_SPACE);
2603 2603
2604 // All objects should be alive. 2604 // All objects should be alive.
2605 CHECK_EQ(0, counter.NumberOfWeakCalls()); 2605 CHECK_EQ(0, counter.NumberOfWeakCalls());
2606 2606
2607 // Weaken the root. 2607 // Weaken the root.
2608 root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); 2608 root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
2609 root.MarkPartiallyDependent(); 2609 root.MarkPartiallyDependent();
2610 2610
2611 v8::Isolate* isolate = v8::Isolate::GetCurrent();
2611 // Groups are deleted, rebuild groups. 2612 // Groups are deleted, rebuild groups.
2612 { 2613 {
2613 g1s1.MarkPartiallyDependent(); 2614 g1s1.MarkPartiallyDependent(isolate);
2614 g1s2.MarkPartiallyDependent(); 2615 g1s2.MarkPartiallyDependent(isolate);
2615 g2s1.MarkPartiallyDependent(); 2616 g2s1.MarkPartiallyDependent(isolate);
2616 g2s2.MarkPartiallyDependent(); 2617 g2s2.MarkPartiallyDependent(isolate);
2617 g3s1.MarkPartiallyDependent(); 2618 g3s1.MarkPartiallyDependent(isolate);
2618 g3s2.MarkPartiallyDependent(); 2619 g3s2.MarkPartiallyDependent(isolate);
2619 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; 2620 Persistent<Value> g1_objects[] = { g1s1, g1s2 };
2620 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; 2621 Persistent<Value> g2_objects[] = { g2s1, g2s2 };
2621 Persistent<Value> g3_objects[] = { g3s1, g3s2 }; 2622 Persistent<Value> g3_objects[] = { g3s1, g3s2 };
2622 V8::AddObjectGroup(g1_objects, 2); 2623 V8::AddObjectGroup(g1_objects, 2);
2623 g1s1->Set(v8_str("x"), g2s1); 2624 g1s1->Set(v8_str("x"), g2s1);
2624 V8::AddObjectGroup(g2_objects, 2); 2625 V8::AddObjectGroup(g2_objects, 2);
2625 g2s1->Set(v8_str("x"), g3s1); 2626 g2s1->Set(v8_str("x"), g3s1);
2626 V8::AddObjectGroup(g3_objects, 2); 2627 V8::AddObjectGroup(g3_objects, 2);
2627 g3s1->Set(v8_str("x"), g1s1); 2628 g3s1->Set(v8_str("x"), g1s1);
2628 } 2629 }
(...skipping 2867 matching lines...) Expand 10 before | Expand all | Expand 10 after
5496 obj.Dispose(); 5497 obj.Dispose();
5497 obj.Clear(); 5498 obj.Clear();
5498 *(reinterpret_cast<bool*>(data)) = true; 5499 *(reinterpret_cast<bool*>(data)) = true;
5499 } 5500 }
5500 5501
5501 5502
5502 THREADED_TEST(IndependentWeakHandle) { 5503 THREADED_TEST(IndependentWeakHandle) {
5503 v8::Persistent<Context> context = Context::New(); 5504 v8::Persistent<Context> context = Context::New();
5504 Context::Scope context_scope(context); 5505 Context::Scope context_scope(context);
5505 5506
5506 v8::Persistent<v8::Object> object_a; 5507 v8::Persistent<v8::Object> object_a, object_b;
5507 5508
5508 { 5509 {
5509 v8::HandleScope handle_scope; 5510 v8::HandleScope handle_scope;
5510 object_a = v8::Persistent<v8::Object>::New(v8::Object::New()); 5511 object_a = v8::Persistent<v8::Object>::New(v8::Object::New());
5512 object_b = v8::Persistent<v8::Object>::New(v8::Object::New());
5511 } 5513 }
5512 5514
5513 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 5515 v8::Isolate* isolate = v8::Isolate::GetCurrent();
5514 bool object_a_disposed = false; 5516 bool object_a_disposed = false;
5517 bool object_b_disposed = false;
5515 object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag); 5518 object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag);
5519 object_b.MakeWeak(&object_b_disposed, &DisposeAndSetFlag);
5516 CHECK(!object_a.IsIndependent()); 5520 CHECK(!object_a.IsIndependent());
5517 CHECK(!object_a.IsIndependent(isolate)); 5521 CHECK(!object_b.IsIndependent(isolate));
5518 object_a.MarkIndependent(); 5522 object_a.MarkIndependent();
5523 object_b.MarkIndependent(isolate);
5519 CHECK(object_a.IsIndependent()); 5524 CHECK(object_a.IsIndependent());
5520 CHECK(object_a.IsIndependent(isolate)); 5525 CHECK(object_b.IsIndependent(isolate));
5521 HEAP->PerformScavenge(); 5526 HEAP->PerformScavenge();
5522 CHECK(object_a_disposed); 5527 CHECK(object_a_disposed);
5528 CHECK(object_b_disposed);
5523 } 5529 }
5524 5530
5525 5531
5526 static void InvokeScavenge() { 5532 static void InvokeScavenge() {
5527 HEAP->PerformScavenge(); 5533 HEAP->PerformScavenge();
5528 } 5534 }
5529 5535
5530 5536
5531 static void InvokeMarkSweep() { 5537 static void InvokeMarkSweep() {
5532 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); 5538 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
(...skipping 12442 matching lines...) Expand 10 before | Expand all | Expand 10 after
17975 17981
17976 i::Semaphore* sem_; 17982 i::Semaphore* sem_;
17977 volatile int sem_value_; 17983 volatile int sem_value_;
17978 }; 17984 };
17979 17985
17980 17986
17981 THREADED_TEST(SemaphoreInterruption) { 17987 THREADED_TEST(SemaphoreInterruption) {
17982 ThreadInterruptTest().RunTest(); 17988 ThreadInterruptTest().RunTest();
17983 } 17989 }
17984 #endif // WIN32 17990 #endif // WIN32
OLDNEW
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698