Instance-type-related fixes and cleanup.

Things got quite a bit out of sync (don't we all love copy-n-paste?):

   * TypeToString didn't handle SLICED_STRING_TYPE,
     SLICED_ASCII_STRING_TYPE, FIXED_DOUBLE_ARRAY_TYPE,
     JS_FUNCTION_PROXY_TYPE and JS_DATE_TYPE.

   * INSTANCE_TYPE_LIST was missing entries for
     SLICED_ASCII_STRING_TYPE, JS_SET_TYPE, and JS_MAP_TYPE.

To improve this maintenance nightmare a little bit, the missing
instance types were added to the INSTANCE_TYPE_LIST macro and this
list is now used via our beloved 2nd order macro technique in
TypeToString. As a side-effect, the strings returned by TypeToString
have a "_TYPE" suffix now, but this doesn't really matter and is a
small price to pay for consistency.

Removed INVALID_TYPE on the way, it had no real use.

R=mstarzinger@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16120 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 85d8178d
......@@ -1393,8 +1393,10 @@ Handle<JSFunction> Factory::CreateApiFunction(
Smi::cast(instance_template->internal_field_count())->value();
}
// TODO(svenpanne) Kill ApiInstanceType and refactor things by generalizing
// JSObject::GetHeaderSize.
int instance_size = kPointerSize * internal_field_count;
InstanceType type = INVALID_TYPE;
InstanceType type;
switch (instance_type) {
case JavaScriptObject:
type = JS_OBJECT_TYPE;
......@@ -1409,9 +1411,10 @@ Handle<JSFunction> Factory::CreateApiFunction(
instance_size += JSGlobalProxy::kSize;
break;
default:
UNREACHABLE();
type = JS_OBJECT_TYPE; // Keep the compiler happy.
break;
}
ASSERT(type != INVALID_TYPE);
Handle<JSFunction> result =
NewFunction(Factory::empty_string(),
......
......@@ -37,9 +37,6 @@ namespace internal {
#ifdef OBJECT_PRINT
static const char* TypeToString(InstanceType type);
void MaybeObject::Print() {
Print(stdout);
}
......@@ -509,83 +506,12 @@ void JSModule::JSModulePrint(FILE* out) {
static const char* TypeToString(InstanceType type) {
switch (type) {
case INVALID_TYPE: return "INVALID";
case MAP_TYPE: return "MAP";
case HEAP_NUMBER_TYPE: return "HEAP_NUMBER";
case SYMBOL_TYPE: return "SYMBOL";
case STRING_TYPE: return "TWO_BYTE_STRING";
case ASCII_STRING_TYPE: return "ASCII_STRING";
case CONS_STRING_TYPE:
case CONS_ASCII_STRING_TYPE:
return "CONS_STRING";
case EXTERNAL_STRING_TYPE:
case EXTERNAL_ASCII_STRING_TYPE:
case EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE:
return "EXTERNAL_STRING";
case SHORT_EXTERNAL_STRING_TYPE:
case SHORT_EXTERNAL_ASCII_STRING_TYPE:
case SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE:
return "SHORT_EXTERNAL_STRING";
case INTERNALIZED_STRING_TYPE: return "INTERNALIZED_STRING";
case ASCII_INTERNALIZED_STRING_TYPE: return "ASCII_INTERNALIZED_STRING";
case CONS_INTERNALIZED_STRING_TYPE: return "CONS_INTERNALIZED_STRING";
case CONS_ASCII_INTERNALIZED_STRING_TYPE:
return "CONS_ASCII_INTERNALIZED_STRING";
case EXTERNAL_INTERNALIZED_STRING_TYPE:
case EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE:
case EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE:
return "EXTERNAL_INTERNALIZED_STRING";
case SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE:
case SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE:
case SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE:
return "SHORT_EXTERNAL_INTERNALIZED_STRING";
case FIXED_ARRAY_TYPE: return "FIXED_ARRAY";
case BYTE_ARRAY_TYPE: return "BYTE_ARRAY";
case FREE_SPACE_TYPE: return "FREE_SPACE";
case EXTERNAL_PIXEL_ARRAY_TYPE: return "EXTERNAL_PIXEL_ARRAY";
case EXTERNAL_BYTE_ARRAY_TYPE: return "EXTERNAL_BYTE_ARRAY";
case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
return "EXTERNAL_UNSIGNED_BYTE_ARRAY";
case EXTERNAL_SHORT_ARRAY_TYPE: return "EXTERNAL_SHORT_ARRAY";
case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE:
return "EXTERNAL_UNSIGNED_SHORT_ARRAY";
case EXTERNAL_INT_ARRAY_TYPE: return "EXTERNAL_INT_ARRAY";
case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
return "EXTERNAL_UNSIGNED_INT_ARRAY";
case EXTERNAL_FLOAT_ARRAY_TYPE: return "EXTERNAL_FLOAT_ARRAY";
case EXTERNAL_DOUBLE_ARRAY_TYPE: return "EXTERNAL_DOUBLE_ARRAY";
case FILLER_TYPE: return "FILLER";
case JS_OBJECT_TYPE: return "JS_OBJECT";
case JS_CONTEXT_EXTENSION_OBJECT_TYPE: return "JS_CONTEXT_EXTENSION_OBJECT";
case ODDBALL_TYPE: return "ODDBALL";
case CELL_TYPE: return "CELL";
case PROPERTY_CELL_TYPE: return "PROPERTY_CELL";
case SHARED_FUNCTION_INFO_TYPE: return "SHARED_FUNCTION_INFO";
case JS_GENERATOR_OBJECT_TYPE: return "JS_GENERATOR_OBJECT";
case JS_MODULE_TYPE: return "JS_MODULE";
case JS_FUNCTION_TYPE: return "JS_FUNCTION";
case CODE_TYPE: return "CODE";
case JS_ARRAY_TYPE: return "JS_ARRAY";
case JS_PROXY_TYPE: return "JS_PROXY";
case JS_SET_TYPE: return "JS_SET";
case JS_MAP_TYPE: return "JS_MAP";
case JS_WEAK_MAP_TYPE: return "JS_WEAK_MAP";
case JS_WEAK_SET_TYPE: return "JS_WEAK_SET";
case JS_REGEXP_TYPE: return "JS_REGEXP";
case JS_VALUE_TYPE: return "JS_VALUE";
case JS_GLOBAL_OBJECT_TYPE: return "JS_GLOBAL_OBJECT";
case JS_BUILTINS_OBJECT_TYPE: return "JS_BUILTINS_OBJECT";
case JS_GLOBAL_PROXY_TYPE: return "JS_GLOBAL_PROXY";
case JS_ARRAY_BUFFER_TYPE: return "JS_ARRAY_BUFFER";
case JS_TYPED_ARRAY_TYPE: return "JS_TYPED_ARRAY";
case JS_DATA_VIEW_TYPE: return "JS_DATA_VIEW";
case FOREIGN_TYPE: return "FOREIGN";
case JS_MESSAGE_OBJECT_TYPE: return "JS_MESSAGE_OBJECT_TYPE";
#define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: return #NAME;
STRUCT_LIST(MAKE_STRUCT_CASE)
#undef MAKE_STRUCT_CASE
default: return "UNKNOWN";
#define TYPE_TO_STRING(TYPE) case TYPE: return #TYPE;
INSTANCE_TYPE_LIST(TYPE_TO_STRING)
#undef TYPE_TO_STRING
}
UNREACHABLE();
return "UNKNOWN"; // Keep the compiler happy.
}
......
......@@ -333,6 +333,7 @@ const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize - kStubMajorKeyBits;
V(CONS_STRING_TYPE) \
V(CONS_ASCII_STRING_TYPE) \
V(SLICED_STRING_TYPE) \
V(SLICED_ASCII_STRING_TYPE) \
V(EXTERNAL_STRING_TYPE) \
V(EXTERNAL_ASCII_STRING_TYPE) \
V(EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE) \
......@@ -416,6 +417,8 @@ const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize - kStubMajorKeyBits;
V(JS_TYPED_ARRAY_TYPE) \
V(JS_DATA_VIEW_TYPE) \
V(JS_PROXY_TYPE) \
V(JS_SET_TYPE) \
V(JS_MAP_TYPE) \
V(JS_WEAK_MAP_TYPE) \
V(JS_WEAK_SET_TYPE) \
V(JS_REGEXP_TYPE) \
......@@ -783,7 +786,6 @@ enum InstanceType {
// Pseudo-types
FIRST_TYPE = 0x0,
LAST_TYPE = JS_FUNCTION_TYPE,
INVALID_TYPE = FIRST_TYPE - 1,
FIRST_NAME_TYPE = FIRST_TYPE,
LAST_NAME_TYPE = SYMBOL_TYPE,
FIRST_UNIQUE_NAME_TYPE = INTERNALIZED_STRING_TYPE,
......
......@@ -35,6 +35,7 @@ INSTANCE_TYPES = {
65: "CONS_STRING_TYPE",
69: "CONS_ASCII_STRING_TYPE",
67: "SLICED_STRING_TYPE",
71: "SLICED_ASCII_STRING_TYPE",
66: "EXTERNAL_STRING_TYPE",
70: "EXTERNAL_ASCII_STRING_TYPE",
74: "EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE",
......@@ -108,6 +109,8 @@ INSTANCE_TYPES = {
186: "JS_TYPED_ARRAY_TYPE",
187: "JS_DATA_VIEW_TYPE",
174: "JS_PROXY_TYPE",
188: "JS_SET_TYPE",
189: "JS_MAP_TYPE",
190: "JS_WEAK_MAP_TYPE",
191: "JS_WEAK_SET_TYPE",
192: "JS_REGEXP_TYPE",
......@@ -231,7 +234,7 @@ KNOWN_OBJECTS = {
("OLD_POINTER_SPACE", 0x0e0a1): "ElementsTransitionSymbol",
("OLD_POINTER_SPACE", 0x0e0ad): "EmptySlowElementDictionary",
("OLD_POINTER_SPACE", 0x0e249): "ObservedSymbol",
("OLD_POINTER_SPACE", 0x27585): "StringTable",
("OLD_POINTER_SPACE", 0x274e9): "StringTable",
("OLD_DATA_SPACE", 0x08099): "EmptyDescriptorArray",
("OLD_DATA_SPACE", 0x080a1): "EmptyFixedArray",
("OLD_DATA_SPACE", 0x080a9): "NanValue",
......@@ -247,6 +250,6 @@ KNOWN_OBJECTS = {
("OLD_DATA_SPACE", 0x082c9): "EmptyExternalPixelArray",
("OLD_DATA_SPACE", 0x082d5): "InfinityValue",
("OLD_DATA_SPACE", 0x082e1): "MinusZeroValue",
("CODE_SPACE", 0x0eb41): "JsConstructEntryCode",
("CODE_SPACE", 0x177a1): "JsEntryCode",
("CODE_SPACE", 0x10d01): "JsConstructEntryCode",
("CODE_SPACE", 0x183c1): "JsEntryCode",
}
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