Remove GlobalHandles::number_of_weak_handles_ and number_of_global_object_weak_handles_

This is a preparation patch for inlining MakeWeak() and Clear().

Given that NumberOfWeakHandles() is used only by CHECK_EQ() in serialized.cc and that NumberOfGlobalObjectWeakHandles is unused, it is wasteful to keep track of number_of_weak_handles_ and number_of_global_object_weak_handles_ at every MakeWeak() and Clear(). Instead, we can count the number at the point where NumberOfWeakHandles() or NumberOfGlobalObjectWeakHandles() is called.

BUG=

Review URL: https://codereview.chromium.org/11958015
Patch from Kentaro Hara <haraken@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13443 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b659b460
......@@ -106,12 +106,6 @@ class GlobalHandles::Node {
void Release(GlobalHandles* global_handles) {
ASSERT(state() != FREE);
if (IsWeakRetainer()) {
global_handles->number_of_weak_handles_--;
if (object_->IsJSGlobalObject()) {
global_handles->number_of_global_object_weak_handles_--;
}
}
set_state(FREE);
parameter_or_next_free_.next_free = global_handles->first_free_;
global_handles->first_free_ = this;
......@@ -221,12 +215,6 @@ class GlobalHandles::Node {
void* parameter,
WeakReferenceCallback callback) {
ASSERT(state() != FREE);
if (!IsWeakRetainer()) {
global_handles->number_of_weak_handles_++;
if (object_->IsJSGlobalObject()) {
global_handles->number_of_global_object_weak_handles_++;
}
}
set_state(WEAK);
set_parameter(parameter);
callback_ = callback;
......@@ -234,12 +222,6 @@ class GlobalHandles::Node {
void ClearWeakness(GlobalHandles* global_handles) {
ASSERT(state() != FREE);
if (IsWeakRetainer()) {
global_handles->number_of_weak_handles_--;
if (object_->IsJSGlobalObject()) {
global_handles->number_of_global_object_weak_handles_--;
}
}
set_state(NORMAL);
set_parameter(NULL);
}
......@@ -421,8 +403,6 @@ class GlobalHandles::NodeIterator {
GlobalHandles::GlobalHandles(Isolate* isolate)
: isolate_(isolate),
number_of_weak_handles_(0),
number_of_global_object_weak_handles_(0),
number_of_global_handles_(0),
first_block_(NULL),
first_used_block_(NULL),
......@@ -712,6 +692,29 @@ void GlobalHandles::IterateAllRootsWithClassIds(ObjectVisitor* v) {
}
int GlobalHandles::NumberOfWeakHandles() {
int count = 0;
for (NodeIterator it(this); !it.done(); it.Advance()) {
if (it.node()->IsWeakRetainer()) {
count++;
}
}
return count;
}
int GlobalHandles::NumberOfGlobalObjectWeakHandles() {
int count = 0;
for (NodeIterator it(this); !it.done(); it.Advance()) {
if (it.node()->IsWeakRetainer() &&
it.node()->object()->IsJSGlobalObject()) {
count++;
}
}
return count;
}
void GlobalHandles::RecordStats(HeapStats* stats) {
*stats->global_handle_count = 0;
*stats->weak_global_handle_count = 0;
......
......@@ -130,16 +130,14 @@ class GlobalHandles {
void* parameter,
WeakReferenceCallback callback);
// Returns the current number of weak handles.
int NumberOfWeakHandles() { return number_of_weak_handles_; }
void RecordStats(HeapStats* stats);
// Returns the current number of weak handles.
int NumberOfWeakHandles();
// Returns the current number of weak handles to global objects.
// These handles are also included in NumberOfWeakHandles().
int NumberOfGlobalObjectWeakHandles() {
return number_of_global_object_weak_handles_;
}
int NumberOfGlobalObjectWeakHandles();
// Returns the current number of handles to global objects.
int NumberOfGlobalHandles() {
......@@ -255,14 +253,6 @@ class GlobalHandles {
Isolate* isolate_;
// Field always containing the number of weak and near-death handles.
int number_of_weak_handles_;
// Field always containing the number of weak and near-death handles
// to global objects. These objects are also included in
// number_of_weak_handles_.
int number_of_global_object_weak_handles_;
// Field always containing the number of handles to global objects.
int number_of_global_handles_;
......
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