OLD | NEW |
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 <sstream> |
| 6 |
5 #include "src/v8.h" | 7 #include "src/v8.h" |
6 | 8 |
7 #include "src/accessors.h" | 9 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
9 #include "src/api.h" | 11 #include "src/api.h" |
10 #include "src/arguments.h" | 12 #include "src/arguments.h" |
11 #include "src/base/bits.h" | 13 #include "src/base/bits.h" |
12 #include "src/bootstrapper.h" | 14 #include "src/bootstrapper.h" |
13 #include "src/code-stubs.h" | 15 #include "src/code-stubs.h" |
14 #include "src/codegen.h" | 16 #include "src/codegen.h" |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 } | 904 } |
903 | 905 |
904 | 906 |
905 void Object::ShortPrint(FILE* out) { | 907 void Object::ShortPrint(FILE* out) { |
906 OFStream os(out); | 908 OFStream os(out); |
907 os << Brief(this); | 909 os << Brief(this); |
908 } | 910 } |
909 | 911 |
910 | 912 |
911 void Object::ShortPrint(StringStream* accumulator) { | 913 void Object::ShortPrint(StringStream* accumulator) { |
912 OStringStream os; | 914 std::ostringstream os; |
913 os << Brief(this); | 915 os << Brief(this); |
914 accumulator->Add(os.c_str()); | 916 accumulator->Add(os.str().c_str()); |
915 } | 917 } |
916 | 918 |
917 | 919 |
918 OStream& operator<<(OStream& os, const Brief& v) { | 920 std::ostream& operator<<(std::ostream& os, const Brief& v) { |
919 if (v.value->IsSmi()) { | 921 if (v.value->IsSmi()) { |
920 Smi::cast(v.value)->SmiPrint(os); | 922 Smi::cast(v.value)->SmiPrint(os); |
921 } else { | 923 } else { |
922 // TODO(svenpanne) Const-correct HeapObjectShortPrint! | 924 // TODO(svenpanne) Const-correct HeapObjectShortPrint! |
923 HeapObject* obj = const_cast<HeapObject*>(HeapObject::cast(v.value)); | 925 HeapObject* obj = const_cast<HeapObject*>(HeapObject::cast(v.value)); |
924 obj->HeapObjectShortPrint(os); | 926 obj->HeapObjectShortPrint(os); |
925 } | 927 } |
926 return os; | 928 return os; |
927 } | 929 } |
928 | 930 |
929 | 931 |
930 void Smi::SmiPrint(OStream& os) const { // NOLINT | 932 void Smi::SmiPrint(std::ostream& os) const { // NOLINT |
931 os << value(); | 933 os << value(); |
932 } | 934 } |
933 | 935 |
934 | 936 |
935 // Should a word be prefixed by 'a' or 'an' in order to read naturally in | 937 // Should a word be prefixed by 'a' or 'an' in order to read naturally in |
936 // English? Returns false for non-ASCII or words that don't start with | 938 // English? Returns false for non-ASCII or words that don't start with |
937 // a capital letter. The a/an rule follows pronunciation in English. | 939 // a capital letter. The a/an rule follows pronunciation in English. |
938 // We don't use the BBC's overcorrect "an historic occasion" though if | 940 // We don't use the BBC's overcorrect "an historic occasion" though if |
939 // you speak a dialect you may well say "an 'istoric occasion". | 941 // you speak a dialect you may well say "an 'istoric occasion". |
940 static bool AnWord(String* str) { | 942 static bool AnWord(String* str) { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 accumulator->Put('.'); | 1167 accumulator->Put('.'); |
1166 accumulator->Put('.'); | 1168 accumulator->Put('.'); |
1167 accumulator->Put('.'); | 1169 accumulator->Put('.'); |
1168 } | 1170 } |
1169 accumulator->Put('>'); | 1171 accumulator->Put('>'); |
1170 } | 1172 } |
1171 return; | 1173 return; |
1172 } | 1174 } |
1173 | 1175 |
1174 | 1176 |
1175 void String::PrintUC16(OStream& os, int start, int end) { // NOLINT | 1177 void String::PrintUC16(std::ostream& os, int start, int end) { // NOLINT |
1176 if (end < 0) end = length(); | 1178 if (end < 0) end = length(); |
1177 ConsStringIteratorOp op; | 1179 ConsStringIteratorOp op; |
1178 StringCharacterStream stream(this, &op, start); | 1180 StringCharacterStream stream(this, &op, start); |
1179 for (int i = start; i < end && stream.HasMore(); i++) { | 1181 for (int i = start; i < end && stream.HasMore(); i++) { |
1180 os << AsUC16(stream.GetNext()); | 1182 os << AsUC16(stream.GetNext()); |
1181 } | 1183 } |
1182 } | 1184 } |
1183 | 1185 |
1184 | 1186 |
1185 void JSObject::JSObjectShortPrint(StringStream* accumulator) { | 1187 void JSObject::JSObjectShortPrint(StringStream* accumulator) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 } else { | 1366 } else { |
1365 PrintF(file, "{symbol %p}", static_cast<void*>(name)); | 1367 PrintF(file, "{symbol %p}", static_cast<void*>(name)); |
1366 } | 1368 } |
1367 PrintF(file, " "); | 1369 PrintF(file, " "); |
1368 } | 1370 } |
1369 } | 1371 } |
1370 PrintF(file, "\n"); | 1372 PrintF(file, "\n"); |
1371 } | 1373 } |
1372 | 1374 |
1373 | 1375 |
1374 void HeapObject::HeapObjectShortPrint(OStream& os) { // NOLINT | 1376 void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT |
1375 Heap* heap = GetHeap(); | 1377 Heap* heap = GetHeap(); |
1376 if (!heap->Contains(this)) { | 1378 if (!heap->Contains(this)) { |
1377 os << "!!!INVALID POINTER!!!"; | 1379 os << "!!!INVALID POINTER!!!"; |
1378 return; | 1380 return; |
1379 } | 1381 } |
1380 if (!heap->Contains(map())) { | 1382 if (!heap->Contains(map())) { |
1381 os << "!!!INVALID MAP!!!"; | 1383 os << "!!!INVALID MAP!!!"; |
1382 return; | 1384 return; |
1383 } | 1385 } |
1384 | 1386 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 UNREACHABLE(); | 1663 UNREACHABLE(); |
1662 } | 1664 } |
1663 } | 1665 } |
1664 | 1666 |
1665 | 1667 |
1666 bool HeapNumber::HeapNumberBooleanValue() { | 1668 bool HeapNumber::HeapNumberBooleanValue() { |
1667 return DoubleToBoolean(value()); | 1669 return DoubleToBoolean(value()); |
1668 } | 1670 } |
1669 | 1671 |
1670 | 1672 |
1671 void HeapNumber::HeapNumberPrint(OStream& os) { // NOLINT | 1673 void HeapNumber::HeapNumberPrint(std::ostream& os) { // NOLINT |
1672 os << value(); | 1674 os << value(); |
1673 } | 1675 } |
1674 | 1676 |
1675 | 1677 |
1676 String* JSReceiver::class_name() { | 1678 String* JSReceiver::class_name() { |
1677 if (IsJSFunction() || IsJSFunctionProxy()) { | 1679 if (IsJSFunction() || IsJSFunctionProxy()) { |
1678 return GetHeap()->Function_string(); | 1680 return GetHeap()->Function_string(); |
1679 } | 1681 } |
1680 if (map()->constructor()->IsJSFunction()) { | 1682 if (map()->constructor()->IsJSFunction()) { |
1681 JSFunction* constructor = JSFunction::cast(map()->constructor()); | 1683 JSFunction* constructor = JSFunction::cast(map()->constructor()); |
(...skipping 8121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9803 return instance_size; | 9805 return instance_size; |
9804 } | 9806 } |
9805 | 9807 |
9806 | 9808 |
9807 int SharedFunctionInfo::CalculateInObjectProperties() { | 9809 int SharedFunctionInfo::CalculateInObjectProperties() { |
9808 return (CalculateInstanceSize() - JSObject::kHeaderSize) / kPointerSize; | 9810 return (CalculateInstanceSize() - JSObject::kHeaderSize) / kPointerSize; |
9809 } | 9811 } |
9810 | 9812 |
9811 | 9813 |
9812 // Output the source code without any allocation in the heap. | 9814 // Output the source code without any allocation in the heap. |
9813 OStream& operator<<(OStream& os, const SourceCodeOf& v) { | 9815 std::ostream& operator<<(std::ostream& os, const SourceCodeOf& v) { |
9814 const SharedFunctionInfo* s = v.value; | 9816 const SharedFunctionInfo* s = v.value; |
9815 // For some native functions there is no source. | 9817 // For some native functions there is no source. |
9816 if (!s->HasSourceCode()) return os << "<No Source>"; | 9818 if (!s->HasSourceCode()) return os << "<No Source>"; |
9817 | 9819 |
9818 // Get the source for the script which this function came from. | 9820 // Get the source for the script which this function came from. |
9819 // Don't use String::cast because we don't want more assertion errors while | 9821 // Don't use String::cast because we don't want more assertion errors while |
9820 // we are already creating a stack dump. | 9822 // we are already creating a stack dump. |
9821 String* script_source = | 9823 String* script_source = |
9822 reinterpret_cast<String*>(Script::cast(s->script())->source()); | 9824 reinterpret_cast<String*>(Script::cast(s->script())->source()); |
9823 | 9825 |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10623 case NUMBER_OF_KINDS: break; | 10625 case NUMBER_OF_KINDS: break; |
10624 } | 10626 } |
10625 UNREACHABLE(); | 10627 UNREACHABLE(); |
10626 return NULL; | 10628 return NULL; |
10627 } | 10629 } |
10628 | 10630 |
10629 | 10631 |
10630 #ifdef ENABLE_DISASSEMBLER | 10632 #ifdef ENABLE_DISASSEMBLER |
10631 | 10633 |
10632 void DeoptimizationInputData::DeoptimizationInputDataPrint( | 10634 void DeoptimizationInputData::DeoptimizationInputDataPrint( |
10633 OStream& os) { // NOLINT | 10635 std::ostream& os) { // NOLINT |
10634 disasm::NameConverter converter; | 10636 disasm::NameConverter converter; |
10635 int deopt_count = DeoptCount(); | 10637 int deopt_count = DeoptCount(); |
10636 os << "Deoptimization Input Data (deopt points = " << deopt_count << ")\n"; | 10638 os << "Deoptimization Input Data (deopt points = " << deopt_count << ")\n"; |
10637 if (0 != deopt_count) { | 10639 if (0 != deopt_count) { |
10638 os << " index ast id argc pc"; | 10640 os << " index ast id argc pc"; |
10639 if (FLAG_print_code_verbose) os << " commands"; | 10641 if (FLAG_print_code_verbose) os << " commands"; |
10640 os << "\n"; | 10642 os << "\n"; |
10641 } | 10643 } |
10642 for (int i = 0; i < deopt_count; i++) { | 10644 for (int i = 0; i < deopt_count; i++) { |
10643 // TODO(svenpanne) Add some basic formatting to our streams. | 10645 // TODO(svenpanne) Add some basic formatting to our streams. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10784 break; | 10786 break; |
10785 } | 10787 } |
10786 } | 10788 } |
10787 os << "\n"; | 10789 os << "\n"; |
10788 } | 10790 } |
10789 } | 10791 } |
10790 } | 10792 } |
10791 | 10793 |
10792 | 10794 |
10793 void DeoptimizationOutputData::DeoptimizationOutputDataPrint( | 10795 void DeoptimizationOutputData::DeoptimizationOutputDataPrint( |
10794 OStream& os) { // NOLINT | 10796 std::ostream& os) { // NOLINT |
10795 os << "Deoptimization Output Data (deopt points = " << this->DeoptPoints() | 10797 os << "Deoptimization Output Data (deopt points = " << this->DeoptPoints() |
10796 << ")\n"; | 10798 << ")\n"; |
10797 if (this->DeoptPoints() == 0) return; | 10799 if (this->DeoptPoints() == 0) return; |
10798 | 10800 |
10799 os << "ast id pc state\n"; | 10801 os << "ast id pc state\n"; |
10800 for (int i = 0; i < this->DeoptPoints(); i++) { | 10802 for (int i = 0; i < this->DeoptPoints(); i++) { |
10801 int pc_and_state = this->PcAndState(i)->value(); | 10803 int pc_and_state = this->PcAndState(i)->value(); |
10802 // TODO(svenpanne) Add some basic formatting to our streams. | 10804 // TODO(svenpanne) Add some basic formatting to our streams. |
10803 Vector<char> buf = Vector<char>::New(100); | 10805 Vector<char> buf = Vector<char>::New(100); |
10804 SNPrintF(buf, "%6d %8d %s\n", this->AstId(i).ToInt(), | 10806 SNPrintF(buf, "%6d %8d %s\n", this->AstId(i).ToInt(), |
(...skipping 27 matching lines...) Expand all Loading... |
10832 const char* Code::StubType2String(StubType type) { | 10834 const char* Code::StubType2String(StubType type) { |
10833 switch (type) { | 10835 switch (type) { |
10834 case NORMAL: return "NORMAL"; | 10836 case NORMAL: return "NORMAL"; |
10835 case FAST: return "FAST"; | 10837 case FAST: return "FAST"; |
10836 } | 10838 } |
10837 UNREACHABLE(); // keep the compiler happy | 10839 UNREACHABLE(); // keep the compiler happy |
10838 return NULL; | 10840 return NULL; |
10839 } | 10841 } |
10840 | 10842 |
10841 | 10843 |
10842 void Code::PrintExtraICState(OStream& os, // NOLINT | 10844 void Code::PrintExtraICState(std::ostream& os, // NOLINT |
10843 Kind kind, ExtraICState extra) { | 10845 Kind kind, ExtraICState extra) { |
10844 os << "extra_ic_state = "; | 10846 os << "extra_ic_state = "; |
10845 if ((kind == STORE_IC || kind == KEYED_STORE_IC) && (extra == STRICT)) { | 10847 if ((kind == STORE_IC || kind == KEYED_STORE_IC) && (extra == STRICT)) { |
10846 os << "STRICT\n"; | 10848 os << "STRICT\n"; |
10847 } else { | 10849 } else { |
10848 os << extra << "\n"; | 10850 os << extra << "\n"; |
10849 } | 10851 } |
10850 } | 10852 } |
10851 | 10853 |
10852 | 10854 |
10853 void Code::Disassemble(const char* name, OStream& os) { // NOLINT | 10855 void Code::Disassemble(const char* name, std::ostream& os) { // NOLINT |
10854 os << "kind = " << Kind2String(kind()) << "\n"; | 10856 os << "kind = " << Kind2String(kind()) << "\n"; |
10855 if (IsCodeStubOrIC()) { | 10857 if (IsCodeStubOrIC()) { |
10856 const char* n = CodeStub::MajorName(CodeStub::GetMajorKey(this), true); | 10858 const char* n = CodeStub::MajorName(CodeStub::GetMajorKey(this), true); |
10857 os << "major_key = " << (n == NULL ? "null" : n) << "\n"; | 10859 os << "major_key = " << (n == NULL ? "null" : n) << "\n"; |
10858 } | 10860 } |
10859 if (is_inline_cache_stub()) { | 10861 if (is_inline_cache_stub()) { |
10860 os << "ic_state = " << ICState2String(ic_state()) << "\n"; | 10862 os << "ic_state = " << ICState2String(ic_state()) << "\n"; |
10861 PrintExtraICState(os, kind(), extra_ic_state()); | 10863 PrintExtraICState(os, kind(), extra_ic_state()); |
10862 if (ic_state() == MONOMORPHIC) { | 10864 if (ic_state() == MONOMORPHIC) { |
10863 os << "type = " << StubType2String(type()) << "\n"; | 10865 os << "type = " << StubType2String(type()) << "\n"; |
(...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13049 } | 13051 } |
13050 | 13052 |
13051 | 13053 |
13052 // Certain compilers request function template instantiation when they | 13054 // Certain compilers request function template instantiation when they |
13053 // see the definition of the other template functions in the | 13055 // see the definition of the other template functions in the |
13054 // class. This requires us to have the template functions put | 13056 // class. This requires us to have the template functions put |
13055 // together, so even though this function belongs in objects-debug.cc, | 13057 // together, so even though this function belongs in objects-debug.cc, |
13056 // we keep it here instead to satisfy certain compilers. | 13058 // we keep it here instead to satisfy certain compilers. |
13057 #ifdef OBJECT_PRINT | 13059 #ifdef OBJECT_PRINT |
13058 template <typename Derived, typename Shape, typename Key> | 13060 template <typename Derived, typename Shape, typename Key> |
13059 void Dictionary<Derived, Shape, Key>::Print(OStream& os) { // NOLINT | 13061 void Dictionary<Derived, Shape, Key>::Print(std::ostream& os) { // NOLINT |
13060 int capacity = DerivedHashTable::Capacity(); | 13062 int capacity = DerivedHashTable::Capacity(); |
13061 for (int i = 0; i < capacity; i++) { | 13063 for (int i = 0; i < capacity; i++) { |
13062 Object* k = DerivedHashTable::KeyAt(i); | 13064 Object* k = DerivedHashTable::KeyAt(i); |
13063 if (DerivedHashTable::IsKey(k)) { | 13065 if (DerivedHashTable::IsKey(k)) { |
13064 os << " "; | 13066 os << " "; |
13065 if (k->IsString()) { | 13067 if (k->IsString()) { |
13066 String::cast(k)->StringPrint(os); | 13068 String::cast(k)->StringPrint(os); |
13067 } else { | 13069 } else { |
13068 os << Brief(k); | 13070 os << Brief(k); |
13069 } | 13071 } |
(...skipping 3301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16371 Handle<DependentCode> codes = | 16373 Handle<DependentCode> codes = |
16372 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), | 16374 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), |
16373 DependentCode::kPropertyCellChangedGroup, | 16375 DependentCode::kPropertyCellChangedGroup, |
16374 info->object_wrapper()); | 16376 info->object_wrapper()); |
16375 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 16377 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
16376 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 16378 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
16377 cell, info->zone()); | 16379 cell, info->zone()); |
16378 } | 16380 } |
16379 | 16381 |
16380 } } // namespace v8::internal | 16382 } } // namespace v8::internal |
OLD | NEW |