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

Unified Diff: src/d8.h

Issue 13050: Live counters in d8 (Closed)
Patch Set: Created 12 years 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 | « no previous file | src/d8.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.h
diff --git a/src/d8.h b/src/d8.h
index 2bbe690c73de6f5daac925437619ee607452287d..371e529859e17bf4f757fdcb9143638c670ea88d 100644
--- a/src/d8.h
+++ b/src/d8.h
@@ -42,16 +42,33 @@ namespace v8 {
namespace i = v8::internal;
+// A single counter in a counter collection.
class Counter {
public:
- explicit Counter(const char* name)
- : name_(name), value_(0) { }
- int* GetValuePtr() { return &value_; }
- const char* name() { return name_; }
- int value() { return value_; }
+ static const int kMaxNameSize = 64;
+ int32_t* Bind(const char* name);
+ int32_t* ptr() { return &counter_; }
+ int32_t value() { return counter_; }
private:
- const char* name_;
- int value_;
+ int32_t counter_;
+ uint8_t name_[kMaxNameSize];
+};
+
+
+// A set of counters and associated information. An instance of this
+// class is stored directly in the memory-mapped counters file if
+// the --map-counters options is used
+class CounterCollection {
+ public:
+ CounterCollection();
+ Counter* GetNextCounter();
+ private:
+ static const unsigned kMaxCounters = 256;
+ uint32_t magic_number_;
+ uint32_t max_counters_;
+ uint32_t max_name_size_;
+ uint32_t counters_in_use_;
+ Counter counters_[kMaxCounters];
};
@@ -65,6 +82,7 @@ class Shell: public i::AllStatic {
static void Initialize();
static void OnExit();
static int* LookupCounter(const char* name);
+ static void MapCounters(const char* name);
static Handle<String> ReadFile(const char* name);
static void RunShell();
static int Main(int argc, char* argv[]);
@@ -83,6 +101,11 @@ class Shell: public i::AllStatic {
static Persistent<Context> evaluation_context_;
typedef std::map<const char*, Counter*> CounterMap;
static CounterMap counter_map_;
+ // We statically allocate a set of local counters to be used if we
+ // don't want to store the stats in a memory-mapped file
+ static CounterCollection local_counters_;
+ static CounterCollection* counters_;
+ static i::OS::MemoryMappedFile* counters_file_;
};
« no previous file with comments | « no previous file | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698