Commit 88d4740d authored by ager@chromium.org's avatar ager@chromium.org

Commiting Evan's change to use char instead of wchar_t for counter names.

Code review URL:

  http://codereview.chromium.org/13011/show


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@871 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f87ad674
...@@ -1813,7 +1813,7 @@ class EXPORT Exception { ...@@ -1813,7 +1813,7 @@ class EXPORT Exception {
// --- C o u n t e r s C a l l b a c k s --- // --- C o u n t e r s C a l l b a c k s ---
typedef int* (*CounterLookupCallback)(const wchar_t* name); typedef int* (*CounterLookupCallback)(const char* name);
// --- F a i l e d A c c e s s C h e c k C a l l b a c k --- // --- F a i l e d A c c e s s C h e c k C a l l b a c k ---
typedef void (*FailedAccessCheckCallback)(Local<Object> target, typedef void (*FailedAccessCheckCallback)(Local<Object> target,
......
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
#ifndef V8_COUNTERS_H_ #ifndef V8_COUNTERS_H_
#define V8_COUNTERS_H_ #define V8_COUNTERS_H_
#include <wchar.h>
namespace v8 { namespace internal { namespace v8 { namespace internal {
// StatsCounters is an interface for plugging into external // StatsCounters is an interface for plugging into external
...@@ -54,7 +52,7 @@ class StatsTable : public AllStatic { ...@@ -54,7 +52,7 @@ class StatsTable : public AllStatic {
// may receive a different location to store it's counter. // may receive a different location to store it's counter.
// The return value must not be cached and re-used across // The return value must not be cached and re-used across
// threads, although a single thread is free to cache it. // threads, although a single thread is free to cache it.
static int *FindLocation(const wchar_t* name) { static int *FindLocation(const char* name) {
if (!lookup_function_) return NULL; if (!lookup_function_) return NULL;
return lookup_function_(name); return lookup_function_(name);
} }
...@@ -74,9 +72,9 @@ class StatsTable : public AllStatic { ...@@ -74,9 +72,9 @@ class StatsTable : public AllStatic {
// //
// This class is designed to be POD initialized. It will be registered with // This class is designed to be POD initialized. It will be registered with
// the counter system on first use. For example: // the counter system on first use. For example:
// StatsCounter c = { L"c:myctr", NULL, false }; // StatsCounter c = { "c:myctr", NULL, false };
struct StatsCounter { struct StatsCounter {
const wchar_t* name_; const char* name_;
int* ptr_; int* ptr_;
bool lookup_done_; bool lookup_done_;
......
...@@ -209,7 +209,7 @@ Handle<Array> Shell::GetCompletions(Handle<String> text, Handle<String> full) { ...@@ -209,7 +209,7 @@ Handle<Array> Shell::GetCompletions(Handle<String> text, Handle<String> full) {
} }
int* Shell::LookupCounter(const wchar_t* name) { int* Shell::LookupCounter(const char* name) {
CounterMap::iterator item = counter_map_.find(name); CounterMap::iterator item = counter_map_.find(name);
if (item != counter_map_.end()) { if (item != counter_map_.end()) {
Counter* result = (*item).second; Counter* result = (*item).second;
......
...@@ -44,13 +44,13 @@ namespace i = v8::internal; ...@@ -44,13 +44,13 @@ namespace i = v8::internal;
class Counter { class Counter {
public: public:
explicit Counter(const wchar_t* name) explicit Counter(const char* name)
: name_(name), value_(0) { } : name_(name), value_(0) { }
int* GetValuePtr() { return &value_; } int* GetValuePtr() { return &value_; }
const wchar_t* name() { return name_; } const char* name() { return name_; }
int value() { return value_; } int value() { return value_; }
private: private:
const wchar_t* name_; const char* name_;
int value_; int value_;
}; };
...@@ -64,7 +64,7 @@ class Shell: public i::AllStatic { ...@@ -64,7 +64,7 @@ class Shell: public i::AllStatic {
static void ReportException(TryCatch* try_catch); static void ReportException(TryCatch* try_catch);
static void Initialize(); static void Initialize();
static void OnExit(); static void OnExit();
static int* LookupCounter(const wchar_t* name); static int* LookupCounter(const char* name);
static Handle<String> ReadFile(const char* name); static Handle<String> ReadFile(const char* name);
static void RunShell(); static void RunShell();
static int Main(int argc, char* argv[]); static int Main(int argc, char* argv[]);
...@@ -81,7 +81,7 @@ class Shell: public i::AllStatic { ...@@ -81,7 +81,7 @@ class Shell: public i::AllStatic {
private: private:
static Persistent<Context> utility_context_; static Persistent<Context> utility_context_;
static Persistent<Context> evaluation_context_; static Persistent<Context> evaluation_context_;
typedef std::map<const wchar_t*, Counter*> CounterMap; typedef std::map<const char*, Counter*> CounterMap;
static CounterMap counter_map_; static CounterMap counter_map_;
}; };
......
...@@ -48,10 +48,10 @@ static const unsigned int kMaxCounters = 256; ...@@ -48,10 +48,10 @@ static const unsigned int kMaxCounters = 256;
class Counter { class Counter {
public: public:
static const int kMaxNameSize = 64; static const int kMaxNameSize = 64;
int32_t* Bind(const wchar_t* name) { int32_t* Bind(const char* name) {
int i; int i;
for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) { for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) {
name_[i] = static_cast<char>(name[i]); name_[i] = name[i];
} }
name_[i] = '\0'; name_[i] = '\0';
return &counter_; return &counter_;
...@@ -92,13 +92,13 @@ static CounterCollection local_counters; ...@@ -92,13 +92,13 @@ static CounterCollection local_counters;
static CounterCollection* counters = &local_counters; static CounterCollection* counters = &local_counters;
typedef std::map<std::wstring, int*> CounterMap; typedef std::map<std::string, int*> CounterMap;
typedef std::map<std::wstring, int*>::iterator CounterMapIterator; typedef std::map<std::string, int*>::iterator CounterMapIterator;
static CounterMap counter_table_; static CounterMap counter_table_;
// Callback receiver when v8 has a counter to track. // Callback receiver when v8 has a counter to track.
static int* counter_callback(const wchar_t* name) { static int* counter_callback(const char* name) {
std::wstring counter = name; std::string counter = name;
// See if this counter name is already known. // See if this counter name is already known.
if (counter_table_.find(counter) != counter_table_.end()) if (counter_table_.find(counter) != counter_table_.end())
return counter_table_[counter]; return counter_table_[counter];
......
...@@ -33,14 +33,14 @@ namespace v8 { namespace internal { ...@@ -33,14 +33,14 @@ namespace v8 { namespace internal {
#define SR(name, caption) \ #define SR(name, caption) \
StatsRate Counters::name = { \ StatsRate Counters::name = { \
{ { L"t:" L###caption, NULL, false }, 0, 0 }, \ { { "t:" #caption, NULL, false }, 0, 0 }, \
{ L"c:" L###caption, NULL, false } }; { "c:" #caption, NULL, false } };
STATS_RATE_LIST(SR) STATS_RATE_LIST(SR)
#undef SR #undef SR
#define SC(name, caption) \ #define SC(name, caption) \
StatsCounter Counters::name = { L"c:" L###caption, NULL, false }; StatsCounter Counters::name = { "c:" #caption, NULL, false };
STATS_COUNTER_LIST_1(SC) STATS_COUNTER_LIST_1(SC)
STATS_COUNTER_LIST_2(SC) STATS_COUNTER_LIST_2(SC)
...@@ -48,7 +48,7 @@ namespace v8 { namespace internal { ...@@ -48,7 +48,7 @@ namespace v8 { namespace internal {
StatsCounter Counters::state_counters[] = { StatsCounter Counters::state_counters[] = {
#define COUNTER_NAME(name) \ #define COUNTER_NAME(name) \
{ L"c:V8.State" L###name, NULL, false }, { "c:V8.State" #name, NULL, false },
STATE_TAG_LIST(COUNTER_NAME) STATE_TAG_LIST(COUNTER_NAME)
#undef COUNTER_NAME #undef COUNTER_NAME
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment