Revision: 21433
Author: [email protected]
Date: Thu May 22 11:26:48 2014 UTC
Log: Add support for ES6 Symbol in heap profiler
Heap profiler will create a node with name Symbol and type kSymbol.
BUG=chromium:376194
LOG=Y
[email protected], [email protected]
Review URL: https://codereview.chromium.org/290013004
http://code.google.com/p/v8/source/detail?r=21433
Modified:
/branches/bleeding_edge/include/v8-profiler.h
/branches/bleeding_edge/src/heap-snapshot-generator.cc
/branches/bleeding_edge/src/heap-snapshot-generator.h
/branches/bleeding_edge/test/cctest/test-heap-profiler.cc
=======================================
--- /branches/bleeding_edge/include/v8-profiler.h Fri May 9 12:59:24 2014
UTC
+++ /branches/bleeding_edge/include/v8-profiler.h Thu May 22 11:26:48 2014
UTC
@@ -219,19 +219,20 @@
class V8_EXPORT HeapGraphNode {
public:
enum Type {
- kHidden = 0, // Hidden node, may be filtered when shown to user.
- kArray = 1, // An array of elements.
- kString = 2, // A string.
- kObject = 3, // A JS object (except for arrays and strings).
- kCode = 4, // Compiled code.
- kClosure = 5, // Function closure.
- kRegExp = 6, // RegExp.
- kHeapNumber = 7, // Number stored in the heap.
- kNative = 8, // Native object (not from V8 heap).
- kSynthetic = 9, // Synthetic object, usualy used for grouping
- // snapshot items together.
- kConsString = 10, // Concatenated string. A pair of pointers to
strings.
- kSlicedString = 11 // Sliced string. A fragment of another string.
+ kHidden = 0, // Hidden node, may be filtered when shown to
user.
+ kArray = 1, // An array of elements.
+ kString = 2, // A string.
+ kObject = 3, // A JS object (except for arrays and strings).
+ kCode = 4, // Compiled code.
+ kClosure = 5, // Function closure.
+ kRegExp = 6, // RegExp.
+ kHeapNumber = 7, // Number stored in the heap.
+ kNative = 8, // Native object (not from V8 heap).
+ kSynthetic = 9, // Synthetic object, usualy used for grouping
+ // snapshot items together.
+ kConsString = 10, // Concatenated string. A pair of pointers to
strings.
+ kSlicedString = 11, // Sliced string. A fragment of another string.
+ kSymbol = 12 // A Symbol (ES6).
};
/** Returns node type (see HeapGraphNode::Type). */
=======================================
--- /branches/bleeding_edge/src/heap-snapshot-generator.cc Thu May 22
11:13:37 2014 UTC
+++ /branches/bleeding_edge/src/heap-snapshot-generator.cc Thu May 22
11:26:48 2014 UTC
@@ -155,6 +155,7 @@
case kSynthetic: return "/synthetic/";
case kConsString: return "/concatenated string/";
case kSlicedString: return "/sliced string/";
+ case kSymbol: return "/symbol/";
default: return "???";
}
}
@@ -851,6 +852,8 @@
return AddEntry(object,
HeapEntry::kString,
names_->GetName(String::cast(object)));
+ } else if (object->IsSymbol()) {
+ return AddEntry(object, HeapEntry::kSymbol, "symbol");
} else if (object->IsCode()) {
return AddEntry(object, HeapEntry::kCode, "");
} else if (object->IsSharedFunctionInfo()) {
@@ -1098,6 +1101,8 @@
ExtractJSObjectReferences(entry, JSObject::cast(obj));
} else if (obj->IsString()) {
ExtractStringReferences(entry, String::cast(obj));
+ } else if (obj->IsSymbol()) {
+ ExtractSymbolReferences(entry, Symbol::cast(obj));
} else if (obj->IsMap()) {
ExtractMapReferences(entry, Map::cast(obj));
} else if (obj->IsSharedFunctionInfo()) {
@@ -1242,6 +1247,13 @@
SlicedString::kParentOffset);
}
}
+
+
+void V8HeapExplorer::ExtractSymbolReferences(int entry, Symbol* symbol) {
+ SetInternalReference(symbol, entry,
+ "name", symbol->name(),
+ Symbol::kNameOffset);
+}
void V8HeapExplorer::ExtractContextReferences(int entry, Context* context)
{
=======================================
--- /branches/bleeding_edge/src/heap-snapshot-generator.h Tue Apr 29
06:42:26 2014 UTC
+++ /branches/bleeding_edge/src/heap-snapshot-generator.h Thu May 22
11:26:48 2014 UTC
@@ -83,7 +83,8 @@
kNative = v8::HeapGraphNode::kNative,
kSynthetic = v8::HeapGraphNode::kSynthetic,
kConsString = v8::HeapGraphNode::kConsString,
- kSlicedString = v8::HeapGraphNode::kSlicedString
+ kSlicedString = v8::HeapGraphNode::kSlicedString,
+ kSymbol = v8::HeapGraphNode::kSymbol
};
static const int kNoEntry;
@@ -368,6 +369,7 @@
void ExtractJSGlobalProxyReferences(int entry, JSGlobalProxy* proxy);
void ExtractJSObjectReferences(int entry, JSObject* js_obj);
void ExtractStringReferences(int entry, String* obj);
+ void ExtractSymbolReferences(int entry, Symbol* symbol);
void ExtractContextReferences(int entry, Context* context);
void ExtractMapReferences(int entry, Map* map);
void ExtractSharedFunctionInfoReferences(int entry,
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Tue May 20
08:52:42 2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Thu May 22
11:26:48 2014 UTC
@@ -471,6 +471,29 @@
}
+TEST(HeapSnapshotSymbol) {
+ i::FLAG_harmony_symbols = true;
+
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+ v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
+
+ CompileRun("a = Symbol('mySymbol');\n");
+ const v8::HeapSnapshot* snapshot =
+ heap_profiler->TakeHeapSnapshot(v8_str("Symbol"));
+ CHECK(ValidateSnapshot(snapshot));
+ const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
+ const v8::HeapGraphNode* a =
+ GetProperty(global, v8::HeapGraphEdge::kProperty, "a");
+ CHECK_NE(NULL, a);
+ CHECK_EQ(a->GetType(), v8::HeapGraphNode::kSymbol);
+ CHECK_EQ(v8_str("symbol"), a->GetName());
+ const v8::HeapGraphNode* name =
+ GetProperty(a, v8::HeapGraphEdge::kInternal, "name");
+ CHECK_NE(NULL, name);
+ CHECK_EQ(v8_str("mySymbol"), name->GetName());
+}
+
TEST(HeapSnapshotInternalReferences) {
v8::Isolate* isolate = CcTest::isolate();
--
--
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.