| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 30 matching lines...) Expand all Loading... |
| 41 // use explicit namespace to avoid clashing with types in namespace v8 | 41 // use explicit namespace to avoid clashing with types in namespace v8 |
| 42 namespace i = v8::internal; | 42 namespace i = v8::internal; |
| 43 using namespace v8; | 43 using namespace v8; |
| 44 | 44 |
| 45 static const unsigned int kMaxCounters = 256; | 45 static const unsigned int kMaxCounters = 256; |
| 46 | 46 |
| 47 // A single counter in a counter collection. | 47 // A single counter in a counter collection. |
| 48 class Counter { | 48 class Counter { |
| 49 public: | 49 public: |
| 50 static const int kMaxNameSize = 64; | 50 static const int kMaxNameSize = 64; |
| 51 int32_t* Bind(const wchar_t* name) { | 51 int32_t* Bind(const char* name) { |
| 52 int i; | 52 int i; |
| 53 for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) { | 53 for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) { |
| 54 name_[i] = static_cast<char>(name[i]); | 54 name_[i] = name[i]; |
| 55 } | 55 } |
| 56 name_[i] = '\0'; | 56 name_[i] = '\0'; |
| 57 return &counter_; | 57 return &counter_; |
| 58 } | 58 } |
| 59 private: | 59 private: |
| 60 int32_t counter_; | 60 int32_t counter_; |
| 61 uint8_t name_[kMaxNameSize]; | 61 uint8_t name_[kMaxNameSize]; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 | 64 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 85 Counter counters_[kMaxCounters]; | 85 Counter counters_[kMaxCounters]; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 | 88 |
| 89 // We statically allocate a set of local counters to be used if we | 89 // We statically allocate a set of local counters to be used if we |
| 90 // don't want to store the stats in a memory-mapped file | 90 // don't want to store the stats in a memory-mapped file |
| 91 static CounterCollection local_counters; | 91 static CounterCollection local_counters; |
| 92 static CounterCollection* counters = &local_counters; | 92 static CounterCollection* counters = &local_counters; |
| 93 | 93 |
| 94 | 94 |
| 95 typedef std::map<std::wstring, int*> CounterMap; | 95 typedef std::map<std::string, int*> CounterMap; |
| 96 typedef std::map<std::wstring, int*>::iterator CounterMapIterator; | 96 typedef std::map<std::string, int*>::iterator CounterMapIterator; |
| 97 static CounterMap counter_table_; | 97 static CounterMap counter_table_; |
| 98 | 98 |
| 99 // Callback receiver when v8 has a counter to track. | 99 // Callback receiver when v8 has a counter to track. |
| 100 static int* counter_callback(const wchar_t* name) { | 100 static int* counter_callback(const char* name) { |
| 101 std::wstring counter = name; | 101 std::string counter = name; |
| 102 // See if this counter name is already known. | 102 // See if this counter name is already known. |
| 103 if (counter_table_.find(counter) != counter_table_.end()) | 103 if (counter_table_.find(counter) != counter_table_.end()) |
| 104 return counter_table_[counter]; | 104 return counter_table_[counter]; |
| 105 | 105 |
| 106 Counter* ctr = counters->GetNextCounter(); | 106 Counter* ctr = counters->GetNextCounter(); |
| 107 if (ctr == NULL) return NULL; | 107 if (ctr == NULL) return NULL; |
| 108 int* ptr = ctr->Bind(name); | 108 int* ptr = ctr->Bind(name); |
| 109 counter_table_[counter] = ptr; | 109 counter_table_[counter] = ptr; |
| 110 return ptr; | 110 return ptr; |
| 111 } | 111 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 char* str; | 177 char* str; |
| 178 int len; | 178 int len; |
| 179 ser.Finalize(&str, &len); | 179 ser.Finalize(&str, &len); |
| 180 | 180 |
| 181 WriteInternalSnapshotToFile(argv[1], str, len); | 181 WriteInternalSnapshotToFile(argv[1], str, len); |
| 182 | 182 |
| 183 i::DeleteArray(str); | 183 i::DeleteArray(str); |
| 184 | 184 |
| 185 return 0; | 185 return 0; |
| 186 } | 186 } |
| OLD | NEW |