Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: src/zone-inl.h

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/zone.cc ('k') | test/cctest/cctest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « src/zone.cc ('k') | test/cctest/cctest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698