Revision: 24869
Author: [email protected]
Date: Fri Oct 24 12:36:45 2014 UTC
Log: Improve printing for Symbols.
Private symbols we create in the heap don't have names, but we can
resolve them to a constant string.
This gives handy debugger output like:
(gdb) job 0x2020c67d
0x2020c67d: [Symbol]
- hash: 547385396
- name: 0x20208091 <undefined> (uninitialized_symbol)
- private: 1
- own: 1
$7 = void
(gdb)
or with ShortPrint() in an array:
...
[5]: 0x2020c67d <Symbol: 547385396 (uninitialized_symbol)>
...
Printing help for internal symbols
[email protected]
Review URL: https://codereview.chromium.org/677633003
https://code.google.com/p/v8/source/detail?r=24869
Modified:
/branches/bleeding_edge/src/objects-printer.cc
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
=======================================
--- /branches/bleeding_edge/src/objects-printer.cc Thu Oct 23 11:31:33 2014
UTC
+++ /branches/bleeding_edge/src/objects-printer.cc Fri Oct 24 12:36:45 2014
UTC
@@ -395,6 +395,9 @@
HeapObject::PrintHeader(os, "Symbol");
os << " - hash: " << Hash();
os << "\n - name: " << Brief(name());
+ if (name()->IsUndefined()) {
+ os << " (" << PrivateSymbolToName() << ")";
+ }
os << "\n - private: " << is_private();
os << "\n - own: " << is_own();
os << "\n";
=======================================
--- /branches/bleeding_edge/src/objects.cc Fri Oct 24 05:29:54 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc Fri Oct 24 12:36:45 2014 UTC
@@ -1532,15 +1532,7 @@
}
case SYMBOL_TYPE: {
Symbol* symbol = Symbol::cast(this);
- os << "<Symbol: " << symbol->Hash();
- if (!symbol->name()->IsUndefined()) {
- os << " ";
- HeapStringAllocator allocator;
- StringStream accumulator(&allocator);
- String::cast(symbol->name())->StringShortPrint(&accumulator);
- os << accumulator.ToCString().get();
- }
- os << ">";
+ symbol->SymbolShortPrint(os);
break;
}
case HEAP_NUMBER_TYPE: {
@@ -13614,6 +13606,31 @@
int JSObject::GetEnumElementKeys(FixedArray* storage) {
return GetOwnElementKeys(storage,
static_cast<PropertyAttributes>(DONT_ENUM));
}
+
+
+const char* Symbol::PrivateSymbolToName() const {
+ Heap* heap = GetIsolate()->heap();
+#define SYMBOL_CHECK_AND_PRINT(name) \
+ if (this == heap->name()) return #name;
+ PRIVATE_SYMBOL_LIST(SYMBOL_CHECK_AND_PRINT)
+#undef SYMBOL_CHECK_AND_PRINT
+ return "UNKNOWN";
+}
+
+
+void Symbol::SymbolShortPrint(std::ostream& os) {
+ os << "<Symbol: " << Hash();
+ if (!name()->IsUndefined()) {
+ os << " ";
+ HeapStringAllocator allocator;
+ StringStream accumulator(&allocator);
+ String::cast(name())->StringShortPrint(&accumulator);
+ os << accumulator.ToCString().get();
+ } else {
+ os << " (" << PrivateSymbolToName() << ")";
+ }
+ os << ">";
+}
// StringSharedKeys are used as keys in the eval cache.
=======================================
--- /branches/bleeding_edge/src/objects.h Fri Oct 24 05:29:54 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Fri Oct 24 12:36:45 2014 UTC
@@ -8654,10 +8654,14 @@
typedef FixedBodyDescriptor<kNameOffset, kFlagsOffset, kSize>
BodyDescriptor;
+ void SymbolShortPrint(std::ostream& os);
+
private:
static const int kPrivateBit = 0;
static const int kOwnBit = 1;
+ const char* PrivateSymbolToName() const;
+
DISALLOW_IMPLICIT_CONSTRUCTORS(Symbol);
};
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.