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

Side by Side Diff: src/objects.cc

Issue 2008893002: [printing] show symbols when using %DebugPrint (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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/objects.h ('k') | src/objects-printer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 this->synchronized_set_map(new_map); 1906 this->synchronized_set_map(new_map);
1907 1907
1908 ExternalOneByteString* self = ExternalOneByteString::cast(this); 1908 ExternalOneByteString* self = ExternalOneByteString::cast(this);
1909 self->set_resource(resource); 1909 self->set_resource(resource);
1910 if (is_internalized) self->Hash(); // Force regeneration of the hash value. 1910 if (is_internalized) self->Hash(); // Force regeneration of the hash value.
1911 1911
1912 heap->AdjustLiveBytes(this, new_size - size, Heap::CONCURRENT_TO_SWEEPER); 1912 heap->AdjustLiveBytes(this, new_size - size, Heap::CONCURRENT_TO_SWEEPER);
1913 return true; 1913 return true;
1914 } 1914 }
1915 1915
1916 1916 void String::StringShortPrint(StringStream* accumulator, bool show_details) {
1917 void String::StringShortPrint(StringStream* accumulator) {
1918 int len = length(); 1917 int len = length();
1919 if (len > kMaxShortPrintLength) { 1918 if (len > kMaxShortPrintLength) {
1920 accumulator->Add("<Very long string[%u]>", len); 1919 accumulator->Add("<Very long string[%u]>", len);
1921 return; 1920 return;
1922 } 1921 }
1923 1922
1924 if (!LooksValid()) { 1923 if (!LooksValid()) {
1925 accumulator->Add("<Invalid String>"); 1924 accumulator->Add("<Invalid String>");
1926 return; 1925 return;
1927 } 1926 }
1928 1927
1929 StringCharacterStream stream(this); 1928 StringCharacterStream stream(this);
1930 1929
1931 bool truncated = false; 1930 bool truncated = false;
1932 if (len > kMaxShortPrintLength) { 1931 if (len > kMaxShortPrintLength) {
1933 len = kMaxShortPrintLength; 1932 len = kMaxShortPrintLength;
1934 truncated = true; 1933 truncated = true;
1935 } 1934 }
1936 bool one_byte = true; 1935 bool one_byte = true;
1937 for (int i = 0; i < len; i++) { 1936 for (int i = 0; i < len; i++) {
1938 uint16_t c = stream.GetNext(); 1937 uint16_t c = stream.GetNext();
1939 1938
1940 if (c < 32 || c >= 127) { 1939 if (c < 32 || c >= 127) {
1941 one_byte = false; 1940 one_byte = false;
1942 } 1941 }
1943 } 1942 }
1944 stream.Reset(this); 1943 stream.Reset(this);
1945 if (one_byte) { 1944 if (one_byte) {
1946 accumulator->Add("<String[%u]: ", length()); 1945 if (show_details) accumulator->Add("<String[%u]: ", length());
1947 for (int i = 0; i < len; i++) { 1946 for (int i = 0; i < len; i++) {
1948 accumulator->Put(static_cast<char>(stream.GetNext())); 1947 accumulator->Put(static_cast<char>(stream.GetNext()));
1949 } 1948 }
1950 accumulator->Put('>'); 1949 if (show_details) accumulator->Put('>');
1951 } else { 1950 } else {
1952 // Backslash indicates that the string contains control 1951 // Backslash indicates that the string contains control
1953 // characters and that backslashes are therefore escaped. 1952 // characters and that backslashes are therefore escaped.
1954 accumulator->Add("<String[%u]\\: ", length()); 1953 if (show_details) accumulator->Add("<String[%u]\\: ", length());
1955 for (int i = 0; i < len; i++) { 1954 for (int i = 0; i < len; i++) {
1956 uint16_t c = stream.GetNext(); 1955 uint16_t c = stream.GetNext();
1957 if (c == '\n') { 1956 if (c == '\n') {
1958 accumulator->Add("\\n"); 1957 accumulator->Add("\\n");
1959 } else if (c == '\r') { 1958 } else if (c == '\r') {
1960 accumulator->Add("\\r"); 1959 accumulator->Add("\\r");
1961 } else if (c == '\\') { 1960 } else if (c == '\\') {
1962 accumulator->Add("\\\\"); 1961 accumulator->Add("\\\\");
1963 } else if (c < 32 || c > 126) { 1962 } else if (c < 32 || c > 126) {
1964 accumulator->Add("\\x%02x", c); 1963 accumulator->Add("\\x%02x", c);
1965 } else { 1964 } else {
1966 accumulator->Put(static_cast<char>(c)); 1965 accumulator->Put(static_cast<char>(c));
1967 } 1966 }
1968 } 1967 }
1969 if (truncated) { 1968 if (truncated) {
1970 accumulator->Put('.'); 1969 accumulator->Put('.');
1971 accumulator->Put('.'); 1970 accumulator->Put('.');
1972 accumulator->Put('.'); 1971 accumulator->Put('.');
1973 } 1972 }
1974 accumulator->Put('>'); 1973 if (show_details) accumulator->Put('>');
1975 } 1974 }
1976 return; 1975 return;
1977 } 1976 }
1978 1977
1979 1978
1980 void String::PrintUC16(std::ostream& os, int start, int end) { // NOLINT 1979 void String::PrintUC16(std::ostream& os, int start, int end) { // NOLINT
1981 if (end < 0) end = length(); 1980 if (end < 0) end = length();
1982 StringCharacterStream stream(this, start); 1981 StringCharacterStream stream(this, start);
1983 for (int i = start; i < end && stream.HasMore(); i++) { 1982 for (int i = start; i < end && stream.HasMore(); i++) {
1984 os << AsUC16(stream.GetNext()); 1983 os << AsUC16(stream.GetNext());
(...skipping 13306 matching lines...) Expand 10 before | Expand all | Expand 10 after
15291 Heap* heap = GetIsolate()->heap(); 15290 Heap* heap = GetIsolate()->heap();
15292 #define SYMBOL_CHECK_AND_PRINT(name) \ 15291 #define SYMBOL_CHECK_AND_PRINT(name) \
15293 if (this == heap->name()) return #name; 15292 if (this == heap->name()) return #name;
15294 PRIVATE_SYMBOL_LIST(SYMBOL_CHECK_AND_PRINT) 15293 PRIVATE_SYMBOL_LIST(SYMBOL_CHECK_AND_PRINT)
15295 #undef SYMBOL_CHECK_AND_PRINT 15294 #undef SYMBOL_CHECK_AND_PRINT
15296 return "UNKNOWN"; 15295 return "UNKNOWN";
15297 } 15296 }
15298 15297
15299 15298
15300 void Symbol::SymbolShortPrint(std::ostream& os) { 15299 void Symbol::SymbolShortPrint(std::ostream& os) {
15301 os << "<Symbol: " << Hash(); 15300 os << "<Symbol:";
15302 if (!name()->IsUndefined()) { 15301 if (!name()->IsUndefined()) {
15303 os << " "; 15302 os << " ";
15304 HeapStringAllocator allocator; 15303 HeapStringAllocator allocator;
15305 StringStream accumulator(&allocator); 15304 StringStream accumulator(&allocator);
15306 String::cast(name())->StringShortPrint(&accumulator); 15305 String::cast(name())->StringShortPrint(&accumulator, false);
15307 os << accumulator.ToCString().get(); 15306 os << accumulator.ToCString().get();
15308 } else { 15307 } else {
15309 os << " (" << PrivateSymbolToName() << ")"; 15308 os << " (" << PrivateSymbolToName() << ")";
15310 } 15309 }
15311 os << ">"; 15310 os << ">";
15312 } 15311 }
15313 15312
15314 15313
15315 // StringSharedKeys are used as keys in the eval cache. 15314 // StringSharedKeys are used as keys in the eval cache.
15316 class StringSharedKey : public HashTableKey { 15315 class StringSharedKey : public HashTableKey {
(...skipping 3076 matching lines...) Expand 10 before | Expand all | Expand 10 after
18393 if (cell->value() != *new_value) { 18392 if (cell->value() != *new_value) {
18394 cell->set_value(*new_value); 18393 cell->set_value(*new_value);
18395 Isolate* isolate = cell->GetIsolate(); 18394 Isolate* isolate = cell->GetIsolate();
18396 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18395 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18397 isolate, DependentCode::kPropertyCellChangedGroup); 18396 isolate, DependentCode::kPropertyCellChangedGroup);
18398 } 18397 }
18399 } 18398 }
18400 18399
18401 } // namespace internal 18400 } // namespace internal
18402 } // namespace v8 18401 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698