Commit e21d76a0 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

1. Added support for object printing for release mode using the

   objectprint=on (defaults to off) option (which defines OBJECT_PRINT).
2. Added the ability to print objects to a specified file instead of
   just stdout.
3. Added a use_verbose_printer flag (true by default) to allow some
   object printouts to be less verbose when the flag is false.
4. Fixed a bug in VSNPrintF() where it can potentially write into an
   empty char vector.

Patch by Mark Lam from Hewlett-Packard Development Company, LP

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


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6080 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c91f5606
......@@ -108,11 +108,14 @@ LIBRARY_FLAGS = {
'CPPDEFINES': ['V8_INTERPRETED_REGEXP']
},
'mode:debug': {
'CPPDEFINES': ['V8_ENABLE_CHECKS']
'CPPDEFINES': ['V8_ENABLE_CHECKS', 'OBJECT_PRINT']
},
'vmstate:on': {
'CPPDEFINES': ['ENABLE_VMSTATE_TRACKING'],
},
'objectprint:on': {
'CPPDEFINES': ['OBJECT_PRINT'],
},
'protectheap:on': {
'CPPDEFINES': ['ENABLE_VMSTATE_TRACKING', 'ENABLE_HEAP_PROTECTION'],
},
......@@ -711,6 +714,11 @@ SIMPLE_OPTIONS = {
'default': 'off',
'help': 'enable VM state tracking'
},
'objectprint': {
'values': ['on', 'off'],
'default': 'off',
'help': 'enable object printing'
},
'protectheap': {
'values': ['on', 'off'],
'default': 'off',
......
......@@ -230,7 +230,8 @@ SOURCES = {
'mode:release': [],
'mode:debug': [
'objects-debug.cc', 'prettyprinter.cc', 'regexp-macro-assembler-tracer.cc'
]
],
'objectprint:on': ['objects-debug.cc']
}
......
......@@ -467,34 +467,35 @@ const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) {
}
void RelocInfo::Print() {
PrintF("%p %s", pc_, RelocModeName(rmode_));
void RelocInfo::Print(FILE* out) {
PrintF(out, "%p %s", pc_, RelocModeName(rmode_));
if (IsComment(rmode_)) {
PrintF(" (%s)", reinterpret_cast<char*>(data_));
PrintF(out, " (%s)", reinterpret_cast<char*>(data_));
} else if (rmode_ == EMBEDDED_OBJECT) {
PrintF(" (");
target_object()->ShortPrint();
PrintF(")");
PrintF(out, " (");
target_object()->ShortPrint(out);
PrintF(out, ")");
} else if (rmode_ == EXTERNAL_REFERENCE) {
ExternalReferenceEncoder ref_encoder;
PrintF(" (%s) (%p)",
PrintF(out, " (%s) (%p)",
ref_encoder.NameOfAddress(*target_reference_address()),
*target_reference_address());
} else if (IsCodeTarget(rmode_)) {
Code* code = Code::GetCodeFromTargetAddress(target_address());
PrintF(" (%s) (%p)", Code::Kind2String(code->kind()), target_address());
PrintF(out, " (%s) (%p)", Code::Kind2String(code->kind()),
target_address());
} else if (IsPosition(rmode_)) {
PrintF(" (%" V8_PTR_PREFIX "d)", data());
PrintF(out, " (%" V8_PTR_PREFIX "d)", data());
} else if (rmode_ == RelocInfo::RUNTIME_ENTRY) {
// Depotimization bailouts are stored as runtime entries.
int id = Deoptimizer::GetDeoptimizationId(
target_address(), Deoptimizer::EAGER);
if (id != Deoptimizer::kNotDeoptimizationEntry) {
PrintF(" (deoptimization bailout %d)", id);
PrintF(out, " (deoptimization bailout %d)", id);
}
}
PrintF("\n");
PrintF(out, "\n");
}
#endif // ENABLE_DISASSEMBLER
......
......@@ -322,7 +322,7 @@ class RelocInfo BASE_EMBEDDED {
#ifdef ENABLE_DISASSEMBLER
// Printing
static const char* RelocModeName(Mode rmode);
void Print();
void Print(FILE* out);
#endif // ENABLE_DISASSEMBLER
#ifdef DEBUG
// Debugging
......
......@@ -1096,7 +1096,7 @@ int Translation::NumberOfOperandsFor(Opcode opcode) {
}
#ifdef DEBUG
#ifdef OBJECT_PRINT
const char* Translation::StringFor(Opcode opcode) {
switch (opcode) {
......
......@@ -476,7 +476,7 @@ class Translation BASE_EMBEDDED {
static int NumberOfOperandsFor(Opcode opcode);
#ifdef DEBUG
#ifdef OBJECT_PRINT
static const char* StringFor(Opcode opcode);
#endif
......
......@@ -296,6 +296,9 @@ DEFINE_int(max_map_space_pages, MapSpace::kMaxMapPageIndex - 1,
DEFINE_bool(h, false, "print this message")
DEFINE_bool(new_snapshot, true, "use new snapshot implementation")
// objects.cc
DEFINE_bool(use_verbose_printer, true, "allows verbose printing")
// parser.cc
DEFINE_bool(allow_natives_syntax, false, "allow natives syntax")
......
......@@ -35,32 +35,34 @@
namespace v8 {
namespace internal {
#ifdef DEBUG
#ifdef OBJECT_PRINT
static const char* TypeToString(InstanceType type);
void MaybeObject::Print() {
void MaybeObject::Print(FILE* out) {
Object* this_as_object;
if (ToObject(&this_as_object)) {
if (this_as_object->IsSmi()) {
Smi::cast(this_as_object)->SmiPrint();
Smi::cast(this_as_object)->SmiPrint(out);
} else {
HeapObject::cast(this_as_object)->HeapObjectPrint();
HeapObject::cast(this_as_object)->HeapObjectPrint(out);
}
} else {
Failure::cast(this)->FailurePrint();
Failure::cast(this)->FailurePrint(out);
}
Flush();
Flush(out);
}
void MaybeObject::PrintLn() {
Print();
PrintF("\n");
void MaybeObject::PrintLn(FILE* out) {
Print(out);
PrintF(out, "\n");
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void MaybeObject::Verify() {
Object* this_as_object;
if (ToObject(&this_as_object)) {
......@@ -92,114 +94,120 @@ void Smi::SmiVerify() {
void Failure::FailureVerify() {
ASSERT(IsFailure());
}
#endif // DEBUG
void HeapObject::PrintHeader(const char* id) {
PrintF("%p: [%s]\n", reinterpret_cast<void*>(this), id);
#ifdef OBJECT_PRINT
void HeapObject::PrintHeader(FILE* out, const char* id) {
PrintF(out, "%p: [%s]\n", reinterpret_cast<void*>(this), id);
}
void HeapObject::HeapObjectPrint() {
void HeapObject::HeapObjectPrint(FILE* out) {
InstanceType instance_type = map()->instance_type();
HandleScope scope;
if (instance_type < FIRST_NONSTRING_TYPE) {
String::cast(this)->StringPrint();
String::cast(this)->StringPrint(out);
return;
}
switch (instance_type) {
case MAP_TYPE:
Map::cast(this)->MapPrint();
Map::cast(this)->MapPrint(out);
break;
case HEAP_NUMBER_TYPE:
HeapNumber::cast(this)->HeapNumberPrint();
HeapNumber::cast(this)->HeapNumberPrint(out);
break;
case FIXED_ARRAY_TYPE:
FixedArray::cast(this)->FixedArrayPrint();
FixedArray::cast(this)->FixedArrayPrint(out);
break;
case BYTE_ARRAY_TYPE:
ByteArray::cast(this)->ByteArrayPrint();
ByteArray::cast(this)->ByteArrayPrint(out);
break;
case PIXEL_ARRAY_TYPE:
PixelArray::cast(this)->PixelArrayPrint();
PixelArray::cast(this)->PixelArrayPrint(out);
break;
case EXTERNAL_BYTE_ARRAY_TYPE:
ExternalByteArray::cast(this)->ExternalByteArrayPrint();
ExternalByteArray::cast(this)->ExternalByteArrayPrint(out);
break;
case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
ExternalUnsignedByteArray::cast(this)->ExternalUnsignedByteArrayPrint();
ExternalUnsignedByteArray::cast(this)
->ExternalUnsignedByteArrayPrint(out);
break;
case EXTERNAL_SHORT_ARRAY_TYPE:
ExternalShortArray::cast(this)->ExternalShortArrayPrint();
ExternalShortArray::cast(this)->ExternalShortArrayPrint(out);
break;
case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE:
ExternalUnsignedShortArray::cast(this)->ExternalUnsignedShortArrayPrint();
ExternalUnsignedShortArray::cast(this)
->ExternalUnsignedShortArrayPrint(out);
break;
case EXTERNAL_INT_ARRAY_TYPE:
ExternalIntArray::cast(this)->ExternalIntArrayPrint();
ExternalIntArray::cast(this)->ExternalIntArrayPrint(out);
break;
case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayPrint();
ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayPrint(out);
break;
case EXTERNAL_FLOAT_ARRAY_TYPE:
ExternalFloatArray::cast(this)->ExternalFloatArrayPrint();
ExternalFloatArray::cast(this)->ExternalFloatArrayPrint(out);
break;
case FILLER_TYPE:
PrintF("filler");
PrintF(out, "filler");
break;
case JS_OBJECT_TYPE: // fall through
case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
case JS_ARRAY_TYPE:
case JS_REGEXP_TYPE:
JSObject::cast(this)->JSObjectPrint();
JSObject::cast(this)->JSObjectPrint(out);
break;
case ODDBALL_TYPE:
Oddball::cast(this)->to_string()->Print();
Oddball::cast(this)->to_string()->Print(out);
break;
case JS_FUNCTION_TYPE:
JSFunction::cast(this)->JSFunctionPrint();
JSFunction::cast(this)->JSFunctionPrint(out);
break;
case JS_GLOBAL_PROXY_TYPE:
JSGlobalProxy::cast(this)->JSGlobalProxyPrint();
JSGlobalProxy::cast(this)->JSGlobalProxyPrint(out);
break;
case JS_GLOBAL_OBJECT_TYPE:
JSGlobalObject::cast(this)->JSGlobalObjectPrint();
JSGlobalObject::cast(this)->JSGlobalObjectPrint(out);
break;
case JS_BUILTINS_OBJECT_TYPE:
JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint();
JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(out);
break;
case JS_VALUE_TYPE:
PrintF("Value wrapper around:");
JSValue::cast(this)->value()->Print();
PrintF(out, "Value wrapper around:");
JSValue::cast(this)->value()->Print(out);
break;
case CODE_TYPE:
Code::cast(this)->CodePrint();
Code::cast(this)->CodePrint(out);
break;
case PROXY_TYPE:
Proxy::cast(this)->ProxyPrint();
Proxy::cast(this)->ProxyPrint(out);
break;
case SHARED_FUNCTION_INFO_TYPE:
SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint();
SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(out);
break;
case JS_GLOBAL_PROPERTY_CELL_TYPE:
JSGlobalPropertyCell::cast(this)->JSGlobalPropertyCellPrint();
JSGlobalPropertyCell::cast(this)->JSGlobalPropertyCellPrint(out);
break;
#define MAKE_STRUCT_CASE(NAME, Name, name) \
case NAME##_TYPE: \
Name::cast(this)->Name##Print(); \
Name::cast(this)->Name##Print(out); \
break;
STRUCT_LIST(MAKE_STRUCT_CASE)
#undef MAKE_STRUCT_CASE
default:
PrintF("UNKNOWN TYPE %d", map()->instance_type());
PrintF(out, "UNKNOWN TYPE %d", map()->instance_type());
UNREACHABLE();
break;
}
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void HeapObject::HeapObjectVerify() {
InstanceType instance_type = map()->instance_type();
......@@ -312,53 +320,57 @@ void HeapObject::VerifyHeapPointer(Object* p) {
void HeapNumber::HeapNumberVerify() {
ASSERT(IsHeapNumber());
}
#endif // DEBUG
void ByteArray::ByteArrayPrint() {
PrintF("byte array, data starts at %p", GetDataStartAddress());
#ifdef OBJECT_PRINT
void ByteArray::ByteArrayPrint(FILE* out) {
PrintF(out, "byte array, data starts at %p", GetDataStartAddress());
}
void PixelArray::PixelArrayPrint() {
PrintF("pixel array");
void PixelArray::PixelArrayPrint(FILE* out) {
PrintF(out, "pixel array");
}
void ExternalByteArray::ExternalByteArrayPrint() {
PrintF("external byte array");
void ExternalByteArray::ExternalByteArrayPrint(FILE* out) {
PrintF(out, "external byte array");
}
void ExternalUnsignedByteArray::ExternalUnsignedByteArrayPrint() {
PrintF("external unsigned byte array");
void ExternalUnsignedByteArray::ExternalUnsignedByteArrayPrint(FILE* out) {
PrintF(out, "external unsigned byte array");
}
void ExternalShortArray::ExternalShortArrayPrint() {
PrintF("external short array");
void ExternalShortArray::ExternalShortArrayPrint(FILE* out) {
PrintF(out, "external short array");
}
void ExternalUnsignedShortArray::ExternalUnsignedShortArrayPrint() {
PrintF("external unsigned short array");
void ExternalUnsignedShortArray::ExternalUnsignedShortArrayPrint(FILE* out) {
PrintF(out, "external unsigned short array");
}
void ExternalIntArray::ExternalIntArrayPrint() {
PrintF("external int array");
void ExternalIntArray::ExternalIntArrayPrint(FILE* out) {
PrintF(out, "external int array");
}
void ExternalUnsignedIntArray::ExternalUnsignedIntArrayPrint() {
PrintF("external unsigned int array");
void ExternalUnsignedIntArray::ExternalUnsignedIntArrayPrint(FILE* out) {
PrintF(out, "external unsigned int array");
}
void ExternalFloatArray::ExternalFloatArrayPrint() {
PrintF("external float array");
void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) {
PrintF(out, "external float array");
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void ByteArray::ByteArrayVerify() {
ASSERT(IsByteArray());
}
......@@ -402,38 +414,40 @@ void ExternalUnsignedIntArray::ExternalUnsignedIntArrayVerify() {
void ExternalFloatArray::ExternalFloatArrayVerify() {
ASSERT(IsExternalFloatArray());
}
#endif // DEBUG
void JSObject::PrintProperties() {
#ifdef OBJECT_PRINT
void JSObject::PrintProperties(FILE* out) {
if (HasFastProperties()) {
DescriptorArray* descs = map()->instance_descriptors();
for (int i = 0; i < descs->number_of_descriptors(); i++) {
PrintF(" ");
descs->GetKey(i)->StringPrint();
PrintF(": ");
PrintF(out, " ");
descs->GetKey(i)->StringPrint(out);
PrintF(out, ": ");
switch (descs->GetType(i)) {
case FIELD: {
int index = descs->GetFieldIndex(i);
FastPropertyAt(index)->ShortPrint();
PrintF(" (field at offset %d)\n", index);
FastPropertyAt(index)->ShortPrint(out);
PrintF(out, " (field at offset %d)\n", index);
break;
}
case CONSTANT_FUNCTION:
descs->GetConstantFunction(i)->ShortPrint();
PrintF(" (constant function)\n");
descs->GetConstantFunction(i)->ShortPrint(out);
PrintF(out, " (constant function)\n");
break;
case CALLBACKS:
descs->GetCallbacksObject(i)->ShortPrint();
PrintF(" (callback)\n");
descs->GetCallbacksObject(i)->ShortPrint(out);
PrintF(out, " (callback)\n");
break;
case MAP_TRANSITION:
PrintF(" (map transition)\n");
PrintF(out, " (map transition)\n");
break;
case CONSTANT_TRANSITION:
PrintF(" (constant transition)\n");
PrintF(out, " (constant transition)\n");
break;
case NULL_DESCRIPTOR:
PrintF(" (null descriptor)\n");
PrintF(out, " (null descriptor)\n");
break;
default:
UNREACHABLE();
......@@ -441,34 +455,34 @@ void JSObject::PrintProperties() {
}
}
} else {
property_dictionary()->Print();
property_dictionary()->Print(out);
}
}
void JSObject::PrintElements() {
void JSObject::PrintElements(FILE* out) {
switch (GetElementsKind()) {
case FAST_ELEMENTS: {
// Print in array notation for non-sparse arrays.
FixedArray* p = FixedArray::cast(elements());
for (int i = 0; i < p->length(); i++) {
PrintF(" %d: ", i);
p->get(i)->ShortPrint();
PrintF("\n");
PrintF(out, " %d: ", i);
p->get(i)->ShortPrint(out);
PrintF(out, "\n");
}
break;
}
case PIXEL_ELEMENTS: {
PixelArray* p = PixelArray::cast(elements());
for (int i = 0; i < p->length(); i++) {
PrintF(" %d: %d\n", i, p->get(i));
PrintF(out, " %d: %d\n", i, p->get(i));
}
break;
}
case EXTERNAL_BYTE_ELEMENTS: {
ExternalByteArray* p = ExternalByteArray::cast(elements());
for (int i = 0; i < p->length(); i++) {
PrintF(" %d: %d\n", i, static_cast<int>(p->get(i)));
PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i)));
}
break;
}
......@@ -476,14 +490,14 @@ void JSObject::PrintElements() {
ExternalUnsignedByteArray* p =
ExternalUnsignedByteArray::cast(elements());
for (int i = 0; i < p->length(); i++) {
PrintF(" %d: %d\n", i, static_cast<int>(p->get(i)));
PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i)));
}
break;
}
case EXTERNAL_SHORT_ELEMENTS: {
ExternalShortArray* p = ExternalShortArray::cast(elements());
for (int i = 0; i < p->length(); i++) {
PrintF(" %d: %d\n", i, static_cast<int>(p->get(i)));
PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i)));
}
break;
}
......@@ -491,14 +505,14 @@ void JSObject::PrintElements() {
ExternalUnsignedShortArray* p =
ExternalUnsignedShortArray::cast(elements());
for (int i = 0; i < p->length(); i++) {
PrintF(" %d: %d\n", i, static_cast<int>(p->get(i)));
PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i)));
}
break;
}
case EXTERNAL_INT_ELEMENTS: {
ExternalIntArray* p = ExternalIntArray::cast(elements());
for (int i = 0; i < p->length(); i++) {
PrintF(" %d: %d\n", i, static_cast<int>(p->get(i)));
PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i)));
}
break;
}
......@@ -506,19 +520,19 @@ void JSObject::PrintElements() {
ExternalUnsignedIntArray* p =
ExternalUnsignedIntArray::cast(elements());
for (int i = 0; i < p->length(); i++) {
PrintF(" %d: %d\n", i, static_cast<int>(p->get(i)));
PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i)));
}
break;
}
case EXTERNAL_FLOAT_ELEMENTS: {
ExternalFloatArray* p = ExternalFloatArray::cast(elements());
for (int i = 0; i < p->length(); i++) {
PrintF(" %d: %f\n", i, p->get(i));
PrintF(out, " %d: %f\n", i, p->get(i));
}
break;
}
case DICTIONARY_ELEMENTS:
elements()->Print();
elements()->Print(out);
break;
default:
UNREACHABLE();
......@@ -527,17 +541,19 @@ void JSObject::PrintElements() {
}
void JSObject::JSObjectPrint() {
PrintF("%p: [JSObject]\n", reinterpret_cast<void*>(this));
PrintF(" - map = %p\n", reinterpret_cast<void*>(map()));
PrintF(" - prototype = %p\n", reinterpret_cast<void*>(GetPrototype()));
PrintF(" {\n");
PrintProperties();
PrintElements();
PrintF(" }\n");
void JSObject::JSObjectPrint(FILE* out) {
PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this));
PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
PrintF(out, " - prototype = %p\n", reinterpret_cast<void*>(GetPrototype()));
PrintF(out, " {\n");
PrintProperties(out);
PrintElements(out);
PrintF(out, " }\n");
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void JSObject::JSObjectVerify() {
VerifyHeapPointer(properties());
VerifyHeapPointer(elements());
......@@ -551,8 +567,10 @@ void JSObject::JSObjectVerify() {
elements()->map() == Heap::fixed_cow_array_map()));
ASSERT(map()->has_fast_elements() == HasFastElements());
}
#endif // DEBUG
#ifdef OBJECT_PRINT
static const char* TypeToString(InstanceType type) {
switch (type) {
case INVALID_TYPE: return "INVALID";
......@@ -608,42 +626,44 @@ static const char* TypeToString(InstanceType type) {
}
void Map::MapPrint() {
HeapObject::PrintHeader("Map");
PrintF(" - type: %s\n", TypeToString(instance_type()));
PrintF(" - instance size: %d\n", instance_size());
PrintF(" - inobject properties: %d\n", inobject_properties());
PrintF(" - pre-allocated property fields: %d\n",
void Map::MapPrint(FILE* out) {
HeapObject::PrintHeader(out, "Map");
PrintF(out, " - type: %s\n", TypeToString(instance_type()));
PrintF(out, " - instance size: %d\n", instance_size());
PrintF(out, " - inobject properties: %d\n", inobject_properties());
PrintF(out, " - pre-allocated property fields: %d\n",
pre_allocated_property_fields());
PrintF(" - unused property fields: %d\n", unused_property_fields());
PrintF(out, " - unused property fields: %d\n", unused_property_fields());
if (is_hidden_prototype()) {
PrintF(" - hidden_prototype\n");
PrintF(out, " - hidden_prototype\n");
}
if (has_named_interceptor()) {
PrintF(" - named_interceptor\n");
PrintF(out, " - named_interceptor\n");
}
if (has_indexed_interceptor()) {
PrintF(" - indexed_interceptor\n");
PrintF(out, " - indexed_interceptor\n");
}
if (is_undetectable()) {
PrintF(" - undetectable\n");
PrintF(out, " - undetectable\n");
}
if (has_instance_call_handler()) {
PrintF(" - instance_call_handler\n");
PrintF(out, " - instance_call_handler\n");
}
if (is_access_check_needed()) {
PrintF(" - access_check_needed\n");
PrintF(out, " - access_check_needed\n");
}
PrintF(" - instance descriptors: ");
instance_descriptors()->ShortPrint();
PrintF("\n - prototype: ");
prototype()->ShortPrint();
PrintF("\n - constructor: ");
constructor()->ShortPrint();
PrintF("\n");
PrintF(out, " - instance descriptors: ");
instance_descriptors()->ShortPrint(out);
PrintF(out, "\n - prototype: ");
prototype()->ShortPrint(out);
PrintF(out, "\n - constructor: ");
constructor()->ShortPrint(out);
PrintF(out, "\n");
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void Map::MapVerify() {
ASSERT(!Heap::InNewSpace(this));
ASSERT(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE);
......@@ -665,17 +685,21 @@ void Map::SharedMapVerify() {
ASSERT_EQ(StaticVisitorBase::GetVisitorId(instance_type(), instance_size()),
visitor_id());
}
#endif // DEBUG
void CodeCache::CodeCachePrint() {
HeapObject::PrintHeader("CodeCache");
PrintF("\n - default_cache: ");
default_cache()->ShortPrint();
PrintF("\n - normal_type_cache: ");
normal_type_cache()->ShortPrint();
#ifdef OBJECT_PRINT
void CodeCache::CodeCachePrint(FILE* out) {
HeapObject::PrintHeader(out, "CodeCache");
PrintF(out, "\n - default_cache: ");
default_cache()->ShortPrint(out);
PrintF(out, "\n - normal_type_cache: ");
normal_type_cache()->ShortPrint(out);
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void CodeCache::CodeCacheVerify() {
VerifyHeapPointer(default_cache());
VerifyHeapPointer(normal_type_cache());
......@@ -683,19 +707,23 @@ void CodeCache::CodeCacheVerify() {
ASSERT(normal_type_cache()->IsUndefined()
|| normal_type_cache()->IsCodeCacheHashTable());
}
#endif // DEBUG
void FixedArray::FixedArrayPrint() {
HeapObject::PrintHeader("FixedArray");
PrintF(" - length: %d", length());
#ifdef OBJECT_PRINT
void FixedArray::FixedArrayPrint(FILE* out) {
HeapObject::PrintHeader(out, "FixedArray");
PrintF(out, " - length: %d", length());
for (int i = 0; i < length(); i++) {
PrintF("\n [%d]: ", i);
get(i)->ShortPrint();
PrintF(out, "\n [%d]: ", i);
get(i)->ShortPrint(out);
}
PrintF("\n");
PrintF(out, "\n");
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void FixedArray::FixedArrayVerify() {
for (int i = 0; i < length(); i++) {
Object* e = get(i);
......@@ -706,39 +734,57 @@ void FixedArray::FixedArrayVerify() {
}
}
}
#endif // DEBUG
void JSValue::JSValuePrint() {
HeapObject::PrintHeader("ValueObject");
value()->Print();
#ifdef OBJECT_PRINT
void JSValue::JSValuePrint(FILE* out) {
HeapObject::PrintHeader(out, "ValueObject");
value()->Print(out);
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void JSValue::JSValueVerify() {
Object* v = value();
if (v->IsHeapObject()) {
VerifyHeapPointer(v);
}
}
#endif // DEBUG
void String::StringPrint() {
#ifdef OBJECT_PRINT
void String::StringPrint(FILE* out) {
if (StringShape(this).IsSymbol()) {
PrintF("#");
PrintF(out, "#");
} else if (StringShape(this).IsCons()) {
PrintF("c\"");
PrintF(out, "c\"");
} else {
PrintF("\"");
PrintF(out, "\"");
}
for (int i = 0; i < length(); i++) {
PrintF("%c", Get(i));
const char truncated_epilogue[] = "...<truncated>";
int len = length();
if (!FLAG_use_verbose_printer) {
if (len > 100) {
len = 100 - sizeof(truncated_epilogue);
}
}
for (int i = 0; i < len; i++) {
PrintF(out, "%c", Get(i));
}
if (len != length()) {
PrintF(out, "%s", truncated_epilogue);
}
if (!StringShape(this).IsSymbol()) PrintF("\"");
if (!StringShape(this).IsSymbol()) PrintF(out, "\"");
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void String::StringVerify() {
CHECK(IsString());
CHECK(length() >= 0 && length() <= Smi::kMaxValue);
......@@ -746,32 +792,36 @@ void String::StringVerify() {
CHECK(!Heap::InNewSpace(this));
}
}
#endif // DEBUG
void JSFunction::JSFunctionPrint() {
HeapObject::PrintHeader("Function");
PrintF(" - map = 0x%p\n", reinterpret_cast<void*>(map()));
PrintF(" - initial_map = ");
#ifdef OBJECT_PRINT
void JSFunction::JSFunctionPrint(FILE* out) {
HeapObject::PrintHeader(out, "Function");
PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map()));
PrintF(out, " - initial_map = ");
if (has_initial_map()) {
initial_map()->ShortPrint();
initial_map()->ShortPrint(out);
}
PrintF("\n - shared_info = ");
shared()->ShortPrint();
PrintF("\n - name = ");
shared()->name()->Print();
PrintF("\n - context = ");
unchecked_context()->ShortPrint();
PrintF("\n - code = ");
code()->ShortPrint();
PrintF("\n");
PrintF(out, "\n - shared_info = ");
shared()->ShortPrint(out);
PrintF(out, "\n - name = ");
shared()->name()->Print(out);
PrintF(out, "\n - context = ");
unchecked_context()->ShortPrint(out);
PrintF(out, "\n - code = ");
code()->ShortPrint(out);
PrintF(out, "\n");
PrintProperties();
PrintElements();
PrintProperties(out);
PrintElements(out);
PrintF("\n");
PrintF(out, "\n");
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void JSFunction::JSFunctionVerify() {
CHECK(IsJSFunction());
VerifyObjectField(kPrototypeOrInitialMapOffset);
......@@ -779,36 +829,41 @@ void JSFunction::JSFunctionVerify() {
CHECK(next_function_link()->IsUndefined() ||
next_function_link()->IsJSFunction());
}
#endif // DEBUG
void SharedFunctionInfo::SharedFunctionInfoPrint() {
HeapObject::PrintHeader("SharedFunctionInfo");
PrintF(" - name: ");
name()->ShortPrint();
PrintF("\n - expected_nof_properties: %d", expected_nof_properties());
PrintF("\n - instance class name = ");
instance_class_name()->Print();
PrintF("\n - code = ");
code()->ShortPrint();
PrintF("\n - source code = ");
GetSourceCode()->ShortPrint();
#ifdef OBJECT_PRINT
void SharedFunctionInfo::SharedFunctionInfoPrint(FILE* out) {
HeapObject::PrintHeader(out, "SharedFunctionInfo");
PrintF(out, " - name: ");
name()->ShortPrint(out);
PrintF(out, "\n - expected_nof_properties: %d", expected_nof_properties());
PrintF(out, "\n - instance class name = ");
instance_class_name()->Print(out);
PrintF(out, "\n - code = ");
code()->ShortPrint(out);
PrintF(out, "\n - source code = ");
GetSourceCode()->ShortPrint(out);
// Script files are often large, hard to read.
// PrintF("\n - script =");
// script()->Print();
PrintF("\n - function token position = %d", function_token_position());
PrintF("\n - start position = %d", start_position());
PrintF("\n - end position = %d", end_position());
PrintF("\n - is expression = %d", is_expression());
PrintF("\n - debug info = ");
debug_info()->ShortPrint();
PrintF("\n - length = %d", length());
PrintF("\n - has_only_simple_this_property_assignments = %d",
// PrintF(out, "\n - script =");
// script()->Print(out);
PrintF(out, "\n - function token position = %d", function_token_position());
PrintF(out, "\n - start position = %d", start_position());
PrintF(out, "\n - end position = %d", end_position());
PrintF(out, "\n - is expression = %d", is_expression());
PrintF(out, "\n - debug info = ");
debug_info()->ShortPrint(out);
PrintF(out, "\n - length = %d", length());
PrintF(out, "\n - has_only_simple_this_property_assignments = %d",
has_only_simple_this_property_assignments());
PrintF("\n - this_property_assignments = ");
this_property_assignments()->ShortPrint();
PrintF("\n");
PrintF(out, "\n - this_property_assignments = ");
this_property_assignments()->ShortPrint(out);
PrintF(out, "\n");
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void SharedFunctionInfo::SharedFunctionInfoVerify() {
CHECK(IsSharedFunctionInfo());
VerifyObjectField(kNameOffset);
......@@ -819,17 +874,21 @@ void SharedFunctionInfo::SharedFunctionInfoVerify() {
VerifyObjectField(kScriptOffset);
VerifyObjectField(kDebugInfoOffset);
}
#endif // DEBUG
void JSGlobalProxy::JSGlobalProxyPrint() {
PrintF("global_proxy");
JSObjectPrint();
PrintF("context : ");
context()->ShortPrint();
PrintF("\n");
#ifdef OBJECT_PRINT
void JSGlobalProxy::JSGlobalProxyPrint(FILE* out) {
PrintF(out, "global_proxy");
JSObjectPrint(out);
PrintF(out, "context : ");
context()->ShortPrint(out);
PrintF(out, "\n");
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void JSGlobalProxy::JSGlobalProxyVerify() {
CHECK(IsJSGlobalProxy());
JSObjectVerify();
......@@ -839,17 +898,21 @@ void JSGlobalProxy::JSGlobalProxyVerify() {
CHECK(HasFastElements());
CHECK_EQ(0, FixedArray::cast(elements())->length());
}
#endif // DEBUG
void JSGlobalObject::JSGlobalObjectPrint() {
PrintF("global ");
JSObjectPrint();
PrintF("global context : ");
global_context()->ShortPrint();
PrintF("\n");
#ifdef OBJECT_PRINT
void JSGlobalObject::JSGlobalObjectPrint(FILE* out) {
PrintF(out, "global ");
JSObjectPrint(out);
PrintF(out, "global context : ");
global_context()->ShortPrint(out);
PrintF(out, "\n");
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void JSGlobalObject::JSGlobalObjectVerify() {
CHECK(IsJSGlobalObject());
JSObjectVerify();
......@@ -859,14 +922,18 @@ void JSGlobalObject::JSGlobalObjectVerify() {
VerifyObjectField(i);
}
}
#endif // DEBUG
void JSBuiltinsObject::JSBuiltinsObjectPrint() {
PrintF("builtins ");
JSObjectPrint();
#ifdef OBJECT_PRINT
void JSBuiltinsObject::JSBuiltinsObjectPrint(FILE* out) {
PrintF(out, "builtins ");
JSObjectPrint(out);
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void JSBuiltinsObject::JSBuiltinsObjectVerify() {
CHECK(IsJSBuiltinsObject());
JSObjectVerify();
......@@ -897,21 +964,27 @@ void JSGlobalPropertyCell::JSGlobalPropertyCellVerify() {
CHECK(IsJSGlobalPropertyCell());
VerifyObjectField(kValueOffset);
}
#endif // DEBUG
void JSGlobalPropertyCell::JSGlobalPropertyCellPrint() {
HeapObject::PrintHeader("JSGlobalPropertyCell");
#ifdef OBJECT_PRINT
void JSGlobalPropertyCell::JSGlobalPropertyCellPrint(FILE* out) {
HeapObject::PrintHeader(out, "JSGlobalPropertyCell");
}
void Code::CodePrint() {
HeapObject::PrintHeader("Code");
void Code::CodePrint(FILE* out) {
HeapObject::PrintHeader(out, "Code");
#ifdef ENABLE_DISASSEMBLER
Disassemble(NULL);
if (FLAG_use_verbose_printer) {
Disassemble(NULL, out);
}
#endif
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void Code::CodeVerify() {
CHECK(IsAligned(reinterpret_cast<intptr_t>(instruction_start()),
kCodeAlignment));
......@@ -966,13 +1039,17 @@ void JSRegExp::JSRegExpVerify() {
break;
}
}
#endif // DEBUG
void Proxy::ProxyPrint() {
PrintF("proxy to %p", proxy());
#ifdef OBJECT_PRINT
void Proxy::ProxyPrint(FILE* out) {
PrintF(out, "proxy to %p", proxy());
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void Proxy::ProxyVerify() {
ASSERT(IsProxy());
}
......@@ -986,38 +1063,50 @@ void AccessorInfo::AccessorInfoVerify() {
VerifyPointer(data());
VerifyPointer(flag());
}
#endif // DEBUG
void AccessorInfo::AccessorInfoPrint() {
HeapObject::PrintHeader("AccessorInfo");
PrintF("\n - getter: ");
getter()->ShortPrint();
PrintF("\n - setter: ");
setter()->ShortPrint();
PrintF("\n - name: ");
name()->ShortPrint();
PrintF("\n - data: ");
data()->ShortPrint();
PrintF("\n - flag: ");
flag()->ShortPrint();
#ifdef OBJECT_PRINT
void AccessorInfo::AccessorInfoPrint(FILE* out) {
HeapObject::PrintHeader(out, "AccessorInfo");
PrintF(out, "\n - getter: ");
getter()->ShortPrint(out);
PrintF(out, "\n - setter: ");
setter()->ShortPrint(out);
PrintF(out, "\n - name: ");
name()->ShortPrint(out);
PrintF(out, "\n - data: ");
data()->ShortPrint(out);
PrintF(out, "\n - flag: ");
flag()->ShortPrint(out);
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void AccessCheckInfo::AccessCheckInfoVerify() {
CHECK(IsAccessCheckInfo());
VerifyPointer(named_callback());
VerifyPointer(indexed_callback());
VerifyPointer(data());
}
#endif // DEBUG
void AccessCheckInfo::AccessCheckInfoPrint() {
HeapObject::PrintHeader("AccessCheckInfo");
PrintF("\n - named_callback: ");
named_callback()->ShortPrint();
PrintF("\n - indexed_callback: ");
indexed_callback()->ShortPrint();
PrintF("\n - data: ");
data()->ShortPrint();
#ifdef OBJECT_PRINT
void AccessCheckInfo::AccessCheckInfoPrint(FILE* out) {
HeapObject::PrintHeader(out, "AccessCheckInfo");
PrintF(out, "\n - named_callback: ");
named_callback()->ShortPrint(out);
PrintF(out, "\n - indexed_callback: ");
indexed_callback()->ShortPrint(out);
PrintF(out, "\n - data: ");
data()->ShortPrint(out);
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void InterceptorInfo::InterceptorInfoVerify() {
CHECK(IsInterceptorInfo());
VerifyPointer(getter());
......@@ -1027,38 +1116,50 @@ void InterceptorInfo::InterceptorInfoVerify() {
VerifyPointer(enumerator());
VerifyPointer(data());
}
#endif // DEBUG
void InterceptorInfo::InterceptorInfoPrint() {
HeapObject::PrintHeader("InterceptorInfo");
PrintF("\n - getter: ");
getter()->ShortPrint();
PrintF("\n - setter: ");
setter()->ShortPrint();
PrintF("\n - query: ");
query()->ShortPrint();
PrintF("\n - deleter: ");
deleter()->ShortPrint();
PrintF("\n - enumerator: ");
enumerator()->ShortPrint();
PrintF("\n - data: ");
data()->ShortPrint();
#ifdef OBJECT_PRINT
void InterceptorInfo::InterceptorInfoPrint(FILE* out) {
HeapObject::PrintHeader(out, "InterceptorInfo");
PrintF(out, "\n - getter: ");
getter()->ShortPrint(out);
PrintF(out, "\n - setter: ");
setter()->ShortPrint(out);
PrintF(out, "\n - query: ");
query()->ShortPrint(out);
PrintF(out, "\n - deleter: ");
deleter()->ShortPrint(out);
PrintF(out, "\n - enumerator: ");
enumerator()->ShortPrint(out);
PrintF(out, "\n - data: ");
data()->ShortPrint(out);
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void CallHandlerInfo::CallHandlerInfoVerify() {
CHECK(IsCallHandlerInfo());
VerifyPointer(callback());
VerifyPointer(data());
}
#endif // DEBUG
void CallHandlerInfo::CallHandlerInfoPrint() {
HeapObject::PrintHeader("CallHandlerInfo");
PrintF("\n - callback: ");
callback()->ShortPrint();
PrintF("\n - data: ");
data()->ShortPrint();
PrintF("\n - call_stub_cache: ");
#ifdef OBJECT_PRINT
void CallHandlerInfo::CallHandlerInfoPrint(FILE* out) {
HeapObject::PrintHeader(out, "CallHandlerInfo");
PrintF(out, "\n - callback: ");
callback()->ShortPrint(out);
PrintF(out, "\n - data: ");
data()->ShortPrint(out);
PrintF(out, "\n - call_stub_cache: ");
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void TemplateInfo::TemplateInfoVerify() {
VerifyPointer(tag());
VerifyPointer(property_list());
......@@ -1078,81 +1179,106 @@ void FunctionTemplateInfo::FunctionTemplateInfoVerify() {
VerifyPointer(signature());
VerifyPointer(access_check_info());
}
#endif // DEBUG
#ifdef OBJECT_PRINT
void FunctionTemplateInfo::FunctionTemplateInfoPrint(FILE* out) {
HeapObject::PrintHeader(out, "FunctionTemplateInfo");
PrintF(out, "\n - class name: ");
class_name()->ShortPrint(out);
PrintF(out, "\n - tag: ");
tag()->ShortPrint(out);
PrintF(out, "\n - property_list: ");
property_list()->ShortPrint(out);
PrintF(out, "\n - serial_number: ");
serial_number()->ShortPrint(out);
PrintF(out, "\n - call_code: ");
call_code()->ShortPrint(out);
PrintF(out, "\n - property_accessors: ");
property_accessors()->ShortPrint(out);
PrintF(out, "\n - prototype_template: ");
prototype_template()->ShortPrint(out);
PrintF(out, "\n - parent_template: ");
parent_template()->ShortPrint(out);
PrintF(out, "\n - named_property_handler: ");
named_property_handler()->ShortPrint(out);
PrintF(out, "\n - indexed_property_handler: ");
indexed_property_handler()->ShortPrint(out);
PrintF(out, "\n - instance_template: ");
instance_template()->ShortPrint(out);
PrintF(out, "\n - signature: ");
signature()->ShortPrint(out);
PrintF(out, "\n - access_check_info: ");
access_check_info()->ShortPrint(out);
PrintF(out, "\n - hidden_prototype: %s",
hidden_prototype() ? "true" : "false");
PrintF(out, "\n - undetectable: %s", undetectable() ? "true" : "false");
PrintF(out, "\n - need_access_check: %s",
needs_access_check() ? "true" : "false");
}
#endif // OBJECT_PRINT
void FunctionTemplateInfo::FunctionTemplateInfoPrint() {
HeapObject::PrintHeader("FunctionTemplateInfo");
PrintF("\n - class name: ");
class_name()->ShortPrint();
PrintF("\n - tag: ");
tag()->ShortPrint();
PrintF("\n - property_list: ");
property_list()->ShortPrint();
PrintF("\n - serial_number: ");
serial_number()->ShortPrint();
PrintF("\n - call_code: ");
call_code()->ShortPrint();
PrintF("\n - property_accessors: ");
property_accessors()->ShortPrint();
PrintF("\n - prototype_template: ");
prototype_template()->ShortPrint();
PrintF("\n - parent_template: ");
parent_template()->ShortPrint();
PrintF("\n - named_property_handler: ");
named_property_handler()->ShortPrint();
PrintF("\n - indexed_property_handler: ");
indexed_property_handler()->ShortPrint();
PrintF("\n - instance_template: ");
instance_template()->ShortPrint();
PrintF("\n - signature: ");
signature()->ShortPrint();
PrintF("\n - access_check_info: ");
access_check_info()->ShortPrint();
PrintF("\n - hidden_prototype: %s", hidden_prototype() ? "true" : "false");
PrintF("\n - undetectable: %s", undetectable() ? "true" : "false");
PrintF("\n - need_access_check: %s", needs_access_check() ? "true" : "false");
}
#ifdef DEBUG
void ObjectTemplateInfo::ObjectTemplateInfoVerify() {
CHECK(IsObjectTemplateInfo());
TemplateInfoVerify();
VerifyPointer(constructor());
VerifyPointer(internal_field_count());
}
#endif // DEBUG
void ObjectTemplateInfo::ObjectTemplateInfoPrint() {
HeapObject::PrintHeader("ObjectTemplateInfo");
PrintF("\n - constructor: ");
constructor()->ShortPrint();
PrintF("\n - internal_field_count: ");
internal_field_count()->ShortPrint();
#ifdef OBJECT_PRINT
void ObjectTemplateInfo::ObjectTemplateInfoPrint(FILE* out) {
HeapObject::PrintHeader(out, "ObjectTemplateInfo");
PrintF(out, "\n - constructor: ");
constructor()->ShortPrint(out);
PrintF(out, "\n - internal_field_count: ");
internal_field_count()->ShortPrint(out);
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void SignatureInfo::SignatureInfoVerify() {
CHECK(IsSignatureInfo());
VerifyPointer(receiver());
VerifyPointer(args());
}
#endif // DEBUG
void SignatureInfo::SignatureInfoPrint() {
HeapObject::PrintHeader("SignatureInfo");
PrintF("\n - receiver: ");
receiver()->ShortPrint();
PrintF("\n - args: ");
args()->ShortPrint();
#ifdef OBJECT_PRINT
void SignatureInfo::SignatureInfoPrint(FILE* out) {
HeapObject::PrintHeader(out, "SignatureInfo");
PrintF(out, "\n - receiver: ");
receiver()->ShortPrint(out);
PrintF(out, "\n - args: ");
args()->ShortPrint(out);
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void TypeSwitchInfo::TypeSwitchInfoVerify() {
CHECK(IsTypeSwitchInfo());
VerifyPointer(types());
}
#endif // DEBUG
void TypeSwitchInfo::TypeSwitchInfoPrint() {
HeapObject::PrintHeader("TypeSwitchInfo");
PrintF("\n - types: ");
types()->ShortPrint();
#ifdef OBJECT_PRINT
void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) {
HeapObject::PrintHeader(out, "TypeSwitchInfo");
PrintF(out, "\n - types: ");
types()->ShortPrint(out);
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void Script::ScriptVerify() {
CHECK(IsScript());
VerifyPointer(source());
......@@ -1165,41 +1291,45 @@ void Script::ScriptVerify() {
VerifyPointer(line_ends());
VerifyPointer(id());
}
#endif // DEBUG
void Script::ScriptPrint() {
HeapObject::PrintHeader("Script");
PrintF("\n - source: ");
source()->ShortPrint();
PrintF("\n - name: ");
name()->ShortPrint();
PrintF("\n - line_offset: ");
line_offset()->ShortPrint();
PrintF("\n - column_offset: ");
column_offset()->ShortPrint();
PrintF("\n - type: ");
type()->ShortPrint();
PrintF("\n - id: ");
id()->ShortPrint();
PrintF("\n - data: ");
data()->ShortPrint();
PrintF("\n - context data: ");
context_data()->ShortPrint();
PrintF("\n - wrapper: ");
wrapper()->ShortPrint();
PrintF("\n - compilation type: ");
compilation_type()->ShortPrint();
PrintF("\n - line ends: ");
line_ends()->ShortPrint();
PrintF("\n - eval from shared: ");
eval_from_shared()->ShortPrint();
PrintF("\n - eval from instructions offset: ");
eval_from_instructions_offset()->ShortPrint();
PrintF("\n");
}
#ifdef OBJECT_PRINT
void Script::ScriptPrint(FILE* out) {
HeapObject::PrintHeader(out, "Script");
PrintF(out, "\n - source: ");
source()->ShortPrint(out);
PrintF(out, "\n - name: ");
name()->ShortPrint(out);
PrintF(out, "\n - line_offset: ");
line_offset()->ShortPrint(out);
PrintF(out, "\n - column_offset: ");
column_offset()->ShortPrint(out);
PrintF(out, "\n - type: ");
type()->ShortPrint(out);
PrintF(out, "\n - id: ");
id()->ShortPrint(out);
PrintF(out, "\n - data: ");
data()->ShortPrint(out);
PrintF(out, "\n - context data: ");
context_data()->ShortPrint(out);
PrintF(out, "\n - wrapper: ");
wrapper()->ShortPrint(out);
PrintF(out, "\n - compilation type: ");
compilation_type()->ShortPrint(out);
PrintF(out, "\n - line ends: ");
line_ends()->ShortPrint(out);
PrintF(out, "\n - eval from shared: ");
eval_from_shared()->ShortPrint(out);
PrintF(out, "\n - eval from instructions offset: ");
eval_from_instructions_offset()->ShortPrint(out);
PrintF(out, "\n");
}
#endif // OBJECT_PRINT
#ifdef ENABLE_DEBUGGER_SUPPORT
#ifdef DEBUG
void DebugInfo::DebugInfoVerify() {
CHECK(IsDebugInfo());
VerifyPointer(shared());
......@@ -1207,21 +1337,25 @@ void DebugInfo::DebugInfoVerify() {
VerifyPointer(code());
VerifyPointer(break_points());
}
#endif // DEBUG
void DebugInfo::DebugInfoPrint() {
HeapObject::PrintHeader("DebugInfo");
PrintF("\n - shared: ");
shared()->ShortPrint();
PrintF("\n - original_code: ");
original_code()->ShortPrint();
PrintF("\n - code: ");
code()->ShortPrint();
PrintF("\n - break_points: ");
break_points()->Print();
#ifdef OBJECT_PRINT
void DebugInfo::DebugInfoPrint(FILE* out) {
HeapObject::PrintHeader(out, "DebugInfo");
PrintF(out, "\n - shared: ");
shared()->ShortPrint(out);
PrintF(out, "\n - original_code: ");
original_code()->ShortPrint(out);
PrintF(out, "\n - code: ");
code()->ShortPrint(out);
PrintF(out, "\n - break_points: ");
break_points()->Print(out);
}
#endif // OBJECT_PRINT
#ifdef DEBUG
void BreakPointInfo::BreakPointInfoVerify() {
CHECK(IsBreakPointInfo());
code_position()->SmiVerify();
......@@ -1229,19 +1363,23 @@ void BreakPointInfo::BreakPointInfoVerify() {
statement_position()->SmiVerify();
VerifyPointer(break_point_objects());
}
#endif // DEBUG
void BreakPointInfo::BreakPointInfoPrint() {
HeapObject::PrintHeader("BreakPointInfo");
PrintF("\n - code_position: %d", code_position()->value());
PrintF("\n - source_position: %d", source_position()->value());
PrintF("\n - statement_position: %d", statement_position()->value());
PrintF("\n - break_point_objects: ");
break_point_objects()->ShortPrint();
#ifdef OBJECT_PRINT
void BreakPointInfo::BreakPointInfoPrint(FILE* out) {
HeapObject::PrintHeader(out, "BreakPointInfo");
PrintF(out, "\n - code_position: %d", code_position()->value());
PrintF(out, "\n - source_position: %d", source_position()->value());
PrintF(out, "\n - statement_position: %d", statement_position()->value());
PrintF(out, "\n - break_point_objects: ");
break_point_objects()->ShortPrint(out);
}
#endif
#endif // OBJECT_PRINT
#endif // ENABLE_DEBUGGER_SUPPORT
#ifdef DEBUG
void JSObject::IncrementSpillStatistics(SpillInformation* info) {
info->number_of_objects_++;
// Named properties
......@@ -1324,20 +1462,24 @@ void JSObject::SpillInformation::Print() {
PrintF("\n");
}
#endif // DEBUG
void DescriptorArray::PrintDescriptors() {
PrintF("Descriptor array %d\n", number_of_descriptors());
#ifdef OBJECT_PRINT
void DescriptorArray::PrintDescriptors(FILE* out) {
PrintF(out, "Descriptor array %d\n", number_of_descriptors());
for (int i = 0; i < number_of_descriptors(); i++) {
PrintF(" %d: ", i);
PrintF(out, " %d: ", i);
Descriptor desc;
Get(i, &desc);
desc.Print();
desc.Print(out);
}
PrintF("\n");
PrintF(out, "\n");
}
#endif // OBJECT_PRINT
#ifdef DEBUG
bool DescriptorArray::IsSortedNoDuplicates() {
String* current_key = NULL;
uint32_t current = 0;
......
......@@ -553,11 +553,11 @@ Object* Object::GetPrototype() {
}
void Object::ShortPrint() {
void Object::ShortPrint(FILE* out) {
HeapStringAllocator allocator;
StringStream accumulator(&allocator);
ShortPrint(&accumulator);
accumulator.OutputToStdOut();
accumulator.OutputToFile(out);
}
......@@ -572,8 +572,8 @@ void Object::ShortPrint(StringStream* accumulator) {
}
void Smi::SmiPrint() {
PrintF("%d", value());
void Smi::SmiPrint(FILE* out) {
PrintF(out, "%d", value());
}
......@@ -587,8 +587,8 @@ void Failure::FailurePrint(StringStream* accumulator) {
}
void Failure::FailurePrint() {
PrintF("Failure(%p)", reinterpret_cast<void*>(value()));
void Failure::FailurePrint(FILE* out) {
PrintF(out, "Failure(%p)", reinterpret_cast<void*>(value()));
}
......@@ -1141,8 +1141,8 @@ Object* HeapNumber::HeapNumberToBoolean() {
}
void HeapNumber::HeapNumberPrint() {
PrintF("%.16g", Number());
void HeapNumber::HeapNumberPrint(FILE* out) {
PrintF(out, "%.16g", Number());
}
......@@ -5467,9 +5467,9 @@ Object* JSFunction::SetInstanceClassName(String* name) {
}
void JSFunction::PrintName() {
void JSFunction::PrintName(FILE* out) {
SmartPointer<char> name = shared()->DebugName()->ToCString();
PrintF("%s", *name);
PrintF(out, "%s", *name);
}
......@@ -5999,18 +5999,18 @@ Map* Code::FindFirstMap() {
#ifdef ENABLE_DISASSEMBLER
#ifdef DEBUG
#ifdef OBJECT_PRINT
void DeoptimizationInputData::DeoptimizationInputDataPrint() {
void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) {
disasm::NameConverter converter;
int deopt_count = DeoptCount();
PrintF("Deoptimization Input Data (deopt points = %d)\n", deopt_count);
PrintF(out, "Deoptimization Input Data (deopt points = %d)\n", deopt_count);
if (0 == deopt_count) return;
PrintF("%6s %6s %6s %12s\n", "index", "ast id", "argc", "commands");
PrintF(out, "%6s %6s %6s %12s\n", "index", "ast id", "argc", "commands");
for (int i = 0; i < deopt_count; i++) {
int command_count = 0;
PrintF("%6d %6d %6d",
PrintF(out, "%6d %6d %6d",
i, AstId(i)->value(), ArgumentsStackHeight(i)->value());
int translation_index = TranslationIndex(i)->value();
TranslationIterator iterator(TranslationByteArray(), translation_index);
......@@ -6019,7 +6019,8 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint() {
ASSERT(Translation::BEGIN == opcode);
int frame_count = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF(" %s {count=%d}\n", Translation::StringFor(opcode), frame_count);
PrintF(out, " %s {count=%d}\n", Translation::StringFor(opcode),
frame_count);
}
for (int i = 0; i < frame_count; ++i) {
......@@ -6031,10 +6032,10 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint() {
JSFunction::cast(LiteralArray()->get(function_id));
unsigned height = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF("%24s %s {ast_id=%d, function=",
PrintF(out, "%24s %s {ast_id=%d, function=",
"", Translation::StringFor(opcode), ast_id);
function->PrintName();
PrintF(", height=%u}\n", height);
function->PrintName(out);
PrintF(out, ", height=%u}\n", height);
}
// Size of translation is height plus all incoming arguments including
......@@ -6044,13 +6045,13 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint() {
for (int j = 0; j < size; ++j) {
opcode = static_cast<Translation::Opcode>(iterator.Next());
if (FLAG_print_code_verbose) {
PrintF("%24s %s ", "", Translation::StringFor(opcode));
PrintF(out, "%24s %s ", "", Translation::StringFor(opcode));
}
if (opcode == Translation::DUPLICATE) {
opcode = static_cast<Translation::Opcode>(iterator.Next());
if (FLAG_print_code_verbose) {
PrintF("%s ", Translation::StringFor(opcode));
PrintF(out, "%s ", Translation::StringFor(opcode));
}
--j; // Two commands share the same frame index.
}
......@@ -6065,7 +6066,7 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint() {
case Translation::REGISTER: {
int reg_code = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF("{input=%s}", converter.NameOfCPURegister(reg_code));
PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code));
}
break;
}
......@@ -6073,7 +6074,7 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint() {
case Translation::INT32_REGISTER: {
int reg_code = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF("{input=%s}", converter.NameOfCPURegister(reg_code));
PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code));
}
break;
}
......@@ -6081,7 +6082,7 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint() {
case Translation::DOUBLE_REGISTER: {
int reg_code = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF("{input=%s}",
PrintF(out, "{input=%s}",
DoubleRegister::AllocationIndexToString(reg_code));
}
break;
......@@ -6090,7 +6091,7 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint() {
case Translation::STACK_SLOT: {
int input_slot_index = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF("{input=%d}", input_slot_index);
PrintF(out, "{input=%d}", input_slot_index);
}
break;
}
......@@ -6098,7 +6099,7 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint() {
case Translation::INT32_STACK_SLOT: {
int input_slot_index = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF("{input=%d}", input_slot_index);
PrintF(out, "{input=%d}", input_slot_index);
}
break;
}
......@@ -6106,7 +6107,7 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint() {
case Translation::DOUBLE_STACK_SLOT: {
int input_slot_index = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF("{input=%d}", input_slot_index);
PrintF(out, "{input=%d}", input_slot_index);
}
break;
}
......@@ -6114,7 +6115,7 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint() {
case Translation::LITERAL: {
unsigned literal_index = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF("{literal_id=%u}", literal_index);
PrintF(out, "{literal_id=%u}", literal_index);
}
break;
}
......@@ -6122,16 +6123,16 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint() {
case Translation::ARGUMENTS_OBJECT:
break;
}
if (FLAG_print_code_verbose) PrintF("\n");
if (FLAG_print_code_verbose) PrintF(out, "\n");
}
}
if (!FLAG_print_code_verbose) PrintF(" %12d\n", command_count);
if (!FLAG_print_code_verbose) PrintF(out, " %12d\n", command_count);
}
}
void DeoptimizationOutputData::DeoptimizationOutputDataPrint() {
PrintF("Deoptimization Output Data (deopt points = %d)\n",
void DeoptimizationOutputData::DeoptimizationOutputDataPrint(FILE* out) {
PrintF(out, "Deoptimization Output Data (deopt points = %d)\n",
this->DeoptPoints());
if (this->DeoptPoints() == 0) return;
......@@ -6202,56 +6203,56 @@ const char* Code::PropertyType2String(PropertyType type) {
}
void Code::Disassemble(const char* name) {
PrintF("kind = %s\n", Kind2String(kind()));
void Code::Disassemble(const char* name, FILE* out) {
PrintF(out, "kind = %s\n", Kind2String(kind()));
if (is_inline_cache_stub()) {
PrintF("ic_state = %s\n", ICState2String(ic_state()));
PrintF("ic_in_loop = %d\n", ic_in_loop() == IN_LOOP);
PrintF(out, "ic_state = %s\n", ICState2String(ic_state()));
PrintF(out, "ic_in_loop = %d\n", ic_in_loop() == IN_LOOP);
if (ic_state() == MONOMORPHIC) {
PrintF("type = %s\n", PropertyType2String(type()));
PrintF(out, "type = %s\n", PropertyType2String(type()));
}
}
if ((name != NULL) && (name[0] != '\0')) {
PrintF("name = %s\n", name);
PrintF(out, "name = %s\n", name);
}
if (kind() == OPTIMIZED_FUNCTION) {
PrintF("stack_slots = %d\n", stack_slots());
PrintF(out, "stack_slots = %d\n", stack_slots());
}
PrintF("Instructions (size = %d)\n", instruction_size());
Disassembler::Decode(NULL, this);
PrintF("\n");
PrintF(out, "Instructions (size = %d)\n", instruction_size());
Disassembler::Decode(out, this);
PrintF(out, "\n");
#ifdef DEBUG
if (kind() == FUNCTION) {
DeoptimizationOutputData* data =
DeoptimizationOutputData::cast(this->deoptimization_data());
data->DeoptimizationOutputDataPrint();
data->DeoptimizationOutputDataPrint(out);
} else if (kind() == OPTIMIZED_FUNCTION) {
DeoptimizationInputData* data =
DeoptimizationInputData::cast(this->deoptimization_data());
data->DeoptimizationInputDataPrint();
data->DeoptimizationInputDataPrint(out);
}
PrintF("\n");
#endif
if (kind() == OPTIMIZED_FUNCTION) {
SafepointTable table(this);
PrintF("Safepoints (size = %u)\n", table.size());
PrintF(out, "Safepoints (size = %u)\n", table.size());
for (unsigned i = 0; i < table.length(); i++) {
unsigned pc_offset = table.GetPcOffset(i);
PrintF("%p %4d ", (instruction_start() + pc_offset), pc_offset);
PrintF(out, "%p %4d ", (instruction_start() + pc_offset), pc_offset);
table.PrintEntry(i);
PrintF(" (sp -> fp)");
PrintF(out, " (sp -> fp)");
int deoptimization_index = table.GetDeoptimizationIndex(i);
if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) {
PrintF(" %6d", deoptimization_index);
PrintF(out, " %6d", deoptimization_index);
} else {
PrintF(" <none>");
PrintF(out, " <none>");
}
PrintF("\n");
PrintF(out, "\n");
}
PrintF("\n");
PrintF(out, "\n");
} else if (kind() == FUNCTION) {
unsigned offset = stack_check_table_start();
// If there is no stack check table, the "table start" will at or after
......@@ -6260,19 +6261,19 @@ void Code::Disassemble(const char* name) {
unsigned* address =
reinterpret_cast<unsigned*>(instruction_start() + offset);
unsigned length = address[0];
PrintF("Stack checks (size = %u)\n", length);
PrintF("ast_id pc_offset\n");
PrintF(out, "Stack checks (size = %u)\n", length);
PrintF(out, "ast_id pc_offset\n");
for (unsigned i = 0; i < length; ++i) {
unsigned index = (2 * i) + 1;
PrintF("%6u %9u\n", address[index], address[index + 1]);
PrintF(out, "%6u %9u\n", address[index], address[index + 1]);
}
PrintF("\n");
PrintF(out, "\n");
}
}
PrintF("RelocInfo (size = %d)\n", relocation_size());
for (RelocIterator it(this); !it.done(); it.next()) it.rinfo()->Print();
PrintF("\n");
for (RelocIterator it(this); !it.done(); it.next()) it.rinfo()->Print(out);
PrintF(out, "\n");
}
#endif // ENABLE_DISASSEMBLER
......@@ -7421,22 +7422,22 @@ bool JSObject::ShouldConvertToFastElements() {
// class. This requires us to have the template functions put
// together, so even though this function belongs in objects-debug.cc,
// we keep it here instead to satisfy certain compilers.
#ifdef DEBUG
#ifdef OBJECT_PRINT
template<typename Shape, typename Key>
void Dictionary<Shape, Key>::Print() {
void Dictionary<Shape, Key>::Print(FILE* out) {
int capacity = HashTable<Shape, Key>::Capacity();
for (int i = 0; i < capacity; i++) {
Object* k = HashTable<Shape, Key>::KeyAt(i);
if (HashTable<Shape, Key>::IsKey(k)) {
PrintF(" ");
PrintF(out, " ");
if (k->IsString()) {
String::cast(k)->StringPrint();
String::cast(k)->StringPrint(out);
} else {
k->ShortPrint();
k->ShortPrint(out);
}
PrintF(": ");
ValueAt(i)->ShortPrint();
PrintF("\n");
PrintF(out, ": ");
ValueAt(i)->ShortPrint(out);
PrintF(out, "\n");
}
}
}
......
......@@ -607,10 +607,18 @@ class MaybeObject BASE_EMBEDDED {
return reinterpret_cast<Object*>(this);
}
#ifdef DEBUG
#ifdef OBJECT_PRINT
// Prints this object with details.
void Print();
void PrintLn();
inline void Print() {
Print(stdout);
};
inline void PrintLn() {
PrintLn(stdout);
}
void Print(FILE* out);
void PrintLn(FILE* out);
#endif
#ifdef DEBUG
// Verifies the object.
void Verify();
#endif
......@@ -762,7 +770,10 @@ class Object : public MaybeObject {
#endif
// Prints this object without details.
void ShortPrint();
inline void ShortPrint() {
ShortPrint(stdout);
}
void ShortPrint(FILE* out);
// Prints this object without details to a message accumulator.
void ShortPrint(StringStream* accumulator);
......@@ -801,7 +812,10 @@ class Smi: public Object {
static inline Smi* cast(Object* object);
// Dispatched behavior.
void SmiPrint();
inline void SmiPrint() {
SmiPrint(stdout);
}
void SmiPrint(FILE* out);
void SmiPrint(StringStream* accumulator);
#ifdef DEBUG
void SmiVerify();
......@@ -870,7 +884,10 @@ class Failure: public MaybeObject {
static inline Failure* cast(MaybeObject* object);
// Dispatched behavior.
void FailurePrint();
inline void FailurePrint() {
FailurePrint(stdout);
}
void FailurePrint(FILE* out);
void FailurePrint(StringStream* accumulator);
#ifdef DEBUG
void FailureVerify();
......@@ -1099,14 +1116,23 @@ class HeapObject: public Object {
// Dispatched behavior.
void HeapObjectShortPrint(StringStream* accumulator);
#ifdef OBJECT_PRINT
inline void HeapObjectPrint() {
HeapObjectPrint(stdout);
}
void HeapObjectPrint(FILE* out);
#endif
#ifdef DEBUG
void HeapObjectPrint();
void HeapObjectVerify();
inline void VerifyObjectField(int offset);
inline void VerifySmiField(int offset);
#endif
void PrintHeader(const char* id);
#ifdef OBJECT_PRINT
void PrintHeader(FILE* out, const char* id);
#endif
#ifdef DEBUG
// Verify a pointer is a valid HeapObject pointer that points to object
// areas in the heap.
static void VerifyHeapPointer(Object* p);
......@@ -1189,7 +1215,10 @@ class HeapNumber: public HeapObject {
// Dispatched behavior.
Object* HeapNumberToBoolean();
void HeapNumberPrint();
inline void HeapNumberPrint() {
HeapNumberPrint(stdout);
}
void HeapNumberPrint(FILE* out);
void HeapNumberPrint(StringStream* accumulator);
#ifdef DEBUG
void HeapNumberVerify();
......@@ -1649,12 +1678,28 @@ class JSObject: public HeapObject {
// Dispatched behavior.
void JSObjectShortPrint(StringStream* accumulator);
#ifdef OBJECT_PRINT
inline void JSObjectPrint() {
JSObjectPrint(stdout);
}
void JSObjectPrint(FILE* out);
#endif
#ifdef DEBUG
void JSObjectPrint();
void JSObjectVerify();
void PrintProperties();
void PrintElements();
#endif
#ifdef OBJECT_PRINT
inline void PrintProperties() {
PrintProperties(stdout);
}
void PrintProperties(FILE* out);
inline void PrintElements() {
PrintElements(stdout);
}
void PrintElements(FILE* out);
#endif
#ifdef DEBUG
// Structure for collecting spill information about JSObjects.
class SpillInformation {
public:
......@@ -1835,8 +1880,13 @@ class FixedArray: public HeapObject {
static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize;
// Dispatched behavior.
#ifdef OBJECT_PRINT
inline void FixedArrayPrint() {
FixedArrayPrint(stdout);
}
void FixedArrayPrint(FILE* out);
#endif
#ifdef DEBUG
void FixedArrayPrint();
void FixedArrayVerify();
// Checks if two FixedArrays have identical contents.
bool IsEqualTo(FixedArray* other);
......@@ -2012,10 +2062,15 @@ class DescriptorArray: public FixedArray {
static const int kEnumCacheBridgeCacheOffset =
kEnumCacheBridgeEnumOffset + kPointerSize;
#ifdef DEBUG
#ifdef OBJECT_PRINT
// Print all the descriptors.
void PrintDescriptors();
inline void PrintDescriptors() {
PrintDescriptors(stdout);
}
void PrintDescriptors(FILE* out);
#endif
#ifdef DEBUG
// Is the descriptor array sorted and without duplicates?
bool IsSortedNoDuplicates();
......@@ -2396,8 +2451,11 @@ class Dictionary: public HashTable<Shape, Key> {
// Ensure enough space for n additional elements.
MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key);
#ifdef DEBUG
void Print();
#ifdef OBJECT_PRINT
inline void Print() {
Print(stdout);
}
void Print(FILE* out);
#endif
// Returns the key (slow).
Object* SlowReverseLookup(Object* value);
......@@ -2619,8 +2677,13 @@ class ByteArray: public HeapObject {
inline int ByteArraySize() {
return SizeFor(this->length());
}
#ifdef OBJECT_PRINT
inline void ByteArrayPrint() {
ByteArrayPrint(stdout);
}
void ByteArrayPrint(FILE* out);
#endif
#ifdef DEBUG
void ByteArrayPrint();
void ByteArrayVerify();
#endif
......@@ -2669,8 +2732,13 @@ class PixelArray: public HeapObject {
// Casting.
static inline PixelArray* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void PixelArrayPrint() {
PixelArrayPrint(stdout);
}
void PixelArrayPrint(FILE* out);
#endif
#ifdef DEBUG
void PixelArrayPrint();
void PixelArrayVerify();
#endif // DEBUG
......@@ -2741,8 +2809,13 @@ class ExternalByteArray: public ExternalArray {
// Casting.
static inline ExternalByteArray* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void ExternalByteArrayPrint() {
ExternalByteArrayPrint(stdout);
}
void ExternalByteArrayPrint(FILE* out);
#endif
#ifdef DEBUG
void ExternalByteArrayPrint();
void ExternalByteArrayVerify();
#endif // DEBUG
......@@ -2764,8 +2837,13 @@ class ExternalUnsignedByteArray: public ExternalArray {
// Casting.
static inline ExternalUnsignedByteArray* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void ExternalUnsignedByteArrayPrint() {
ExternalUnsignedByteArrayPrint(stdout);
}
void ExternalUnsignedByteArrayPrint(FILE* out);
#endif
#ifdef DEBUG
void ExternalUnsignedByteArrayPrint();
void ExternalUnsignedByteArrayVerify();
#endif // DEBUG
......@@ -2787,8 +2865,13 @@ class ExternalShortArray: public ExternalArray {
// Casting.
static inline ExternalShortArray* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void ExternalShortArrayPrint() {
ExternalShortArrayPrint(stdout);
}
void ExternalShortArrayPrint(FILE* out);
#endif
#ifdef DEBUG
void ExternalShortArrayPrint();
void ExternalShortArrayVerify();
#endif // DEBUG
......@@ -2810,8 +2893,13 @@ class ExternalUnsignedShortArray: public ExternalArray {
// Casting.
static inline ExternalUnsignedShortArray* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void ExternalUnsignedShortArrayPrint() {
ExternalUnsignedShortArrayPrint(stdout);
}
void ExternalUnsignedShortArrayPrint(FILE* out);
#endif
#ifdef DEBUG
void ExternalUnsignedShortArrayPrint();
void ExternalUnsignedShortArrayVerify();
#endif // DEBUG
......@@ -2833,8 +2921,13 @@ class ExternalIntArray: public ExternalArray {
// Casting.
static inline ExternalIntArray* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void ExternalIntArrayPrint() {
ExternalIntArrayPrint(stdout);
}
void ExternalIntArrayPrint(FILE* out);
#endif
#ifdef DEBUG
void ExternalIntArrayPrint();
void ExternalIntArrayVerify();
#endif // DEBUG
......@@ -2856,8 +2949,13 @@ class ExternalUnsignedIntArray: public ExternalArray {
// Casting.
static inline ExternalUnsignedIntArray* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void ExternalUnsignedIntArrayPrint() {
ExternalUnsignedIntArrayPrint(stdout);
}
void ExternalUnsignedIntArrayPrint(FILE* out);
#endif
#ifdef DEBUG
void ExternalUnsignedIntArrayPrint();
void ExternalUnsignedIntArrayVerify();
#endif // DEBUG
......@@ -2879,8 +2977,13 @@ class ExternalFloatArray: public ExternalArray {
// Casting.
static inline ExternalFloatArray* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void ExternalFloatArrayPrint() {
ExternalFloatArrayPrint(stdout);
}
void ExternalFloatArrayPrint(FILE* out);
#endif
#ifdef DEBUG
void ExternalFloatArrayPrint();
void ExternalFloatArrayVerify();
#endif // DEBUG
......@@ -2960,8 +3063,8 @@ class DeoptimizationInputData: public FixedArray {
// Casting.
static inline DeoptimizationInputData* cast(Object* obj);
#ifdef DEBUG
void DeoptimizationInputDataPrint();
#ifdef OBJECT_PRINT
void DeoptimizationInputDataPrint(FILE* out);
#endif
private:
......@@ -2999,8 +3102,8 @@ class DeoptimizationOutputData: public FixedArray {
// Casting.
static inline DeoptimizationOutputData* cast(Object* obj);
#ifdef DEBUG
void DeoptimizationOutputDataPrint();
#ifdef OBJECT_PRINT
void DeoptimizationOutputDataPrint(FILE* out);
#endif
};
......@@ -3049,7 +3152,10 @@ class Code: public HeapObject {
static const char* Kind2String(Kind kind);
static const char* ICState2String(InlineCacheState state);
static const char* PropertyType2String(PropertyType type);
void Disassemble(const char* name);
inline void Disassemble(const char* name) {
Disassemble(name, stdout);
}
void Disassemble(const char* name, FILE* out);
#endif // ENABLE_DISASSEMBLER
// [instruction_size]: Size of the native instructions
......@@ -3242,8 +3348,13 @@ class Code: public HeapObject {
template<typename StaticVisitor>
inline void CodeIterateBody();
#ifdef OBJECT_PRINT
inline void CodePrint() {
CodePrint(stdout);
}
void CodePrint(FILE* out);
#endif
#ifdef DEBUG
void CodePrint();
void CodeVerify();
#endif
......@@ -3531,8 +3642,13 @@ class Map: public HeapObject {
void ClearNonLiveTransitions(Object* real_prototype);
// Dispatched behavior.
#ifdef OBJECT_PRINT
inline void MapPrint() {
MapPrint(stdout);
}
void MapPrint(FILE* out);
#endif
#ifdef DEBUG
void MapPrint();
void MapVerify();
void SharedMapVerify();
#endif
......@@ -3688,8 +3804,13 @@ class Script: public Struct {
// resource is accessible. Otherwise, always return true.
inline bool HasValidSource();
#ifdef OBJECT_PRINT
inline void ScriptPrint() {
ScriptPrint(stdout);
}
void ScriptPrint(FILE* out);
#endif
#ifdef DEBUG
void ScriptPrint();
void ScriptVerify();
#endif
......@@ -4052,8 +4173,13 @@ class SharedFunctionInfo: public HeapObject {
// Dispatched behavior.
// Set max_length to -1 for unlimited length.
void SourceCodePrint(StringStream* accumulator, int max_length);
#ifdef OBJECT_PRINT
inline void SharedFunctionInfoPrint() {
SharedFunctionInfoPrint(stdout);
}
void SharedFunctionInfoPrint(FILE* out);
#endif
#ifdef DEBUG
void SharedFunctionInfoPrint();
void SharedFunctionInfoVerify();
#endif
......@@ -4285,7 +4411,10 @@ class JSFunction: public JSObject {
DECL_ACCESSORS(next_function_link, Object)
// Prints the name of the function using PrintF.
void PrintName();
inline void PrintName() {
PrintName(stdout);
}
void PrintName(FILE* out);
// Casting.
static inline JSFunction* cast(Object* obj);
......@@ -4295,8 +4424,13 @@ class JSFunction: public JSObject {
void JSFunctionIterateBody(int object_size, ObjectVisitor* v);
// Dispatched behavior.
#ifdef OBJECT_PRINT
inline void JSFunctionPrint() {
JSFunctionPrint(stdout);
}
void JSFunctionPrint(FILE* out);
#endif
#ifdef DEBUG
void JSFunctionPrint();
void JSFunctionVerify();
#endif
......@@ -4345,8 +4479,13 @@ class JSGlobalProxy : public JSObject {
static inline JSGlobalProxy* cast(Object* obj);
// Dispatched behavior.
#ifdef OBJECT_PRINT
inline void JSGlobalProxyPrint() {
JSGlobalProxyPrint(stdout);
}
void JSGlobalProxyPrint(FILE* out);
#endif
#ifdef DEBUG
void JSGlobalProxyPrint();
void JSGlobalProxyVerify();
#endif
......@@ -4416,8 +4555,13 @@ class JSGlobalObject: public GlobalObject {
static inline JSGlobalObject* cast(Object* obj);
// Dispatched behavior.
#ifdef OBJECT_PRINT
inline void JSGlobalObjectPrint() {
JSGlobalObjectPrint(stdout);
}
void JSGlobalObjectPrint(FILE* out);
#endif
#ifdef DEBUG
void JSGlobalObjectPrint();
void JSGlobalObjectVerify();
#endif
......@@ -4445,8 +4589,13 @@ class JSBuiltinsObject: public GlobalObject {
static inline JSBuiltinsObject* cast(Object* obj);
// Dispatched behavior.
#ifdef OBJECT_PRINT
inline void JSBuiltinsObjectPrint() {
JSBuiltinsObjectPrint(stdout);
}
void JSBuiltinsObjectPrint(FILE* out);
#endif
#ifdef DEBUG
void JSBuiltinsObjectPrint();
void JSBuiltinsObjectVerify();
#endif
......@@ -4483,8 +4632,13 @@ class JSValue: public JSObject {
static inline JSValue* cast(Object* obj);
// Dispatched behavior.
#ifdef OBJECT_PRINT
inline void JSValuePrint() {
JSValuePrint(stdout);
}
void JSValuePrint(FILE* out);
#endif
#ifdef DEBUG
void JSValuePrint();
void JSValueVerify();
#endif
......@@ -4673,8 +4827,13 @@ class CodeCache: public Struct {
static inline CodeCache* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void CodeCachePrint() {
CodeCachePrint(stdout);
}
void CodeCachePrint(FILE* out);
#endif
#ifdef DEBUG
void CodeCachePrint();
void CodeCacheVerify();
#endif
......@@ -4975,8 +5134,13 @@ class String: public HeapObject {
// Dispatched behavior.
void StringShortPrint(StringStream* accumulator);
#ifdef OBJECT_PRINT
inline void StringPrint() {
StringPrint(stdout);
}
void StringPrint(FILE* out);
#endif
#ifdef DEBUG
void StringPrint();
void StringVerify();
#endif
inline bool IsFlat();
......@@ -5531,7 +5695,12 @@ class JSGlobalPropertyCell: public HeapObject {
#ifdef DEBUG
void JSGlobalPropertyCellVerify();
void JSGlobalPropertyCellPrint();
#endif
#ifdef OBJECT_PRINT
inline void JSGlobalPropertyCellPrint() {
JSGlobalPropertyCellPrint(stdout);
}
void JSGlobalPropertyCellPrint(FILE* out);
#endif
// Layout description.
......@@ -5566,8 +5735,13 @@ class Proxy: public HeapObject {
template<typename StaticVisitor>
inline void ProxyIterateBody();
#ifdef OBJECT_PRINT
inline void ProxyPrint() {
ProxyPrint(stdout);
}
void ProxyPrint(FILE* out);
#endif
#ifdef DEBUG
void ProxyPrint();
void ProxyVerify();
#endif
......@@ -5616,8 +5790,13 @@ class JSArray: public JSObject {
inline void EnsureSize(int minimum_size_of_backing_fixed_array);
// Dispatched behavior.
#ifdef OBJECT_PRINT
inline void JSArrayPrint() {
JSArrayPrint(stdout);
}
void JSArrayPrint(FILE* out);
#endif
#ifdef DEBUG
void JSArrayPrint();
void JSArrayVerify();
#endif
......@@ -5688,8 +5867,13 @@ class AccessorInfo: public Struct {
static inline AccessorInfo* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void AccessorInfoPrint() {
AccessorInfoPrint(stdout);
}
void AccessorInfoPrint(FILE* out);
#endif
#ifdef DEBUG
void AccessorInfoPrint();
void AccessorInfoVerify();
#endif
......@@ -5719,8 +5903,13 @@ class AccessCheckInfo: public Struct {
static inline AccessCheckInfo* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void AccessCheckInfoPrint() {
AccessCheckInfoPrint(stdout);
}
void AccessCheckInfoPrint(FILE* out);
#endif
#ifdef DEBUG
void AccessCheckInfoPrint();
void AccessCheckInfoVerify();
#endif
......@@ -5745,8 +5934,13 @@ class InterceptorInfo: public Struct {
static inline InterceptorInfo* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void InterceptorInfoPrint() {
InterceptorInfoPrint(stdout);
}
void InterceptorInfoPrint(FILE* out);
#endif
#ifdef DEBUG
void InterceptorInfoPrint();
void InterceptorInfoVerify();
#endif
......@@ -5770,8 +5964,13 @@ class CallHandlerInfo: public Struct {
static inline CallHandlerInfo* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void CallHandlerInfoPrint() {
CallHandlerInfoPrint(stdout);
}
void CallHandlerInfoPrint(FILE* out);
#endif
#ifdef DEBUG
void CallHandlerInfoPrint();
void CallHandlerInfoVerify();
#endif
......@@ -5827,8 +6026,13 @@ class FunctionTemplateInfo: public TemplateInfo {
static inline FunctionTemplateInfo* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void FunctionTemplateInfoPrint() {
FunctionTemplateInfoPrint(stdout);
}
void FunctionTemplateInfoPrint(FILE* out);
#endif
#ifdef DEBUG
void FunctionTemplateInfoPrint();
void FunctionTemplateInfoVerify();
#endif
......@@ -5870,8 +6074,13 @@ class ObjectTemplateInfo: public TemplateInfo {
static inline ObjectTemplateInfo* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void ObjectTemplateInfoPrint() {
ObjectTemplateInfoPrint(stdout);
}
void ObjectTemplateInfoPrint(FILE* out);
#endif
#ifdef DEBUG
void ObjectTemplateInfoPrint();
void ObjectTemplateInfoVerify();
#endif
......@@ -5889,8 +6098,13 @@ class SignatureInfo: public Struct {
static inline SignatureInfo* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void SignatureInfoPrint() {
SignatureInfoPrint(stdout);
}
void SignatureInfoPrint(FILE* out);
#endif
#ifdef DEBUG
void SignatureInfoPrint();
void SignatureInfoVerify();
#endif
......@@ -5909,8 +6123,13 @@ class TypeSwitchInfo: public Struct {
static inline TypeSwitchInfo* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void TypeSwitchInfoPrint() {
TypeSwitchInfoPrint(stdout);
}
void TypeSwitchInfoPrint(FILE* out);
#endif
#ifdef DEBUG
void TypeSwitchInfoPrint();
void TypeSwitchInfoVerify();
#endif
......@@ -5956,8 +6175,13 @@ class DebugInfo: public Struct {
static inline DebugInfo* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void DebugInfoPrint() {
DebugInfoPrint(stdout);
}
void DebugInfoPrint(FILE* out);
#endif
#ifdef DEBUG
void DebugInfoPrint();
void DebugInfoVerify();
#endif
......@@ -6009,8 +6233,13 @@ class BreakPointInfo: public Struct {
static inline BreakPointInfo* cast(Object* obj);
#ifdef OBJECT_PRINT
inline void BreakPointInfoPrint() {
BreakPointInfoPrint(stdout);
}
void BreakPointInfoPrint(FILE* out);
#endif
#ifdef DEBUG
void BreakPointInfoPrint();
void BreakPointInfoVerify();
#endif
......
......@@ -128,6 +128,19 @@ void OS::VPrint(const char* format, va_list args) {
}
void OS::FPrint(FILE* out, const char* format, ...) {
va_list args;
va_start(args, format);
VFPrint(out, format, args);
va_end(args);
}
void OS::VFPrint(FILE* out, const char* format, va_list args) {
vfprintf(out, format, args);
}
// Print error message to console.
void OS::PrintError(const char* format, ...) {
// Minimalistic implementation for bootstrapping.
......
......@@ -142,6 +142,23 @@ void OS::VPrint(const char* format, va_list args) {
}
void OS::FPrint(FILE* out, const char* format, ...) {
va_list args;
va_start(args, format);
VFPrint(out, format, args);
va_end(args);
}
void OS::VFPrint(FILE* out, const char* format, va_list args) {
#if defined(ANDROID)
LOG_PRI_VA(ANDROID_LOG_INFO, LOG_TAG, format, args);
#else
vfprintf(out, format, args);
#endif
}
void OS::PrintError(const char* format, ...) {
va_list args;
va_start(args, format);
......@@ -173,7 +190,9 @@ int OS::VSNPrintF(Vector<char> str,
va_list args) {
int n = vsnprintf(str.start(), str.length(), format, args);
if (n < 0 || n >= str.length()) {
str[str.length() - 1] = '\0';
// If the length is zero, the assignment fails.
if (str.length() > 0)
str[str.length() - 1] = '\0';
return -1;
} else {
return n;
......
......@@ -688,6 +688,19 @@ void OS::VPrint(const char* format, va_list args) {
}
void OS::FPrint(FILE* out, const char* format, ...) {
va_list args;
va_start(args, format);
VFPrint(out, format, args);
va_end(args);
}
void OS::VFPrint(FILE* out, const char* format, va_list args) {
VPrintHelper(out, format, args);
}
// Print error message to console.
void OS::PrintError(const char* format, ...) {
va_list args;
......@@ -716,7 +729,8 @@ int OS::VSNPrintF(Vector<char> str, const char* format, va_list args) {
// Make sure to zero-terminate the string if the output was
// truncated or if there was an error.
if (n < 0 || n >= str.length()) {
str[str.length() - 1] = '\0';
if (str.length() > 0)
str[str.length() - 1] = '\0';
return -1;
} else {
return n;
......
......@@ -184,6 +184,10 @@ class OS {
static void Print(const char* format, ...);
static void VPrint(const char* format, va_list args);
// Print output to a file. This is mostly used for debugging output.
static void FPrint(FILE* out, const char* format, ...);
static void VFPrint(FILE* out, const char* format, va_list args);
// Print error output to console. This is mostly used for error message
// output. On platforms that has standard terminal output, the output
// should go to stderr.
......
......@@ -31,62 +31,62 @@ namespace v8 {
namespace internal {
#ifdef DEBUG
void LookupResult::Print() {
#ifdef OBJECT_PRINT
void LookupResult::Print(FILE* out) {
if (!IsFound()) {
PrintF("Not Found\n");
PrintF(out, "Not Found\n");
return;
}
PrintF("LookupResult:\n");
PrintF(" -cacheable = %s\n", IsCacheable() ? "true" : "false");
PrintF(" -attributes = %x\n", GetAttributes());
PrintF(out, "LookupResult:\n");
PrintF(out, " -cacheable = %s\n", IsCacheable() ? "true" : "false");
PrintF(out, " -attributes = %x\n", GetAttributes());
switch (type()) {
case NORMAL:
PrintF(" -type = normal\n");
PrintF(" -entry = %d", GetDictionaryEntry());
PrintF(out, " -type = normal\n");
PrintF(out, " -entry = %d", GetDictionaryEntry());
break;
case MAP_TRANSITION:
PrintF(" -type = map transition\n");
PrintF(" -map:\n");
GetTransitionMap()->Print();
PrintF("\n");
PrintF(out, " -type = map transition\n");
PrintF(out, " -map:\n");
GetTransitionMap()->Print(out);
PrintF(out, "\n");
break;
case CONSTANT_FUNCTION:
PrintF(" -type = constant function\n");
PrintF(" -function:\n");
GetConstantFunction()->Print();
PrintF("\n");
PrintF(out, " -type = constant function\n");
PrintF(out, " -function:\n");
GetConstantFunction()->Print(out);
PrintF(out, "\n");
break;
case FIELD:
PrintF(" -type = field\n");
PrintF(" -index = %d", GetFieldIndex());
PrintF("\n");
PrintF(out, " -type = field\n");
PrintF(out, " -index = %d", GetFieldIndex());
PrintF(out, "\n");
break;
case CALLBACKS:
PrintF(" -type = call backs\n");
PrintF(" -callback object:\n");
GetCallbackObject()->Print();
PrintF(out, " -type = call backs\n");
PrintF(out, " -callback object:\n");
GetCallbackObject()->Print(out);
break;
case INTERCEPTOR:
PrintF(" -type = lookup interceptor\n");
PrintF(out, " -type = lookup interceptor\n");
break;
case CONSTANT_TRANSITION:
PrintF(" -type = constant property transition\n");
PrintF(out, " -type = constant property transition\n");
break;
case NULL_DESCRIPTOR:
PrintF(" =type = null descriptor\n");
PrintF(out, " =type = null descriptor\n");
break;
}
}
void Descriptor::Print() {
PrintF("Descriptor ");
GetKey()->ShortPrint();
PrintF(" @ ");
GetValue()->ShortPrint();
PrintF(" %d\n", GetDetails().index());
void Descriptor::Print(FILE* out) {
PrintF(out, "Descriptor ");
GetKey()->ShortPrint(out);
PrintF(out, " @ ");
GetValue()->ShortPrint(out);
PrintF(out, " %d\n", GetDetails().index());
}
......
......@@ -60,8 +60,8 @@ class Descriptor BASE_EMBEDDED {
Object* GetValue() { return value_; }
PropertyDetails GetDetails() { return details_; }
#ifdef DEBUG
void Print();
#ifdef OBJECT_PRINT
void Print(FILE* out);
#endif
void SetEnumerationIndex(int index) {
......@@ -310,8 +310,8 @@ class LookupResult BASE_EMBEDDED {
return GetValue();
}
#ifdef DEBUG
void Print();
#ifdef OBJECT_PRINT
void Print(FILE* out);
#endif
Object* GetValue() {
......
......@@ -264,7 +264,7 @@ void StringStream::Log() {
}
void StringStream::OutputToStdOut() {
void StringStream::OutputToFile(FILE* out) {
// Dump the output to stdout, but make sure to break it up into
// manageable chunks to avoid losing parts of the output in the OS
// printing code. This is a problem on Windows in particular; see
......@@ -273,10 +273,10 @@ void StringStream::OutputToStdOut() {
for (unsigned next; (next = position + 2048) < length_; position = next) {
char save = buffer_[next];
buffer_[next] = '\0';
internal::PrintF("%s", &buffer_[position]);
internal::PrintF(out, "%s", &buffer_[position]);
buffer_[next] = save;
}
internal::PrintF("%s", &buffer_[position]);
internal::PrintF(out, "%s", &buffer_[position]);
}
......
......@@ -138,7 +138,8 @@ class StringStream {
FmtElm arg3);
// Getting the message out.
void OutputToStdOut();
void OutputToFile(FILE* out);
void OutputToStdOut() { OutputToFile(stdout); }
void Log();
Handle<String> ToString();
SmartPointer<const char> ToCString() const;
......
......@@ -45,8 +45,16 @@ void PrintF(const char* format, ...) {
}
void Flush() {
fflush(stdout);
void PrintF(FILE* out, const char* format, ...) {
va_list arguments;
va_start(arguments, format);
OS::VFPrint(out, format, arguments);
va_end(arguments);
}
void Flush(FILE* out) {
fflush(out);
}
......
......@@ -42,18 +42,26 @@ namespace internal {
// so it works on MacOSX.
#if defined(__MACH__) && defined(__APPLE__)
#define PRINTF_CHECKING
#define FPRINTF_CHECKING
#else // MacOsX.
#define PRINTF_CHECKING __attribute__ ((format (printf, 1, 2)))
#define FPRINTF_CHECKING __attribute__ ((format (printf, 2, 3)))
#endif
#else
#define PRINTF_CHECKING
#define FPRINTF_CHECKING
#endif
// Our version of printf().
void PRINTF_CHECKING PrintF(const char* format, ...);
void FPRINTF_CHECKING PrintF(FILE* out, const char* format, ...);
// Our version of fflush.
void Flush();
void Flush(FILE* out);
inline void Flush() {
Flush(stdout);
}
// Read a line of characters after printing the prompt to stdout. The resulting
......
......@@ -70,7 +70,8 @@
'DEBUG',
'_DEBUG',
'ENABLE_DISASSEMBLER',
'V8_ENABLE_CHECKS'
'V8_ENABLE_CHECKS',
'OBJECT_PRINT',
],
'msvs_settings': {
'VCCLCompilerTool': {
......
......@@ -1850,6 +1850,7 @@
DEBUG,
ENABLE_LOGGING_AND_PROFILING,
V8_ENABLE_CHECKS,
OBJECT_PRINT,
ENABLE_VMSTATE_TRACKING,
);
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
......@@ -1914,6 +1915,7 @@
V8_TARGET_ARCH_IA32,
DEBUG,
V8_ENABLE_CHECKS,
OBJECT_PRINT,
ENABLE_DEBUGGER_SUPPORT,
);
HEADER_SEARCH_PATHS = ../src;
......@@ -1976,6 +1978,7 @@
V8_TARGET_ARCH_IA32,
DEBUG,
V8_ENABLE_CHECKS,
OBJECT_PRINT,
ENABLE_DEBUGGER_SUPPORT,
);
HEADER_SEARCH_PATHS = ../src;
......
......@@ -7,7 +7,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="DEBUG;_DEBUG;ENABLE_DISASSEMBLER;V8_ENABLE_CHECKS"
PreprocessorDefinitions="DEBUG;_DEBUG;ENABLE_DISASSEMBLER;V8_ENABLE_CHECKS,OBJECT_PRINT"
RuntimeLibrary="1"
/>
<Tool
......
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