diff options
Diffstat (limited to 'deps/v8/src/global-handles.cc')
-rw-r--r-- | deps/v8/src/global-handles.cc | 99 |
1 files changed, 50 insertions, 49 deletions
diff --git a/deps/v8/src/global-handles.cc b/deps/v8/src/global-handles.cc index 168a670d2..940d53bb1 100644 --- a/deps/v8/src/global-handles.cc +++ b/deps/v8/src/global-handles.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "v8.h" +#include "src/v8.h" -#include "api.h" -#include "global-handles.h" +#include "src/api.h" +#include "src/global-handles.h" -#include "vm-state-inl.h" +#include "src/vm-state-inl.h" namespace v8 { namespace internal { @@ -38,13 +38,13 @@ class GlobalHandles::Node { // Maps handle location (slot) to the containing node. static Node* FromLocation(Object** location) { - ASSERT(OFFSET_OF(Node, object_) == 0); + DCHECK(OFFSET_OF(Node, object_) == 0); return reinterpret_cast<Node*>(location); } Node() { - ASSERT(OFFSET_OF(Node, class_id_) == Internals::kNodeClassIdOffset); - ASSERT(OFFSET_OF(Node, flags_) == Internals::kNodeFlagsOffset); + DCHECK(OFFSET_OF(Node, class_id_) == Internals::kNodeClassIdOffset); + DCHECK(OFFSET_OF(Node, flags_) == Internals::kNodeFlagsOffset); STATIC_ASSERT(static_cast<int>(NodeState::kMask) == Internals::kNodeStateMask); STATIC_ASSERT(WEAK == Internals::kNodeStateIsWeakValue); @@ -73,7 +73,7 @@ class GlobalHandles::Node { void Initialize(int index, Node** first_free) { index_ = static_cast<uint8_t>(index); - ASSERT(static_cast<int>(index_) == index); + DCHECK(static_cast<int>(index_) == index); set_state(FREE); set_in_new_space_list(false); parameter_or_next_free_.next_free = *first_free; @@ -81,7 +81,7 @@ class GlobalHandles::Node { } void Acquire(Object* object) { - ASSERT(state() == FREE); + DCHECK(state() == FREE); object_ = object; class_id_ = v8::HeapProfiler::kPersistentHandleNoClassId; set_independent(false); @@ -93,7 +93,7 @@ class GlobalHandles::Node { } void Release() { - ASSERT(state() != FREE); + DCHECK(state() != FREE); set_state(FREE); // Zap the values for eager trapping. object_ = reinterpret_cast<Object*>(kGlobalHandleZapValue); @@ -162,18 +162,18 @@ class GlobalHandles::Node { } void MarkPending() { - ASSERT(state() == WEAK); + DCHECK(state() == WEAK); set_state(PENDING); } // Independent flag accessors. void MarkIndependent() { - ASSERT(state() != FREE); + DCHECK(state() != FREE); set_independent(true); } void MarkPartiallyDependent() { - ASSERT(state() != FREE); + DCHECK(state() != FREE); if (GetGlobalHandles()->isolate()->heap()->InNewSpace(object_)) { set_partially_dependent(true); } @@ -186,34 +186,35 @@ class GlobalHandles::Node { // Callback parameter accessors. void set_parameter(void* parameter) { - ASSERT(state() != FREE); + DCHECK(state() != FREE); parameter_or_next_free_.parameter = parameter; } void* parameter() const { - ASSERT(state() != FREE); + DCHECK(state() != FREE); return parameter_or_next_free_.parameter; } // Accessors for next free node in the free list. Node* next_free() { - ASSERT(state() == FREE); + DCHECK(state() == FREE); return parameter_or_next_free_.next_free; } void set_next_free(Node* value) { - ASSERT(state() == FREE); + DCHECK(state() == FREE); parameter_or_next_free_.next_free = value; } void MakeWeak(void* parameter, WeakCallback weak_callback) { - ASSERT(weak_callback != NULL); - ASSERT(state() != FREE); + DCHECK(weak_callback != NULL); + DCHECK(state() != FREE); + CHECK(object_ != NULL); set_state(WEAK); set_parameter(parameter); weak_callback_ = weak_callback; } void* ClearWeakness() { - ASSERT(state() != FREE); + DCHECK(state() != FREE); void* p = parameter(); set_state(NORMAL); set_parameter(NULL); @@ -234,9 +235,9 @@ class GlobalHandles::Node { { // Check that we are not passing a finalized external string to // the callback. - ASSERT(!object_->IsExternalAsciiString() || + DCHECK(!object_->IsExternalAsciiString() || ExternalAsciiString::cast(object_)->resource() != NULL); - ASSERT(!object_->IsExternalTwoByteString() || + DCHECK(!object_->IsExternalTwoByteString() || ExternalTwoByteString::cast(object_)->resource() != NULL); // Leaving V8. VMState<EXTERNAL> state(isolate); @@ -315,12 +316,12 @@ class GlobalHandles::NodeBlock { } Node* node_at(int index) { - ASSERT(0 <= index && index < kSize); + DCHECK(0 <= index && index < kSize); return &nodes_[index]; } void IncreaseUses() { - ASSERT(used_nodes_ < kSize); + DCHECK(used_nodes_ < kSize); if (used_nodes_++ == 0) { NodeBlock* old_first = global_handles_->first_used_block_; global_handles_->first_used_block_ = this; @@ -332,7 +333,7 @@ class GlobalHandles::NodeBlock { } void DecreaseUses() { - ASSERT(used_nodes_ > 0); + DCHECK(used_nodes_ > 0); if (--used_nodes_ == 0) { if (next_used_ != NULL) next_used_->prev_used_ = prev_used_; if (prev_used_ != NULL) prev_used_->next_used_ = next_used_; @@ -370,7 +371,7 @@ GlobalHandles::NodeBlock* GlobalHandles::Node::FindBlock() { intptr_t ptr = reinterpret_cast<intptr_t>(this); ptr = ptr - index_ * sizeof(Node); NodeBlock* block = reinterpret_cast<NodeBlock*>(ptr); - ASSERT(block->node_at(index_) == this); + DCHECK(block->node_at(index_) == this); return block; } @@ -404,12 +405,12 @@ class GlobalHandles::NodeIterator { bool done() const { return block_ == NULL; } Node* node() const { - ASSERT(!done()); + DCHECK(!done()); return block_->node_at(index_); } void Advance() { - ASSERT(!done()); + DCHECK(!done()); if (++index_ < NodeBlock::kSize) return; index_ = 0; block_ = block_->next_used(); @@ -449,7 +450,7 @@ Handle<Object> GlobalHandles::Create(Object* value) { first_block_ = new NodeBlock(this, first_block_); first_block_->PutNodesOnFreeList(&first_free_); } - ASSERT(first_free_ != NULL); + DCHECK(first_free_ != NULL); // Take the first node in the free list. Node* result = first_free_; first_free_ = result->next_free(); @@ -464,7 +465,7 @@ Handle<Object> GlobalHandles::Create(Object* value) { Handle<Object> GlobalHandles::CopyGlobal(Object** location) { - ASSERT(location != NULL); + DCHECK(location != NULL); return Node::FromLocation(location)->GetGlobalHandles()->Create(*location); } @@ -543,7 +544,7 @@ void GlobalHandles::IdentifyNewSpaceWeakIndependentHandles( WeakSlotCallbackWithHeap f) { for (int i = 0; i < new_space_nodes_.length(); ++i) { Node* node = new_space_nodes_[i]; - ASSERT(node->is_in_new_space_list()); + DCHECK(node->is_in_new_space_list()); if ((node->is_independent() || node->is_partially_dependent()) && node->IsWeak() && f(isolate_->heap(), node->location())) { node->MarkPending(); @@ -555,7 +556,7 @@ void GlobalHandles::IdentifyNewSpaceWeakIndependentHandles( void GlobalHandles::IterateNewSpaceWeakIndependentRoots(ObjectVisitor* v) { for (int i = 0; i < new_space_nodes_.length(); ++i) { Node* node = new_space_nodes_[i]; - ASSERT(node->is_in_new_space_list()); + DCHECK(node->is_in_new_space_list()); if ((node->is_independent() || node->is_partially_dependent()) && node->IsWeakRetainer()) { v->VisitPointer(node->location()); @@ -571,7 +572,7 @@ bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, bool any_group_was_visited = false; for (int i = 0; i < object_groups_.length(); i++) { ObjectGroup* entry = object_groups_.at(i); - ASSERT(entry != NULL); + DCHECK(entry != NULL); Object*** objects = entry->objects; bool group_should_be_visited = false; @@ -611,17 +612,17 @@ bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, int GlobalHandles::PostGarbageCollectionProcessing( - GarbageCollector collector, GCTracer* tracer) { + GarbageCollector collector) { // Process weak global handle callbacks. This must be done after the // GC is completely done, because the callbacks may invoke arbitrary // API functions. - ASSERT(isolate_->heap()->gc_state() == Heap::NOT_IN_GC); + DCHECK(isolate_->heap()->gc_state() == Heap::NOT_IN_GC); const int initial_post_gc_processing_count = ++post_gc_processing_count_; int freed_nodes = 0; if (collector == SCAVENGER) { for (int i = 0; i < new_space_nodes_.length(); ++i) { Node* node = new_space_nodes_[i]; - ASSERT(node->is_in_new_space_list()); + DCHECK(node->is_in_new_space_list()); if (!node->IsRetainer()) { // Free nodes do not have weak callbacks. Do not use them to compute // the freed_nodes. @@ -670,18 +671,18 @@ int GlobalHandles::PostGarbageCollectionProcessing( int last = 0; for (int i = 0; i < new_space_nodes_.length(); ++i) { Node* node = new_space_nodes_[i]; - ASSERT(node->is_in_new_space_list()); + DCHECK(node->is_in_new_space_list()); if (node->IsRetainer()) { if (isolate_->heap()->InNewSpace(node->object())) { new_space_nodes_[last++] = node; - tracer->increment_nodes_copied_in_new_space(); + isolate_->heap()->IncrementNodesCopiedInNewSpace(); } else { node->set_in_new_space_list(false); - tracer->increment_nodes_promoted(); + isolate_->heap()->IncrementNodesPromoted(); } } else { node->set_in_new_space_list(false); - tracer->increment_nodes_died_in_new_space(); + isolate_->heap()->IncrementNodesDiedInNewSpace(); } } new_space_nodes_.Rewind(last); @@ -817,7 +818,7 @@ void GlobalHandles::AddObjectGroup(Object*** handles, v8::RetainedObjectInfo* info) { #ifdef DEBUG for (size_t i = 0; i < length; ++i) { - ASSERT(!Node::FromLocation(handles[i])->is_independent()); + DCHECK(!Node::FromLocation(handles[i])->is_independent()); } #endif if (length == 0) { @@ -848,9 +849,9 @@ void GlobalHandles::AddImplicitReferences(HeapObject** parent, Object*** children, size_t length) { #ifdef DEBUG - ASSERT(!Node::FromLocation(BitCast<Object**>(parent))->is_independent()); + DCHECK(!Node::FromLocation(BitCast<Object**>(parent))->is_independent()); for (size_t i = 0; i < length; ++i) { - ASSERT(!Node::FromLocation(children[i])->is_independent()); + DCHECK(!Node::FromLocation(children[i])->is_independent()); } #endif if (length == 0) return; @@ -862,13 +863,13 @@ void GlobalHandles::AddImplicitReferences(HeapObject** parent, void GlobalHandles::SetReferenceFromGroup(UniqueId id, Object** child) { - ASSERT(!Node::FromLocation(child)->is_independent()); + DCHECK(!Node::FromLocation(child)->is_independent()); implicit_ref_connections_.Add(ObjectGroupConnection(id, child)); } void GlobalHandles::SetReference(HeapObject** parent, Object** child) { - ASSERT(!Node::FromLocation(child)->is_independent()); + DCHECK(!Node::FromLocation(child)->is_independent()); ImplicitRefGroup* group = new ImplicitRefGroup(parent, 1); group->children[0] = child; implicit_ref_groups_.Add(group); @@ -1020,7 +1021,7 @@ EternalHandles::~EternalHandles() { void EternalHandles::IterateAllRoots(ObjectVisitor* visitor) { int limit = size_; for (int i = 0; i < blocks_.length(); i++) { - ASSERT(limit > 0); + DCHECK(limit > 0); Object** block = blocks_[i]; visitor->VisitPointers(block, block + Min(limit, kSize)); limit -= kSize; @@ -1048,9 +1049,9 @@ void EternalHandles::PostGarbageCollectionProcessing(Heap* heap) { void EternalHandles::Create(Isolate* isolate, Object* object, int* index) { - ASSERT_EQ(kInvalidIndex, *index); + DCHECK_EQ(kInvalidIndex, *index); if (object == NULL) return; - ASSERT_NE(isolate->heap()->the_hole_value(), object); + DCHECK_NE(isolate->heap()->the_hole_value(), object); int block = size_ >> kShift; int offset = size_ & kMask; // need to resize @@ -1060,7 +1061,7 @@ void EternalHandles::Create(Isolate* isolate, Object* object, int* index) { MemsetPointer(next_block, the_hole, kSize); blocks_.Add(next_block); } - ASSERT_EQ(isolate->heap()->the_hole_value(), blocks_[block][offset]); + DCHECK_EQ(isolate->heap()->the_hole_value(), blocks_[block][offset]); blocks_[block][offset] = object; if (isolate->heap()->InNewSpace(object)) { new_space_indices_.Add(size_); |