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

Unified Diff: src/global-handles.cc

Issue 16160010: remove old MakeWeak (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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
« no previous file with comments | « src/global-handles.h ('k') | src/handles.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/global-handles.cc
diff --git a/src/global-handles.cc b/src/global-handles.cc
index 8ed6fc9e93b9722f720bc48d01fc0a2d15480f1e..20a258c5b4899bd8ca01cf752696cb57d51fb634 100644
--- a/src/global-handles.cc
+++ b/src/global-handles.cc
@@ -92,7 +92,7 @@ class GlobalHandles::Node {
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 @@ class GlobalHandles::Node {
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 GlobalHandles::Node {
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 @@ class GlobalHandles::Node {
}
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 @@ class GlobalHandles::Node {
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 @@ class GlobalHandles::Node {
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 @@ class GlobalHandles::Node {
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 GlobalHandles::Node {
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::Destroy(Object** location) {
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);
}
« no previous file with comments | « src/global-handles.h ('k') | src/handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698