Revision: 14911
Author: [email protected]
Date: Mon Jun 3 01:17:04 2013
Log: remove old MakeWeak
[email protected]
BUG=
Review URL: https://codereview.chromium.org/16160010
http://code.google.com/p/v8/source/detail?r=14911
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/debug.cc
/branches/bleeding_edge/src/debug.h
/branches/bleeding_edge/src/deoptimizer.cc
/branches/bleeding_edge/src/deoptimizer.h
/branches/bleeding_edge/src/global-handles.cc
/branches/bleeding_edge/src/global-handles.h
/branches/bleeding_edge/src/handles.cc
/branches/bleeding_edge/src/profile-generator.cc
/branches/bleeding_edge/src/profile-generator.h
/branches/bleeding_edge/test/cctest/test-heap.cc
/branches/bleeding_edge/test/cctest/test-mark-compact.cc
/branches/bleeding_edge/test/cctest/test-weakmaps.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Fri May 31 04:06:50 2013
+++ /branches/bleeding_edge/include/v8.h Mon Jun 3 01:17:04 2013
@@ -214,11 +214,6 @@
P* parameter);
};
-// TODO(svenpanne) Temporary definition until Chrome is in sync.
-typedef void (*NearDeathCallback)(Isolate* isolate,
- Persistent<Value> object,
- void* parameter);
-
// --- Handles ---
#define TYPE_CHECK(T, S) \
@@ -675,11 +670,6 @@
typename WeakReferenceCallbacks<T, P>::Revivable callback)) {
MakeWeak<P>(parameters, callback);
}
-
- // TODO(dcarney): remove before cutover
- V8_INLINE(void MakeWeak(Isolate* isolate,
- void* parameters,
- NearDeathCallback callback));
V8_INLINE(void ClearWeak());
@@ -4606,8 +4596,7 @@
typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback;
static void MakeWeak(internal::Object** global_handle,
void* data,
- RevivableCallback weak_reference_callback,
- NearDeathCallback near_death_callback);
+ RevivableCallback weak_reference_callback);
static void ClearWeak(internal::Object** global_handle);
template <class T> friend class Handle;
@@ -5541,8 +5530,7 @@
typedef typename WeakReferenceCallbacks<Value, void>::Revivable
Revivable;
V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_),
parameters,
- reinterpret_cast<Revivable>(callback),
- NULL);
+ reinterpret_cast<Revivable>(callback));
}
@@ -5553,17 +5541,6 @@
typename WeakReferenceCallbacks<T, P>::Revivable callback) {
MakeWeak<T, P>(parameters, callback);
}
-
-
-template <class T>
-void Persistent<T>::MakeWeak(Isolate* isolate,
- void* parameters,
- NearDeathCallback callback) {
- V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_),
- parameters,
- NULL,
- callback);
-}
template <class T>
=======================================
--- /branches/bleeding_edge/src/api.cc Wed May 29 04:09:01 2013
+++ /branches/bleeding_edge/src/api.cc Mon Jun 3 01:17:04 2013
@@ -627,12 +627,10 @@
void V8::MakeWeak(i::Object** object,
void* parameters,
- RevivableCallback weak_reference_callback,
- NearDeathCallback near_death_callback) {
+ RevivableCallback weak_reference_callback) {
i::GlobalHandles::MakeWeak(object,
parameters,
- weak_reference_callback,
- near_death_callback);
+ weak_reference_callback);
}
=======================================
--- /branches/bleeding_edge/src/debug.cc Thu May 2 23:47:24 2013
+++ /branches/bleeding_edge/src/debug.cc Mon Jun 3 01:17:04 2013
@@ -619,7 +619,6 @@
(global_handles->Create(*script)));
global_handles->MakeWeak(reinterpret_cast<Object**>(script_.location()),
this,
- NULL,
ScriptCache::HandleWeakScript);
entry->value = script_.location();
}
@@ -664,12 +663,12 @@
void ScriptCache::HandleWeakScript(v8::Isolate* isolate,
- v8::Persistent<v8::Value> obj,
+ v8::Persistent<v8::Value>* obj,
void* data) {
ScriptCache* script_cache = reinterpret_cast<ScriptCache*>(data);
// Find the location of the global handle.
Script** location =
- reinterpret_cast<Script**>(Utils::OpenHandle(*obj).location());
+ reinterpret_cast<Script**>(Utils::OpenHandle(**obj).location());
ASSERT((*location)->IsScript());
// Remove the entry from the cache.
@@ -678,8 +677,7 @@
script_cache->collected_scripts_.Add(id);
// Clear the weak handle.
- obj.Dispose(isolate);
- obj.Clear();
+ obj->Dispose(isolate);
}
@@ -699,7 +697,7 @@
void Debug::HandleWeakDebugInfo(v8::Isolate* isolate,
- v8::Persistent<v8::Value> obj,
+ v8::Persistent<v8::Value>* obj,
void* data) {
Debug* debug = reinterpret_cast<Isolate*>(isolate)->debug();
DebugInfoListNode* node = reinterpret_cast<DebugInfoListNode*>(data);
@@ -727,7 +725,6 @@
(global_handles->Create(debug_info)));
global_handles->MakeWeak(reinterpret_cast<Object**>(debug_info_.location()),
this,
- NULL,
Debug::HandleWeakDebugInfo);
}
=======================================
--- /branches/bleeding_edge/src/debug.h Tue Apr 30 00:56:09 2013
+++ /branches/bleeding_edge/src/debug.h Mon Jun 3 01:17:04 2013
@@ -190,7 +190,7 @@
// Weak handle callback for scripts in the cache.
static void HandleWeakScript(v8::Isolate* isolate,
- v8::Persistent<v8::Value> obj,
+ v8::Persistent<v8::Value>* obj,
void* data);
// List used during GC to temporarily store id's of collected scripts.
@@ -387,7 +387,7 @@
// Passed to MakeWeak.
static void HandleWeakDebugInfo(v8::Isolate* isolate,
- v8::Persistent<v8::Value> obj,
+ v8::Persistent<v8::Value>* obj,
void* data);
friend class Debugger;
=======================================
--- /branches/bleeding_edge/src/deoptimizer.cc Fri May 17 01:27:56 2013
+++ /branches/bleeding_edge/src/deoptimizer.cc Mon Jun 3 01:17:04 2013
@@ -463,7 +463,7 @@
void Deoptimizer::HandleWeakDeoptimizedCode(v8::Isolate* isolate,
- v8::Persistent<v8::Value> obj,
+ v8::Persistent<v8::Value>* obj,
void* parameter) {
DeoptimizingCodeListNode* node =
reinterpret_cast<DeoptimizingCodeListNode*>(parameter);
@@ -2750,7 +2750,6 @@
code_ = Handle<Code>::cast(global_handles->Create(code));
global_handles->MakeWeak(reinterpret_cast<Object**>(code_.location()),
this,
- NULL,
Deoptimizer::HandleWeakDeoptimizedCode);
}
=======================================
--- /branches/bleeding_edge/src/deoptimizer.h Mon May 27 10:12:48 2013
+++ /branches/bleeding_edge/src/deoptimizer.h Mon Jun 3 01:17:04 2013
@@ -403,7 +403,7 @@
// Weak handle callback for deoptimizing code objects.
static void HandleWeakDeoptimizedCode(v8::Isolate* isolate,
- v8::Persistent<v8::Value> obj,
+ v8::Persistent<v8::Value>* obj,
void* data);
// Deoptimize function assuming that function->next_function_link()
points
=======================================
--- /branches/bleeding_edge/src/global-handles.cc Wed May 29 01:32:45 2013
+++ /branches/bleeding_edge/src/global-handles.cc Mon Jun 3 01:17:04 2013
@@ -92,7 +92,7 @@
set_partially_dependent(false);
set_in_new_space_list(false);
parameter_or_next_free_.next_free = NULL;
- near_death_callback_ = NULL;
+ weak_reference_callback_ = NULL;
}
#endif
@@ -113,7 +113,7 @@
set_partially_dependent(false);
set_state(NORMAL);
parameter_or_next_free_.parameter = NULL;
- near_death_callback_ = NULL;
+ weak_reference_callback_ = NULL;
IncreaseBlockUses();
}
@@ -126,7 +126,7 @@
class_id_ = v8::HeapProfiler::kPersistentHandleNoClassId;
set_independent(false);
set_partially_dependent(false);
- near_death_callback_ = NULL;
+ weak_reference_callback_ = NULL;
#endif
DecreaseBlockUses();
}
@@ -232,19 +232,11 @@
}
void MakeWeak(void* parameter,
- RevivableCallback weak_reference_callback,
- NearDeathCallback near_death_callback) {
+ RevivableCallback weak_reference_callback) {
ASSERT(state() != FREE);
set_state(WEAK);
set_parameter(parameter);
- if (weak_reference_callback != NULL) {
- flags_ = IsWeakCallback::update(flags_, true);
- near_death_callback_ =
- reinterpret_cast<NearDeathCallback>(weak_reference_callback);
- } else {
- flags_ = IsWeakCallback::update(flags_, false);
- near_death_callback_ = near_death_callback;
- }
+ weak_reference_callback_ = weak_reference_callback;
}
void ClearWeakness() {
@@ -255,7 +247,7 @@
bool PostGarbageCollectionProcessing(Isolate* isolate) {
if (state() != Node::PENDING) return false;
- if (near_death_callback_ == NULL) {
+ if (weak_reference_callback_ == NULL) {
Release();
return false;
}
@@ -263,7 +255,7 @@
set_state(NEAR_DEATH);
set_parameter(NULL);
- v8::Persistent<v8::Value> object = ToApi<v8::Value>(handle());
+ Object** object = location();
{
// Check that we are not passing a finalized external string to
// the callback.
@@ -273,19 +265,9 @@
ExternalTwoByteString::cast(object_)->resource() != NULL);
// Leaving V8.
VMState<EXTERNAL> state(isolate);
- if (near_death_callback_ != NULL) {
- if (IsWeakCallback::decode(flags_)) {
- RevivableCallback callback =
- reinterpret_cast<RevivableCallback>(near_death_callback_);
- callback(reinterpret_cast<v8::Isolate*>(isolate),
- &object,
- par);
- } else {
- near_death_callback_(reinterpret_cast<v8::Isolate*>(isolate),
- object,
+ weak_reference_callback_(reinterpret_cast<v8::Isolate*>(isolate),
+
reinterpret_cast<Persistent<Value>*>(&object),
par);
- }
- }
}
// Absence of explicit cleanup or revival of weak handle
// in most of the cases would lead to memory leak.
@@ -318,12 +300,11 @@
class IsIndependent: public BitField<bool, 4, 1> {};
class IsPartiallyDependent: public BitField<bool, 5, 1> {};
class IsInNewSpaceList: public BitField<bool, 6, 1> {};
- class IsWeakCallback: public BitField<bool, 7, 1> {};
uint8_t flags_;
// Handle specific callback - might be a weak reference in disguise.
- NearDeathCallback near_death_callback_;
+ RevivableCallback weak_reference_callback_;
// Provided data for callback. In FREE state, this is used for
// the free list link.
@@ -509,12 +490,9 @@
void GlobalHandles::MakeWeak(Object** location,
void* parameter,
- RevivableCallback weak_reference_callback,
- NearDeathCallback near_death_callback) {
- ASSERT((weak_reference_callback == NULL) != (near_death_callback ==
NULL));
- Node::FromLocation(location)->MakeWeak(parameter,
- weak_reference_callback,
- near_death_callback);
+ RevivableCallback weak_reference_callback) {
+ ASSERT(weak_reference_callback != NULL);
+ Node::FromLocation(location)->MakeWeak(parameter,
weak_reference_callback);
}
=======================================
--- /branches/bleeding_edge/src/global-handles.h Wed May 29 01:32:45 2013
+++ /branches/bleeding_edge/src/global-handles.h Mon Jun 3 01:17:04 2013
@@ -140,8 +140,7 @@
// reason is that Smi::FromInt(0) does not change during garage
collection.
static void MakeWeak(Object** location,
void* parameter,
- RevivableCallback weak_reference_callback,
- NearDeathCallback near_death_callback);
+ RevivableCallback weak_reference_callback);
void RecordStats(HeapStats* stats);
=======================================
--- /branches/bleeding_edge/src/handles.cc Fri May 31 12:11:09 2013
+++ /branches/bleeding_edge/src/handles.cc Mon Jun 3 01:17:04 2013
@@ -345,9 +345,9 @@
// associated with the wrapper and get rid of both the wrapper and the
// handle.
static void ClearWrapperCache(v8::Isolate* v8_isolate,
- Persistent<v8::Value> handle,
+ Persistent<v8::Value>* handle,
void*) {
- Handle<Object> cache = Utils::OpenHandle(*handle);
+ Handle<Object> cache = Utils::OpenHandle(**handle);
JSValue* wrapper = JSValue::cast(*cache);
Foreign* foreign = Script::cast(wrapper->value())->wrapper();
ASSERT(foreign->foreign_address() ==
@@ -388,7 +388,6 @@
Handle<Object> handle = isolate->global_handles()->Create(*result);
isolate->global_handles()->MakeWeak(handle.location(),
NULL,
- NULL,
&ClearWrapperCache);
script->wrapper()->set_foreign_address(
reinterpret_cast<Address>(handle.location()));
=======================================
--- /branches/bleeding_edge/src/profile-generator.cc Tue May 14 16:54:39
2013
+++ /branches/bleeding_edge/src/profile-generator.cc Mon Jun 3 01:17:04
2013
@@ -68,7 +68,6 @@
// to a token object in the V8's heap.
isolate->global_handles()->MakeWeak(handle.location(),
this,
- NULL,
TokenRemovedCallback);
token_locations_.Add(handle.location());
token_removed_.Add(false);
@@ -77,11 +76,11 @@
void TokenEnumerator::TokenRemovedCallback(v8::Isolate* isolate,
- v8::Persistent<v8::Value>
handle,
+ v8::Persistent<v8::Value>*
handle,
void* parameter) {
reinterpret_cast<TokenEnumerator*>(parameter)->TokenRemoved(
- Utils::OpenHandle(*handle).location());
- handle.Dispose(isolate);
+ Utils::OpenHandle(**handle).location());
+ handle->Dispose(isolate);
}
=======================================
--- /branches/bleeding_edge/src/profile-generator.h Tue May 14 15:51:33 2013
+++ /branches/bleeding_edge/src/profile-generator.h Mon Jun 3 01:17:04 2013
@@ -48,7 +48,7 @@
private:
static void TokenRemovedCallback(v8::Isolate* isolate,
- v8::Persistent<v8::Value> handle,
+ v8::Persistent<v8::Value>* handle,
void* parameter);
void TokenRemoved(Object** token_location);
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap.cc Wed May 29 04:13:59
2013
+++ /branches/bleeding_edge/test/cctest/test-heap.cc Mon Jun 3 01:17:04
2013
@@ -423,8 +423,7 @@
global_handles->MakeWeak(h2.location(),
reinterpret_cast<void*>(1234),
- &TestWeakGlobalHandleCallback,
- NULL);
+ &TestWeakGlobalHandleCallback);
// Scavenge treats weak pointers as normal roots.
heap->PerformScavenge();
@@ -470,8 +469,7 @@
global_handles->MakeWeak(h2.location(),
reinterpret_cast<void*>(1234),
- &TestWeakGlobalHandleCallback,
- NULL);
+ &TestWeakGlobalHandleCallback);
CHECK(!GlobalHandles::IsNearDeath(h1.location()));
CHECK(!GlobalHandles::IsNearDeath(h2.location()));
@@ -507,8 +505,7 @@
global_handles->MakeWeak(h.location(),
reinterpret_cast<void*>(1234),
- &TestWeakGlobalHandleCallback,
- NULL);
+ &TestWeakGlobalHandleCallback);
// Scanvenge does not recognize weak reference.
heap->PerformScavenge();
=======================================
--- /branches/bleeding_edge/test/cctest/test-mark-compact.cc Tue May 28
04:54:52 2013
+++ /branches/bleeding_edge/test/cctest/test-mark-compact.cc Mon Jun 3
01:17:04 2013
@@ -323,16 +323,13 @@
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->MakeWeak(g1s1.location(),
reinterpret_cast<void*>(1234),
- &WeakPointerCallback,
- NULL);
+ &WeakPointerCallback);
global_handles->MakeWeak(g1s2.location(),
reinterpret_cast<void*>(1234),
- &WeakPointerCallback,
- NULL);
+ &WeakPointerCallback);
global_handles->MakeWeak(g1c1.location(),
reinterpret_cast<void*>(1234),
- &WeakPointerCallback,
- NULL);
+ &WeakPointerCallback);
Handle<Object> g2s1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
@@ -342,16 +339,13 @@
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->MakeWeak(g2s1.location(),
reinterpret_cast<void*>(1234),
- &WeakPointerCallback,
- NULL);
+ &WeakPointerCallback);
global_handles->MakeWeak(g2s2.location(),
reinterpret_cast<void*>(1234),
- &WeakPointerCallback,
- NULL);
+ &WeakPointerCallback);
global_handles->MakeWeak(g2c1.location(),
reinterpret_cast<void*>(1234),
- &WeakPointerCallback,
- NULL);
+ &WeakPointerCallback);
Handle<Object> root = global_handles->Create(*g1s1); // make a root.
@@ -380,8 +374,7 @@
// Weaken the root.
global_handles->MakeWeak(root.location(),
reinterpret_cast<void*>(1234),
- &WeakPointerCallback,
- NULL);
+ &WeakPointerCallback);
// But make children strong roots---all the objects (except for children)
// should be collectable now.
global_handles->ClearWeakness(g1c1.location());
@@ -409,12 +402,10 @@
// And now make children weak again and collect them.
global_handles->MakeWeak(g1c1.location(),
reinterpret_cast<void*>(1234),
- &WeakPointerCallback,
- NULL);
+ &WeakPointerCallback);
global_handles->MakeWeak(g2c1.location(),
reinterpret_cast<void*>(1234),
- &WeakPointerCallback,
- NULL);
+ &WeakPointerCallback);
HEAP->CollectGarbage(OLD_POINTER_SPACE);
CHECK_EQ(7, NumberOfWeakCalls);
=======================================
--- /branches/bleeding_edge/test/cctest/test-weakmaps.cc Tue May 7
03:44:30 2013
+++ /branches/bleeding_edge/test/cctest/test-weakmaps.cc Mon Jun 3
01:17:04 2013
@@ -114,8 +114,7 @@
HandleScope scope(isolate);
global_handles->MakeWeak(key.location(),
reinterpret_cast<void*>(1234),
- &WeakPointerCallback,
- NULL);
+ &WeakPointerCallback);
}
CHECK(global_handles->IsWeak(key.location()));
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.