Skip to content

Instantly share code, notes, and snippets.

Created August 16, 2011 15:48
Show Gist options
  • Save anonymous/1149397 to your computer and use it in GitHub Desktop.
Save anonymous/1149397 to your computer and use it in GitHub Desktop.
diff --git a/samples/shell.cc b/samples/shell.cc
index f37e731..171256f 100644
--- a/samples/shell.cc
+++ b/samples/shell.cc
@@ -36,6 +36,8 @@
#include <stdio.h>
#include <stdlib.h>
+extern int zone_allocated;
+
// When building with V8 in a shared library we cannot use functions which
// is not explicitly a part of the public V8 API. This extensive use of
// #ifndef USING_V8_SHARED/#endif is a hack until we can resolve whether to
@@ -312,6 +314,7 @@ int RunMain(int argc, char* argv[]) {
}
context->Exit();
context.Dispose();
+ printf("Zone allocated: %d\n", zone_allocated);
return 0;
}
diff --git a/src/zone-inl.h b/src/zone-inl.h
index 6e2d558..24371ca 100644
--- a/src/zone-inl.h
+++ b/src/zone-inl.h
@@ -32,10 +32,11 @@
#include "zone.h"
#include "v8-counters.h"
+extern int zone_allocated;
+
namespace v8 {
namespace internal {
-
AssertNoZoneAllocation::AssertNoZoneAllocation()
: prev_(Isolate::Current()->zone_allow_allocation()) {
Isolate::Current()->set_zone_allow_allocation(false);
@@ -52,6 +53,7 @@ inline void* Zone::New(int size) {
ASSERT(ZoneScope::nesting() > 0);
// Round up the requested size to fit the alignment.
size = RoundUp(size, kAlignment);
+ zone_allocated += size;
// Check if the requested size is available without expanding.
Address result = position_;
diff --git a/src/zone.cc b/src/zone.cc
index 42ce8c5..5d80fee 100644
--- a/src/zone.cc
+++ b/src/zone.cc
@@ -30,6 +30,8 @@
#include "zone-inl.h"
#include "splay-tree-inl.h"
+int zone_allocated = 0;
+
namespace v8 {
namespace internal {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment