| 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 2474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2485 | 2485 |
| 2486 g3s1 = Persistent<Object>::New(Object::New()); | 2486 g3s1 = Persistent<Object>::New(Object::New()); |
| 2487 g3s2 = Persistent<Object>::New(Object::New()); | 2487 g3s2 = Persistent<Object>::New(Object::New()); |
| 2488 g3s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2488 g3s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
| 2489 g3s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2489 g3s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
| 2490 CHECK(g3s1.IsWeak()); | 2490 CHECK(g3s1.IsWeak()); |
| 2491 CHECK(g3s2.IsWeak()); | 2491 CHECK(g3s2.IsWeak()); |
| 2492 | 2492 |
| 2493 g4s1 = Persistent<Object>::New(Object::New()); | 2493 g4s1 = Persistent<Object>::New(Object::New()); |
| 2494 g4s2 = Persistent<Object>::New(Object::New()); | 2494 g4s2 = Persistent<Object>::New(Object::New()); |
| 2495 g4s1.MakeWeak(isolate, | 2495 g4s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
| 2496 reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2496 g4s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
| 2497 g4s2.MakeWeak(isolate, | |
| 2498 reinterpret_cast<void*>(&counter), &WeakPointerCallback); | |
| 2499 CHECK(g4s1.IsWeak(isolate)); | 2497 CHECK(g4s1.IsWeak(isolate)); |
| 2500 CHECK(g4s2.IsWeak(isolate)); | 2498 CHECK(g4s2.IsWeak(isolate)); |
| 2501 } | 2499 } |
| 2502 | 2500 |
| 2503 Persistent<Object> root = Persistent<Object>::New(g1s1); // make a root. | 2501 Persistent<Object> root = Persistent<Object>::New(g1s1); // make a root. |
| 2504 | 2502 |
| 2505 // Connect groups. We're building the following cycle: | 2503 // Connect groups. We're building the following cycle: |
| 2506 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other | 2504 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other |
| 2507 // groups. | 2505 // groups. |
| 2508 { | 2506 { |
| (...skipping 3033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5542 "}" | 5540 "}" |
| 5543 "gc();" | 5541 "gc();" |
| 5544 "4"; | 5542 "4"; |
| 5545 v8::Handle<Value> result = CompileRun(code); | 5543 v8::Handle<Value> result = CompileRun(code); |
| 5546 CHECK_EQ(4.0, result->NumberValue()); | 5544 CHECK_EQ(4.0, result->NumberValue()); |
| 5547 delete whammy; | 5545 delete whammy; |
| 5548 context.Dispose(); | 5546 context.Dispose(); |
| 5549 } | 5547 } |
| 5550 | 5548 |
| 5551 | 5549 |
| 5552 static void DisposeAndSetFlag(v8::Persistent<v8::Value> obj, void* data) { | 5550 static void DisposeAndSetFlag(v8::Isolate* isolate, |
| 5551 v8::Persistent<v8::Value> obj, void* data) { |
| 5553 obj.Dispose(); | 5552 obj.Dispose(); |
| 5554 obj.Clear(); | 5553 obj.Clear(); |
| 5555 *(reinterpret_cast<bool*>(data)) = true; | 5554 *(reinterpret_cast<bool*>(data)) = true; |
| 5556 } | 5555 } |
| 5557 | 5556 |
| 5558 | 5557 |
| 5559 THREADED_TEST(IndependentWeakHandle) { | 5558 THREADED_TEST(IndependentWeakHandle) { |
| 5560 v8::Persistent<Context> context = Context::New(); | 5559 v8::Persistent<Context> context = Context::New(); |
| 5561 Context::Scope context_scope(context); | 5560 Context::Scope context_scope(context); |
| 5562 | 5561 |
| 5563 v8::Persistent<v8::Object> object_a, object_b; | 5562 v8::Persistent<v8::Object> object_a, object_b; |
| 5564 | 5563 |
| 5565 { | 5564 { |
| 5566 v8::HandleScope handle_scope; | 5565 v8::HandleScope handle_scope; |
| 5567 object_a = v8::Persistent<v8::Object>::New(v8::Object::New()); | 5566 object_a = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 5568 object_b = v8::Persistent<v8::Object>::New(v8::Object::New()); | 5567 object_b = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 5569 } | 5568 } |
| 5570 | 5569 |
| 5571 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 5570 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 5572 bool object_a_disposed = false; | 5571 bool object_a_disposed = false; |
| 5573 bool object_b_disposed = false; | 5572 bool object_b_disposed = false; |
| 5574 object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag); | 5573 object_a.MakeWeak(isolate, &object_a_disposed, &DisposeAndSetFlag); |
| 5575 object_b.MakeWeak(&object_b_disposed, &DisposeAndSetFlag); | 5574 object_b.MakeWeak(isolate, &object_b_disposed, &DisposeAndSetFlag); |
| 5576 CHECK(!object_a.IsIndependent()); | 5575 CHECK(!object_a.IsIndependent()); |
| 5577 CHECK(!object_b.IsIndependent(isolate)); | 5576 CHECK(!object_b.IsIndependent(isolate)); |
| 5578 object_a.MarkIndependent(); | 5577 object_a.MarkIndependent(); |
| 5579 object_b.MarkIndependent(isolate); | 5578 object_b.MarkIndependent(isolate); |
| 5580 CHECK(object_a.IsIndependent()); | 5579 CHECK(object_a.IsIndependent()); |
| 5581 CHECK(object_b.IsIndependent(isolate)); | 5580 CHECK(object_b.IsIndependent(isolate)); |
| 5582 HEAP->PerformScavenge(); | 5581 HEAP->PerformScavenge(); |
| 5583 CHECK(object_a_disposed); | 5582 CHECK(object_a_disposed); |
| 5584 CHECK(object_b_disposed); | 5583 CHECK(object_b_disposed); |
| 5585 } | 5584 } |
| (...skipping 12569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18155 i::Semaphore* sem_; | 18154 i::Semaphore* sem_; |
| 18156 volatile int sem_value_; | 18155 volatile int sem_value_; |
| 18157 }; | 18156 }; |
| 18158 | 18157 |
| 18159 | 18158 |
| 18160 THREADED_TEST(SemaphoreInterruption) { | 18159 THREADED_TEST(SemaphoreInterruption) { |
| 18161 ThreadInterruptTest().RunTest(); | 18160 ThreadInterruptTest().RunTest(); |
| 18162 } | 18161 } |
| 18163 | 18162 |
| 18164 #endif // WIN32 | 18163 #endif // WIN32 |
| OLD | NEW |