| Index: src/zone-inl.h
|
| ===================================================================
|
| --- src/zone-inl.h (revision 7267)
|
| +++ src/zone-inl.h (working copy)
|
| @@ -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 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 @@
|
|
|
| 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 @@
|
|
|
| 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,36 @@
|
| }
|
|
|
|
|
| +// 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));
|
| +}
|
| +
|
| +
|
| +inline void* ZoneListAllocationPolicy::New(int size) {
|
| + return ZONE->New(size);
|
| +}
|
| +
|
| +
|
| +ZoneScope::ZoneScope(ZoneScopeMode mode)
|
| + : isolate_(Isolate::Current()),
|
| + 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_
|
|
|