Commit 66efb966 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Fix compilation error introduced with r15287.

REGEXP was added to Code::Kind after TO_BOOLEAN_IC, but NUMBER_OF_KINDS,
which is used as array size for table[] in ReportCodeKindStatistics, was
still TO_BOOLEAN_IC + 1 (indirectly via LAST_IC_KIND).

BUG=
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/17636003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15315 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e7adf305
......@@ -1873,7 +1873,7 @@ class Heap {
enum {
FIRST_CODE_KIND_SUB_TYPE = LAST_TYPE + 1,
FIRST_FIXED_ARRAY_SUB_TYPE =
FIRST_CODE_KIND_SUB_TYPE + Code::LAST_CODE_KIND + 1,
FIRST_CODE_KIND_SUB_TYPE + Code::NUMBER_OF_KINDS,
OBJECT_STATS_COUNT =
FIRST_FIXED_ARRAY_SUB_TYPE + LAST_FIXED_ARRAY_SUB_TYPE + 1
};
......@@ -1885,7 +1885,7 @@ class Heap {
object_sizes_[type] += size;
} else {
if (type == CODE_TYPE) {
ASSERT(sub_type <= Code::LAST_CODE_KIND);
ASSERT(sub_type < Code::NUMBER_OF_KINDS);
object_counts_[FIRST_CODE_KIND_SUB_TYPE + sub_type]++;
object_sizes_[FIRST_CODE_KIND_SUB_TYPE + sub_type] += size;
} else if (type == FIXED_ARRAY_TYPE) {
......
......@@ -4041,7 +4041,12 @@ void Code::set_marked_for_deoptimization(bool flag) {
bool Code::is_inline_cache_stub() {
Kind kind = this->kind();
return kind >= FIRST_IC_KIND && kind <= LAST_IC_KIND;
switch (kind) {
#define CASE(name) case name: return true;
IC_KIND_LIST(CASE)
#undef CASE
default: return false;
}
}
......
......@@ -4439,39 +4439,45 @@ class Code: public HeapObject {
// cache state, and arguments count.
typedef uint32_t Flags;
#define CODE_KIND_LIST(V) \
V(FUNCTION) \
V(OPTIMIZED_FUNCTION) \
V(STUB) \
V(BUILTIN) \
V(LOAD_IC) \
V(KEYED_LOAD_IC) \
V(CALL_IC) \
V(KEYED_CALL_IC) \
V(STORE_IC) \
V(KEYED_STORE_IC) \
V(UNARY_OP_IC) \
V(BINARY_OP_IC) \
V(COMPARE_IC) \
V(COMPARE_NIL_IC) \
V(TO_BOOLEAN_IC) \
#define NON_IC_KIND_LIST(V) \
V(FUNCTION) \
V(OPTIMIZED_FUNCTION) \
V(STUB) \
V(BUILTIN) \
V(REGEXP)
#define IC_KIND_LIST(V) \
V(LOAD_IC) \
V(KEYED_LOAD_IC) \
V(CALL_IC) \
V(KEYED_CALL_IC) \
V(STORE_IC) \
V(KEYED_STORE_IC) \
V(UNARY_OP_IC) \
V(BINARY_OP_IC) \
V(COMPARE_IC) \
V(COMPARE_NIL_IC) \
V(TO_BOOLEAN_IC)
#define CODE_KIND_LIST(V) \
NON_IC_KIND_LIST(V) \
IC_KIND_LIST(V)
enum Kind {
#define DEFINE_CODE_KIND_ENUM(name) name,
CODE_KIND_LIST(DEFINE_CODE_KIND_ENUM)
#undef DEFINE_CODE_KIND_ENUM
};
// Pseudo-kinds.
LAST_CODE_KIND = TO_BOOLEAN_IC,
FIRST_IC_KIND = LOAD_IC,
LAST_IC_KIND = TO_BOOLEAN_IC
enum {
#define COUNT_FLAG(name) + 1
NUMBER_OF_KINDS = 0 CODE_KIND_LIST(COUNT_FLAG)
#undef COUNT_FLAG
};
// No more than 16 kinds. The value is currently encoded in four bits in
// Flags.
STATIC_ASSERT(LAST_CODE_KIND < 16);
STATIC_ASSERT(NUMBER_OF_KINDS <= 16);
static const char* Kind2String(Kind kind);
......@@ -4491,10 +4497,6 @@ class Code: public HeapObject {
PROTOTYPE_STUB
};
enum {
NUMBER_OF_KINDS = LAST_IC_KIND + 1
};
typedef int ExtraICState;
static const ExtraICState kNoExtraICState = 0;
......
......@@ -1790,50 +1790,20 @@ static void ClearHistograms() {
}
static void ClearCodeKindStatistics() {
Isolate* isolate = Isolate::Current();
static void ClearCodeKindStatistics(int* code_kind_statistics) {
for (int i = 0; i < Code::NUMBER_OF_KINDS; i++) {
isolate->code_kind_statistics()[i] = 0;
code_kind_statistics[i] = 0;
}
}
static void ReportCodeKindStatistics() {
Isolate* isolate = Isolate::Current();
const char* table[Code::NUMBER_OF_KINDS] = { NULL };
#define CASE(name) \
case Code::name: table[Code::name] = #name; \
break
for (int i = 0; i < Code::NUMBER_OF_KINDS; i++) {
switch (static_cast<Code::Kind>(i)) {
CASE(FUNCTION);
CASE(OPTIMIZED_FUNCTION);
CASE(STUB);
CASE(BUILTIN);
CASE(LOAD_IC);
CASE(KEYED_LOAD_IC);
CASE(STORE_IC);
CASE(KEYED_STORE_IC);
CASE(CALL_IC);
CASE(KEYED_CALL_IC);
CASE(UNARY_OP_IC);
CASE(BINARY_OP_IC);
CASE(COMPARE_IC);
CASE(COMPARE_NIL_IC);
CASE(TO_BOOLEAN_IC);
CASE(REGEXP);
}
}
#undef CASE
static void ReportCodeKindStatistics(int* code_kind_statistics) {
PrintF("\n Code kind histograms: \n");
for (int i = 0; i < Code::NUMBER_OF_KINDS; i++) {
if (isolate->code_kind_statistics()[i] > 0) {
PrintF(" %-20s: %10d bytes\n", table[i],
isolate->code_kind_statistics()[i]);
if (code_kind_statistics[i] > 0) {
PrintF(" %-20s: %10d bytes\n",
Code::Kind2String(static_cast<Code::Kind>(i)),
code_kind_statistics[i]);
}
}
PrintF("\n");
......@@ -1841,7 +1811,7 @@ static void ReportCodeKindStatistics() {
static int CollectHistogramInfo(HeapObject* obj) {
Isolate* isolate = Isolate::Current();
Isolate* isolate = obj->GetIsolate();
InstanceType type = obj->map()->instance_type();
ASSERT(0 <= type && type <= LAST_TYPE);
ASSERT(isolate->heap_histograms()[type].name() != NULL);
......@@ -2715,7 +2685,7 @@ void PagedSpace::ReportCodeStatistics() {
Isolate* isolate = Isolate::Current();
CommentStatistic* comments_statistics =
isolate->paged_space_comments_statistics();
ReportCodeKindStatistics();
ReportCodeKindStatistics(isolate->code_kind_statistics());
PrintF("Code comment statistics (\" [ comment-txt : size/ "
"count (average)\"):\n");
for (int i = 0; i <= CommentStatistic::kMaxComments; i++) {
......@@ -2733,7 +2703,7 @@ void PagedSpace::ResetCodeStatistics() {
Isolate* isolate = Isolate::Current();
CommentStatistic* comments_statistics =
isolate->paged_space_comments_statistics();
ClearCodeKindStatistics();
ClearCodeKindStatistics(isolate->code_kind_statistics());
for (int i = 0; i < CommentStatistic::kMaxComments; i++) {
comments_statistics[i].Clear();
}
......
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