Chromium Code Reviews| Index: src/zone-inl.h |
| =================================================================== |
| --- src/zone-inl.h (revision 4781) |
| +++ 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); |
| @@ -53,7 +65,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))); |
| } |
| @@ -77,6 +89,18 @@ |
| } |
| +// TODO(isolates): maybe replace uses of this with placement new so that |
|
Vitaly Repeshko
2010/06/02 15:30:40
"placement new" -> "new operator that takes a zone
|
| +// the zone pointer can be locally cached |
| +void* ZoneObject::operator new(size_t size) { |
| + return ZONE->New(static_cast<int>(size)); |
| +} |
| + |
| + |
| +inline void* ZoneListAllocationPolicy::New(int size) { |
| + return ZONE->New(size); |
| +} |
| + |
| + |
| } } // namespace v8::internal |
| #endif // V8_ZONE_INL_H_ |