Revision: 13443
Author: [email protected]
Date: Mon Jan 21 04:15:31 2013
Log: 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 <[email protected]>.
http://code.google.com/p/v8/source/detail?r=13443
Modified:
/branches/bleeding_edge/src/global-handles.cc
/branches/bleeding_edge/src/global-handles.h
=======================================
--- /branches/bleeding_edge/src/global-handles.cc Thu Jan 17 02:42:17 2013
+++ /branches/bleeding_edge/src/global-handles.cc Mon Jan 21 04:15:31 2013
@@ -106,12 +106,6 @@
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 @@
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 @@
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 @@
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),
@@ -710,6 +690,29 @@
}
}
}
+
+
+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) {
=======================================
--- /branches/bleeding_edge/src/global-handles.h Thu Jan 17 02:42:17 2013
+++ /branches/bleeding_edge/src/global-handles.h Mon Jan 21 04:15:31 2013
@@ -130,16 +130,14 @@
void* parameter,
WeakReferenceCallback callback);
+ void RecordStats(HeapStats* stats);
+
// Returns the current number of weak handles.
- int NumberOfWeakHandles() { return number_of_weak_handles_; }
-
- void RecordStats(HeapStats* stats);
+ 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 @@
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_;
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev