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
This commit is contained in:
ager@chromium.org 2008-12-01 07:40:43 +00:00
parent f87ad6741f
commit 88d4740d89
6 changed files with 20 additions and 22 deletions

View File

@ -1813,7 +1813,7 @@ class EXPORT Exception {
// --- 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 ---
typedef void (*FailedAccessCheckCallback)(Local<Object> target,

View File

@ -28,8 +28,6 @@
#ifndef V8_COUNTERS_H_
#define V8_COUNTERS_H_
#include <wchar.h>
namespace v8 { namespace internal {
// StatsCounters is an interface for plugging into external
@ -54,7 +52,7 @@ class StatsTable : public AllStatic {
// may receive a different location to store it's counter.
// The return value must not be cached and re-used across
// 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;
return lookup_function_(name);
}
@ -74,9 +72,9 @@ class StatsTable : public AllStatic {
//
// This class is designed to be POD initialized. It will be registered with
// the counter system on first use. For example:
// StatsCounter c = { L"c:myctr", NULL, false };
// StatsCounter c = { "c:myctr", NULL, false };
struct StatsCounter {
const wchar_t* name_;
const char* name_;
int* ptr_;
bool lookup_done_;

View File

@ -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);
if (item != counter_map_.end()) {
Counter* result = (*item).second;

View File

@ -44,13 +44,13 @@ namespace i = v8::internal;
class Counter {
public:
explicit Counter(const wchar_t* name)
explicit Counter(const char* name)
: name_(name), value_(0) { }
int* GetValuePtr() { return &value_; }
const wchar_t* name() { return name_; }
const char* name() { return name_; }
int value() { return value_; }
private:
const wchar_t* name_;
const char* name_;
int value_;
};
@ -64,7 +64,7 @@ class Shell: public i::AllStatic {
static void ReportException(TryCatch* try_catch);
static void Initialize();
static void OnExit();
static int* LookupCounter(const wchar_t* name);
static int* LookupCounter(const char* name);
static Handle<String> ReadFile(const char* name);
static void RunShell();
static int Main(int argc, char* argv[]);
@ -81,7 +81,7 @@ class Shell: public i::AllStatic {
private:
static Persistent<Context> utility_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_;
};

View File

@ -48,10 +48,10 @@ static const unsigned int kMaxCounters = 256;
class Counter {
public:
static const int kMaxNameSize = 64;
int32_t* Bind(const wchar_t* name) {
int32_t* Bind(const char* name) {
int i;
for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) {
name_[i] = static_cast<char>(name[i]);
name_[i] = name[i];
}
name_[i] = '\0';
return &counter_;
@ -92,13 +92,13 @@ static CounterCollection local_counters;
static CounterCollection* counters = &local_counters;
typedef std::map<std::wstring, int*> CounterMap;
typedef std::map<std::wstring, int*>::iterator CounterMapIterator;
typedef std::map<std::string, int*> CounterMap;
typedef std::map<std::string, int*>::iterator CounterMapIterator;
static CounterMap counter_table_;
// Callback receiver when v8 has a counter to track.
static int* counter_callback(const wchar_t* name) {
std::wstring counter = name;
static int* counter_callback(const char* name) {
std::string counter = name;
// See if this counter name is already known.
if (counter_table_.find(counter) != counter_table_.end())
return counter_table_[counter];

View File

@ -33,14 +33,14 @@ namespace v8 { namespace internal {
#define SR(name, caption) \
StatsRate Counters::name = { \
{ { L"t:" L###caption, NULL, false }, 0, 0 }, \
{ L"c:" L###caption, NULL, false } };
{ { "t:" #caption, NULL, false }, 0, 0 }, \
{ "c:" #caption, NULL, false } };
STATS_RATE_LIST(SR)
#undef SR
#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_2(SC)
@ -48,7 +48,7 @@ namespace v8 { namespace internal {
StatsCounter Counters::state_counters[] = {
#define COUNTER_NAME(name) \
{ L"c:V8.State" L###name, NULL, false },
{ "c:V8.State" #name, NULL, false },
STATE_TAG_LIST(COUNTER_NAME)
#undef COUNTER_NAME
};