Commit a4ad7b8b authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Give the binary op stubs better names to make profiles more informative.

Review URL: http://codereview.chromium.org/488017

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3454 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cfb6b2de
...@@ -5680,6 +5680,29 @@ static void MultiplyByKnownInt2( ...@@ -5680,6 +5680,29 @@ static void MultiplyByKnownInt2(
} }
const char* GenericBinaryOpStub::GetName() {
if (name_ != NULL) return name_;
const int len = 100;
name_ = Bootstrapper::AllocateAutoDeletedArray(len);
if (name_ == NULL) return "OOM";
const char* op_name = Token::Name(op_);
const char* overwrite_name;
switch (mode_) {
case NO_OVERWRITE: overwrite_name = "Alloc"; break;
case OVERWRITE_RIGHT: overwrite_name = "OverwriteRight"; break;
case OVERWRITE_LEFT: overwrite_name = "OverwriteLeft"; break;
default: overwrite_name = "UnknownOverwrite"; break;
}
OS::SNPrintF(Vector<char>(name_, len),
"GenericBinaryOpStub_%s_%s%s",
op_name,
overwrite_name,
specialized_on_rhs_ ? "_ConstantRhs" : 0);
return name_;
}
void GenericBinaryOpStub::Generate(MacroAssembler* masm) { void GenericBinaryOpStub::Generate(MacroAssembler* masm) {
// r1 : x // r1 : x
// r0 : y // r0 : y
......
...@@ -455,13 +455,15 @@ class GenericBinaryOpStub : public CodeStub { ...@@ -455,13 +455,15 @@ class GenericBinaryOpStub : public CodeStub {
: op_(op), : op_(op),
mode_(mode), mode_(mode),
constant_rhs_(constant_rhs), constant_rhs_(constant_rhs),
specialized_on_rhs_(RhsIsOneWeWantToOptimizeFor(op, constant_rhs)) { } specialized_on_rhs_(RhsIsOneWeWantToOptimizeFor(op, constant_rhs)),
name_(NULL) { }
private: private:
Token::Value op_; Token::Value op_;
OverwriteMode mode_; OverwriteMode mode_;
int constant_rhs_; int constant_rhs_;
bool specialized_on_rhs_; bool specialized_on_rhs_;
char* name_;
static const int kMaxKnownRhs = 0x40000000; static const int kMaxKnownRhs = 0x40000000;
...@@ -506,22 +508,7 @@ class GenericBinaryOpStub : public CodeStub { ...@@ -506,22 +508,7 @@ class GenericBinaryOpStub : public CodeStub {
return key; return key;
} }
const char* GetName() { const char* GetName();
switch (op_) {
case Token::ADD: return "GenericBinaryOpStub_ADD";
case Token::SUB: return "GenericBinaryOpStub_SUB";
case Token::MUL: return "GenericBinaryOpStub_MUL";
case Token::DIV: return "GenericBinaryOpStub_DIV";
case Token::MOD: return "GenericBinaryOpStub_MOD";
case Token::BIT_OR: return "GenericBinaryOpStub_BIT_OR";
case Token::BIT_AND: return "GenericBinaryOpStub_BIT_AND";
case Token::BIT_XOR: return "GenericBinaryOpStub_BIT_XOR";
case Token::SAR: return "GenericBinaryOpStub_SAR";
case Token::SHL: return "GenericBinaryOpStub_SHL";
case Token::SHR: return "GenericBinaryOpStub_SHR";
default: return "GenericBinaryOpStub";
}
}
#ifdef DEBUG #ifdef DEBUG
void Print() { void Print() {
......
...@@ -95,6 +95,8 @@ static SourceCodeCache natives_cache(Script::TYPE_NATIVE); ...@@ -95,6 +95,8 @@ static SourceCodeCache natives_cache(Script::TYPE_NATIVE);
static SourceCodeCache extensions_cache(Script::TYPE_EXTENSION); static SourceCodeCache extensions_cache(Script::TYPE_EXTENSION);
// This is for delete, not delete[]. // This is for delete, not delete[].
static List<char*>* delete_these_non_arrays_on_tear_down = NULL; static List<char*>* delete_these_non_arrays_on_tear_down = NULL;
// This is for delete[]
static List<char*>* delete_these_arrays_on_tear_down = NULL;
NativesExternalStringResource::NativesExternalStringResource(const char* source) NativesExternalStringResource::NativesExternalStringResource(const char* source)
...@@ -150,17 +152,41 @@ void Bootstrapper::Initialize(bool create_heap_objects) { ...@@ -150,17 +152,41 @@ void Bootstrapper::Initialize(bool create_heap_objects) {
} }
char* Bootstrapper::AllocateAutoDeletedArray(int bytes) {
char* memory = new char[bytes];
if (memory != NULL) {
if (delete_these_arrays_on_tear_down == NULL) {
delete_these_arrays_on_tear_down = new List<char*>(2);
}
delete_these_arrays_on_tear_down->Add(memory);
}
return memory;
}
void Bootstrapper::TearDown() { void Bootstrapper::TearDown() {
if (delete_these_non_arrays_on_tear_down != NULL) { if (delete_these_non_arrays_on_tear_down != NULL) {
int len = delete_these_non_arrays_on_tear_down->length(); int len = delete_these_non_arrays_on_tear_down->length();
ASSERT(len < 20); // Don't use this mechanism for unbounded allocations. ASSERT(len < 20); // Don't use this mechanism for unbounded allocations.
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
delete delete_these_non_arrays_on_tear_down->at(i); delete delete_these_non_arrays_on_tear_down->at(i);
delete_these_non_arrays_on_tear_down->at(i) = NULL;
} }
delete delete_these_non_arrays_on_tear_down; delete delete_these_non_arrays_on_tear_down;
delete_these_non_arrays_on_tear_down = NULL; delete_these_non_arrays_on_tear_down = NULL;
} }
if (delete_these_arrays_on_tear_down != NULL) {
int len = delete_these_arrays_on_tear_down->length();
ASSERT(len < 1000); // Don't use this mechanism for unbounded allocations.
for (int i = 0; i < len; i++) {
delete[] delete_these_arrays_on_tear_down->at(i);
delete_these_arrays_on_tear_down->at(i) = NULL;
}
delete delete_these_arrays_on_tear_down;
delete_these_arrays_on_tear_down = NULL;
}
natives_cache.Initialize(false); // Yes, symmetrical natives_cache.Initialize(false); // Yes, symmetrical
extensions_cache.Initialize(false); extensions_cache.Initialize(false);
} }
......
...@@ -74,6 +74,10 @@ class Bootstrapper : public AllStatic { ...@@ -74,6 +74,10 @@ class Bootstrapper : public AllStatic {
static char* ArchiveState(char* to); static char* ArchiveState(char* to);
static char* RestoreState(char* from); static char* RestoreState(char* from);
static void FreeThreadResources(); static void FreeThreadResources();
// This will allocate a char array that is deleted when V8 is shut down.
// It should only be used for strictly finite allocations.
static char* AllocateAutoDeletedArray(int bytes);
}; };
......
...@@ -763,19 +763,27 @@ class FloatingPointHelper : public AllStatic { ...@@ -763,19 +763,27 @@ class FloatingPointHelper : public AllStatic {
const char* GenericBinaryOpStub::GetName() { const char* GenericBinaryOpStub::GetName() {
switch (op_) { if (name_ != NULL) return name_;
case Token::ADD: return "GenericBinaryOpStub_ADD"; const int len = 100;
case Token::SUB: return "GenericBinaryOpStub_SUB"; name_ = Bootstrapper::AllocateAutoDeletedArray(len);
case Token::MUL: return "GenericBinaryOpStub_MUL"; if (name_ == NULL) return "OOM";
case Token::DIV: return "GenericBinaryOpStub_DIV"; const char* op_name = Token::Name(op_);
case Token::BIT_OR: return "GenericBinaryOpStub_BIT_OR"; const char* overwrite_name;
case Token::BIT_AND: return "GenericBinaryOpStub_BIT_AND"; switch (mode_) {
case Token::BIT_XOR: return "GenericBinaryOpStub_BIT_XOR"; case NO_OVERWRITE: overwrite_name = "Alloc"; break;
case Token::SAR: return "GenericBinaryOpStub_SAR"; case OVERWRITE_RIGHT: overwrite_name = "OverwriteRight"; break;
case Token::SHL: return "GenericBinaryOpStub_SHL"; case OVERWRITE_LEFT: overwrite_name = "OverwriteLeft"; break;
case Token::SHR: return "GenericBinaryOpStub_SHR"; default: overwrite_name = "UnknownOverwrite"; break;
default: return "GenericBinaryOpStub"; }
}
OS::SNPrintF(Vector<char>(name_, len),
"GenericBinaryOpStub_%s_%s%s_%s%s",
op_name,
overwrite_name,
(flags_ & NO_SMI_CODE_IN_STUB) ? "_NoSmiInStub" : "",
args_in_registers_ ? "RegArgs" : "StackArgs",
args_reversed_ ? "_R" : "");
return name_;
} }
......
...@@ -665,7 +665,8 @@ class GenericBinaryOpStub: public CodeStub { ...@@ -665,7 +665,8 @@ class GenericBinaryOpStub: public CodeStub {
mode_(mode), mode_(mode),
flags_(flags), flags_(flags),
args_in_registers_(false), args_in_registers_(false),
args_reversed_(false) { args_reversed_(false),
name_(NULL) {
use_sse3_ = CpuFeatures::IsSupported(SSE3); use_sse3_ = CpuFeatures::IsSupported(SSE3);
ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); ASSERT(OpBits::is_valid(Token::NUM_TOKENS));
} }
...@@ -684,6 +685,7 @@ class GenericBinaryOpStub: public CodeStub { ...@@ -684,6 +685,7 @@ class GenericBinaryOpStub: public CodeStub {
bool args_in_registers_; // Arguments passed in registers not on the stack. bool args_in_registers_; // Arguments passed in registers not on the stack.
bool args_reversed_; // Left and right argument are swapped. bool args_reversed_; // Left and right argument are swapped.
bool use_sse3_; bool use_sse3_;
char* name_;
const char* GetName(); const char* GetName();
......
...@@ -32,13 +32,11 @@ ...@@ -32,13 +32,11 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
#ifdef DEBUG
#define T(name, string, precedence) #name, #define T(name, string, precedence) #name,
const char* Token::name_[NUM_TOKENS] = { const char* Token::name_[NUM_TOKENS] = {
TOKEN_LIST(T, T, IGNORE_TOKEN) TOKEN_LIST(T, T, IGNORE_TOKEN)
}; };
#undef T #undef T
#endif
#define T(name, string, precedence) string, #define T(name, string, precedence) string,
......
...@@ -211,14 +211,12 @@ class Token { ...@@ -211,14 +211,12 @@ class Token {
}; };
#undef T #undef T
#ifdef DEBUG
// Returns a string corresponding to the C++ token name // Returns a string corresponding to the C++ token name
// (e.g. "LT" for the token LT). // (e.g. "LT" for the token LT).
static const char* Name(Value tok) { static const char* Name(Value tok) {
ASSERT(0 <= tok && tok < NUM_TOKENS); ASSERT(0 <= tok && tok < NUM_TOKENS);
return name_[tok]; return name_[tok];
} }
#endif
// Predicates // Predicates
static bool IsAssignmentOp(Value tok) { static bool IsAssignmentOp(Value tok) {
...@@ -261,9 +259,7 @@ class Token { ...@@ -261,9 +259,7 @@ class Token {
} }
private: private:
#ifdef DEBUG
static const char* name_[NUM_TOKENS]; static const char* name_[NUM_TOKENS];
#endif
static const char* string_[NUM_TOKENS]; static const char* string_[NUM_TOKENS];
static int8_t precedence_[NUM_TOKENS]; static int8_t precedence_[NUM_TOKENS];
}; };
......
...@@ -7372,19 +7372,28 @@ void FloatingPointHelper::CheckNumberOperands(MacroAssembler* masm, ...@@ -7372,19 +7372,28 @@ void FloatingPointHelper::CheckNumberOperands(MacroAssembler* masm,
const char* GenericBinaryOpStub::GetName() { const char* GenericBinaryOpStub::GetName() {
switch (op_) { if (name_ != NULL) return name_;
case Token::ADD: return "GenericBinaryOpStub_ADD"; const int len = 100;
case Token::SUB: return "GenericBinaryOpStub_SUB"; name_ = Bootstrapper::AllocateAutoDeletedArray(len);
case Token::MUL: return "GenericBinaryOpStub_MUL"; if (name_ == NULL) return "OOM";
case Token::DIV: return "GenericBinaryOpStub_DIV"; const char* op_name = Token::Name(op_);
case Token::BIT_OR: return "GenericBinaryOpStub_BIT_OR"; const char* overwrite_name;
case Token::BIT_AND: return "GenericBinaryOpStub_BIT_AND"; switch (mode_) {
case Token::BIT_XOR: return "GenericBinaryOpStub_BIT_XOR"; case NO_OVERWRITE: overwrite_name = "Alloc"; break;
case Token::SAR: return "GenericBinaryOpStub_SAR"; case OVERWRITE_RIGHT: overwrite_name = "OverwriteRight"; break;
case Token::SHL: return "GenericBinaryOpStub_SHL"; case OVERWRITE_LEFT: overwrite_name = "OverwriteLeft"; break;
case Token::SHR: return "GenericBinaryOpStub_SHR"; default: overwrite_name = "UnknownOverwrite"; break;
default: return "GenericBinaryOpStub"; }
}
OS::SNPrintF(Vector<char>(name_, len),
"GenericBinaryOpStub_%s_%s%s_%s%s_%s",
op_name,
overwrite_name,
(flags_ & NO_SMI_CODE_IN_STUB) ? "_NoSmiInStub" : "",
args_in_registers_ ? "RegArgs" : "StackArgs",
args_reversed_ ? "_R" : "",
use_sse3_ ? "SSE3" : "SSE2");
return name_;
} }
......
...@@ -670,7 +670,8 @@ class GenericBinaryOpStub: public CodeStub { ...@@ -670,7 +670,8 @@ class GenericBinaryOpStub: public CodeStub {
mode_(mode), mode_(mode),
flags_(flags), flags_(flags),
args_in_registers_(false), args_in_registers_(false),
args_reversed_(false) { args_reversed_(false),
name_(NULL) {
use_sse3_ = CpuFeatures::IsSupported(SSE3); use_sse3_ = CpuFeatures::IsSupported(SSE3);
ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); ASSERT(OpBits::is_valid(Token::NUM_TOKENS));
} }
...@@ -689,6 +690,7 @@ class GenericBinaryOpStub: public CodeStub { ...@@ -689,6 +690,7 @@ class GenericBinaryOpStub: public CodeStub {
bool args_in_registers_; // Arguments passed in registers not on the stack. bool args_in_registers_; // Arguments passed in registers not on the stack.
bool args_reversed_; // Left and right argument are swapped. bool args_reversed_; // Left and right argument are swapped.
bool use_sse3_; bool use_sse3_;
char* name_;
const char* GetName(); const char* GetName();
......
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