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
};
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) {
// 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);
PROTOTYPE_STUB
};
- enum {
- NUMBER_OF_KINDS = LAST_IC_KIND + 1
- };
-
typedef int ExtraICState;
static const ExtraICState kNoExtraICState = 0;
}
-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");
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);
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++) {
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();
}