| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 | 36 |
| 37 | 37 |
| 38 namespace i = v8::internal; | 38 namespace i = v8::internal; |
| 39 | 39 |
| 40 | 40 |
| 41 // A single counter in a counter collection. | 41 // A single counter in a counter collection. |
| 42 class Counter { | 42 class Counter { |
| 43 public: | 43 public: |
| 44 static const int kMaxNameSize = 64; | 44 static const int kMaxNameSize = 64; |
| 45 int32_t* Bind(const char* name); | 45 int32_t* Bind(const char* name, bool histogram); |
| 46 int32_t* ptr() { return &counter_; } | 46 int32_t* ptr() { return &count_; } |
| 47 int32_t value() { return counter_; } | 47 int32_t count() { return count_; } |
| 48 int32_t sample_total() { return sample_total_; } |
| 49 bool is_histogram() { return is_histogram_; } |
| 50 void AddSample(int32_t sample); |
| 48 private: | 51 private: |
| 49 int32_t counter_; | 52 int32_t count_; |
| 53 int32_t sample_total_; |
| 54 bool is_histogram_; |
| 50 uint8_t name_[kMaxNameSize]; | 55 uint8_t name_[kMaxNameSize]; |
| 51 }; | 56 }; |
| 52 | 57 |
| 53 | 58 |
| 54 // A set of counters and associated information. An instance of this | 59 // A set of counters and associated information. An instance of this |
| 55 // class is stored directly in the memory-mapped counters file if | 60 // class is stored directly in the memory-mapped counters file if |
| 56 // the --map-counters options is used | 61 // the --map-counters options is used |
| 57 class CounterCollection { | 62 class CounterCollection { |
| 58 public: | 63 public: |
| 59 CounterCollection(); | 64 CounterCollection(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 class Shell: public i::AllStatic { | 114 class Shell: public i::AllStatic { |
| 110 public: | 115 public: |
| 111 static bool ExecuteString(Handle<String> source, | 116 static bool ExecuteString(Handle<String> source, |
| 112 Handle<Value> name, | 117 Handle<Value> name, |
| 113 bool print_result, | 118 bool print_result, |
| 114 bool report_exceptions); | 119 bool report_exceptions); |
| 115 static void ReportException(TryCatch* try_catch); | 120 static void ReportException(TryCatch* try_catch); |
| 116 static void Initialize(); | 121 static void Initialize(); |
| 117 static void OnExit(); | 122 static void OnExit(); |
| 118 static int* LookupCounter(const char* name); | 123 static int* LookupCounter(const char* name); |
| 124 static void* CreateHistogram(const char* name, |
| 125 int min, |
| 126 int max, |
| 127 size_t buckets); |
| 128 static void AddHistogramSample(void* histogram, int sample); |
| 119 static void MapCounters(const char* name); | 129 static void MapCounters(const char* name); |
| 120 static Handle<String> ReadFile(const char* name); | 130 static Handle<String> ReadFile(const char* name); |
| 121 static void RunShell(); | 131 static void RunShell(); |
| 122 static int Main(int argc, char* argv[]); | 132 static int Main(int argc, char* argv[]); |
| 123 static Handle<Array> GetCompletions(Handle<String> text, | 133 static Handle<Array> GetCompletions(Handle<String> text, |
| 124 Handle<String> full); | 134 Handle<String> full); |
| 125 static Handle<Object> DebugMessageDetails(Handle<String> message); | 135 static Handle<Object> DebugMessageDetails(Handle<String> message); |
| 126 static Handle<Value> DebugCommandToJSONRequest(Handle<String> command); | 136 static Handle<Value> DebugCommandToJSONRequest(Handle<String> command); |
| 127 | 137 |
| 128 static Handle<Value> Print(const Arguments& args); | 138 static Handle<Value> Print(const Arguments& args); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 static const char* kPrompt; | 182 static const char* kPrompt; |
| 173 private: | 183 private: |
| 174 static Persistent<Context> utility_context_; | 184 static Persistent<Context> utility_context_; |
| 175 static Persistent<Context> evaluation_context_; | 185 static Persistent<Context> evaluation_context_; |
| 176 static CounterMap* counter_map_; | 186 static CounterMap* counter_map_; |
| 177 // We statically allocate a set of local counters to be used if we | 187 // We statically allocate a set of local counters to be used if we |
| 178 // don't want to store the stats in a memory-mapped file | 188 // don't want to store the stats in a memory-mapped file |
| 179 static CounterCollection local_counters_; | 189 static CounterCollection local_counters_; |
| 180 static CounterCollection* counters_; | 190 static CounterCollection* counters_; |
| 181 static i::OS::MemoryMappedFile* counters_file_; | 191 static i::OS::MemoryMappedFile* counters_file_; |
| 192 static Counter* GetCounter(const char* name, bool is_histogram); |
| 182 }; | 193 }; |
| 183 | 194 |
| 184 | 195 |
| 185 class LineEditor { | 196 class LineEditor { |
| 186 public: | 197 public: |
| 187 enum Type { DUMB = 0, READLINE = 1 }; | 198 enum Type { DUMB = 0, READLINE = 1 }; |
| 188 LineEditor(Type type, const char* name); | 199 LineEditor(Type type, const char* name); |
| 189 virtual ~LineEditor() { } | 200 virtual ~LineEditor() { } |
| 190 | 201 |
| 191 virtual i::SmartPointer<char> Prompt(const char* prompt) = 0; | 202 virtual i::SmartPointer<char> Prompt(const char* prompt) = 0; |
| 192 virtual bool Open() { return true; } | 203 virtual bool Open() { return true; } |
| 193 virtual bool Close() { return true; } | 204 virtual bool Close() { return true; } |
| 194 virtual void AddHistory(const char* str) { } | 205 virtual void AddHistory(const char* str) { } |
| 195 | 206 |
| 196 const char* name() { return name_; } | 207 const char* name() { return name_; } |
| 197 static LineEditor* Get(); | 208 static LineEditor* Get(); |
| 198 private: | 209 private: |
| 199 Type type_; | 210 Type type_; |
| 200 const char* name_; | 211 const char* name_; |
| 201 LineEditor* next_; | 212 LineEditor* next_; |
| 202 static LineEditor* first_; | 213 static LineEditor* first_; |
| 203 }; | 214 }; |
| 204 | 215 |
| 205 | 216 |
| 206 } // namespace v8 | 217 } // namespace v8 |
| 207 | 218 |
| 208 | 219 |
| 209 #endif // V8_D8_H_ | 220 #endif // V8_D8_H_ |
| OLD | NEW |