Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(662)

Unified Diff: src/objects.cc

Issue 5998001: 1. Added support for object printing for release mode using the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
===================================================================
--- src/objects.cc (revision 6074)
+++ src/objects.cc (working copy)
@@ -553,11 +553,11 @@
}
-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 Smi::SmiPrint() {
- PrintF("%d", value());
+void Smi::SmiPrint(FILE* out) {
+ PrintF(out, "%d", value());
}
@@ -587,8 +587,8 @@
}
-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 @@
}
-void HeapNumber::HeapNumberPrint() {
- PrintF("%.16g", Number());
+void HeapNumber::HeapNumberPrint(FILE* out) {
+ PrintF(out, "%.16g", Number());
}
@@ -5467,9 +5467,9 @@
}
-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 @@
#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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
-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 @@
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 @@
// 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");
}
}
}
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698