diff options
Diffstat (limited to 'deps/v8/src/zone-inl.h')
-rw-r--r-- | deps/v8/src/zone-inl.h | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/deps/v8/src/zone-inl.h b/deps/v8/src/zone-inl.h index 467296039c..6e2d558a60 100644 --- a/deps/v8/src/zone-inl.h +++ b/deps/v8/src/zone-inl.h @@ -28,6 +28,7 @@ #ifndef V8_ZONE_INL_H_ #define V8_ZONE_INL_H_ +#include "isolate.h" #include "zone.h" #include "v8-counters.h" @@ -35,8 +36,19 @@ namespace v8 { namespace internal { +AssertNoZoneAllocation::AssertNoZoneAllocation() + : prev_(Isolate::Current()->zone_allow_allocation()) { + Isolate::Current()->set_zone_allow_allocation(false); +} + + +AssertNoZoneAllocation::~AssertNoZoneAllocation() { + Isolate::Current()->set_zone_allow_allocation(prev_); +} + + inline void* Zone::New(int size) { - ASSERT(AssertNoZoneAllocation::allow_allocation()); + ASSERT(Isolate::Current()->zone_allow_allocation()); ASSERT(ZoneScope::nesting() > 0); // Round up the requested size to fit the alignment. size = RoundUp(size, kAlignment); @@ -54,7 +66,7 @@ inline void* Zone::New(int size) { template <typename T> T* Zone::NewArray(int length) { - return static_cast<T*>(Zone::New(length * sizeof(T))); + return static_cast<T*>(New(length * sizeof(T))); } @@ -65,7 +77,7 @@ bool Zone::excess_allocation() { void Zone::adjust_segment_bytes_allocated(int delta) { segment_bytes_allocated_ += delta; - Counters::zone_segment_bytes.Set(segment_bytes_allocated_); + isolate_->counters()->zone_segment_bytes()->Set(segment_bytes_allocated_); } @@ -78,6 +90,51 @@ ZoneSplayTree<Config>::~ZoneSplayTree() { } +// TODO(isolates): for performance reasons, this should be replaced with a new +// operator that takes the zone in which the object should be +// allocated. +void* ZoneObject::operator new(size_t size) { + return ZONE->New(static_cast<int>(size)); +} + +void* ZoneObject::operator new(size_t size, Zone* zone) { + return zone->New(static_cast<int>(size)); +} + + +inline void* ZoneListAllocationPolicy::New(int size) { + return ZONE->New(size); +} + + +template <typename T> +void* ZoneList<T>::operator new(size_t size) { + return ZONE->New(static_cast<int>(size)); +} + + +template <typename T> +void* ZoneList<T>::operator new(size_t size, Zone* zone) { + return zone->New(static_cast<int>(size)); +} + + +ZoneScope::ZoneScope(Isolate* isolate, ZoneScopeMode mode) + : isolate_(isolate), mode_(mode) { + isolate_->zone()->scope_nesting_++; +} + + +bool ZoneScope::ShouldDeleteOnExit() { + return isolate_->zone()->scope_nesting_ == 1 && mode_ == DELETE_ON_EXIT; +} + + +int ZoneScope::nesting() { + return Isolate::Current()->zone()->scope_nesting_; +} + + } } // namespace v8::internal #endif // V8_ZONE_INL_H_ |