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

Side by Side Diff: src/objects.cc

Issue 677633003: Improve printing for Symbols. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
« 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 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> 5 #include <sstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 os << "<true>"; 1527 os << "<true>";
1528 } else if (IsFalse()) { 1528 } else if (IsFalse()) {
1529 os << "<false>"; 1529 os << "<false>";
1530 } else { 1530 } else {
1531 os << "<Odd Oddball>"; 1531 os << "<Odd Oddball>";
1532 } 1532 }
1533 break; 1533 break;
1534 } 1534 }
1535 case SYMBOL_TYPE: { 1535 case SYMBOL_TYPE: {
1536 Symbol* symbol = Symbol::cast(this); 1536 Symbol* symbol = Symbol::cast(this);
1537 os << "<Symbol: " << symbol->Hash(); 1537 symbol->SymbolShortPrint(os);
1538 if (!symbol->name()->IsUndefined()) {
1539 os << " ";
1540 HeapStringAllocator allocator;
1541 StringStream accumulator(&allocator);
1542 String::cast(symbol->name())->StringShortPrint(&accumulator);
1543 os << accumulator.ToCString().get();
1544 }
1545 os << ">";
1546 break; 1538 break;
1547 } 1539 }
1548 case HEAP_NUMBER_TYPE: { 1540 case HEAP_NUMBER_TYPE: {
1549 os << "<Number: "; 1541 os << "<Number: ";
1550 HeapNumber::cast(this)->HeapNumberPrint(os); 1542 HeapNumber::cast(this)->HeapNumberPrint(os);
1551 os << ">"; 1543 os << ">";
1552 break; 1544 break;
1553 } 1545 }
1554 case MUTABLE_HEAP_NUMBER_TYPE: { 1546 case MUTABLE_HEAP_NUMBER_TYPE: {
1555 os << "<MutableNumber: "; 1547 os << "<MutableNumber: ";
(...skipping 12067 matching lines...) Expand 10 before | Expand all | Expand 10 after
13623 DCHECK(!storage || storage->length() == counter); 13615 DCHECK(!storage || storage->length() == counter);
13624 return counter; 13616 return counter;
13625 } 13617 }
13626 13618
13627 13619
13628 int JSObject::GetEnumElementKeys(FixedArray* storage) { 13620 int JSObject::GetEnumElementKeys(FixedArray* storage) {
13629 return GetOwnElementKeys(storage, static_cast<PropertyAttributes>(DONT_ENUM)); 13621 return GetOwnElementKeys(storage, static_cast<PropertyAttributes>(DONT_ENUM));
13630 } 13622 }
13631 13623
13632 13624
13625 const char* Symbol::PrivateSymbolToName() const {
13626 Heap* heap = GetIsolate()->heap();
13627 #define SYMBOL_CHECK_AND_PRINT(name) \
13628 if (this == heap->name()) return #name;
13629 PRIVATE_SYMBOL_LIST(SYMBOL_CHECK_AND_PRINT)
13630 #undef SYMBOL_CHECK_AND_PRINT
13631 return "UNKNOWN";
13632 }
13633
13634
13635 void Symbol::SymbolShortPrint(std::ostream& os) {
13636 os << "<Symbol: " << Hash();
13637 if (!name()->IsUndefined()) {
13638 os << " ";
13639 HeapStringAllocator allocator;
13640 StringStream accumulator(&allocator);
13641 String::cast(name())->StringShortPrint(&accumulator);
13642 os << accumulator.ToCString().get();
13643 } else {
13644 os << " (" << PrivateSymbolToName() << ")";
13645 }
13646 os << ">";
13647 }
13648
13649
13633 // StringSharedKeys are used as keys in the eval cache. 13650 // StringSharedKeys are used as keys in the eval cache.
13634 class StringSharedKey : public HashTableKey { 13651 class StringSharedKey : public HashTableKey {
13635 public: 13652 public:
13636 StringSharedKey(Handle<String> source, 13653 StringSharedKey(Handle<String> source,
13637 Handle<SharedFunctionInfo> shared, 13654 Handle<SharedFunctionInfo> shared,
13638 StrictMode strict_mode, 13655 StrictMode strict_mode,
13639 int scope_position) 13656 int scope_position)
13640 : source_(source), 13657 : source_(source),
13641 shared_(shared), 13658 shared_(shared),
13642 strict_mode_(strict_mode), 13659 strict_mode_(strict_mode),
(...skipping 2826 matching lines...) Expand 10 before | Expand all | Expand 10 after
16469 Handle<DependentCode> codes = 16486 Handle<DependentCode> codes =
16470 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), 16487 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()),
16471 DependentCode::kPropertyCellChangedGroup, 16488 DependentCode::kPropertyCellChangedGroup,
16472 info->object_wrapper()); 16489 info->object_wrapper());
16473 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 16490 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
16474 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16491 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16475 cell, info->zone()); 16492 cell, info->zone());
16476 } 16493 }
16477 16494
16478 } } // namespace v8::internal 16495 } } // namespace v8::internal
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