diff --git a/src/assert-scope.h b/src/assert-scope.h index b64f95dfa5..0ccbe16504 100644 --- a/src/assert-scope.h +++ b/src/assert-scope.h @@ -112,6 +112,11 @@ typedef PerThreadAssertScopeDebugOnly // Scope to document where we do not expect any allocation and GC. typedef PerThreadAssertScopeDebugOnly DisallowHeapAllocation; +#ifdef DEBUG +#define DISALLOW_HEAP_ALLOCATION(name) DisallowHeapAllocation name +#else +#define DISALLOW_HEAP_ALLOCATION(name) +#endif // Scope to introduce an exception to DisallowHeapAllocation. typedef PerThreadAssertScopeDebugOnly diff --git a/src/handler-table.h b/src/handler-table.h index c2e282001c..79eeaf674c 100644 --- a/src/handler-table.h +++ b/src/handler-table.h @@ -110,7 +110,7 @@ class V8_EXPORT_PRIVATE HandlerTable { // the GC heap (either {ByteArray} or {Code}) and hence would become stale // during a collection. Hence we disallow any allocation. Address raw_encoded_data_; - DisallowHeapAllocation no_gc_; + DISALLOW_HEAP_ALLOCATION(no_gc_); // Layout description for handler table based on ranges. static const int kRangeStartIndex = 0; diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 4a8810d22b..edfa8f1d04 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -5036,8 +5036,7 @@ class UnreachableObjectsFilter : public HeapObjectsFilter { HeapIterator::HeapIterator(Heap* heap, HeapIterator::HeapObjectsFiltering filtering) - : no_heap_allocation_(), - heap_(heap), + : heap_(heap), filtering_(filtering), filter_(nullptr), space_iterator_(nullptr), diff --git a/src/heap/heap.h b/src/heap/heap.h index a52e6d5b23..1d725d3914 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -2130,7 +2130,7 @@ class CodePageMemoryModificationScope { // Disallow any GCs inside this scope, as a relocation of the underlying // object would change the {MemoryChunk} that this scope targets. - DisallowHeapAllocation no_heap_allocation_; + DISALLOW_HEAP_ALLOCATION(no_heap_allocation_); }; // Visitor class to verify interior pointers in spaces that do not contain @@ -2221,7 +2221,7 @@ class HeapIterator { private: HeapObject* NextObject(); - DisallowHeapAllocation no_heap_allocation_; + DISALLOW_HEAP_ALLOCATION(no_heap_allocation_); Heap* heap_; HeapObjectsFiltering filtering_; diff --git a/src/objects/code.h b/src/objects/code.h index 1f1d4b71d6..95d7b598ad 100644 --- a/src/objects/code.h +++ b/src/objects/code.h @@ -364,7 +364,7 @@ class Code : public HeapObject, public NeverReadOnlySpaceObject { Code* current_code_; Isolate* isolate_; - DisallowHeapAllocation no_gc; + DISALLOW_HEAP_ALLOCATION(no_gc); DISALLOW_COPY_AND_ASSIGN(OptimizedCodeIterator) }; diff --git a/src/objects/shared-function-info.h b/src/objects/shared-function-info.h index f43fa61b2f..d6889736a0 100644 --- a/src/objects/shared-function-info.h +++ b/src/objects/shared-function-info.h @@ -568,7 +568,7 @@ class SharedFunctionInfo : public HeapObject, public NeverReadOnlySpaceObject { Script::Iterator script_iterator_; WeakArrayList::Iterator noscript_sfi_iterator_; SharedFunctionInfo::ScriptIterator sfi_iterator_; - DisallowHeapAllocation no_gc_; + DISALLOW_HEAP_ALLOCATION(no_gc_); DISALLOW_COPY_AND_ASSIGN(GlobalIterator); }; diff --git a/src/parsing/preparsed-scope-data-impl.h b/src/parsing/preparsed-scope-data-impl.h index e2d31c07d5..f1dc3d1bb4 100644 --- a/src/parsing/preparsed-scope-data-impl.h +++ b/src/parsing/preparsed-scope-data-impl.h @@ -85,7 +85,7 @@ class BaseConsumedPreParsedScopeData : public ConsumedPreParsedScopeData { private: ByteData* consumed_data_; - DisallowHeapAllocation no_gc; + DISALLOW_HEAP_ALLOCATION(no_gc); }; void SetPosition(int position) { index_ = position; } diff --git a/src/safepoint-table.h b/src/safepoint-table.h index 475b4a80b1..ab4b514300 100644 --- a/src/safepoint-table.h +++ b/src/safepoint-table.h @@ -154,7 +154,7 @@ class SafepointTable { static void PrintBits(std::ostream& os, // NOLINT uint8_t byte, int digits); - DisallowHeapAllocation no_allocation_; + DISALLOW_HEAP_ALLOCATION(no_allocation_); Address instruction_start_; uint32_t stack_slots_; unsigned length_; diff --git a/src/snapshot/code-serializer.h b/src/snapshot/code-serializer.h index d9b4be9a34..3b24ed8e48 100644 --- a/src/snapshot/code-serializer.h +++ b/src/snapshot/code-serializer.h @@ -79,7 +79,7 @@ class CodeSerializer : public Serializer<> { bool SerializeReadOnlyObject(HeapObject* obj, HowToCode how_to_code, WhereToPoint where_to_point, int skip); - DisallowHeapAllocation no_gc_; + DISALLOW_HEAP_ALLOCATION(no_gc_); uint32_t source_hash_; std::vector stub_keys_; DISALLOW_COPY_AND_ASSIGN(CodeSerializer); diff --git a/src/snapshot/deserializer.h b/src/snapshot/deserializer.h index 8340a93538..c151a416a4 100644 --- a/src/snapshot/deserializer.h +++ b/src/snapshot/deserializer.h @@ -190,7 +190,7 @@ class StringTableInsertionKey : public StringTableKey { uint32_t ComputeHashField(String* string); String* string_; - DisallowHeapAllocation no_gc; + DISALLOW_HEAP_ALLOCATION(no_gc); }; } // namespace internal diff --git a/src/snapshot/references.h b/src/snapshot/references.h index 6beb2065c1..40f1d60345 100644 --- a/src/snapshot/references.h +++ b/src/snapshot/references.h @@ -156,7 +156,7 @@ class SerializerReferenceMap public: typedef base::TemplateHashMapEntry Entry; - SerializerReferenceMap() : no_allocation_(), attached_reference_index_(0) {} + SerializerReferenceMap() : attached_reference_index_(0) {} SerializerReference LookupReference(void* value) const { uintptr_t key = Key(value); @@ -186,7 +186,7 @@ class SerializerReferenceMap static uint32_t Hash(uintptr_t key) { return static_cast(key); } - DisallowHeapAllocation no_allocation_; + DISALLOW_HEAP_ALLOCATION(no_allocation_); int attached_reference_index_; DISALLOW_COPY_AND_ASSIGN(SerializerReferenceMap); }; diff --git a/src/snapshot/serializer.cc b/src/snapshot/serializer.cc index 2073f970f7..90cde8daf6 100644 --- a/src/snapshot/serializer.cc +++ b/src/snapshot/serializer.cc @@ -612,7 +612,7 @@ class UnlinkWeakNextScope { private: HeapObject* object_; Object* next_; - DisallowHeapAllocation no_gc_; + DISALLOW_HEAP_ALLOCATION(no_gc_); }; template diff --git a/src/snapshot/startup-serializer.h b/src/snapshot/startup-serializer.h index 7df6fb5454..82f47a14ba 100644 --- a/src/snapshot/startup-serializer.h +++ b/src/snapshot/startup-serializer.h @@ -57,7 +57,7 @@ class StartupSerializer : public Serializer<> { } private: - DisallowHeapAllocation no_allocation_; + DISALLOW_HEAP_ALLOCATION(no_allocation_); HeapObjectToIndexHashMap map_; int next_index_; diff --git a/src/source-position-table.cc b/src/source-position-table.cc index 6ae24533df..476781cff1 100644 --- a/src/source-position-table.cc +++ b/src/source-position-table.cc @@ -198,16 +198,20 @@ SourcePositionTableIterator::SourcePositionTableIterator( Handle byte_array) : table_(byte_array) { Advance(); +#ifdef DEBUG // We can enable allocation because we keep the table in a handle. no_gc.Release(); +#endif // DEBUG } SourcePositionTableIterator::SourcePositionTableIterator( Vector bytes) : raw_table_(bytes) { Advance(); +#ifdef DEBUG // We can enable allocation because the underlying vector does not move. no_gc.Release(); +#endif // DEBUG } void SourcePositionTableIterator::Advance() { diff --git a/src/source-position-table.h b/src/source-position-table.h index 60853bc938..608bb4534a 100644 --- a/src/source-position-table.h +++ b/src/source-position-table.h @@ -111,7 +111,7 @@ class V8_EXPORT_PRIVATE SourcePositionTableIterator { Handle table_; int index_ = 0; PositionTableEntry current_; - DisallowHeapAllocation no_gc; + DISALLOW_HEAP_ALLOCATION(no_gc); }; } // namespace internal diff --git a/src/string-builder-inl.h b/src/string-builder-inl.h index dccdb3d01a..c356093606 100644 --- a/src/string-builder-inl.h +++ b/src/string-builder-inl.h @@ -205,7 +205,7 @@ class IncrementalStringBuilder { private: DestChar* start_; DestChar* cursor_; - DisallowHeapAllocation no_gc_; + DISALLOW_HEAP_ALLOCATION(no_gc_); }; template