Commit 9103afa2 authored by dcarney@chromium.org's avatar dcarney@chromium.org

Deprecate the version of MakeWeak which takes an Isolate.

BUG=NONE
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/16528009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15105 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2ed2fde8
......@@ -652,23 +652,17 @@ template <class T> class Persistent // NOLINT
P* parameters,
typename WeakReferenceCallbacks<T, P>::Revivable callback));
// TODO(dcarney): deprecate
template<typename S, typename P>
V8_INLINE(void MakeWeak(
V8_DEPRECATED(void MakeWeak(
Isolate* isolate,
P* parameters,
typename WeakReferenceCallbacks<S, P>::Revivable callback)) {
MakeWeak<S, P>(parameters, callback);
}
typename WeakReferenceCallbacks<S, P>::Revivable callback));
// TODO(dcarney): deprecate
template<typename P>
V8_INLINE(void MakeWeak(
V8_DEPRECATED(void MakeWeak(
Isolate* isolate,
P* parameters,
typename WeakReferenceCallbacks<T, P>::Revivable callback)) {
MakeWeak<P>(parameters, callback);
}
typename WeakReferenceCallbacks<T, P>::Revivable callback));
V8_INLINE(void ClearWeak());
......@@ -5597,6 +5591,26 @@ void Persistent<T>::MakeWeak(
}
template <class T>
template <typename S, typename P>
void Persistent<T>::MakeWeak(
Isolate* isolate,
P* parameters,
typename WeakReferenceCallbacks<S, P>::Revivable callback) {
MakeWeak<S, P>(parameters, callback);
}
template <class T>
template<typename P>
void Persistent<T>::MakeWeak(
Isolate* isolate,
P* parameters,
typename WeakReferenceCallbacks<T, P>::Revivable callback) {
MakeWeak<P>(parameters, callback);
}
template <class T>
void Persistent<T>::ClearWeak() {
V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_));
......
......@@ -1104,7 +1104,7 @@ void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
Handle<v8::ArrayBuffer> buffer = ArrayBuffer::New(data, length);
v8::Persistent<v8::Value> weak_handle(isolate, buffer);
weak_handle.MakeWeak(isolate, data, ReadBufferWeakCallback);
weak_handle.MakeWeak(data, ReadBufferWeakCallback);
weak_handle.MarkIndependent();
isolate->AdjustAmountOfExternalAllocatedMemory(length);
......
......@@ -714,7 +714,7 @@ bool Runtime::SetupArrayBufferAllocatingData(
v8::Isolate* external_isolate = reinterpret_cast<v8::Isolate*>(isolate);
v8::Persistent<v8::Value> weak_handle(
external_isolate, v8::Utils::ToLocal(Handle<Object>::cast(array_buffer)));
weak_handle.MakeWeak(external_isolate, data, ArrayBufferWeakCallback);
weak_handle.MakeWeak(data, ArrayBufferWeakCallback);
weak_handle.MarkIndependent(external_isolate);
isolate->heap()->AdjustAmountOfExternalAllocatedMemory(allocated_length);
......
......@@ -3121,16 +3121,16 @@ THREADED_TEST(ApiObjectGroups) {
g1s1.Reset(iso, Object::New());
g1s2.Reset(iso, Object::New());
g1c1.Reset(iso, Object::New());
g1s1.MakeWeak(iso, &counter, &WeakPointerCallback);
g1s2.MakeWeak(iso, &counter, &WeakPointerCallback);
g1c1.MakeWeak(iso, &counter, &WeakPointerCallback);
g1s1.MakeWeak(&counter, &WeakPointerCallback);
g1s2.MakeWeak(&counter, &WeakPointerCallback);
g1c1.MakeWeak(&counter, &WeakPointerCallback);
g2s1.Reset(iso, Object::New());
g2s2.Reset(iso, Object::New());
g2c1.Reset(iso, Object::New());
g2s1.MakeWeak(iso, &counter, &WeakPointerCallback);
g2s2.MakeWeak(iso, &counter, &WeakPointerCallback);
g2c1.MakeWeak(iso, &counter, &WeakPointerCallback);
g2s1.MakeWeak(&counter, &WeakPointerCallback);
g2s2.MakeWeak(&counter, &WeakPointerCallback);
g2c1.MakeWeak(&counter, &WeakPointerCallback);
}
Persistent<Value> root(iso, g1s1); // make a root.
......@@ -3163,7 +3163,7 @@ THREADED_TEST(ApiObjectGroups) {
CHECK_EQ(0, counter.NumberOfWeakCalls());
// Weaken the root.
root.MakeWeak(iso, &counter, &WeakPointerCallback);
root.MakeWeak(&counter, &WeakPointerCallback);
// But make children strong roots---all the objects (except for children)
// should be collectable now.
g1c1.ClearWeak(iso);
......@@ -3187,8 +3187,8 @@ THREADED_TEST(ApiObjectGroups) {
CHECK_EQ(5, counter.NumberOfWeakCalls());
// And now make children weak again and collect them.
g1c1.MakeWeak(iso, &counter, &WeakPointerCallback);
g2c1.MakeWeak(iso, &counter, &WeakPointerCallback);
g1c1.MakeWeak(&counter, &WeakPointerCallback);
g2c1.MakeWeak(&counter, &WeakPointerCallback);
heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
CHECK_EQ(7, counter.NumberOfWeakCalls());
......@@ -3215,29 +3215,29 @@ THREADED_TEST(ApiObjectGroupsCycle) {
HandleScope scope(iso);
g1s1.Reset(iso, Object::New());
g1s2.Reset(iso, Object::New());
g1s1.MakeWeak(iso, &counter, &WeakPointerCallback);
g1s2.MakeWeak(iso, &counter, &WeakPointerCallback);
g1s1.MakeWeak(&counter, &WeakPointerCallback);
g1s2.MakeWeak(&counter, &WeakPointerCallback);
CHECK(g1s1.IsWeak(iso));
CHECK(g1s2.IsWeak(iso));
g2s1.Reset(iso, Object::New());
g2s2.Reset(iso, Object::New());
g2s1.MakeWeak(iso, &counter, &WeakPointerCallback);
g2s2.MakeWeak(iso, &counter, &WeakPointerCallback);
g2s1.MakeWeak(&counter, &WeakPointerCallback);
g2s2.MakeWeak(&counter, &WeakPointerCallback);
CHECK(g2s1.IsWeak(iso));
CHECK(g2s2.IsWeak(iso));
g3s1.Reset(iso, Object::New());
g3s2.Reset(iso, Object::New());
g3s1.MakeWeak(iso, &counter, &WeakPointerCallback);
g3s2.MakeWeak(iso, &counter, &WeakPointerCallback);
g3s1.MakeWeak(&counter, &WeakPointerCallback);
g3s2.MakeWeak(&counter, &WeakPointerCallback);
CHECK(g3s1.IsWeak(iso));
CHECK(g3s2.IsWeak(iso));
g4s1.Reset(iso, Object::New());
g4s2.Reset(iso, Object::New());
g4s1.MakeWeak(iso, &counter, &WeakPointerCallback);
g4s2.MakeWeak(iso, &counter, &WeakPointerCallback);
g4s1.MakeWeak(&counter, &WeakPointerCallback);
g4s2.MakeWeak(&counter, &WeakPointerCallback);
CHECK(g4s1.IsWeak(iso));
CHECK(g4s2.IsWeak(iso));
}
......@@ -3274,7 +3274,7 @@ THREADED_TEST(ApiObjectGroupsCycle) {
CHECK_EQ(0, counter.NumberOfWeakCalls());
// Weaken the root.
root.MakeWeak(iso, &counter, &WeakPointerCallback);
root.MakeWeak(&counter, &WeakPointerCallback);
// Groups are deleted, rebuild groups.
{
......@@ -3325,18 +3325,18 @@ TEST(ApiObjectGroupsCycleForScavenger) {
HandleScope scope(iso);
g1s1.Reset(iso, Object::New());
g1s2.Reset(iso, Object::New());
g1s1.MakeWeak(iso, &counter, &WeakPointerCallback);
g1s2.MakeWeak(iso, &counter, &WeakPointerCallback);
g1s1.MakeWeak(&counter, &WeakPointerCallback);
g1s2.MakeWeak(&counter, &WeakPointerCallback);
g2s1.Reset(iso, Object::New());
g2s2.Reset(iso, Object::New());
g2s1.MakeWeak(iso, &counter, &WeakPointerCallback);
g2s2.MakeWeak(iso, &counter, &WeakPointerCallback);
g2s1.MakeWeak(&counter, &WeakPointerCallback);
g2s2.MakeWeak(&counter, &WeakPointerCallback);
g3s1.Reset(iso, Object::New());
g3s2.Reset(iso, Object::New());
g3s1.MakeWeak(iso, &counter, &WeakPointerCallback);
g3s2.MakeWeak(iso, &counter, &WeakPointerCallback);
g3s1.MakeWeak(&counter, &WeakPointerCallback);
g3s2.MakeWeak(&counter, &WeakPointerCallback);
}
// Make a root.
......@@ -3376,7 +3376,7 @@ TEST(ApiObjectGroupsCycleForScavenger) {
CHECK_EQ(0, counter.NumberOfWeakCalls());
// Weaken the root.
root.MakeWeak(iso, &counter, &WeakPointerCallback);
root.MakeWeak(&counter, &WeakPointerCallback);
root.MarkPartiallyDependent(iso);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
......@@ -6276,9 +6276,7 @@ v8::Handle<Value> WhammyPropertyGetter(Local<String> name,
if (!prev.IsEmpty()) {
v8::Local<v8::Object>::New(info.GetIsolate(), prev)
->Set(v8_str("next"), obj);
prev.MakeWeak<Value, Snorkel>(info.GetIsolate(),
new Snorkel(),
&HandleWeakReference);
prev.MakeWeak<Value, Snorkel>(new Snorkel(), &HandleWeakReference);
whammy->objects_[whammy->cursor_].Clear();
}
whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj);
......@@ -6340,8 +6338,8 @@ THREADED_TEST(IndependentWeakHandle) {
bool object_a_disposed = false;
bool object_b_disposed = false;
object_a.MakeWeak(iso, &object_a_disposed, &DisposeAndSetFlag);
object_b.MakeWeak(iso, &object_b_disposed, &DisposeAndSetFlag);
object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag);
object_b.MakeWeak(&object_b_disposed, &DisposeAndSetFlag);
CHECK(!object_b.IsIndependent(iso));
object_a.MarkIndependent(iso);
object_b.MarkIndependent(iso);
......@@ -6402,7 +6400,7 @@ THREADED_TEST(GCFromWeakCallbacks) {
object.Reset(isolate, v8::Object::New());
}
bool disposed = false;
object.MakeWeak(isolate, &disposed, gc_forcing_callback[inner_gc]);
object.MakeWeak(&disposed, gc_forcing_callback[inner_gc]);
object.MarkIndependent(isolate);
invoke_gc[outer_gc]();
CHECK(disposed);
......@@ -6435,7 +6433,7 @@ THREADED_TEST(IndependentHandleRevival) {
o->Set(y_str, y_str);
}
bool revived = false;
object.MakeWeak(isolate, &revived, &RevivingCallback);
object.MakeWeak(&revived, &RevivingCallback);
object.MarkIndependent(isolate);
HEAP->PerformScavenge();
CHECK(revived);
......@@ -12161,9 +12159,7 @@ 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<v8::Value, void>(isolate,
NULL,
NewPersistentHandleCallback);
handle1.MakeWeak<v8::Value, void>(NULL, NewPersistentHandleCallback);
handle2.Dispose(isolate);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
}
......@@ -12190,7 +12186,7 @@ THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) {
handle1.Reset(isolate, v8::Object::New());
handle2.Reset(isolate, v8::Object::New());
}
handle1.MakeWeak<v8::Value, void>(isolate, NULL, DisposeAndForceGcCallback);
handle1.MakeWeak<v8::Value, void>(NULL, DisposeAndForceGcCallback);
to_be_disposed.Reset(isolate, handle2);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
}
......@@ -12221,8 +12217,8 @@ THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) {
handle2.Reset(isolate, v8::Object::New());
handle1.Reset(isolate, v8::Object::New());
}
handle2.MakeWeak<v8::Value, void>(isolate, NULL, DisposingCallback);
handle3.MakeWeak<v8::Value, void>(isolate, NULL, HandleCreatingCallback);
handle2.MakeWeak<v8::Value, void>(NULL, DisposingCallback);
handle3.MakeWeak<v8::Value, void>(NULL, HandleCreatingCallback);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
}
......
......@@ -1605,9 +1605,7 @@ TEST(WeakGlobalHandle) {
CHECK(!HasWeakGlobalHandle());
v8::Persistent<v8::Object> handle(env->GetIsolate(), v8::Object::New());
handle.MakeWeak<v8::Value, void>(env->GetIsolate(),
NULL,
PersistentHandleCallback);
handle.MakeWeak<v8::Value, void>(NULL, PersistentHandleCallback);
CHECK(HasWeakGlobalHandle());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment