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

Unified Diff: test/cctest/test-api.cc

Issue 12033011: Add Isolate parameter to Persistent class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added new kind of callback Created 7 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index d3b88245bb0c3aad0f750a87f51c51d987a4f49c..f19d53bb33630d6399a474ae0a35796288105b3e 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -181,7 +181,7 @@ THREADED_TEST(IsolateOfContext) {
CHECK(!env->InContext());
CHECK(env->GetIsolate() == v8::Isolate::GetCurrent());
- env.Dispose();
+ env.Dispose(env->GetIsolate());
}
@@ -2324,7 +2324,7 @@ THREADED_TEST(GlobalHandle) {
global = v8::Persistent<String>::New(str);
}
CHECK_EQ(global->Length(), 3);
- global.Dispose();
+ global.Dispose(v8::Isolate::GetCurrent());
{
v8::HandleScope scope;
@@ -2358,17 +2358,20 @@ class WeakCallCounter {
};
-static void WeakPointerCallback(Persistent<Value> handle, void* id) {
+static void WeakPointerCallback(v8::Isolate* isolate,
+ Persistent<Value> handle,
+ void* id) {
WeakCallCounter* counter = reinterpret_cast<WeakCallCounter*>(id);
CHECK_EQ(1234, counter->id());
counter->increment();
- handle.Dispose();
+ handle.Dispose(isolate);
}
THREADED_TEST(ApiObjectGroups) {
HandleScope scope;
LocalContext env;
+ v8::Isolate* iso = env->GetIsolate();
Persistent<Object> g1s1;
Persistent<Object> g1s2;
@@ -2384,16 +2387,16 @@ THREADED_TEST(ApiObjectGroups) {
g1s1 = Persistent<Object>::New(Object::New());
g1s2 = Persistent<Object>::New(Object::New());
g1c1 = Persistent<Object>::New(Object::New());
- g1s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- g1s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- g1c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g1s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g1s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g1c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
g2s1 = Persistent<Object>::New(Object::New());
g2s2 = Persistent<Object>::New(Object::New());
g2c1 = Persistent<Object>::New(Object::New());
- g2s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- g2s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- g2c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g2s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g2s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g2c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
}
Persistent<Object> root = Persistent<Object>::New(g1s1); // make a root.
@@ -2419,11 +2422,11 @@ THREADED_TEST(ApiObjectGroups) {
CHECK_EQ(0, counter.NumberOfWeakCalls());
// Weaken the root.
- root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ root.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
// But make children strong roots---all the objects (except for children)
// should be collectable now.
- g1c1.ClearWeak();
- g2c1.ClearWeak();
+ g1c1.ClearWeak(iso);
+ g2c1.ClearWeak(iso);
// Groups are deleted, rebuild groups.
{
@@ -2443,8 +2446,8 @@ THREADED_TEST(ApiObjectGroups) {
CHECK_EQ(5, counter.NumberOfWeakCalls());
// And now make children weak again and collect them.
- g1c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- g2c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g1c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g2c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
CHECK_EQ(7, counter.NumberOfWeakCalls());
@@ -2454,6 +2457,7 @@ THREADED_TEST(ApiObjectGroups) {
THREADED_TEST(ApiObjectGroupsCycle) {
HandleScope scope;
LocalContext env;
+ v8::Isolate* iso = env->GetIsolate();
WeakCallCounter counter(1234);
@@ -2466,38 +2470,35 @@ THREADED_TEST(ApiObjectGroupsCycle) {
Persistent<Object> g4s1;
Persistent<Object> g4s2;
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
{
HandleScope scope;
g1s1 = Persistent<Object>::New(Object::New());
g1s2 = Persistent<Object>::New(Object::New());
- g1s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- g1s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- CHECK(g1s1.IsWeak());
- CHECK(g1s2.IsWeak());
+ g1s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g1s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ CHECK(g1s1.IsWeak(iso));
+ CHECK(g1s2.IsWeak(iso));
g2s1 = Persistent<Object>::New(Object::New());
g2s2 = Persistent<Object>::New(Object::New());
- g2s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- g2s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- CHECK(g2s1.IsWeak());
- CHECK(g2s2.IsWeak());
+ g2s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g2s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ CHECK(g2s1.IsWeak(iso));
+ CHECK(g2s2.IsWeak(iso));
g3s1 = Persistent<Object>::New(Object::New());
g3s2 = Persistent<Object>::New(Object::New());
- g3s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- g3s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- CHECK(g3s1.IsWeak());
- CHECK(g3s2.IsWeak());
+ g3s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g3s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ CHECK(g3s1.IsWeak(iso));
+ CHECK(g3s2.IsWeak(iso));
g4s1 = Persistent<Object>::New(Object::New());
g4s2 = Persistent<Object>::New(Object::New());
- g4s1.MakeWeak(isolate,
- reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- g4s2.MakeWeak(isolate,
- reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- CHECK(g4s1.IsWeak(isolate));
- CHECK(g4s2.IsWeak(isolate));
+ g4s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g4s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ CHECK(g4s1.IsWeak(iso));
+ CHECK(g4s2.IsWeak(iso));
}
Persistent<Object> root = Persistent<Object>::New(g1s1); // make a root.
@@ -2520,7 +2521,7 @@ THREADED_TEST(ApiObjectGroupsCycle) {
V8::AddImplicitReferences(g2s1, g2_children, 1);
V8::AddObjectGroup(g3_objects, 2);
V8::AddImplicitReferences(g3s1, g3_children, 1);
- V8::AddObjectGroup(isolate, g4_objects, 2);
+ V8::AddObjectGroup(iso, g4_objects, 2);
V8::AddImplicitReferences(g4s1, g4_children, 1);
}
// Do a single full GC
@@ -2530,7 +2531,7 @@ THREADED_TEST(ApiObjectGroupsCycle) {
CHECK_EQ(0, counter.NumberOfWeakCalls());
// Weaken the root.
- root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ root.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
// Groups are deleted, rebuild groups.
{
@@ -2566,6 +2567,7 @@ TEST(ApiObjectGroupsCycleForScavenger) {
i::FLAG_gc_global = false;
HandleScope scope;
LocalContext env;
+ v8::Isolate* iso = env->GetIsolate();
WeakCallCounter counter(1234);
@@ -2580,34 +2582,34 @@ TEST(ApiObjectGroupsCycleForScavenger) {
HandleScope scope;
g1s1 = Persistent<Object>::New(Object::New());
g1s2 = Persistent<Object>::New(Object::New());
- g1s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- g1s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g1s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g1s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
g2s1 = Persistent<Object>::New(Object::New());
g2s2 = Persistent<Object>::New(Object::New());
- g2s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- g2s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g2s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g2s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
g3s1 = Persistent<Object>::New(Object::New());
g3s2 = Persistent<Object>::New(Object::New());
- g3s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- g3s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g3s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ g3s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
}
// Make a root.
Persistent<Object> root = Persistent<Object>::New(g1s1);
- root.MarkPartiallyDependent();
+ root.MarkPartiallyDependent(iso);
// Connect groups. We're building the following cycle:
// G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other
// groups.
{
- g1s1.MarkPartiallyDependent();
- g1s2.MarkPartiallyDependent();
- g2s1.MarkPartiallyDependent();
- g2s2.MarkPartiallyDependent();
- g3s1.MarkPartiallyDependent();
- g3s2.MarkPartiallyDependent();
+ g1s1.MarkPartiallyDependent(iso);
+ g1s2.MarkPartiallyDependent(iso);
+ g2s1.MarkPartiallyDependent(iso);
+ g2s2.MarkPartiallyDependent(iso);
+ g3s1.MarkPartiallyDependent(iso);
+ g3s2.MarkPartiallyDependent(iso);
Persistent<Value> g1_objects[] = { g1s1, g1s2 };
Persistent<Value> g2_objects[] = { g2s1, g2s2 };
Persistent<Value> g3_objects[] = { g3s1, g3s2 };
@@ -2625,8 +2627,8 @@ TEST(ApiObjectGroupsCycleForScavenger) {
CHECK_EQ(0, counter.NumberOfWeakCalls());
// Weaken the root.
- root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback);
- root.MarkPartiallyDependent();
+ root.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
+ root.MarkPartiallyDependent(iso);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
// Groups are deleted, rebuild groups.
@@ -3784,7 +3786,7 @@ THREADED_TEST(Equality) {
v8::Handle<v8::Object> obj = v8::Object::New();
v8::Persistent<v8::Object> alias = v8::Persistent<v8::Object>::New(obj);
CHECK(alias->StrictEquals(obj));
- alias.Dispose();
+ alias.Dispose(context->GetIsolate());
}
@@ -4097,7 +4099,7 @@ THREADED_TEST(SimplePropertyWrite) {
CHECK(xValue.IsEmpty());
script->Run();
CHECK_EQ(v8_num(4), xValue);
- xValue.Dispose();
+ xValue.Dispose(context->GetIsolate());
xValue = v8::Persistent<Value>();
}
}
@@ -4114,7 +4116,7 @@ THREADED_TEST(SetterOnly) {
CHECK(xValue.IsEmpty());
script->Run();
CHECK_EQ(v8_num(4), xValue);
- xValue.Dispose();
+ xValue.Dispose(context->GetIsolate());
xValue = v8::Persistent<Value>();
}
}
@@ -4224,7 +4226,7 @@ THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) {
CompileRun("var obj = { x : 0 }; delete obj.x;");
context1->Exit();
- context1.Dispose();
+ context1.Dispose(context1->GetIsolate());
}
@@ -5006,7 +5008,7 @@ THREADED_TEST(GlobalObjectTemplate) {
v8::Persistent<Context> context = Context::New(0, global_template);
Context::Scope context_scope(context);
Script::Compile(v8_str("JSNI_Log('LOG')"))->Run();
- context.Dispose();
+ context.Dispose(context->GetIsolate());
}
@@ -5479,7 +5481,7 @@ class Whammy {
cursor_ = 0;
}
~Whammy() {
- script_.Dispose();
+ script_.Dispose(v8::Isolate::GetCurrent());
}
v8::Handle<Script> getScript() {
if (script_.IsEmpty())
@@ -5494,10 +5496,12 @@ class Whammy {
v8::Persistent<Script> script_;
};
-static void HandleWeakReference(v8::Persistent<v8::Value> obj, void* data) {
+static void HandleWeakReference(v8::Isolate* isolate,
+ v8::Persistent<v8::Value> obj,
+ void* data) {
Snorkel* snorkel = reinterpret_cast<Snorkel*>(data);
delete snorkel;
- obj.ClearWeak();
+ obj.ClearWeak(isolate);
}
v8::Handle<Value> WhammyPropertyGetter(Local<String> name,
@@ -5511,7 +5515,8 @@ v8::Handle<Value> WhammyPropertyGetter(Local<String> name,
v8::Persistent<v8::Object> global = v8::Persistent<v8::Object>::New(obj);
if (!prev.IsEmpty()) {
prev->Set(v8_str("next"), obj);
- prev.MakeWeak(new Snorkel(), &HandleWeakReference);
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ prev.MakeWeak(isolate, new Snorkel(), &HandleWeakReference);
Michael Starzinger 2013/01/24 13:09:05 Can we use info.GetIsolate() here?
Sven Panne 2013/01/25 08:28:40 Done.
whammy->objects_[whammy->cursor_].Clear();
}
whammy->objects_[whammy->cursor_] = global;
@@ -5545,12 +5550,14 @@ THREADED_TEST(WeakReference) {
v8::Handle<Value> result = CompileRun(code);
CHECK_EQ(4.0, result->NumberValue());
delete whammy;
- context.Dispose();
+ context.Dispose(context->GetIsolate());
}
-static void DisposeAndSetFlag(v8::Persistent<v8::Value> obj, void* data) {
- obj.Dispose();
+static void DisposeAndSetFlag(v8::Isolate* isolate,
+ v8::Persistent<v8::Value> obj,
+ void* data) {
+ obj.Dispose(isolate);
obj.Clear();
*(reinterpret_cast<bool*>(data)) = true;
}
@@ -5558,6 +5565,7 @@ static void DisposeAndSetFlag(v8::Persistent<v8::Value> obj, void* data) {
THREADED_TEST(IndependentWeakHandle) {
v8::Persistent<Context> context = Context::New();
+ v8::Isolate* iso = context->GetIsolate();
Context::Scope context_scope(context);
v8::Persistent<v8::Object> object_a, object_b;
@@ -5568,17 +5576,14 @@ THREADED_TEST(IndependentWeakHandle) {
object_b = v8::Persistent<v8::Object>::New(v8::Object::New());
}
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
bool object_a_disposed = false;
bool object_b_disposed = false;
- object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag);
- object_b.MakeWeak(&object_b_disposed, &DisposeAndSetFlag);
- CHECK(!object_a.IsIndependent());
- CHECK(!object_b.IsIndependent(isolate));
- object_a.MarkIndependent();
- object_b.MarkIndependent(isolate);
- CHECK(object_a.IsIndependent());
- CHECK(object_b.IsIndependent(isolate));
+ object_a.MakeWeak(iso, &object_a_disposed, &DisposeAndSetFlag);
+ object_b.MakeWeak(iso, &object_b_disposed, &DisposeAndSetFlag);
+ CHECK(!object_b.IsIndependent(iso));
+ object_a.MarkIndependent(iso);
+ object_b.MarkIndependent(iso);
+ CHECK(object_b.IsIndependent(iso));
HEAP->PerformScavenge();
CHECK(object_a_disposed);
CHECK(object_b_disposed);
@@ -5595,16 +5600,20 @@ static void InvokeMarkSweep() {
}
-static void ForceScavenge(v8::Persistent<v8::Value> obj, void* data) {
- obj.Dispose();
+static void ForceScavenge(v8::Isolate* isolate,
+ v8::Persistent<v8::Value> obj,
+ void* data) {
+ obj.Dispose(isolate);
obj.Clear();
*(reinterpret_cast<bool*>(data)) = true;
InvokeScavenge();
}
-static void ForceMarkSweep(v8::Persistent<v8::Value> obj, void* data) {
- obj.Dispose();
+static void ForceMarkSweep(v8::Isolate* isolate,
+ v8::Persistent<v8::Value> obj,
+ void* data) {
+ obj.Dispose(isolate);
obj.Clear();
*(reinterpret_cast<bool*>(data)) = true;
InvokeMarkSweep();
@@ -5616,7 +5625,7 @@ THREADED_TEST(GCFromWeakCallbacks) {
Context::Scope context_scope(context);
static const int kNumberOfGCTypes = 2;
- v8::WeakReferenceCallback gc_forcing_callback[kNumberOfGCTypes] =
+ v8::NearDeathCallback gc_forcing_callback[kNumberOfGCTypes] =
{&ForceScavenge, &ForceMarkSweep};
typedef void (*GCInvoker)();
@@ -5630,8 +5639,9 @@ THREADED_TEST(GCFromWeakCallbacks) {
object = v8::Persistent<v8::Object>::New(v8::Object::New());
}
bool disposed = false;
- object.MakeWeak(&disposed, gc_forcing_callback[inner_gc]);
- object.MarkIndependent();
+ v8::Isolate* isolate = context->GetIsolate();
+ object.MakeWeak(isolate, &disposed, gc_forcing_callback[inner_gc]);
+ object.MarkIndependent(isolate);
invoke_gc[outer_gc]();
CHECK(disposed);
}
@@ -5639,8 +5649,10 @@ THREADED_TEST(GCFromWeakCallbacks) {
}
-static void RevivingCallback(v8::Persistent<v8::Value> obj, void* data) {
- obj.ClearWeak();
+static void RevivingCallback(v8::Isolate* isolate,
+ v8::Persistent<v8::Value> obj,
+ void* data) {
+ obj.ClearWeak(isolate);
*(reinterpret_cast<bool*>(data)) = true;
}
@@ -5648,6 +5660,7 @@ static void RevivingCallback(v8::Persistent<v8::Value> obj, void* data) {
THREADED_TEST(IndependentHandleRevival) {
v8::Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
+ v8::Isolate* isolate = context->GetIsolate();
v8::Persistent<v8::Object> object;
{
@@ -5658,8 +5671,8 @@ THREADED_TEST(IndependentHandleRevival) {
object->Set(y_str, y_str);
}
bool revived = false;
- object.MakeWeak(&revived, &RevivingCallback);
- object.MarkIndependent();
+ object.MakeWeak(isolate, &revived, &RevivingCallback);
+ object.MarkIndependent(isolate);
HEAP->PerformScavenge();
CHECK(revived);
HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
@@ -6755,10 +6768,10 @@ TEST(SecurityHandler) {
}
context1->Exit();
- context1.Dispose();
+ context1.Dispose(context1->GetIsolate());
context0->Exit();
- context0.Dispose();
+ context0.Dispose(context0->GetIsolate());
}
@@ -6802,7 +6815,7 @@ THREADED_TEST(SecurityChecks) {
CHECK(try_catch.HasCaught());
}
- env2.Dispose();
+ env2.Dispose(env2->GetIsolate());
}
@@ -6871,7 +6884,7 @@ THREADED_TEST(SecurityChecksForPrototypeChain) {
CHECK(!access_f3->Run()->Equals(v8_num(101)));
CHECK(access_f3->Run()->IsUndefined());
}
- other.Dispose();
+ other.Dispose(other->GetIsolate());
}
@@ -6904,7 +6917,7 @@ THREADED_TEST(CrossDomainDelete) {
CHECK(v->IsNumber());
CHECK_EQ(3, v->Int32Value());
- env2.Dispose();
+ env2.Dispose(env2->GetIsolate());
}
@@ -6939,7 +6952,7 @@ THREADED_TEST(CrossDomainIsPropertyEnumerable) {
CHECK(result->IsFalse());
}
- env2.Dispose();
+ env2.Dispose(env2->GetIsolate());
}
@@ -6972,7 +6985,7 @@ THREADED_TEST(CrossDomainForIn) {
"return true;})()");
CHECK(result->IsTrue());
}
- env2.Dispose();
+ env2.Dispose(env2->GetIsolate());
}
@@ -7035,8 +7048,8 @@ TEST(ContextDetachGlobal) {
CHECK(r->IsUndefined());
}
- env2.Dispose();
- env3.Dispose();
+ env2.Dispose(env2->GetIsolate());
+ env3.Dispose(env3->GetIsolate());
}
@@ -7114,8 +7127,8 @@ TEST(DetachAndReattachGlobal) {
CHECK(result->IsInt32());
CHECK_EQ(42, result->Int32Value());
- env2.Dispose();
- env3.Dispose();
+ env2.Dispose(env2->GetIsolate());
+ env3.Dispose(env3->GetIsolate());
}
@@ -7405,8 +7418,8 @@ TEST(AccessControl) {
context1->Exit();
context0->Exit();
- context1.Dispose();
- context0.Dispose();
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
@@ -7534,8 +7547,8 @@ THREADED_TEST(AccessControlGetOwnPropertyNames) {
context1->Exit();
context0->Exit();
- context1.Dispose();
- context0.Dispose();
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
@@ -7618,8 +7631,8 @@ THREADED_TEST(CrossDomainAccessors) {
context1->Exit();
context0->Exit();
- context1.Dispose();
- context0.Dispose();
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
@@ -7753,8 +7766,8 @@ TEST(AccessControlIC) {
context1->Exit();
context0->Exit();
- context1.Dispose();
- context0.Dispose();
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
@@ -7828,8 +7841,8 @@ THREADED_TEST(AccessControlFlatten) {
context1->Exit();
context0->Exit();
- context1.Dispose();
- context0.Dispose();
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
@@ -7920,8 +7933,8 @@ THREADED_TEST(AccessControlInterceptorIC) {
context1->Exit();
context0->Exit();
- context1.Dispose();
- context0.Dispose();
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
@@ -8811,8 +8824,8 @@ THREADED_TEST(EvalInDetachedGlobal) {
CHECK(catcher.HasCaught());
context1->Exit();
- context1.Dispose();
- context0.Dispose();
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
@@ -11329,10 +11342,12 @@ TEST(DontLeakGlobalObjects) {
v8::Persistent<v8::Object> some_object;
v8::Persistent<v8::Object> bad_handle;
-void NewPersistentHandleCallback(v8::Persistent<v8::Value> handle, void*) {
+void NewPersistentHandleCallback(v8::Isolate* isolate,
+ v8::Persistent<v8::Value> handle,
+ void*) {
v8::HandleScope scope;
bad_handle = v8::Persistent<v8::Object>::New(some_object);
- handle.Dispose();
+ handle.Dispose(isolate);
}
@@ -11350,18 +11365,21 @@ THREADED_TEST(NewPersistentHandleFromWeakCallback) {
// global handle nodes are processed by PostGarbageCollectionProcessing
// in reverse allocation order, so if second allocated handle is deleted,
// weak callback of the first handle would be able to 'reallocate' it.
- handle1.MakeWeak(NULL, NewPersistentHandleCallback);
- handle2.Dispose();
+ v8::Isolate* isolate = context->GetIsolate();
+ handle1.MakeWeak(isolate, NULL, NewPersistentHandleCallback);
+ handle2.Dispose(isolate);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
}
v8::Persistent<v8::Object> to_be_disposed;
-void DisposeAndForceGcCallback(v8::Persistent<v8::Value> handle, void*) {
- to_be_disposed.Dispose();
+void DisposeAndForceGcCallback(v8::Isolate* isolate,
+ v8::Persistent<v8::Value> handle,
+ void*) {
+ to_be_disposed.Dispose(isolate);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
- handle.Dispose();
+ handle.Dispose(isolate);
}
@@ -11374,24 +11392,29 @@ THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) {
handle1 = v8::Persistent<v8::Object>::New(v8::Object::New());
handle2 = v8::Persistent<v8::Object>::New(v8::Object::New());
}
- handle1.MakeWeak(NULL, DisposeAndForceGcCallback);
+ handle1.MakeWeak(context->GetIsolate(), NULL, DisposeAndForceGcCallback);
to_be_disposed = handle2;
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
}
-void DisposingCallback(v8::Persistent<v8::Value> handle, void*) {
- handle.Dispose();
+void DisposingCallback(v8::Isolate* isolate,
+ v8::Persistent<v8::Value> handle,
+ void*) {
+ handle.Dispose(isolate);
}
-void HandleCreatingCallback(v8::Persistent<v8::Value> handle, void*) {
+void HandleCreatingCallback(v8::Isolate* isolate,
+ v8::Persistent<v8::Value> handle,
+ void*) {
v8::HandleScope scope;
v8::Persistent<v8::Object>::New(v8::Object::New());
- handle.Dispose();
+ handle.Dispose(isolate);
}
THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) {
LocalContext context;
+ v8::Isolate* isolate = context->GetIsolate();
v8::Persistent<v8::Object> handle1, handle2, handle3;
{
@@ -11400,8 +11423,8 @@ THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) {
handle2 = v8::Persistent<v8::Object>::New(v8::Object::New());
handle1 = v8::Persistent<v8::Object>::New(v8::Object::New());
}
- handle2.MakeWeak(NULL, DisposingCallback);
- handle3.MakeWeak(NULL, HandleCreatingCallback);
+ handle2.MakeWeak(isolate, NULL, DisposingCallback);
+ handle3.MakeWeak(isolate, NULL, HandleCreatingCallback);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
}
@@ -11447,7 +11470,7 @@ THREADED_TEST(NestedHandleScopeAndContexts) {
v8::Handle<String> str(value->ToString());
CHECK(!str.IsEmpty());
env->Exit();
- env.Dispose();
+ env.Dispose(env->GetIsolate());
}
@@ -11769,7 +11792,7 @@ THREADED_TEST(DisposeEnteredContext) {
LocalContext outer;
{ v8::Persistent<v8::Context> inner = v8::Context::New();
inner->Enter();
- inner.Dispose();
+ inner.Dispose(inner->GetIsolate());
inner.Clear();
inner->Exit();
}
@@ -12476,8 +12499,8 @@ THREADED_TEST(CrossContextNew) {
context1->Exit();
// Dispose the contexts to allow them to be garbage collected.
- context0.Dispose();
- context1.Dispose();
+ context0.Dispose(context0->GetIsolate());
+ context1.Dispose(context1->GetIsolate());
}
@@ -13292,9 +13315,9 @@ TEST(InlinedFunctionAcrossContexts) {
"ReferenceError: G is not defined");
ctx2->Exit();
ctx1->Exit();
- ctx1.Dispose();
+ ctx1.Dispose(ctx1->GetIsolate());
}
- ctx2.Dispose();
+ ctx2.Dispose(ctx2->GetIsolate());
}
@@ -13353,9 +13376,9 @@ THREADED_TEST(GetCallingContext) {
calling_context2->Exit();
// Dispose the contexts to allow them to be garbage collected.
- calling_context0.Dispose();
- calling_context1.Dispose();
- calling_context2.Dispose();
+ calling_context0.Dispose(calling_context0->GetIsolate());
+ calling_context1.Dispose(calling_context1->GetIsolate());
+ calling_context2.Dispose(calling_context2->GetIsolate());
calling_context0.Clear();
calling_context1.Clear();
calling_context2.Clear();
@@ -15077,7 +15100,7 @@ TEST(Regress2107) {
ctx->Enter();
CreateGarbageInOldSpace();
ctx->Exit();
- ctx.Dispose();
+ ctx.Dispose(ctx->GetIsolate());
v8::V8::ContextDisposedNotification();
v8::V8::IdleNotification(kLongIdlePauseInMs);
}
@@ -15429,7 +15452,7 @@ TEST(Regress528) {
CompileRun(source_simple);
context->Exit();
}
- context.Dispose();
+ context.Dispose(context->GetIsolate());
v8::V8::ContextDisposedNotification();
for (gc_count = 1; gc_count < 10; gc_count++) {
other_context->Enter();
@@ -15452,7 +15475,7 @@ TEST(Regress528) {
CompileRun(source_eval);
context->Exit();
}
- context.Dispose();
+ context.Dispose(context->GetIsolate());
v8::V8::ContextDisposedNotification();
for (gc_count = 1; gc_count < 10; gc_count++) {
other_context->Enter();
@@ -15480,7 +15503,7 @@ TEST(Regress528) {
CHECK_EQ(1, message->GetLineNumber());
context->Exit();
}
- context.Dispose();
+ context.Dispose(context->GetIsolate());
v8::V8::ContextDisposedNotification();
for (gc_count = 1; gc_count < 10; gc_count++) {
other_context->Enter();
@@ -15492,7 +15515,7 @@ TEST(Regress528) {
CHECK_GE(2, gc_count);
CHECK_EQ(1, GetGlobalObjectsCount());
- other_context.Dispose();
+ other_context.Dispose(other_context->GetIsolate());
v8::V8::ContextDisposedNotification();
}
@@ -16282,10 +16305,10 @@ TEST(RunTwoIsolatesOnSingleThread) {
{
v8::Isolate::Scope iscope(isolate2);
- context2.Dispose();
+ context2.Dispose(context2->GetIsolate());
}
- context1.Dispose();
+ context1.Dispose(context1->GetIsolate());
isolate1->Exit();
v8::V8::SetFatalErrorHandler(StoringErrorCallback);
@@ -16659,7 +16682,7 @@ class Visitor42 : public v8::PersistentHandleVisitor {
CHECK(value->IsObject());
v8::Persistent<v8::Object> visited =
v8::Persistent<v8::Object>::Cast(value);
- CHECK_EQ(42, visited.WrapperClassId());
+ CHECK_EQ(42, visited.WrapperClassId(v8::Isolate::GetCurrent()));
CHECK_EQ(object_, visited);
++counter_;
}
@@ -16673,29 +16696,31 @@ class Visitor42 : public v8::PersistentHandleVisitor {
TEST(PersistentHandleVisitor) {
v8::HandleScope scope;
LocalContext context;
+ v8::Isolate* isolate = context->GetIsolate();
v8::Persistent<v8::Object> object =
v8::Persistent<v8::Object>::New(v8::Object::New());
- CHECK_EQ(0, object.WrapperClassId());
+ CHECK_EQ(0, object.WrapperClassId(isolate));
object.SetWrapperClassId(42);
- CHECK_EQ(42, object.WrapperClassId());
+ CHECK_EQ(42, object.WrapperClassId(isolate));
Visitor42 visitor(object);
v8::V8::VisitHandlesWithClassIds(&visitor);
CHECK_EQ(1, visitor.counter_);
- object.Dispose();
+ object.Dispose(isolate);
}
TEST(WrapperClassId) {
v8::HandleScope scope;
LocalContext context;
+ v8::Isolate* isolate = context->GetIsolate();
v8::Persistent<v8::Object> object =
v8::Persistent<v8::Object>::New(v8::Object::New());
- CHECK_EQ(0, object.WrapperClassId());
+ CHECK_EQ(0, object.WrapperClassId(isolate));
object.SetWrapperClassId(65535);
- CHECK_EQ(65535, object.WrapperClassId());
- object.Dispose();
+ CHECK_EQ(65535, object.WrapperClassId(isolate));
+ object.Dispose(isolate);
}
@@ -16925,9 +16950,9 @@ THREADED_TEST(CreationContext) {
CheckContextId(instance2, 2);
}
- context1.Dispose();
- context2.Dispose();
- context3.Dispose();
+ context1.Dispose(context1->GetIsolate());
+ context2.Dispose(context2->GetIsolate());
+ context3.Dispose(context3->GetIsolate());
}
@@ -16945,7 +16970,7 @@ THREADED_TEST(CreationContextOfJsFunction) {
CHECK(function->CreationContext() == context);
CheckContextId(function, 1);
- context.Dispose();
+ context.Dispose(context->GetIsolate());
}
@@ -17321,7 +17346,7 @@ THREADED_TEST(Regress93759) {
Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)");
CHECK(result6->Equals(Undefined()));
- context.Dispose();
+ context.Dispose(context->GetIsolate());
}
@@ -17449,7 +17474,7 @@ THREADED_TEST(ForeignFunctionReceiver) {
// Calling with no base.
TestReceiver(o, context->Global(), "(1,func)()");
- foreign_context.Dispose();
+ foreign_context.Dispose(foreign_context->GetIsolate());
}
« src/global-handles.cc ('K') | « test/cctest/cctest.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698