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

Side by Side Diff: src/objects.cc

Issue 944223003: Use iostream formatting when printing code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months 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 unified diff | Download patch
« no previous file with comments | « src/compiler/scheduler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <iomanip>
5 #include <sstream> 6 #include <sstream>
6 7
7 #include "src/v8.h" 8 #include "src/v8.h"
8 9
9 #include "src/accessors.h" 10 #include "src/accessors.h"
10 #include "src/allocation-site-scopes.h" 11 #include "src/allocation-site-scopes.h"
11 #include "src/api.h" 12 #include "src/api.h"
12 #include "src/arguments.h" 13 #include "src/arguments.h"
13 #include "src/base/bits.h" 14 #include "src/base/bits.h"
14 #include "src/bootstrapper.h" 15 #include "src/bootstrapper.h"
(...skipping 11306 matching lines...) Expand 10 before | Expand all | Expand 10 after
11321 std::ostream& os) { // NOLINT 11322 std::ostream& os) { // NOLINT
11322 disasm::NameConverter converter; 11323 disasm::NameConverter converter;
11323 int deopt_count = DeoptCount(); 11324 int deopt_count = DeoptCount();
11324 os << "Deoptimization Input Data (deopt points = " << deopt_count << ")\n"; 11325 os << "Deoptimization Input Data (deopt points = " << deopt_count << ")\n";
11325 if (0 != deopt_count) { 11326 if (0 != deopt_count) {
11326 os << " index ast id argc pc"; 11327 os << " index ast id argc pc";
11327 if (FLAG_print_code_verbose) os << " commands"; 11328 if (FLAG_print_code_verbose) os << " commands";
11328 os << "\n"; 11329 os << "\n";
11329 } 11330 }
11330 for (int i = 0; i < deopt_count; i++) { 11331 for (int i = 0; i < deopt_count; i++) {
11331 // TODO(svenpanne) Add some basic formatting to our streams. 11332 os << std::setw(6) << i << " " << std::setw(6) << AstId(i).ToInt() << " "
11332 Vector<char> buf1 = Vector<char>::New(128); 11333 << std::setw(6) << ArgumentsStackHeight(i)->value() << " "
11333 SNPrintF(buf1, "%6d %6d %6d %6d", i, AstId(i).ToInt(), 11334 << std::setw(6) << Pc(i)->value();
11334 ArgumentsStackHeight(i)->value(), Pc(i)->value());
11335 os << buf1.start();
11336 11335
11337 if (!FLAG_print_code_verbose) { 11336 if (!FLAG_print_code_verbose) {
11338 os << "\n"; 11337 os << "\n";
11339 continue; 11338 continue;
11340 } 11339 }
11341 // Print details of the frame translation. 11340 // Print details of the frame translation.
11342 int translation_index = TranslationIndex(i)->value(); 11341 int translation_index = TranslationIndex(i)->value();
11343 TranslationIterator iterator(TranslationByteArray(), translation_index); 11342 TranslationIterator iterator(TranslationByteArray(), translation_index);
11344 Translation::Opcode opcode = 11343 Translation::Opcode opcode =
11345 static_cast<Translation::Opcode>(iterator.Next()); 11344 static_cast<Translation::Opcode>(iterator.Next());
11346 DCHECK(Translation::BEGIN == opcode); 11345 DCHECK(Translation::BEGIN == opcode);
11347 int frame_count = iterator.Next(); 11346 int frame_count = iterator.Next();
11348 int jsframe_count = iterator.Next(); 11347 int jsframe_count = iterator.Next();
11349 os << " " << Translation::StringFor(opcode) 11348 os << " " << Translation::StringFor(opcode)
11350 << " {frame count=" << frame_count 11349 << " {frame count=" << frame_count
11351 << ", js frame count=" << jsframe_count << "}\n"; 11350 << ", js frame count=" << jsframe_count << "}\n";
11352 11351
11353 while (iterator.HasNext() && 11352 while (iterator.HasNext() &&
11354 Translation::BEGIN != 11353 Translation::BEGIN !=
11355 (opcode = static_cast<Translation::Opcode>(iterator.Next()))) { 11354 (opcode = static_cast<Translation::Opcode>(iterator.Next()))) {
11356 Vector<char> buf2 = Vector<char>::New(128); 11355 os << std::setw(31) << " " << Translation::StringFor(opcode) << " ";
11357 SNPrintF(buf2, "%27s %s ", "", Translation::StringFor(opcode));
11358 os << buf2.start();
11359 11356
11360 switch (opcode) { 11357 switch (opcode) {
11361 case Translation::BEGIN: 11358 case Translation::BEGIN:
11362 UNREACHABLE(); 11359 UNREACHABLE();
11363 break; 11360 break;
11364 11361
11365 case Translation::JS_FRAME: { 11362 case Translation::JS_FRAME: {
11366 int ast_id = iterator.Next(); 11363 int ast_id = iterator.Next();
11367 int function_id = iterator.Next(); 11364 int function_id = iterator.Next();
11368 unsigned height = iterator.Next(); 11365 unsigned height = iterator.Next();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
11480 11477
11481 void DeoptimizationOutputData::DeoptimizationOutputDataPrint( 11478 void DeoptimizationOutputData::DeoptimizationOutputDataPrint(
11482 std::ostream& os) { // NOLINT 11479 std::ostream& os) { // NOLINT
11483 os << "Deoptimization Output Data (deopt points = " << this->DeoptPoints() 11480 os << "Deoptimization Output Data (deopt points = " << this->DeoptPoints()
11484 << ")\n"; 11481 << ")\n";
11485 if (this->DeoptPoints() == 0) return; 11482 if (this->DeoptPoints() == 0) return;
11486 11483
11487 os << "ast id pc state\n"; 11484 os << "ast id pc state\n";
11488 for (int i = 0; i < this->DeoptPoints(); i++) { 11485 for (int i = 0; i < this->DeoptPoints(); i++) {
11489 int pc_and_state = this->PcAndState(i)->value(); 11486 int pc_and_state = this->PcAndState(i)->value();
11490 // TODO(svenpanne) Add some basic formatting to our streams. 11487 os << std::setw(6) << this->AstId(i).ToInt() << " " << std::setw(8)
11491 Vector<char> buf = Vector<char>::New(100); 11488 << FullCodeGenerator::PcField::decode(pc_and_state) << " "
11492 SNPrintF(buf, "%6d %8d %s\n", this->AstId(i).ToInt(), 11489 << FullCodeGenerator::State2String(
11493 FullCodeGenerator::PcField::decode(pc_and_state), 11490 FullCodeGenerator::StateField::decode(pc_and_state)) << "\n";
11494 FullCodeGenerator::State2String(
11495 FullCodeGenerator::StateField::decode(pc_and_state)));
11496 os << buf.start();
11497 } 11491 }
11498 } 11492 }
11499 11493
11500 11494
11501 const char* Code::ICState2String(InlineCacheState state) { 11495 const char* Code::ICState2String(InlineCacheState state) {
11502 switch (state) { 11496 switch (state) {
11503 case UNINITIALIZED: return "UNINITIALIZED"; 11497 case UNINITIALIZED: return "UNINITIALIZED";
11504 case PREMONOMORPHIC: return "PREMONOMORPHIC"; 11498 case PREMONOMORPHIC: return "PREMONOMORPHIC";
11505 case MONOMORPHIC: return "MONOMORPHIC"; 11499 case MONOMORPHIC: return "MONOMORPHIC";
11506 case PROTOTYPE_FAILURE: 11500 case PROTOTYPE_FAILURE:
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
11594 data->DeoptimizationInputDataPrint(os); 11588 data->DeoptimizationInputDataPrint(os);
11595 } 11589 }
11596 os << "\n"; 11590 os << "\n";
11597 11591
11598 if (is_crankshafted()) { 11592 if (is_crankshafted()) {
11599 SafepointTable table(this); 11593 SafepointTable table(this);
11600 os << "Safepoints (size = " << table.size() << ")\n"; 11594 os << "Safepoints (size = " << table.size() << ")\n";
11601 for (unsigned i = 0; i < table.length(); i++) { 11595 for (unsigned i = 0; i < table.length(); i++) {
11602 unsigned pc_offset = table.GetPcOffset(i); 11596 unsigned pc_offset = table.GetPcOffset(i);
11603 os << static_cast<const void*>(instruction_start() + pc_offset) << " "; 11597 os << static_cast<const void*>(instruction_start() + pc_offset) << " ";
11604 // TODO(svenpanne) Add some basic formatting to our streams. 11598 os << std::setw(4) << pc_offset << " ";
11605 Vector<char> buf1 = Vector<char>::New(30);
11606 SNPrintF(buf1, "%4d", pc_offset);
11607 os << buf1.start() << " ";
11608 table.PrintEntry(i, os); 11599 table.PrintEntry(i, os);
11609 os << " (sp -> fp) "; 11600 os << " (sp -> fp) ";
11610 SafepointEntry entry = table.GetEntry(i); 11601 SafepointEntry entry = table.GetEntry(i);
11611 if (entry.deoptimization_index() != Safepoint::kNoDeoptimizationIndex) { 11602 if (entry.deoptimization_index() != Safepoint::kNoDeoptimizationIndex) {
11612 Vector<char> buf2 = Vector<char>::New(30); 11603 os << std::setw(6) << entry.deoptimization_index();
11613 SNPrintF(buf2, "%6d", entry.deoptimization_index());
11614 os << buf2.start();
11615 } else { 11604 } else {
11616 os << "<none>"; 11605 os << "<none>";
11617 } 11606 }
11618 if (entry.argument_count() > 0) { 11607 if (entry.argument_count() > 0) {
11619 os << " argc: " << entry.argument_count(); 11608 os << " argc: " << entry.argument_count();
11620 } 11609 }
11621 os << "\n"; 11610 os << "\n";
11622 } 11611 }
11623 os << "\n"; 11612 os << "\n";
11624 } else if (kind() == FUNCTION) { 11613 } else if (kind() == FUNCTION) {
11625 unsigned offset = back_edge_table_offset(); 11614 unsigned offset = back_edge_table_offset();
11626 // If there is no back edge table, the "table start" will be at or after 11615 // If there is no back edge table, the "table start" will be at or after
11627 // (due to alignment) the end of the instruction stream. 11616 // (due to alignment) the end of the instruction stream.
11628 if (static_cast<int>(offset) < instruction_size()) { 11617 if (static_cast<int>(offset) < instruction_size()) {
11629 DisallowHeapAllocation no_gc; 11618 DisallowHeapAllocation no_gc;
11630 BackEdgeTable back_edges(this, &no_gc); 11619 BackEdgeTable back_edges(this, &no_gc);
11631 11620
11632 os << "Back edges (size = " << back_edges.length() << ")\n"; 11621 os << "Back edges (size = " << back_edges.length() << ")\n";
11633 os << "ast_id pc_offset loop_depth\n"; 11622 os << "ast_id pc_offset loop_depth\n";
11634 11623
11635 for (uint32_t i = 0; i < back_edges.length(); i++) { 11624 for (uint32_t i = 0; i < back_edges.length(); i++) {
11636 Vector<char> buf = Vector<char>::New(100); 11625 os << std::setw(6) << back_edges.ast_id(i).ToInt() << " "
11637 SNPrintF(buf, "%6d %9u %10u\n", back_edges.ast_id(i).ToInt(), 11626 << std::setw(9) << back_edges.pc_offset(i) << " " << std::setw(10)
11638 back_edges.pc_offset(i), back_edges.loop_depth(i)); 11627 << back_edges.loop_depth(i) << "\n";
11639 os << buf.start();
11640 } 11628 }
11641 11629
11642 os << "\n"; 11630 os << "\n";
11643 } 11631 }
11644 #ifdef OBJECT_PRINT 11632 #ifdef OBJECT_PRINT
11645 if (!type_feedback_info()->IsUndefined()) { 11633 if (!type_feedback_info()->IsUndefined()) {
11646 OFStream os(stdout); 11634 OFStream os(stdout);
11647 TypeFeedbackInfo::cast(type_feedback_info())->TypeFeedbackInfoPrint(os); 11635 TypeFeedbackInfo::cast(type_feedback_info())->TypeFeedbackInfoPrint(os);
11648 os << "\n"; 11636 os << "\n";
11649 } 11637 }
11650 #endif 11638 #endif
11651 } 11639 }
11652 11640
11653 if (handler_table()->length() > 0 && is_turbofanned()) { 11641 if (handler_table()->length() > 0 && is_turbofanned()) {
11654 os << "Handler Table (size = " << handler_table()->Size() << ")\n"; 11642 os << "Handler Table (size = " << handler_table()->Size() << ")\n";
11655 for (int i = 0; i < handler_table()->length(); i += 2) { 11643 for (int i = 0; i < handler_table()->length(); i += 2) {
11656 int pc_offset = Smi::cast(handler_table()->get(i))->value(); 11644 int pc_offset = Smi::cast(handler_table()->get(i))->value();
11657 int handler = Smi::cast(handler_table()->get(i + 1))->value(); 11645 int handler = Smi::cast(handler_table()->get(i + 1))->value();
11658 os << static_cast<const void*>(instruction_start() + pc_offset) << " "; 11646 os << static_cast<const void*>(instruction_start() + pc_offset) << " "
11659 Vector<char> buf = Vector<char>::New(20); 11647 << std::setw(4) << pc_offset << " " << std::setw(4) << handler << "\n";
11660 SNPrintF(buf, "%4d %4d\n", pc_offset, handler);
11661 os << buf.start();
11662 } 11648 }
11663 os << "\n"; 11649 os << "\n";
11664 } 11650 }
11665 11651
11666 os << "RelocInfo (size = " << relocation_size() << ")\n"; 11652 os << "RelocInfo (size = " << relocation_size() << ")\n";
11667 for (RelocIterator it(this); !it.done(); it.next()) { 11653 for (RelocIterator it(this); !it.done(); it.next()) {
11668 it.rinfo()->Print(GetIsolate(), os); 11654 it.rinfo()->Print(GetIsolate(), os);
11669 } 11655 }
11670 os << "\n"; 11656 os << "\n";
11671 11657
(...skipping 5488 matching lines...) Expand 10 before | Expand all | Expand 10 after
17160 CompilationInfo* info) { 17146 CompilationInfo* info) {
17161 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( 17147 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo(
17162 handle(cell->dependent_code(), info->isolate()), 17148 handle(cell->dependent_code(), info->isolate()),
17163 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); 17149 DependentCode::kPropertyCellChangedGroup, info->object_wrapper());
17164 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 17150 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
17165 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 17151 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
17166 cell, info->zone()); 17152 cell, info->zone());
17167 } 17153 }
17168 17154
17169 } } // namespace v8::internal 17155 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler/scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698