Commit 2e00b646 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

Add DisallowGarbageCollection and AllowGarbageCollection

Added scopes to diallow/allow GCs from happening using a DCHECK. It is
stricter than DisallowHeapAllocation, since this also doesn't allow
safepoints.

As soon as Turbofan is ready, we can replace all usages of
DisallowHeapAllocation with DisallowGarbageCollection.

Bug: v8:10315
Change-Id: I12c144ec099d9af57d692ff343adbe7aec46c0c7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2362960Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70042}
parent fbd3834e
......@@ -786,7 +786,7 @@ StartupData SnapshotCreator::CreateBlob(
i::Snapshot::ClearReconstructableDataForSerialization(
isolate, function_code_handling == FunctionCodeHandling::kClear);
i::DisallowHeapAllocation no_gc_from_here_on;
i::DisallowGarbageCollection no_gc_from_here_on;
// Create a vector with all contexts and clear associated Persistent fields.
// Note these contexts may be dead after calling Clear(), but will not be
......
......@@ -1625,6 +1625,7 @@ bool Compiler::CollectSourcePositions(Isolate* isolate,
// Collecting source positions requires allocating a new source position
// table.
DCHECK(AllowHeapAllocation::IsAllowed());
DCHECK(AllowGarbageCollection::IsAllowed());
Handle<BytecodeArray> bytecode =
handle(shared_info->GetBytecodeArray(), isolate);
......
......@@ -120,6 +120,8 @@ bool PerIsolateAssertScope<kType, kAllow>::IsAllowed(Isolate* isolate) {
// -----------------------------------------------------------------------------
// Instantiations.
template class PerThreadAssertScope<GARBAGE_COLLECTION_ASSERT, false>;
template class PerThreadAssertScope<GARBAGE_COLLECTION_ASSERT, true>;
template class PerThreadAssertScope<HEAP_ALLOCATION_ASSERT, false>;
template class PerThreadAssertScope<HEAP_ALLOCATION_ASSERT, true>;
template class PerThreadAssertScope<HANDLE_ALLOCATION_ASSERT, false>;
......
......@@ -28,6 +28,7 @@ struct PointerWithPayloadTraits<PerThreadAssertData> {
};
enum PerThreadAssertType {
GARBAGE_COLLECTION_ASSERT,
HEAP_ALLOCATION_ASSERT,
HANDLE_ALLOCATION_ASSERT,
HANDLE_DEREFERENCE_ASSERT,
......@@ -126,7 +127,17 @@ using DisallowHandleAllocation =
using AllowHandleAllocation =
PerThreadAssertScopeDebugOnly<HANDLE_ALLOCATION_ASSERT, true>;
// Scope to document where we do not expect any allocation and GC.
// Scope to document where we do not expect garbage collections. It differs from
// DisallowHeapAllocation by also forbiding safepoints.
using DisallowGarbageCollection =
PerThreadAssertScopeDebugOnly<GARBAGE_COLLECTION_ASSERT, false>;
// Scope to introduce an exception to DisallowGarbageCollection.
using AllowGarbageCollection =
PerThreadAssertScopeDebugOnly<GARBAGE_COLLECTION_ASSERT, true>;
// Scope to document where we do not expect any allocation and GC. Deprecated
// and will eventually be removed, use DisallowGarbageCollection instead.
using DisallowHeapAllocation =
PerThreadAssertScopeDebugOnly<HEAP_ALLOCATION_ASSERT, false>;
#ifdef DEBUG
......
......@@ -12,6 +12,7 @@
#include "src/codegen/callable.h"
#include "src/codegen/macro-assembler.h"
#include "src/codegen/register-configuration.h"
#include "src/common/assert-scope.h"
#include "src/diagnostics/disasm.h"
#include "src/execution/frames-inl.h"
#include "src/execution/pointer-authentication.h"
......@@ -548,7 +549,8 @@ Deoptimizer::Deoptimizer(Isolate* isolate, JSFunction function,
DCHECK(function.IsJSFunction());
#ifdef DEBUG
DCHECK(AllowHeapAllocation::IsAllowed());
disallow_heap_allocation_ = new DisallowHeapAllocation();
DCHECK(AllowGarbageCollection::IsAllowed());
disallow_garbage_collection_ = new DisallowGarbageCollection();
#endif // DEBUG
CHECK(CodeKindCanDeoptimize(compiled_code_.kind()));
if (!compiled_code_.deopt_already_counted() &&
......@@ -620,7 +622,7 @@ bool Deoptimizer::should_reuse_code() const {
Deoptimizer::~Deoptimizer() {
DCHECK(input_ == nullptr && output_ == nullptr);
DCHECK_NULL(disallow_heap_allocation_);
DCHECK_NULL(disallow_garbage_collection_);
}
void Deoptimizer::DeleteFrameDescriptions() {
......@@ -632,10 +634,10 @@ void Deoptimizer::DeleteFrameDescriptions() {
input_ = nullptr;
output_ = nullptr;
#ifdef DEBUG
DCHECK(!AllowHeapAllocation::IsAllowed());
DCHECK_NOT_NULL(disallow_heap_allocation_);
delete disallow_heap_allocation_;
disallow_heap_allocation_ = nullptr;
DCHECK(!AllowGarbageCollection::IsAllowed());
DCHECK_NOT_NULL(disallow_garbage_collection_);
delete disallow_garbage_collection_;
disallow_garbage_collection_ = nullptr;
#endif // DEBUG
}
......
......@@ -12,6 +12,7 @@
#include "src/codegen/label.h"
#include "src/codegen/register-arch.h"
#include "src/codegen/source-position.h"
#include "src/common/assert-scope.h"
#include "src/common/globals.h"
#include "src/deoptimizer/deoptimize-reason.h"
#include "src/diagnostics/code-tracer.h"
......@@ -643,7 +644,7 @@ class Deoptimizer : public Malloced {
std::vector<ValueToMaterialize> values_to_materialize_;
#ifdef DEBUG
DisallowHeapAllocation* disallow_heap_allocation_;
DisallowGarbageCollection* disallow_garbage_collection_;
#endif // DEBUG
std::unique_ptr<CodeTracer::Scope> trace_scope_;
......
......@@ -26,6 +26,7 @@
#include "src/codegen/assembler-inl.h"
#include "src/codegen/compilation-cache.h"
#include "src/codegen/flush-instruction-cache.h"
#include "src/common/assert-scope.h"
#include "src/common/ptr-compr.h"
#include "src/compiler-dispatcher/compiler-dispatcher.h"
#include "src/compiler-dispatcher/optimizing-compile-dispatcher.h"
......@@ -1597,7 +1598,8 @@ Object Isolate::Throw(Object raw_exception, MessageLocation* location) {
// Script::GetLineNumber and Script::GetColumnNumber can allocate on the heap to
// initialize the line_ends array, so be careful when calling them.
#ifdef DEBUG
if (AllowHeapAllocation::IsAllowed()) {
if (AllowHeapAllocation::IsAllowed() &&
AllowGarbageCollection::IsAllowed()) {
#else
if ((false)) {
#endif
......
......@@ -13,6 +13,7 @@
#include "src/base/atomic-utils.h"
#include "src/base/atomicops.h"
#include "src/base/platform/platform.h"
#include "src/common/assert-scope.h"
#include "src/heap/heap-write-barrier.h"
#include "src/heap/heap.h"
#include "src/heap/third-party/heap-api.h"
......@@ -169,6 +170,7 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationType type,
AllocationAlignment alignment) {
DCHECK(AllowHandleAllocation::IsAllowed());
DCHECK(AllowHeapAllocation::IsAllowed());
DCHECK(AllowGarbageCollection::IsAllowed());
DCHECK_IMPLIES(type == AllocationType::kCode,
alignment == AllocationAlignment::kCodeAligned);
DCHECK_EQ(gc_state(), NOT_IN_GC);
......@@ -272,6 +274,7 @@ HeapObject Heap::AllocateRawWith(int size, AllocationType allocation,
AllocationAlignment alignment) {
DCHECK(AllowHandleAllocation::IsAllowed());
DCHECK(AllowHeapAllocation::IsAllowed());
DCHECK(AllowGarbageCollection::IsAllowed());
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) {
AllocationResult result = AllocateRaw(size, allocation, origin, alignment);
DCHECK(!result.IsRetry());
......
......@@ -20,6 +20,7 @@
#include "src/builtins/accessors.h"
#include "src/codegen/assembler-inl.h"
#include "src/codegen/compilation-cache.h"
#include "src/common/assert-scope.h"
#include "src/common/globals.h"
#include "src/debug/debug.h"
#include "src/deoptimizer/deoptimizer.h"
......@@ -1553,7 +1554,9 @@ bool Heap::CollectGarbage(AllocationSpace space,
{
tracer()->Start(collector, gc_reason, collector_reason);
DCHECK(AllowHeapAllocation::IsAllowed());
DCHECK(AllowGarbageCollection::IsAllowed());
DisallowHeapAllocation no_allocation_during_gc;
DisallowGarbageCollection no_gc_during_gc;
GarbageCollectionPrologue();
{
......@@ -1584,6 +1587,7 @@ bool Heap::CollectGarbage(AllocationSpace space,
EmbedderHeapTracer::EmbedderStackState::kMayContainHeapPointers);
if (scope.CheckReenter()) {
AllowHeapAllocation allow_allocation;
AllowGarbageCollection allow_gc;
AllowJavascriptExecution allow_js(isolate());
TRACE_GC(tracer(), GCTracer::Scope::HEAP_EXTERNAL_PROLOGUE);
VMState<EXTERNAL> state(isolate_);
......@@ -1608,6 +1612,7 @@ bool Heap::CollectGarbage(AllocationSpace space,
gc_post_processing_depth_++;
{
AllowHeapAllocation allow_allocation;
AllowGarbageCollection allow_gc;
AllowJavascriptExecution allow_js(isolate());
freed_global_handles +=
isolate_->global_handles()->PostGarbageCollectionProcessing(
......@@ -1620,6 +1625,7 @@ bool Heap::CollectGarbage(AllocationSpace space,
GCCallbacksScope scope(this);
if (scope.CheckReenter()) {
AllowHeapAllocation allow_allocation;
AllowGarbageCollection allow_gc;
AllowJavascriptExecution allow_js(isolate());
TRACE_GC(tracer(), GCTracer::Scope::HEAP_EXTERNAL_EPILOGUE);
VMState<EXTERNAL> state(isolate_);
......
......@@ -19,6 +19,7 @@ AllocationResult LocalHeap::AllocateRaw(int size_in_bytes, AllocationType type,
DCHECK_EQ(LocalHeap::Current(), this);
DCHECK(AllowHandleAllocation::IsAllowed());
DCHECK(AllowHeapAllocation::IsAllowed());
DCHECK(AllowGarbageCollection::IsAllowed());
DCHECK_IMPLIES(type == AllocationType::kCode,
alignment == AllocationAlignment::kCodeAligned);
Heap::HeapState state = heap()->gc_state();
......
......@@ -10,6 +10,7 @@
#include "src/base/platform/condition-variable.h"
#include "src/base/platform/mutex.h"
#include "src/common/assert-scope.h"
#include "src/execution/isolate.h"
#include "src/handles/persistent-handles.h"
#include "src/heap/concurrent-allocator.h"
......@@ -35,6 +36,10 @@ class V8_EXPORT_PRIVATE LocalHeap {
// Frequently invoked by local thread to check whether safepoint was requested
// from the main thread.
void Safepoint() {
// In case garbage collection is disabled, the thread isn't even allowed to
// invoke Safepoint(). Otherwise a GC might happen here.
DCHECK(AllowGarbageCollection::IsAllowed());
if (IsSafepointRequested()) {
ClearSafepointRequested();
EnterSafepoint();
......
......@@ -99,7 +99,7 @@ bool EmbedderDataSlot::store_aligned_pointer(Isolate* isolate, void* ptr) {
}
EmbedderDataSlot::RawData EmbedderDataSlot::load_raw(
Isolate* isolate, const DisallowHeapAllocation& no_gc) const {
Isolate* isolate, const DisallowGarbageCollection& no_gc) const {
// We don't care about atomicity of access here because embedder slots
// are accessed this way only by serializer from the main thread when
// GC is not active (concurrent marker may still look at the tagged part
......@@ -120,7 +120,7 @@ EmbedderDataSlot::RawData EmbedderDataSlot::load_raw(
void EmbedderDataSlot::store_raw(Isolate* isolate,
EmbedderDataSlot::RawData data,
const DisallowHeapAllocation& no_gc) {
const DisallowGarbageCollection& no_gc) {
// We currently have to treat zero as nullptr in embedder slots.
if (data) data = EncodeExternalPointer(isolate, data);
gc_safe_store(data);
......
......@@ -75,9 +75,9 @@ class EmbedderDataSlot
void* ptr);
V8_INLINE RawData load_raw(Isolate* isolate,
const DisallowHeapAllocation& no_gc) const;
const DisallowGarbageCollection& no_gc) const;
V8_INLINE void store_raw(Isolate* isolate, RawData data,
const DisallowHeapAllocation& no_gc);
const DisallowGarbageCollection& no_gc);
private:
// Stores given value to the embedder data slot in a concurrent-marker
......
......@@ -4,6 +4,7 @@
#include "src/objects/string.h"
#include "src/common/assert-scope.h"
#include "src/common/globals.h"
#include "src/handles/handles-inl.h"
#include "src/heap/heap-inl.h"
......@@ -42,6 +43,7 @@ Handle<String> String::SlowFlatten(Isolate* isolate, Handle<ConsString> cons,
}
DCHECK(AllowHeapAllocation::IsAllowed());
DCHECK(AllowGarbageCollection::IsAllowed());
int length = cons->length();
allocation =
ObjectInYoungGeneration(*cons) ? allocation : AllocationType::kOld;
......
......@@ -5,6 +5,7 @@
#include "src/asmjs/asm-js.h"
#include "src/codegen/compilation-cache.h"
#include "src/codegen/compiler.h"
#include "src/common/assert-scope.h"
#include "src/common/message-template.h"
#include "src/compiler-dispatcher/optimizing-compile-dispatcher.h"
#include "src/deoptimizer/deoptimizer.h"
......@@ -170,6 +171,7 @@ RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) {
DCHECK(CodeKindCanDeoptimize(deoptimizer->compiled_code()->kind()));
DCHECK(deoptimizer->compiled_code()->is_turbofanned());
DCHECK(AllowHeapAllocation::IsAllowed());
DCHECK(AllowGarbageCollection::IsAllowed());
DCHECK(isolate->context().is_null());
TimerEventScope<TimerEventDeoptimizeCode> timer(isolate);
......
......@@ -66,7 +66,7 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize(
Handle<String> source(String::cast(script->source()), isolate);
CodeSerializer cs(isolate, SerializedCodeData::SourceHash(
source, script->origin_options()));
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
cs.reference_map()->AddAttachedReference(
reinterpret_cast<void*>(source->ptr()));
ScriptData* script_data = cs.SerializeSharedFunctionInfo(info);
......@@ -88,7 +88,7 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize(
ScriptData* CodeSerializer::SerializeSharedFunctionInfo(
Handle<SharedFunctionInfo> info) {
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
VisitRootPointer(Root::kHandleScope, nullptr,
FullObjectSlot(info.location()));
......@@ -384,7 +384,7 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
SharedFunctionInfo::EnsureSourcePositionsAvailable(isolate,
shared_info);
}
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
int line_num =
script->GetLineNumber(shared_info->StartPosition()) + 1;
int column_num =
......@@ -407,7 +407,7 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
SerializedCodeData::SerializedCodeData(const std::vector<byte>* payload,
const CodeSerializer* cs) {
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
std::vector<Reservation> reservations = cs->EncodeReservations();
// Calculate sizes.
......@@ -520,7 +520,7 @@ SerializedCodeData::SerializedCodeData(ScriptData* data)
SerializedCodeData SerializedCodeData::FromCachedData(
ScriptData* cached_data, uint32_t expected_source_hash,
SanityCheckResult* rejection_result) {
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
SerializedCodeData scd(cached_data);
*rejection_result = scd.SanityCheck(expected_source_hash);
if (*rejection_result != CHECK_SUCCESS) {
......
......@@ -42,7 +42,7 @@ MaybeHandle<Object> ContextDeserializer::Deserialize(
Handle<Object> result;
{
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
// Keep track of the code space start and end pointers in case new
// code objects were unserialized
CodeSpace* code_space = isolate->heap()->code_space();
......@@ -83,7 +83,7 @@ void ContextDeserializer::SetupOffHeapArrayBufferBackingStores() {
void ContextDeserializer::DeserializeEmbedderFields(
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer) {
if (!source()->HasMore() || source()->Get() != kEmbedderFieldsData) return;
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
DisallowJavascriptExecution no_js(isolate());
DisallowCompilation no_compile(isolate());
DCHECK_NOT_NULL(embedder_fields_deserializer.callback);
......
......@@ -24,7 +24,7 @@ class SanitizeNativeContextScope final {
public:
SanitizeNativeContextScope(Isolate* isolate, NativeContext native_context,
bool allow_active_isolate_for_testing,
const DisallowHeapAllocation& no_gc)
const DisallowGarbageCollection& no_gc)
: isolate_(isolate),
native_context_(native_context),
microtask_queue_(native_context.microtask_queue()),
......@@ -82,7 +82,7 @@ ContextSerializer::~ContextSerializer() {
}
void ContextSerializer::Serialize(Context* o,
const DisallowHeapAllocation& no_gc) {
const DisallowGarbageCollection& no_gc) {
context_ = *o;
DCHECK(context_.IsNativeContext());
......@@ -212,7 +212,7 @@ bool ContextSerializer::SerializeJSObjectWithEmbedderFields(Object obj) {
CHECK_GT(embedder_fields_count, 0);
DCHECK(!js_obj.NeedsRehashing());
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
DisallowJavascriptExecution no_js(isolate());
DisallowCompilation no_compile(isolate());
......
......@@ -23,7 +23,7 @@ class V8_EXPORT_PRIVATE ContextSerializer : public Serializer {
~ContextSerializer() override;
// Serialize the objects reachable from a single object pointer.
void Serialize(Context* o, const DisallowHeapAllocation& no_gc);
void Serialize(Context* o, const DisallowGarbageCollection& no_gc);
bool can_be_rehashed() const { return can_be_rehashed_; }
......
......@@ -112,7 +112,7 @@ void Deserializer::Synchronize(VisitorSynchronization::SyncTag tag) {
}
void Deserializer::DeserializeDeferredObjects() {
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
for (int code = source_.Get(); code != kSynchronize; code = source_.Get()) {
SnapshotSpace space = NewObject::Decode(code);
......@@ -121,7 +121,7 @@ void Deserializer::DeserializeDeferredObjects() {
}
void Deserializer::LogNewMapEvents() {
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
for (Map map : new_maps_) {
DCHECK(FLAG_trace_maps);
LOG(isolate(), MapCreate(map));
......@@ -130,7 +130,7 @@ void Deserializer::LogNewMapEvents() {
}
void Deserializer::LogScriptEvents(Script script) {
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
LOG(isolate(),
ScriptEvent(Logger::ScriptEventType::kDeserialize, script.id()));
LOG(isolate(), ScriptDetails(script));
......@@ -159,7 +159,7 @@ uint32_t StringTableInsertionKey::ComputeHashField(String string) {
HeapObject Deserializer::PostProcessNewObject(HeapObject obj,
SnapshotSpace space) {
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
if ((FLAG_rehash_snapshot && can_rehash_) || deserializing_user_code()) {
if (obj.IsString()) {
......@@ -349,7 +349,7 @@ HeapObject Deserializer::ReadObject() {
}
HeapObject Deserializer::ReadObject(SnapshotSpace space) {
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
const int size = source_.GetInt() << kObjectAlignmentBits;
......
......@@ -47,7 +47,7 @@ MaybeHandle<HeapObject> ObjectDeserializer::Deserialize(Isolate* isolate) {
HandleScope scope(isolate);
Handle<HeapObject> result;
{
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
Object root;
VisitRootPointer(Root::kStartupObjectCache, nullptr, FullObjectSlot(&root));
DeserializeDeferredObjects();
......@@ -85,7 +85,7 @@ void ObjectDeserializer::CommitPostProcessedObjects() {
}
void ObjectDeserializer::LinkAllocationSites() {
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
Heap* heap = isolate()->heap();
// Allocation sites are present in the snapshot, and must be linked into
// a list at deserialization time.
......
......@@ -35,7 +35,7 @@ void ReadOnlyDeserializer::DeserializeInto(Isolate* isolate) {
DCHECK(!isolate->builtins()->is_initialized());
{
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
ReadOnlyRoots roots(isolate);
roots.Iterate(this);
......
......@@ -5,6 +5,7 @@
#ifndef V8_SNAPSHOT_SERIALIZER_DESERIALIZER_H_
#define V8_SNAPSHOT_SERIALIZER_DESERIALIZER_H_
#include "src/common/assert-scope.h"
#include "src/objects/visitors.h"
#include "src/snapshot/references.h"
......@@ -27,13 +28,13 @@ class SerializerDeserializer : public RootVisitor {
HotObjectsList() = default;
void Add(HeapObject object) {
DCHECK(!AllowHeapAllocation::IsAllowed());
DCHECK(!AllowGarbageCollection::IsAllowed());
circular_queue_[index_] = object;
index_ = (index_ + 1) & kSizeMask;
}
HeapObject Get(int index) {
DCHECK(!AllowHeapAllocation::IsAllowed());
DCHECK(!AllowGarbageCollection::IsAllowed());
DCHECK(!circular_queue_[index].is_null());
return circular_queue_[index];
}
......@@ -41,7 +42,7 @@ class SerializerDeserializer : public RootVisitor {
static const int kNotFound = -1;
int Find(HeapObject object) {
DCHECK(!AllowHeapAllocation::IsAllowed());
DCHECK(!AllowGarbageCollection::IsAllowed());
for (int i = 0; i < kSize; i++) {
if (circular_queue_[i] == object) return i;
}
......
......@@ -744,7 +744,7 @@ void Serializer::ObjectSerializer::VisitPointers(HeapObject host,
void Serializer::ObjectSerializer::VisitPointers(HeapObject host,
MaybeObjectSlot start,
MaybeObjectSlot end) {
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
MaybeObjectSlot current = start;
while (current < end) {
......
......@@ -25,7 +25,7 @@ void SerializedData::AllocateData(uint32_t size) {
constexpr uint32_t SerializedData::kMagicNumber;
SnapshotData::SnapshotData(const Serializer* serializer) {
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
std::vector<Reservation> reservations = serializer->EncodeReservations();
const std::vector<byte>* payload = serializer->Payload();
......
......@@ -7,6 +7,7 @@
#include "src/snapshot/snapshot.h"
#include "src/base/platform/platform.h"
#include "src/common/assert-scope.h"
#include "src/execution/isolate-inl.h"
#include "src/heap/safepoint.h"
#include "src/init/bootstrapper.h"
......@@ -281,7 +282,7 @@ void Snapshot::SerializeDeserializeAndVerifyForTesting(
// Test serialization.
{
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
Snapshot::SerializerFlags flags(
Snapshot::kAllowUnknownExternalReferencesForTesting |
......@@ -348,7 +349,7 @@ v8::StartupData Snapshot::Create(
Isolate* isolate, std::vector<Context>* contexts,
const std::vector<SerializeInternalFieldsCallback>&
embedder_fields_serializers,
const DisallowHeapAllocation& no_gc, SerializerFlags flags) {
const DisallowGarbageCollection& no_gc, SerializerFlags flags) {
DCHECK_EQ(contexts->size(), embedder_fields_serializers.size());
DCHECK_GT(contexts->size(), 0);
......@@ -403,7 +404,7 @@ v8::StartupData Snapshot::Create(
// static
v8::StartupData Snapshot::Create(Isolate* isolate, Context default_context,
const DisallowHeapAllocation& no_gc,
const DisallowGarbageCollection& no_gc,
SerializerFlags flags) {
std::vector<Context> contexts{default_context};
std::vector<SerializeInternalFieldsCallback> callbacks{{}};
......
......@@ -55,13 +55,13 @@ class Snapshot : public AllStatic {
Isolate* isolate, std::vector<Context>* contexts,
const std::vector<SerializeInternalFieldsCallback>&
embedder_fields_serializers,
const DisallowHeapAllocation& no_gc,
const DisallowGarbageCollection& no_gc,
SerializerFlags flags = kDefaultSerializerFlags);
// Convenience helper for the above when only serializing a single context.
static v8::StartupData Create(
Isolate* isolate, Context default_context,
const DisallowHeapAllocation& no_gc,
const DisallowGarbageCollection& no_gc,
SerializerFlags flags = kDefaultSerializerFlags);
// ---------------- Deserialization -----------------------------------------
......
......@@ -31,7 +31,7 @@ void StartupDeserializer::DeserializeInto(Isolate* isolate) {
DCHECK(!isolate->builtins()->is_initialized());
{
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
isolate->heap()->IterateSmiRoots(this);
isolate->heap()->IterateRoots(
this,
......
......@@ -26,7 +26,7 @@ namespace {
class SanitizeIsolateScope final {
public:
SanitizeIsolateScope(Isolate* isolate, bool allow_active_isolate_for_testing,
const DisallowHeapAllocation& no_gc)
const DisallowGarbageCollection& no_gc)
: isolate_(isolate),
feedback_vectors_for_profiling_tools_(
isolate->heap()->feedback_vectors_for_profiling_tools()),
......@@ -239,7 +239,7 @@ void StartupSerializer::SerializeStringTable(StringTable* string_table) {
}
void StartupSerializer::SerializeStrongReferences(
const DisallowHeapAllocation& no_gc) {
const DisallowGarbageCollection& no_gc) {
Isolate* isolate = this->isolate();
// No active threads.
CHECK_NULL(isolate->thread_manager()->FirstThreadStateInUse());
......
......@@ -27,7 +27,7 @@ class V8_EXPORT_PRIVATE StartupSerializer : public RootsSerializer {
// 2) Builtins and bytecode handlers
// 3) Startup object cache
// 4) Weak references (e.g. the string table)
void SerializeStrongReferences(const DisallowHeapAllocation& no_gc);
void SerializeStrongReferences(const DisallowGarbageCollection& no_gc);
void SerializeWeakReferencesAndDeferred();
// If |obj| can be serialized in the read-only snapshot then add it to the
......
......@@ -33,6 +33,7 @@
#include "src/codegen/compilation-cache.h"
#include "src/codegen/compiler.h"
#include "src/codegen/macro-assembler-inl.h"
#include "src/common/assert-scope.h"
#include "src/debug/debug.h"
#include "src/heap/heap-inl.h"
#include "src/heap/read-only-heap.h"
......@@ -172,7 +173,7 @@ static StartupBlobs Serialize(v8::Isolate* isolate) {
SafepointScope safepoint(internal_isolate->heap());
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
ReadOnlySerializer read_only_serializer(internal_isolate,
Snapshot::kDefaultSerializerFlags);
read_only_serializer.SerializeReadOnlyRoots();
......@@ -385,7 +386,7 @@ static void SerializeContext(Vector<const byte>* startup_blob_out,
SafepointScope safepoint(heap);
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
SnapshotByteSink read_only_sink;
ReadOnlySerializer read_only_serializer(isolate,
Snapshot::kDefaultSerializerFlags);
......@@ -537,7 +538,7 @@ static void SerializeCustomContext(Vector<const byte>* startup_blob_out,
SafepointScope safepoint(isolate->heap());
DisallowHeapAllocation no_gc;
DisallowGarbageCollection no_gc;
SnapshotByteSink read_only_sink;
ReadOnlySerializer read_only_serializer(isolate,
Snapshot::kDefaultSerializerFlags);
......@@ -1582,7 +1583,7 @@ TEST(TestThatAlwaysFails) {
int CountBuiltins() {
// Check that we have not deserialized any additional builtin.
HeapObjectIterator iterator(CcTest::heap());
DisallowHeapAllocation no_allocation;
DisallowGarbageCollection no_allocation;
int counter = 0;
for (HeapObject obj = iterator.Next(); !obj.is_null();
obj = iterator.Next()) {
......
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