diff --git a/runtime/vm/allocation.cc b/runtime/vm/allocation.cc index 7897af8c07e..d46cd4af630 100644 --- a/runtime/vm/allocation.cc +++ b/runtime/vm/allocation.cc @@ -14,16 +14,16 @@ namespace dart { static void* Allocate(uword size, Zone* zone) { ASSERT(zone != nullptr); if (size > static_cast(kIntptrMax)) { - FATAL("ZoneAllocated object has unexpectedly large size %" Pu "", size); + FATAL("ZoneObject object has unexpectedly large size %" Pu "", size); } return reinterpret_cast(zone->AllocUnsafe(size)); } -void* ZoneAllocated::operator new(uword size) { +void* ZoneObject::operator new(uword size) { return Allocate(size, Thread::Current()->zone()); } -void* ZoneAllocated::operator new(uword size, Zone* zone) { +void* ZoneObject::operator new(uword size, Zone* zone) { return Allocate(size, zone); } diff --git a/runtime/vm/allocation.h b/runtime/vm/allocation.h index 1ef19773f4d..41613273224 100644 --- a/runtime/vm/allocation.h +++ b/runtime/vm/allocation.h @@ -50,10 +50,10 @@ class StackResource { // Zone allocated objects cannot be individually deallocated, but have // to rely on the destructor of Zone which is called when the Zone // goes out of scope to reclaim memory. -class ZoneAllocated { +class ZoneObject { public: - ZoneAllocated() {} - virtual ~ZoneAllocated() = default; + ZoneObject() {} + virtual ~ZoneObject() = default; // Implicitly allocate the object in the current zone. void* operator new(size_t size); @@ -61,6 +61,9 @@ class ZoneAllocated { // Allocate the object in the given zone, which must be the current zone. void* operator new(size_t size, Zone* zone); + // Allow non-allocating placement new. + void* operator new(size_t size, void* ptr) { return ptr; } + // Ideally, the delete operator should be protected instead of // public, but unfortunately the compiler sometimes synthesizes // (unused) destructors for classes derived from ZoneObject, which @@ -72,13 +75,13 @@ class ZoneAllocated { void operator delete(void* pointer) { UNREACHABLE(); } private: - DISALLOW_COPY_AND_ASSIGN(ZoneAllocated); + DISALLOW_COPY_AND_ASSIGN(ZoneObject); }; } // namespace dart -// Prevent use of `new (zone) DoesNotExtendZoneAllocated()`, which places the -// DoesNotExtendZoneAllocated on top of the Zone. +// Prevent use of `new (zone) DoesNotExtendZoneObject()`, which places the +// DoesNotExtendZoneObject on top of the Zone. void* operator new(size_t size, dart::Zone* zone) = delete; #endif // RUNTIME_VM_ALLOCATION_H_ diff --git a/runtime/vm/app_snapshot.cc b/runtime/vm/app_snapshot.cc index ad7090fcdd4..a1e6e233346 100644 --- a/runtime/vm/app_snapshot.cc +++ b/runtime/vm/app_snapshot.cc @@ -74,7 +74,7 @@ static constexpr intptr_t kDeltaEncodedTypedDataCid = kNativePointer; // StorageTrait for HashTable which allows to create hash tables backed by // zone memory. Used to compute cluster order for canonical clusters. struct GrowableArrayStorageTraits { - class Array : public ZoneAllocated { + class Array : public ZoneObject { public: Array(Zone* zone, intptr_t length) : length_(length), array_(zone->Alloc(length)) {} @@ -92,7 +92,7 @@ struct GrowableArrayStorageTraits { }; using ArrayPtr = Array*; - class ArrayHandle : public ZoneAllocated { + class ArrayHandle : public ZoneObject { public: explicit ArrayHandle(ArrayPtr ptr) : ptr_(ptr) {} ArrayHandle() {} @@ -157,7 +157,7 @@ static void RelocateCodeObjects( #endif // defined(DART_PRECOMPILER) && !defined(TARGET_ARCH_IA32) -class SerializationCluster : public ZoneAllocated { +class SerializationCluster : public ZoneObject { public: static constexpr intptr_t kSizeVaries = -1; SerializationCluster(const char* name, @@ -216,7 +216,7 @@ class SerializationCluster : public ZoneAllocated { intptr_t target_memory_size_ = 0; }; -class DeserializationCluster : public ZoneAllocated { +class DeserializationCluster : public ZoneObject { public: explicit DeserializationCluster(const char* name, bool is_canonical = false, @@ -8311,7 +8311,7 @@ void Serializer::PrepareInstructions( // - followed by stack maps bytes; // - followed by canonical stack map entries. // - struct StackMapInfo : public ZoneAllocated { + struct StackMapInfo : public ZoneObject { CompressedStackMapsPtr map; intptr_t use_count; uint32_t offset; diff --git a/runtime/vm/app_snapshot.h b/runtime/vm/app_snapshot.h index 89df98fc590..775de0576a2 100644 --- a/runtime/vm/app_snapshot.h +++ b/runtime/vm/app_snapshot.h @@ -39,7 +39,7 @@ class V8SnapshotProfileWriter; class ImageWriter; class Heap; -class LoadingUnitSerializationData : public ZoneAllocated { +class LoadingUnitSerializationData : public ZoneObject { public: LoadingUnitSerializationData(intptr_t id, LoadingUnitSerializationData* parent) diff --git a/runtime/vm/bit_vector.h b/runtime/vm/bit_vector.h index ab8e6245a6b..1bd604610ff 100644 --- a/runtime/vm/bit_vector.h +++ b/runtime/vm/bit_vector.h @@ -12,7 +12,7 @@ namespace dart { // Bit vector implementation. -class BitVector : public ZoneAllocated { +class BitVector : public ZoneObject { public: // Iterator for the elements of this BitVector. class Iterator : public ValueObject { diff --git a/runtime/vm/bitmap.h b/runtime/vm/bitmap.h index 08d269df1a9..f580d26fc9d 100644 --- a/runtime/vm/bitmap.h +++ b/runtime/vm/bitmap.h @@ -15,14 +15,14 @@ namespace dart { // BitmapBuilder is used to build a bitmap. The implementation is optimized // for a dense set of small bit maps without a fixed upper bound (e.g: a // pointer map description of a stack). -class BitmapBuilder : public ZoneAllocated { +class BitmapBuilder : public ZoneObject { public: BitmapBuilder() : length_(0), data_size_in_bytes_(kInlineCapacityInBytes) { memset(data_.inline_, 0, data_size_in_bytes_); } BitmapBuilder(const BitmapBuilder& other) - : ZoneAllocated(), + : ZoneObject(), length_(other.length_), data_size_in_bytes_(other.data_size_in_bytes_) { if (data_size_in_bytes_ == kInlineCapacityInBytes) { diff --git a/runtime/vm/code_descriptors.cc b/runtime/vm/code_descriptors.cc index 6674771507c..2951a3f4e37 100644 --- a/runtime/vm/code_descriptors.cc +++ b/runtime/vm/code_descriptors.cc @@ -156,7 +156,7 @@ ExceptionHandlersPtr ExceptionHandlerList::FinalizeExceptionHandlers( } #if !defined(DART_PRECOMPILED_RUNTIME) -class CatchEntryMovesMapBuilder::TrieNode : public ZoneAllocated { +class CatchEntryMovesMapBuilder::TrieNode : public ZoneObject { public: TrieNode() : move_(), entry_state_offset_(-1) {} TrieNode(CatchEntryMove move, intptr_t index) diff --git a/runtime/vm/code_descriptors.h b/runtime/vm/code_descriptors.h index 4f5c8b6ee1b..66267d056ca 100644 --- a/runtime/vm/code_descriptors.h +++ b/runtime/vm/code_descriptors.h @@ -16,7 +16,7 @@ namespace dart { static constexpr intptr_t kInvalidTryIndex = -1; -class DescriptorList : public ZoneAllocated { +class DescriptorList : public ZoneObject { public: explicit DescriptorList( Zone* zone, @@ -47,7 +47,7 @@ class DescriptorList : public ZoneAllocated { DISALLOW_COPY_AND_ASSIGN(DescriptorList); }; -class CompressedStackMapsBuilder : public ZoneAllocated { +class CompressedStackMapsBuilder : public ZoneObject { public: explicit CompressedStackMapsBuilder(Zone* zone) : encoded_bytes_(zone, kInitialStreamSize) {} @@ -66,7 +66,7 @@ class CompressedStackMapsBuilder : public ZoneAllocated { DISALLOW_COPY_AND_ASSIGN(CompressedStackMapsBuilder); }; -class ExceptionHandlerList : public ZoneAllocated { +class ExceptionHandlerList : public ZoneObject { public: struct HandlerDesc { intptr_t outer_try_index; // Try block in which this try block is nested. @@ -147,7 +147,7 @@ class ExceptionHandlerList : public ZoneAllocated { #if !defined(DART_PRECOMPILED_RUNTIME) // Used to construct CatchEntryMoves for the AOT mode of compilation. -class CatchEntryMovesMapBuilder : public ZoneAllocated { +class CatchEntryMovesMapBuilder : public ZoneObject { public: CatchEntryMovesMapBuilder(); @@ -229,7 +229,7 @@ struct CodeSourceMapOps : AllStatic { // us a peephole optimization that merges adjacent advance PC bytecodes. On AOT, // this allows to skip encoding our position until we reach a PC where we might // throw. -class CodeSourceMapBuilder : public ZoneAllocated { +class CodeSourceMapBuilder : public ZoneObject { public: CodeSourceMapBuilder( Zone* zone, diff --git a/runtime/vm/compiler/aot/precompiler.h b/runtime/vm/compiler/aot/precompiler.h index 824e0ea9b59..44d049ffdaa 100644 --- a/runtime/vm/compiler/aot/precompiler.h +++ b/runtime/vm/compiler/aot/precompiler.h @@ -527,7 +527,7 @@ class Obfuscator : public ValueObject { return name.ptr(); } - class ObfuscationState : public ZoneAllocated { + class ObfuscationState : public ZoneObject { public: ObfuscationState(Thread* thread, const Array& saved_state, diff --git a/runtime/vm/compiler/aot/precompiler_tracer.h b/runtime/vm/compiler/aot/precompiler_tracer.h index 99385cb51e0..354408372ff 100644 --- a/runtime/vm/compiler/aot/precompiler_tracer.h +++ b/runtime/vm/compiler/aot/precompiler_tracer.h @@ -23,7 +23,7 @@ class Precompiler; // information about all compiled functions and dependencies between them. // See pkg/vm_snapshot_analysis/README.md for the definition of the // format. -class PrecompilerTracer : public ZoneAllocated { +class PrecompilerTracer : public ZoneObject { public: static PrecompilerTracer* StartTracingIfRequested(Precompiler* precompiler); diff --git a/runtime/vm/compiler/assembler/assembler_base.h b/runtime/vm/compiler/assembler/assembler_base.h index 59628402fe8..2f50bc064f8 100644 --- a/runtime/vm/compiler/assembler/assembler_base.h +++ b/runtime/vm/compiler/assembler/assembler_base.h @@ -216,7 +216,7 @@ class Address; class FieldAddress; #if defined(TARGET_ARCH_RISCV32) || defined(TARGET_ARCH_RISCV64) -class Label : public ZoneAllocated { +class Label : public ZoneObject { public: Label() {} ~Label() { @@ -273,7 +273,7 @@ class Label : public ZoneAllocated { DISALLOW_COPY_AND_ASSIGN(Label); }; #else -class Label : public ZoneAllocated { +class Label : public ZoneObject { public: Label() : position_(0), unresolved_(0) { #ifdef DEBUG @@ -404,7 +404,7 @@ class ExternalLabel : public ValueObject { // Assembler fixups are positions in generated code that hold relocation // information that needs to be processed before finalizing the code // into executable memory. -class AssemblerFixup : public ZoneAllocated { +class AssemblerFixup : public ZoneObject { public: virtual void Process(const MemoryRegion& region, intptr_t position) = 0; @@ -1225,7 +1225,7 @@ class AssemblerBase : public StackResource { return buffer_.pointer_offsets(); } - class CodeComment : public ZoneAllocated { + class CodeComment : public ZoneObject { public: CodeComment(intptr_t pc_offset, const String& comment) : pc_offset_(pc_offset), comment_(comment) {} diff --git a/runtime/vm/compiler/backend/block_scheduler.cc b/runtime/vm/compiler/backend/block_scheduler.cc index 470830dd145..ead97141d74 100644 --- a/runtime/vm/compiler/backend/block_scheduler.cc +++ b/runtime/vm/compiler/backend/block_scheduler.cc @@ -106,7 +106,7 @@ struct Edge { }; // A linked list node in a chain of blocks. -struct Link : public ZoneAllocated { +struct Link : public ZoneObject { Link(BlockEntryInstr* block, Link* next) : block(block), next(next) {} BlockEntryInstr* block; @@ -115,7 +115,7 @@ struct Link : public ZoneAllocated { // A chain of blocks with first and last pointers for fast concatenation and // a length to support adding a shorter chain's links to a longer chain. -struct Chain : public ZoneAllocated { +struct Chain : public ZoneObject { explicit Chain(BlockEntryInstr* block) : first(new Link(block, nullptr)), last(first), length(1) {} diff --git a/runtime/vm/compiler/backend/compile_type.h b/runtime/vm/compiler/backend/compile_type.h index 80e3801cd2f..f94237668aa 100644 --- a/runtime/vm/compiler/backend/compile_type.h +++ b/runtime/vm/compiler/backend/compile_type.h @@ -40,7 +40,7 @@ class GrowableArray; // Values of CompileType form a lattice with a None type as a bottom and a // nullable Dynamic type as a top element. Method Union provides a join // operation for the lattice. -class CompileType : public ZoneAllocated { +class CompileType : public ZoneObject { public: static constexpr bool kCanBeNull = true; static constexpr bool kCannotBeNull = false; @@ -66,7 +66,7 @@ class CompileType : public ZoneAllocated { } CompileType(const CompileType& other) - : ZoneAllocated(), + : ZoneObject(), flags_(other.flags_), cid_(other.cid_), type_(other.type_) {} diff --git a/runtime/vm/compiler/backend/flow_graph.h b/runtime/vm/compiler/backend/flow_graph.h index a7de56db114..0a347cf5dbf 100644 --- a/runtime/vm/compiler/backend/flow_graph.h +++ b/runtime/vm/compiler/backend/flow_graph.h @@ -141,7 +141,7 @@ struct InliningInfo { }; // Class to encapsulate the construction and manipulation of the flow graph. -class FlowGraph : public ZoneAllocated { +class FlowGraph : public ZoneObject { public: enum class CompilationMode { kUnoptimized, diff --git a/runtime/vm/compiler/backend/flow_graph_compiler.h b/runtime/vm/compiler/backend/flow_graph_compiler.h index bc02db3892b..2f1d48583b4 100644 --- a/runtime/vm/compiler/backend/flow_graph_compiler.h +++ b/runtime/vm/compiler/backend/flow_graph_compiler.h @@ -66,7 +66,7 @@ class NoTemporaryAllocator : public TemporaryRegisterAllocator { // Used for describing a deoptimization point after call (lazy deoptimization). // For deoptimization before instruction use class CompilerDeoptInfoWithStub. -class CompilerDeoptInfo : public ZoneAllocated { +class CompilerDeoptInfo : public ZoneObject { public: CompilerDeoptInfo(intptr_t deopt_id, ICData::DeoptReasonId reason, @@ -142,7 +142,7 @@ class CompilerDeoptInfoWithStub : public CompilerDeoptInfo { DISALLOW_COPY_AND_ASSIGN(CompilerDeoptInfoWithStub); }; -class SlowPathCode : public ZoneAllocated { +class SlowPathCode : public ZoneObject { public: explicit SlowPathCode(Instruction* instruction) : instruction_(instruction), entry_label_(), exit_label_() {} @@ -393,7 +393,7 @@ enum class TypeTestOutcome { kConclusive, kNotConclusive }; class FlowGraphCompiler : public ValueObject { private: - class BlockInfo : public ZoneAllocated { + class BlockInfo : public ZoneObject { public: BlockInfo() : block_label_(), @@ -1190,7 +1190,7 @@ class FlowGraphCompiler : public ValueObject { bool CanPcRelativeCall(const AbstractType& target) const; // This struct contains either function or code, the other one being nullptr. - class StaticCallsStruct : public ZoneAllocated { + class StaticCallsStruct : public ZoneObject { public: Code::CallKind call_kind; Code::CallEntryPoint entry_point; diff --git a/runtime/vm/compiler/backend/il.h b/runtime/vm/compiler/backend/il.h index 91d3e88fee9..34712ab6611 100644 --- a/runtime/vm/compiler/backend/il.h +++ b/runtime/vm/compiler/backend/il.h @@ -72,7 +72,7 @@ class BlockBuilder; struct TableSelector; } // namespace compiler -class Value : public ZoneAllocated { +class Value : public ZoneObject { public: // A forward iterator that allows removing the current value from the // underlying use list during iteration. @@ -199,7 +199,7 @@ class Value : public ZoneAllocated { // Represents a range of class-ids for use in class checks and polymorphic // dispatches. The range includes both ends, i.e. it is [cid_start, cid_end]. -struct CidRange : public ZoneAllocated { +struct CidRange : public ZoneObject { CidRange(intptr_t cid_start_arg, intptr_t cid_end_arg) : cid_start(cid_start_arg), cid_end(cid_end_arg) {} CidRange() : cid_start(kIllegalCid), cid_end(kIllegalCid) {} @@ -739,7 +739,7 @@ struct TargetInfo : public CidRange { // A set of class-ids, arranged in ranges. Used for the CheckClass // and PolymorphicInstanceCall instructions. -class Cids : public ZoneAllocated { +class Cids : public ZoneObject { public: explicit Cids(Zone* zone) : cid_ranges_(zone, 6) {} // Creates the off-heap Cids object that reflects the contents @@ -839,7 +839,7 @@ class CallTargets : public Cids { // Represents type feedback for the binary operators, and a few recognized // static functions (see MethodRecognizer::NumArgsCheckedForStaticCall). -class BinaryFeedback : public ZoneAllocated { +class BinaryFeedback : public ZoneObject { public: explicit BinaryFeedback(Zone* zone) : feedback_(zone, 2) {} @@ -965,7 +965,7 @@ class ValueListIterable { Value* value_; }; -class Instruction : public ZoneAllocated { +class Instruction : public ZoneObject { public: #define DECLARE_TAG(type, attrs) k##type, enum Tag { FOR_EACH_CONCRETE_INSTRUCTION(DECLARE_TAG) kNumInstructions }; @@ -1526,11 +1526,11 @@ class TemplateInstruction virtual void RawSetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } }; -class MoveOperands : public ZoneAllocated { +class MoveOperands : public ZoneObject { public: MoveOperands(Location dest, Location src) : dest_(dest), src_(src) {} MoveOperands(const MoveOperands& other) - : ZoneAllocated(), dest_(other.dest_), src_(other.src_) {} + : ZoneObject(), dest_(other.dest_), src_(other.src_) {} MoveOperands& operator=(const MoveOperands& other) { dest_ = other.dest_; @@ -1643,7 +1643,7 @@ class ParallelMoveInstr : public TemplateInstruction<0, NoThrow> { DISALLOW_COPY_AND_ASSIGN(ParallelMoveInstr); }; -class OsrEntryRelinkingInfo : public ZoneAllocated { +class OsrEntryRelinkingInfo : public ZoneObject { public: OsrEntryRelinkingInfo(GraphEntryInstr* graph_entry, Instruction* instr, @@ -11523,7 +11523,7 @@ class SuspendInstr : public TemplateDefinition<2, Throws> { #undef DECLARE_INSTRUCTION -class Environment : public ZoneAllocated { +class Environment : public ZoneObject { public: // Iterate the non-null values in the innermost level of an environment. class ShallowIterator : public ValueObject { diff --git a/runtime/vm/compiler/backend/linearscan.cc b/runtime/vm/compiler/backend/linearscan.cc index d7c62675f24..a56f0a9f7e0 100644 --- a/runtime/vm/compiler/backend/linearscan.cc +++ b/runtime/vm/compiler/backend/linearscan.cc @@ -58,7 +58,7 @@ static intptr_t ToInstructionEnd(intptr_t pos) { } // Additional information on loops during register allocation. -struct ExtraLoopInfo : public ZoneAllocated { +struct ExtraLoopInfo : public ZoneObject { ExtraLoopInfo(intptr_t s, intptr_t e) : start(s), end(e), backedge_interference(nullptr) {} intptr_t start; diff --git a/runtime/vm/compiler/backend/linearscan.h b/runtime/vm/compiler/backend/linearscan.h index 57b53ed8fcc..04663e08c2b 100644 --- a/runtime/vm/compiler/backend/linearscan.h +++ b/runtime/vm/compiler/backend/linearscan.h @@ -403,7 +403,7 @@ class FlowGraphAllocator : public ValueObject { // where instruction expects the value (if slot contains a fixed location) or // asks register allocator to allocate storage (register or spill slot) for // this use with certain properties (if slot contains an unallocated location). -class UsePosition : public ZoneAllocated { +class UsePosition : public ZoneObject { public: UsePosition(intptr_t pos, UsePosition* next, Location* location_slot) : pos_(pos), location_slot_(location_slot), hint_(nullptr), next_(next) { @@ -445,7 +445,7 @@ class UsePosition : public ZoneAllocated { // the end position. The interval can cover zero or more uses. // Note: currently all uses of the same SSA value are linked together into a // single list (and not split between UseIntervals). -class UseInterval : public ZoneAllocated { +class UseInterval : public ZoneObject { public: UseInterval(intptr_t start, intptr_t end, UseInterval* next) : start_(start), end_(end), next_(next) {} @@ -506,7 +506,7 @@ class AllocationFinger : public ValueObject { DISALLOW_COPY_AND_ASSIGN(AllocationFinger); }; -class SafepointPosition : public ZoneAllocated { +class SafepointPosition : public ZoneObject { public: SafepointPosition(intptr_t pos, LocationSummary* locs) : pos_(pos), locs_(locs), next_(nullptr) {} @@ -526,7 +526,7 @@ class SafepointPosition : public ZoneAllocated { }; // LiveRange represents a sequence of UseIntervals for a given SSA value. -class LiveRange : public ZoneAllocated { +class LiveRange : public ZoneObject { public: explicit LiveRange(intptr_t vreg, Representation rep) : vreg_(vreg), diff --git a/runtime/vm/compiler/backend/locations.h b/runtime/vm/compiler/backend/locations.h index a00fb1aa79e..2f3237b053f 100644 --- a/runtime/vm/compiler/backend/locations.h +++ b/runtime/vm/compiler/backend/locations.h @@ -615,7 +615,7 @@ Location LocationRemapForSlowPath(Location loc, // Return a memory operand for stack slot locations. compiler::Address LocationToStackSlotAddress(Location loc); -class PairLocation : public ZoneAllocated { +class PairLocation : public ZoneObject { public: PairLocation() { for (intptr_t i = 0; i < kPairLength; i++) { @@ -855,7 +855,7 @@ class RegisterSet : public ValueObject { }; // Specification of locations for inputs and output. -class LocationSummary : public ZoneAllocated { +class LocationSummary : public ZoneObject { public: enum ContainsCall { // Used registers must be reserved as tmp. diff --git a/runtime/vm/compiler/backend/locations_helpers_test.cc b/runtime/vm/compiler/backend/locations_helpers_test.cc index 75d4634da27..c0ab04d0fae 100644 --- a/runtime/vm/compiler/backend/locations_helpers_test.cc +++ b/runtime/vm/compiler/backend/locations_helpers_test.cc @@ -65,7 +65,7 @@ static void FillSummary(LocationSummary* locs, } } -class MockInstruction : public ZoneAllocated { +class MockInstruction : public ZoneObject { public: virtual ~MockInstruction() {} diff --git a/runtime/vm/compiler/backend/loops.h b/runtime/vm/compiler/backend/loops.h index 8befc337b61..94c291dbc56 100644 --- a/runtime/vm/compiler/backend/loops.h +++ b/runtime/vm/compiler/backend/loops.h @@ -28,7 +28,7 @@ namespace dart { // Periodic: // alternate initial and next, for invariant initial and next // -class InductionVar : public ZoneAllocated { +class InductionVar : public ZoneObject { public: enum Kind { kInvariant, @@ -207,7 +207,7 @@ class InductionVar : public ZoneAllocated { }; // Information on a "natural loop" in the flow graph. -class LoopInfo : public ZoneAllocated { +class LoopInfo : public ZoneObject { public: LoopInfo(intptr_t id, BlockEntryInstr* header, BitVector* blocks); @@ -271,7 +271,7 @@ class LoopInfo : public ZoneAllocated { typedef RawPointerKeyValueTrait InductionKV; // Mapping from induction to mapping from instruction to induction pair. - class MemoVal : public ZoneAllocated { + class MemoVal : public ZoneObject { public: typedef RawPointerKeyValueTrait> @@ -319,7 +319,7 @@ class LoopInfo : public ZoneAllocated { }; // Information on the loop hierarchy in the flow graph. -class LoopHierarchy : public ZoneAllocated { +class LoopHierarchy : public ZoneObject { public: LoopHierarchy(ZoneGrowableArray* headers, const GrowableArray& preorder, diff --git a/runtime/vm/compiler/backend/range_analysis.h b/runtime/vm/compiler/backend/range_analysis.h index 17202d265c7..c0e68e68bf1 100644 --- a/runtime/vm/compiler/backend/range_analysis.h +++ b/runtime/vm/compiler/backend/range_analysis.h @@ -218,7 +218,7 @@ class RangeBoundary : public ValueObject { int64_t offset_; }; -class Range : public ZoneAllocated { +class Range : public ZoneObject { public: Range() : min_(), max_() {} @@ -227,7 +227,7 @@ class Range : public ZoneAllocated { } Range(const Range& other) - : ZoneAllocated(), min_(other.min_), max_(other.max_) {} + : ZoneObject(), min_(other.min_), max_(other.max_) {} Range& operator=(const Range& other) { min_ = other.min_; diff --git a/runtime/vm/compiler/backend/redundancy_elimination.cc b/runtime/vm/compiler/backend/redundancy_elimination.cc index 64232b52e3c..1ef81f5d327 100644 --- a/runtime/vm/compiler/backend/redundancy_elimination.cc +++ b/runtime/vm/compiler/backend/redundancy_elimination.cc @@ -693,7 +693,7 @@ class Place : public ValueObject { intptr_t id_; }; -class ZonePlace : public ZoneAllocated { +class ZonePlace : public ZoneObject { public: explicit ZonePlace(const Place& place) : place_(place) {} @@ -711,7 +711,7 @@ Place* Place::Wrap(Zone* zone, const Place& place, intptr_t id) { // Correspondence between places connected through outgoing phi moves on the // edge that targets join. -class PhiPlaceMoves : public ZoneAllocated { +class PhiPlaceMoves : public ZoneObject { public: // Record a move from the place with id |from| to the place with id |to| at // the given block. @@ -755,7 +755,7 @@ class PhiPlaceMoves : public ZoneAllocated { // A map from aliases to a set of places sharing the alias. Additionally // carries a set of places that can be aliased by side-effects, essentially // those that are affected by calls. -class AliasedSet : public ZoneAllocated { +class AliasedSet : public ZoneObject { public: AliasedSet(Zone* zone, FlowGraph* graph, @@ -4396,7 +4396,7 @@ class TryCatchAnalyzer : public ValueObject { return false; } - struct ParameterInfo : public ZoneAllocated { + struct ParameterInfo : public ZoneObject { explicit ParameterInfo(ParameterInstr* instr) : instr(instr) {} ParameterInstr* instr; diff --git a/runtime/vm/compiler/backend/redundancy_elimination.h b/runtime/vm/compiler/backend/redundancy_elimination.h index 2ca85facfb5..13621f9b50c 100644 --- a/runtime/vm/compiler/backend/redundancy_elimination.h +++ b/runtime/vm/compiler/backend/redundancy_elimination.h @@ -18,7 +18,7 @@ namespace dart { class CSEInstructionSet; -class AllocationSinking : public ZoneAllocated { +class AllocationSinking : public ZoneObject { public: explicit AllocationSinking(FlowGraph* flow_graph) : flow_graph_(flow_graph), candidates_(5), materializations_(5) {} diff --git a/runtime/vm/compiler/backend/slot.cc b/runtime/vm/compiler/backend/slot.cc index 5770405213f..4bd712bdd96 100644 --- a/runtime/vm/compiler/backend/slot.cc +++ b/runtime/vm/compiler/backend/slot.cc @@ -24,7 +24,7 @@ enum NativeSlotsEnumeration { // // This cache is attached to the CompilerState to ensure that we preserve // identity of Slot objects during each individual compilation. -class SlotCache : public ZoneAllocated { +class SlotCache : public ZoneObject { public: // Returns an instance of SlotCache for the current compilation. static SlotCache& Instance(Thread* thread) { diff --git a/runtime/vm/compiler/backend/slot.h b/runtime/vm/compiler/backend/slot.h index a632e727797..25a74bf066c 100644 --- a/runtime/vm/compiler/backend/slot.h +++ b/runtime/vm/compiler/backend/slot.h @@ -432,7 +432,7 @@ class FieldGuardState { // compared by pointer. If two slots are different they must not alias. // If two slots can alias - they must be represented by identical // slot object. -class Slot : public ZoneAllocated { +class Slot : public ZoneObject { public: // clang-format off enum class Kind : uint8_t { diff --git a/runtime/vm/compiler/compiler_state.h b/runtime/vm/compiler/compiler_state.h index 29354c3c9e0..2cd6a392b3a 100644 --- a/runtime/vm/compiler/compiler_state.h +++ b/runtime/vm/compiler/compiler_state.h @@ -30,7 +30,7 @@ enum class CompilerTracing { kOff, }; -struct FunctionPragmas : public ZoneAllocated { +struct FunctionPragmas : public ZoneObject { explicit FunctionPragmas(const Function& function); const Function& function; diff --git a/runtime/vm/compiler/ffi/marshaller.h b/runtime/vm/compiler/ffi/marshaller.h index 27236581e2a..7087d407026 100644 --- a/runtime/vm/compiler/ffi/marshaller.h +++ b/runtime/vm/compiler/ffi/marshaller.h @@ -39,7 +39,7 @@ const NativeFunctionType* NativeFunctionTypeFromFunctionType( // // This class is set up in a query-able way so that it's underlying logic can // be extended to support more native ABI features and calling conventions. -class BaseMarshaller : public ZoneAllocated { +class BaseMarshaller : public ZoneObject { public: intptr_t num_args() const { return native_calling_convention_.argument_locations().length(); diff --git a/runtime/vm/compiler/ffi/native_calling_convention.h b/runtime/vm/compiler/ffi/native_calling_convention.h index bdaa51231b3..17dd72f9c0b 100644 --- a/runtime/vm/compiler/ffi/native_calling_convention.h +++ b/runtime/vm/compiler/ffi/native_calling_convention.h @@ -26,7 +26,7 @@ using NativeLocations = ZoneGrowableArray; // // This class is meant to be embedded in a class that is aware of Dart calling // convention constraints. -class NativeCallingConvention : public ZoneAllocated { +class NativeCallingConvention : public ZoneObject { public: static const NativeCallingConvention& FromSignature( Zone* zone, diff --git a/runtime/vm/compiler/ffi/native_location.h b/runtime/vm/compiler/ffi/native_location.h index e849c7753f7..bb474479f7d 100644 --- a/runtime/vm/compiler/ffi/native_location.h +++ b/runtime/vm/compiler/ffi/native_location.h @@ -60,7 +60,7 @@ class BothNativeLocations; // // NativeLocation does not satisfy the invariant of Location: bitwise // inequality cannot be used to determine disjointness. -class NativeLocation : public ZoneAllocated { +class NativeLocation : public ZoneObject { public: #if !defined(FFI_UNIT_TESTS) static bool LocationCanBeExpressed(Location loc, Representation rep); diff --git a/runtime/vm/compiler/ffi/native_type.h b/runtime/vm/compiler/ffi/native_type.h index 16cf5529e60..bb77ab0aa66 100644 --- a/runtime/vm/compiler/ffi/native_type.h +++ b/runtime/vm/compiler/ffi/native_type.h @@ -63,7 +63,7 @@ class NativeStructType; // * Compound types (https://en.cppreference.com/w/cpp/language/type): // * Struct // * Union -class NativeType : public ZoneAllocated { +class NativeType : public ZoneObject { public: #if !defined(FFI_UNIT_TESTS) static const NativeType* FromAbstractType(Zone* zone, @@ -455,7 +455,7 @@ class NativeUnionType : public NativeCompoundType { : NativeCompoundType(members, size, alignment_field, alignment_stack) {} }; -class NativeFunctionType : public ZoneAllocated { +class NativeFunctionType : public ZoneObject { public: NativeFunctionType(const NativeTypes& argument_types, const NativeType& return_type, diff --git a/runtime/vm/compiler/ffi/unit_test_custom_zone.cc b/runtime/vm/compiler/ffi/unit_test_custom_zone.cc index 90f01cfb677..3fcc972c599 100644 --- a/runtime/vm/compiler/ffi/unit_test_custom_zone.cc +++ b/runtime/vm/compiler/ffi/unit_test_custom_zone.cc @@ -15,7 +15,7 @@ namespace dart { -void* ZoneAllocated::operator new(uintptr_t size, dart::Zone* zone) { +void* ZoneObject::operator new(uintptr_t size, dart::Zone* zone) { return reinterpret_cast(zone->AllocUnsafe(size)); } diff --git a/runtime/vm/compiler/frontend/flow_graph_builder.h b/runtime/vm/compiler/frontend/flow_graph_builder.h index 3ea39793d40..5978272d66b 100644 --- a/runtime/vm/compiler/frontend/flow_graph_builder.h +++ b/runtime/vm/compiler/frontend/flow_graph_builder.h @@ -21,7 +21,7 @@ namespace dart { // A class to collect the exits from an inlined function during graph // construction so they can be plugged into the caller's flow graph. -class InlineExitCollector : public ZoneAllocated { +class InlineExitCollector : public ZoneObject { public: InlineExitCollector(FlowGraph* caller_graph, Definition* call) : caller_graph_(caller_graph), call_(call), exits_(4) {} diff --git a/runtime/vm/compiler/frontend/kernel_translation_helper.h b/runtime/vm/compiler/frontend/kernel_translation_helper.h index 054a77bd657..12318394927 100644 --- a/runtime/vm/compiler/frontend/kernel_translation_helper.h +++ b/runtime/vm/compiler/frontend/kernel_translation_helper.h @@ -1188,7 +1188,7 @@ struct TableSelectorInfo { }; // Collection of table selector information for all selectors in the program. -class TableSelectorMetadata : public ZoneAllocated { +class TableSelectorMetadata : public ZoneObject { public: explicit TableSelectorMetadata(intptr_t num_selectors) : selectors(num_selectors) { @@ -1219,7 +1219,7 @@ class TableSelectorMetadataHelper : public MetadataHelper { }; // Information about a function regarding unboxed parameters and return value. -class UnboxingInfoMetadata : public ZoneAllocated { +class UnboxingInfoMetadata : public ZoneObject { public: // Should match UnboxingKind in pkg/vm/lib/metadata/unboxing_info.dart. enum UnboxingKind { diff --git a/runtime/vm/compiler/frontend/scope_builder.h b/runtime/vm/compiler/frontend/scope_builder.h index 53cde77df03..f319acc8bf5 100644 --- a/runtime/vm/compiler/frontend/scope_builder.h +++ b/runtime/vm/compiler/frontend/scope_builder.h @@ -178,7 +178,7 @@ struct FunctionScope { LocalScope* scope; }; -class ScopeBuildingResult : public ZoneAllocated { +class ScopeBuildingResult : public ZoneObject { public: ScopeBuildingResult() : type_arguments_variable(nullptr), diff --git a/runtime/vm/compiler/stub_code_compiler.h b/runtime/vm/compiler/stub_code_compiler.h index d325213462b..cee5ed445ab 100644 --- a/runtime/vm/compiler/stub_code_compiler.h +++ b/runtime/vm/compiler/stub_code_compiler.h @@ -31,7 +31,7 @@ namespace compiler { class Assembler; // Represents an unresolved PC-relative Call/TailCall. -class UnresolvedPcRelativeCall : public ZoneAllocated { +class UnresolvedPcRelativeCall : public ZoneObject { public: UnresolvedPcRelativeCall(intptr_t offset, const dart::Code& target, diff --git a/runtime/vm/debugger.h b/runtime/vm/debugger.h index 0a55c25d7f2..e1fe7b2b28f 100644 --- a/runtime/vm/debugger.h +++ b/runtime/vm/debugger.h @@ -290,7 +290,7 @@ class CodeBreakpoint { // ActivationFrame represents one dart function activation frame // on the call stack. -class ActivationFrame : public ZoneAllocated { +class ActivationFrame : public ZoneObject { public: enum Kind { kRegular, @@ -488,7 +488,7 @@ class ActivationFrame : public ZoneAllocated { }; // Array of function activations on the call stack. -class DebuggerStackTrace : public ZoneAllocated { +class DebuggerStackTrace : public ZoneObject { public: explicit DebuggerStackTrace(int capacity) : thread_(Thread::Current()), zone_(thread_->zone()), trace_(capacity) {} diff --git a/runtime/vm/deopt_instructions.cc b/runtime/vm/deopt_instructions.cc index 9dfa54ed440..92490e92f74 100644 --- a/runtime/vm/deopt_instructions.cc +++ b/runtime/vm/deopt_instructions.cc @@ -936,7 +936,7 @@ const char* DeoptInstr::KindToCString(Kind kind) { return nullptr; } -class DeoptInfoBuilder::TrieNode : public ZoneAllocated { +class DeoptInfoBuilder::TrieNode : public ZoneObject { public: // Construct the root node representing the implicit "shared" terminator // at the end of each deopt info. diff --git a/runtime/vm/deopt_instructions.h b/runtime/vm/deopt_instructions.h index 24a885da2ec..296c65d31a2 100644 --- a/runtime/vm/deopt_instructions.h +++ b/runtime/vm/deopt_instructions.h @@ -267,7 +267,7 @@ class DeoptContext : public MallocAllocated { // Represents one deopt instruction, e.g, setup return address, store object, // store register, etc. The target is defined by instruction's position in // the deopt-info array. -class DeoptInstr : public ZoneAllocated { +class DeoptInstr : public ZoneObject { public: enum Kind { kRetAddress, diff --git a/runtime/vm/dwarf.cc b/runtime/vm/dwarf.cc index daa279227a4..f4ceb53d91a 100644 --- a/runtime/vm/dwarf.cc +++ b/runtime/vm/dwarf.cc @@ -59,7 +59,7 @@ class DwarfPosition { static constexpr auto kNoDwarfPositionInfo = DwarfPosition(); -class InliningNode : public ZoneAllocated { +class InliningNode : public ZoneObject { public: InliningNode(const Function& function, const DwarfPosition& position, diff --git a/runtime/vm/dwarf.h b/runtime/vm/dwarf.h index ee93a82247f..8e1958ac4cb 100644 --- a/runtime/vm/dwarf.h +++ b/runtime/vm/dwarf.h @@ -166,7 +166,7 @@ class DwarfWriteStream : public ValueObject { DISALLOW_COPY_AND_ASSIGN(DwarfWriteStream); }; -class Dwarf : public ZoneAllocated { +class Dwarf : public ZoneObject { public: // The compilation unit name is used as the DW_AT_name for the // Dart program's compilation unit. If nullptr, then the name of diff --git a/runtime/vm/elf.cc b/runtime/vm/elf.cc index 1e81350ad77..fbec2bb2863 100644 --- a/runtime/vm/elf.cc +++ b/runtime/vm/elf.cc @@ -85,7 +85,7 @@ class ElfStringTable; // Align note sections and segments to 4 byte boundaries. static constexpr intptr_t kNoteAlignment = 4; -class ElfSection : public ZoneAllocated { +class ElfSection : public ZoneObject { public: ElfSection(elf::SectionHeaderType t, bool allocate, @@ -238,7 +238,7 @@ class ElfSection : public ZoneAllocated { #undef DEFINE_LINEAR_FIELD #undef DEFINE_LINEAR_FIELD_METHODS -class Segment : public ZoneAllocated { +class Segment : public ZoneObject { public: Segment(Zone* zone, ElfSection* initial_section, @@ -721,7 +721,7 @@ class DynamicTable : public ElfSection { } private: - struct Entry : public ZoneAllocated { + struct Entry : public ZoneObject { Entry(elf::DynamicEntryType tag, intptr_t value) : tag(tag), value(value) {} void Write(ElfWriteStream* stream) const { diff --git a/runtime/vm/growable_array.h b/runtime/vm/growable_array.h index ea5ad2351df..53e376f0ef1 100644 --- a/runtime/vm/growable_array.h +++ b/runtime/vm/growable_array.h @@ -48,17 +48,17 @@ class GrowableArray : public BaseGrowableArray { }; template -class ZoneGrowableArray : public BaseGrowableArray { +class ZoneGrowableArray : public BaseGrowableArray { public: ZoneGrowableArray(Zone* zone, intptr_t initial_capacity) - : BaseGrowableArray(initial_capacity, - ASSERT_NOTNULL(zone)) {} + : BaseGrowableArray(initial_capacity, + ASSERT_NOTNULL(zone)) {} explicit ZoneGrowableArray(intptr_t initial_capacity) - : BaseGrowableArray( + : BaseGrowableArray( initial_capacity, ASSERT_NOTNULL(ThreadState::Current()->zone())) {} ZoneGrowableArray() - : BaseGrowableArray( + : BaseGrowableArray( ASSERT_NOTNULL(ThreadState::Current()->zone())) {} ZoneGrowableArray(ZoneGrowableArray&& other) = default; @@ -108,10 +108,10 @@ class GrowableHandlePtrArray template class ZoneGrowableHandlePtrArray - : public BaseGrowableHandlePtrArray { + : public BaseGrowableHandlePtrArray { public: ZoneGrowableHandlePtrArray(Zone* zone, intptr_t initial_capacity) - : BaseGrowableHandlePtrArray(zone, initial_capacity) {} + : BaseGrowableHandlePtrArray(zone, initial_capacity) {} }; } // namespace dart diff --git a/runtime/vm/hash_map.h b/runtime/vm/hash_map.h index 527213847be..51ee4e85429 100644 --- a/runtime/vm/hash_map.h +++ b/runtime/vm/hash_map.h @@ -349,15 +349,15 @@ class MallocDirectChainedHashMap template class ZoneDirectChainedHashMap - : public BaseDirectChainedHashMap { + : public BaseDirectChainedHashMap { public: ZoneDirectChainedHashMap() - : BaseDirectChainedHashMap( + : BaseDirectChainedHashMap( ThreadState::Current()->zone()) {} explicit ZoneDirectChainedHashMap( Zone* zone, intptr_t initial_size = ZoneDirectChainedHashMap::kInitialSize) - : BaseDirectChainedHashMap( + : BaseDirectChainedHashMap( zone, initial_size) {} @@ -445,12 +445,12 @@ class BaseCStringSet DISALLOW_COPY_AND_ASSIGN(BaseCStringSet); }; -class ZoneCStringSet : public BaseCStringSet { +class ZoneCStringSet : public BaseCStringSet { public: ZoneCStringSet() - : BaseCStringSet(ThreadState::Current()->zone()) {} + : BaseCStringSet(ThreadState::Current()->zone()) {} explicit ZoneCStringSet(Zone* zone) - : BaseCStringSet(zone) {} + : BaseCStringSet(zone) {} private: DISALLOW_COPY_AND_ASSIGN(ZoneCStringSet); diff --git a/runtime/vm/image_snapshot.h b/runtime/vm/image_snapshot.h index e8e1d46e8f4..4379c8645f6 100644 --- a/runtime/vm/image_snapshot.h +++ b/runtime/vm/image_snapshot.h @@ -166,7 +166,7 @@ class Image : ValueObject { DISALLOW_COPY_AND_ASSIGN(Image); }; -class ImageReader : public ZoneAllocated { +class ImageReader : public ZoneObject { public: ImageReader(const uint8_t* data_image, const uint8_t* instructions_image); @@ -263,7 +263,7 @@ struct ImageWriterCommand { #if defined(DART_PRECOMPILER) template -class Trie : public ZoneAllocated { +class Trie : public ZoneObject { public: // Returns whether [key] is a valid trie key (that is, a C string that // contains only characters for which charIndex returns a non-negative value). diff --git a/runtime/vm/isolate_reload.h b/runtime/vm/isolate_reload.h index efc0fac83e8..9d70ea867d0 100644 --- a/runtime/vm/isolate_reload.h +++ b/runtime/vm/isolate_reload.h @@ -63,7 +63,7 @@ struct FieldMapping { using FieldMappingArray = ZoneGrowableArray; using FieldOffsetArray = ZoneGrowableArray; -class InstanceMorpher : public ZoneAllocated { +class InstanceMorpher : public ZoneObject { public: // Creates a new [InstanceMorpher] based on the [from]/[to] class // descriptions. @@ -106,7 +106,7 @@ class InstanceMorpher : public ZoneAllocated { GrowableArray before_; }; -class ReasonForCancelling : public ZoneAllocated { +class ReasonForCancelling : public ZoneObject { public: explicit ReasonForCancelling(Zone* zone) {} virtual ~ReasonForCancelling() {} diff --git a/runtime/vm/kernel_loader.h b/runtime/vm/kernel_loader.h index e37bedd5fdd..9fe11e0b95a 100644 --- a/runtime/vm/kernel_loader.h +++ b/runtime/vm/kernel_loader.h @@ -144,7 +144,7 @@ class ClassIndex { DISALLOW_COPY_AND_ASSIGN(ClassIndex); }; -struct UriToSourceTableEntry : public ZoneAllocated { +struct UriToSourceTableEntry : public ZoneObject { UriToSourceTableEntry() {} const String* uri = nullptr; diff --git a/runtime/vm/mach_o.cc b/runtime/vm/mach_o.cc index d5f528b10cc..cd8340e6f44 100644 --- a/runtime/vm/mach_o.cc +++ b/runtime/vm/mach_o.cc @@ -427,7 +427,7 @@ class HashingMachOWriteStream : public BaseWriteStream, }; // A superclass for all objects that represent some content in the MachO output. -class MachOContents : public ZoneAllocated { +class MachOContents : public ZoneObject { public: explicit MachOContents(bool needs_offset = true, bool in_segment = true) // Set the file offset and/or (relative) memory address to 0 if unneeded. diff --git a/runtime/vm/message_snapshot.cc b/runtime/vm/message_snapshot.cc index 1b2e3461711..77206219f64 100644 --- a/runtime/vm/message_snapshot.cc +++ b/runtime/vm/message_snapshot.cc @@ -75,7 +75,7 @@ class MessageDeserializer; class ApiMessageSerializer; class ApiMessageDeserializer; -class MessageSerializationCluster : public ZoneAllocated { +class MessageSerializationCluster : public ZoneObject { public: explicit MessageSerializationCluster(const char* name, MessagePhase phase, @@ -106,7 +106,7 @@ class MessageSerializationCluster : public ZoneAllocated { DISALLOW_COPY_AND_ASSIGN(MessageSerializationCluster); }; -class MessageDeserializationCluster : public ZoneAllocated { +class MessageDeserializationCluster : public ZoneObject { public: explicit MessageDeserializationCluster(const char* name, bool is_canonical = false) diff --git a/runtime/vm/module_snapshot.cc b/runtime/vm/module_snapshot.cc index 1560f20653a..a6017649d45 100644 --- a/runtime/vm/module_snapshot.cc +++ b/runtime/vm/module_snapshot.cc @@ -94,7 +94,7 @@ class ModuleSnapshot : public AllStatic { class Deserializer; -class DeserializationCluster : public ZoneAllocated { +class DeserializationCluster : public ZoneObject { public: explicit DeserializationCluster(const char* name) : name_(name), start_index_(-1), stop_index_(-1) {} diff --git a/runtime/vm/object.h b/runtime/vm/object.h index 19e312cb24f..68b0b1f2cb9 100644 --- a/runtime/vm/object.h +++ b/runtime/vm/object.h @@ -7199,7 +7199,7 @@ class Code : public Object { void Disassemble(DisassemblyFormatter* formatter = nullptr) const; #if defined(INCLUDE_IL_PRINTER) - class Comments : public ZoneAllocated, public CodeComments { + class Comments : public ZoneObject, public CodeComments { public: static Comments& New(intptr_t count); diff --git a/runtime/vm/object_set.h b/runtime/vm/object_set.h index 36a31013bbd..e45e3ba60aa 100644 --- a/runtime/vm/object_set.h +++ b/runtime/vm/object_set.h @@ -13,7 +13,7 @@ namespace dart { -class ObjectSetRegion : public ZoneAllocated { +class ObjectSetRegion : public ZoneObject { public: ObjectSetRegion(Zone* zone, uword start, uword end) : start_(start), @@ -44,7 +44,7 @@ class ObjectSetRegion : public ZoneAllocated { BitVector bit_vector_; }; -class ObjectSet : public ZoneAllocated { +class ObjectSet : public ZoneObject { public: explicit ObjectSet(Zone* zone) : zone_(zone), sorted_(true), regions_() {} diff --git a/runtime/vm/parser.h b/runtime/vm/parser.h index 77b25462451..36a9202668a 100644 --- a/runtime/vm/parser.h +++ b/runtime/vm/parser.h @@ -66,7 +66,7 @@ class FieldKeyValueTrait { typedef DirectChainedHashMap FieldSet; // The class ParsedFunction holds the result of parsing a function. -class ParsedFunction : public ZoneAllocated { +class ParsedFunction : public ZoneObject { public: ParsedFunction(Thread* thread, const Function& function); @@ -248,7 +248,7 @@ class ParsedFunction : public ZoneAllocated { // Variables needed for the InvokeFieldDispatcher for dynamic closure calls, // because they are both read and written to by the builders. - struct DynamicClosureCallVars : ZoneAllocated { + struct DynamicClosureCallVars : ZoneObject { DynamicClosureCallVars(Zone* zone, intptr_t num_named) : named_argument_parameter_indices(zone, num_named) {} diff --git a/runtime/vm/profiler.h b/runtime/vm/profiler.h index 78a082abbb8..9513e4db778 100644 --- a/runtime/vm/profiler.h +++ b/runtime/vm/profiler.h @@ -561,7 +561,7 @@ class AbstractCode { }; // A Code object descriptor. -class CodeDescriptor : public ZoneAllocated { +class CodeDescriptor : public ZoneObject { public: explicit CodeDescriptor(const AbstractCode code); @@ -603,7 +603,7 @@ class CodeDescriptor : public ZoneAllocated { }; // Fast lookup of Dart code objects. -class CodeLookupTable : public ZoneAllocated { +class CodeLookupTable : public ZoneObject { public: explicit CodeLookupTable(Thread* thread); @@ -858,7 +858,7 @@ intptr_t Profiler::Size() { // A |ProcessedSample| is a combination of 1 (or more) |Sample|(s) that have // been merged into a logical sample. The raw data may have been processed to // improve the quality of the stack trace. -class ProcessedSample : public ZoneAllocated { +class ProcessedSample : public ZoneObject { public: ProcessedSample(); @@ -943,7 +943,7 @@ class ProcessedSample : public ZoneAllocated { }; // A collection of |ProcessedSample|s. -class ProcessedSampleBuffer : public ZoneAllocated { +class ProcessedSampleBuffer : public ZoneObject { public: ProcessedSampleBuffer(); diff --git a/runtime/vm/profiler_service.cc b/runtime/vm/profiler_service.cc index 1e3179fe55d..40a1bc8f6e2 100644 --- a/runtime/vm/profiler_service.cc +++ b/runtime/vm/profiler_service.cc @@ -490,7 +490,7 @@ void ProfileCode::PrintToJSONArray(JSONArray* codes) { } #endif // !defined(PRODUCT) -class ProfileFunctionTable : public ZoneAllocated { +class ProfileFunctionTable : public ZoneObject { public: ProfileFunctionTable() : null_function_(Function::ZoneHandle()), diff --git a/runtime/vm/profiler_service.h b/runtime/vm/profiler_service.h index e22e0dc6083..634d95a5377 100644 --- a/runtime/vm/profiler_service.h +++ b/runtime/vm/profiler_service.h @@ -62,7 +62,7 @@ class ProfileFunctionSourcePosition { DISALLOW_ALLOCATION(); }; -class ProfileCodeInlinedFunctionsCache : public ZoneAllocated { +class ProfileCodeInlinedFunctionsCache : public ZoneObject { public: ProfileCodeInlinedFunctionsCache() : cache_cursor_(0), last_hit_(0) { for (intptr_t i = 0; i < kCacheSize; i++) { @@ -138,7 +138,7 @@ class ProfileCodeInlinedFunctionsCache : public ZoneAllocated { }; // Profile data related to a |Function|. -class ProfileFunction : public ZoneAllocated { +class ProfileFunction : public ZoneObject { public: enum Kind { kDartFunction, // Dart function. @@ -234,7 +234,7 @@ class ProfileCodeAddress { }; // Profile data related to a |Code|. -class ProfileCode : public ZoneAllocated { +class ProfileCode : public ZoneObject { public: enum Kind { kDartCode, // Live Dart code. @@ -329,7 +329,7 @@ class ProfileCode : public ZoneAllocated { friend class ProfileBuilder; }; -class ProfileCodeTable : public ZoneAllocated { +class ProfileCodeTable : public ZoneObject { public: ProfileCodeTable() : table_(8) {} diff --git a/runtime/vm/program_visitor.cc b/runtime/vm/program_visitor.cc index dd7bbe94839..b7b8b484498 100644 --- a/runtime/vm/program_visitor.cc +++ b/runtime/vm/program_visitor.cc @@ -17,7 +17,7 @@ namespace dart { -class WorklistElement : public ZoneAllocated { +class WorklistElement : public ZoneObject { public: WorklistElement(Zone* zone, const Object& object) : object_(Object::Handle(zone, object.ptr())), next_(nullptr) {} @@ -448,7 +448,7 @@ void ProgramVisitor::ShareMegamorphicBuckets(Thread* thread) { } } -class StackMapEntry : public ZoneAllocated { +class StackMapEntry : public ZoneObject { public: StackMapEntry(Zone* zone, const CompressedStackMaps::Iterator& it) diff --git a/runtime/vm/raw_object_fields.h b/runtime/vm/raw_object_fields.h index e7b68934f51..e28cd4a901e 100644 --- a/runtime/vm/raw_object_fields.h +++ b/runtime/vm/raw_object_fields.h @@ -21,7 +21,7 @@ namespace dart { #if defined(DART_PRECOMPILER) || defined(DART_ENABLE_HEAP_SNAPSHOT_WRITER) -class OffsetsTable : public ZoneAllocated { +class OffsetsTable : public ZoneObject { public: explicit OffsetsTable(Zone* zone); @@ -67,7 +67,7 @@ class OffsetsTable : public ZoneAllocated { #else -class OffsetsTable : public ZoneAllocated { +class OffsetsTable : public ZoneObject { public: explicit OffsetsTable(Zone* zone) {} diff --git a/runtime/vm/regexp/regexp.h b/runtime/vm/regexp/regexp.h index be1b827c464..c2743e2ff99 100644 --- a/runtime/vm/regexp/regexp.h +++ b/runtime/vm/regexp/regexp.h @@ -89,7 +89,7 @@ class CharacterRange { // A set of unsigned integers that behaves especially well on small // integers (< 32). May do zone-allocation. -class OutSet : public ZoneAllocated { +class OutSet : public ZoneObject { public: OutSet() : first_(0), remaining_(nullptr), successors_(nullptr) {} OutSet* Extend(unsigned value, Zone* zone); @@ -381,7 +381,7 @@ class QuickCheckDetails { DISALLOW_ALLOCATION(); }; -class RegExpNode : public ZoneAllocated { +class RegExpNode : public ZoneObject { public: explicit RegExpNode(Zone* zone) : replacement_(nullptr), trace_count_(0), zone_(zone) { @@ -858,7 +858,7 @@ class NegativeSubmatchSuccess : public EndNode { intptr_t clear_capture_start_; }; -class Guard : public ZoneAllocated { +class Guard : public ZoneObject { public: enum Relation { LT, GEQ }; Guard(intptr_t reg, Relation op, intptr_t value) @@ -1093,7 +1093,7 @@ ContainedInLattice AddRange(ContainedInLattice a, intptr_t ranges_size, Interval new_range); -class BoyerMoorePositionInfo : public ZoneAllocated { +class BoyerMoorePositionInfo : public ZoneObject { public: explicit BoyerMoorePositionInfo(Zone* zone) : map_(new (zone) ZoneGrowableArray(kMapSize)), @@ -1129,7 +1129,7 @@ class BoyerMoorePositionInfo : public ZoneAllocated { ContainedInLattice surrogate_; // Surrogate UTF-16 code units. }; -class BoyerMooreLookahead : public ZoneAllocated { +class BoyerMooreLookahead : public ZoneObject { public: BoyerMooreLookahead(intptr_t length, RegExpCompiler* compiler, Zone* Zone); @@ -1427,7 +1427,7 @@ class Analysis : public NodeVisitor { DISALLOW_IMPLICIT_CONSTRUCTORS(Analysis); }; -struct RegExpCompileData : public ZoneAllocated { +struct RegExpCompileData : public ZoneObject { RegExpCompileData() : tree(nullptr), node(nullptr), diff --git a/runtime/vm/regexp/regexp_assembler.h b/runtime/vm/regexp/regexp_assembler.h index 0c549a58802..16e7297d5b6 100644 --- a/runtime/vm/regexp/regexp_assembler.h +++ b/runtime/vm/regexp/regexp_assembler.h @@ -93,7 +93,7 @@ class BlockLabel : public ValueObject { #endif // !defined(DART_PRECOMPILED_RUNTIME) }; -class RegExpMacroAssembler : public ZoneAllocated { +class RegExpMacroAssembler : public ZoneObject { public: // The implementation must be able to handle at least: static constexpr intptr_t kMaxRegister = (1 << 16) - 1; diff --git a/runtime/vm/regexp/regexp_ast.h b/runtime/vm/regexp/regexp_ast.h index 2bee2f09063..7b87283cb2f 100644 --- a/runtime/vm/regexp/regexp_ast.h +++ b/runtime/vm/regexp/regexp_ast.h @@ -34,7 +34,7 @@ class RegExpVisitor : public ValueObject { #undef MAKE_CASE }; -class RegExpTree : public ZoneAllocated { +class RegExpTree : public ZoneObject { public: static constexpr intptr_t kInfinity = kMaxInt32; virtual ~RegExpTree() {} diff --git a/runtime/vm/regexp/regexp_parser.h b/runtime/vm/regexp/regexp_parser.h index 16932e51c69..c159695ea18 100644 --- a/runtime/vm/regexp/regexp_parser.h +++ b/runtime/vm/regexp/regexp_parser.h @@ -12,7 +12,7 @@ namespace dart { // Accumulates RegExp atoms and assertions into lists of terms and alternatives. -class RegExpBuilder : public ZoneAllocated { +class RegExpBuilder : public ZoneObject { public: explicit RegExpBuilder(RegExpFlags flags); @@ -154,7 +154,7 @@ class RegExpParser : public ValueObject { GROUPING }; - class RegExpParserState : public ZoneAllocated { + class RegExpParserState : public ZoneObject { public: RegExpParserState(RegExpParserState* previous_state, SubexpressionType group_type, diff --git a/runtime/vm/scopes.h b/runtime/vm/scopes.h index 57d120c0cfb..7f55dd7fe1f 100644 --- a/runtime/vm/scopes.h +++ b/runtime/vm/scopes.h @@ -72,7 +72,7 @@ class VariableIndex { int value_; }; -class LocalVariable : public ZoneAllocated { +class LocalVariable : public ZoneObject { public: static constexpr intptr_t kNoKernelOffset = -1; @@ -310,7 +310,7 @@ class LocalVarDescriptorsBuilder : public ValueObject { GrowableArray vars_; }; -class LocalScope : public ZoneAllocated { +class LocalScope : public ZoneObject { public: LocalScope(LocalScope* parent, int function_level, int loop_level); diff --git a/runtime/vm/so_writer.h b/runtime/vm/so_writer.h index b620e9eaeb9..85f0844e54c 100644 --- a/runtime/vm/so_writer.h +++ b/runtime/vm/so_writer.h @@ -20,7 +20,7 @@ class Dwarf; class ElfWriter; class MachOWriter; -class SharedObjectWriter : public ZoneAllocated { +class SharedObjectWriter : public ZoneObject { public: enum class Type { // A snapshot that should include segment contents. diff --git a/runtime/vm/splay-tree.h b/runtime/vm/splay-tree.h index 54c5d9faf0e..15c834de385 100644 --- a/runtime/vm/splay-tree.h +++ b/runtime/vm/splay-tree.h @@ -15,15 +15,15 @@ namespace dart { // platform/splay-tree.h). The tree itself and all its elements are allocated // in the Zone. template -class ZoneSplayTree final : public SplayTree { +class ZoneSplayTree final : public SplayTree { public: explicit ZoneSplayTree(Zone* zone) - : SplayTree(ASSERT_NOTNULL(zone)) {} + : SplayTree(ASSERT_NOTNULL(zone)) {} ~ZoneSplayTree() { // Reset the root to avoid unneeded iteration over all tree nodes // in the destructor. For a zone-allocated tree, nodes will be // freed by the Zone. - SplayTree::ResetRoot(); + SplayTree::ResetRoot(); } }; diff --git a/runtime/vm/v8_snapshot_writer.h b/runtime/vm/v8_snapshot_writer.h index 6cd20bc9512..841d5ff9b86 100644 --- a/runtime/vm/v8_snapshot_writer.h +++ b/runtime/vm/v8_snapshot_writer.h @@ -27,7 +27,7 @@ enum class IdSpace : uint8_t { // Change ObjectId::kIdSpaceBits to use last entry if more are added. }; -class V8SnapshotProfileWriter : public ZoneAllocated { +class V8SnapshotProfileWriter : public ZoneObject { public: struct ObjectId { ObjectId() : ObjectId(IdSpace::kInvalid, -1) {} diff --git a/runtime/vm/zone.h b/runtime/vm/zone.h index e5b5aac86fe..841c54d970a 100644 --- a/runtime/vm/zone.h +++ b/runtime/vm/zone.h @@ -5,6 +5,8 @@ #ifndef RUNTIME_VM_ZONE_H_ #define RUNTIME_VM_ZONE_H_ +#include + #include "platform/utils.h" #include "vm/allocation.h" #include "vm/handles.h" @@ -19,6 +21,15 @@ namespace dart { class Zone { public: + // Allocates memory for T instance and constructs object by calling respective + // Args... constructor. + template + T* New(Args&&... args) { + static_assert(alignof(T) <= kAlignment); + void* memory = reinterpret_cast(AllocUnsafe(sizeof(T))); + return new (memory) T(std::forward(args)...); + } + // Allocate an array sized to hold 'len' elements of type // 'ElementType'. Checks for integer overflow when performing the // size computation. diff --git a/runtime/vm/zone_test.cc b/runtime/vm/zone_test.cc index 56f45664393..1e37efb4a81 100644 --- a/runtime/vm/zone_test.cc +++ b/runtime/vm/zone_test.cc @@ -135,7 +135,7 @@ VM_UNIT_TEST_CASE(ZoneRealloc) { Dart_ShutdownIsolate(); } -VM_UNIT_TEST_CASE(ZoneAllocated) { +VM_UNIT_TEST_CASE(ZoneObject) { #if defined(DEBUG) FLAG_trace_zones = true; #endif @@ -144,7 +144,7 @@ VM_UNIT_TEST_CASE(ZoneAllocated) { EXPECT(thread->zone() == nullptr); static int marker; - class SimpleZoneObject : public ZoneAllocated { + class SimpleZoneObject : public ZoneObject { public: SimpleZoneObject() : slot(marker++) {} virtual ~SimpleZoneObject() {} @@ -162,7 +162,7 @@ VM_UNIT_TEST_CASE(ZoneAllocated) { EXPECT_EQ(0UL, zone.SizeInBytes()); SimpleZoneObject* first = new SimpleZoneObject(); EXPECT(first != nullptr); - SimpleZoneObject* second = new SimpleZoneObject(); + SimpleZoneObject* second = zone.GetZone()->New(); EXPECT(second != nullptr); EXPECT(first != second); uintptr_t expected_size = (2 * sizeof(SimpleZoneObject));