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

Unified Diff: src/heap-snapshot-generator.cc

Issue 17616002: Handle AccessorPair struct in heap snapshot. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments. Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap-snapshot-generator.cc
diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc
index 217d1ca25ecfa9dae22b7270b973700c67a2a09f..882f70638f22d7620f727772d8199f1af59c3293 100644
--- a/src/heap-snapshot-generator.cc
+++ b/src/heap-snapshot-generator.cc
@@ -974,6 +974,8 @@ void V8HeapExplorer::ExtractReferences(HeapObject* obj) {
ExtractSharedFunctionInfoReferences(entry, SharedFunctionInfo::cast(obj));
} else if (obj->IsScript()) {
ExtractScriptReferences(entry, Script::cast(obj));
+ } else if (obj->IsAccessorPair()) {
+ ExtractAccessorPairReferences(entry, AccessorPair::cast(obj));
} else if (obj->IsCodeCache()) {
ExtractCodeCacheReferences(entry, CodeCache::cast(obj));
} else if (obj->IsCode()) {
@@ -1242,6 +1244,15 @@ void V8HeapExplorer::ExtractScriptReferences(int entry, Script* script) {
}
+void V8HeapExplorer::ExtractAccessorPairReferences(
+ int entry, AccessorPair* accessors) {
+ SetInternalReference(accessors, entry, "getter", accessors->getter(),
+ AccessorPair::kGetterOffset);
+ SetInternalReference(accessors, entry, "setter", accessors->setter(),
+ AccessorPair::kSetterOffset);
+}
+
+
void V8HeapExplorer::ExtractCodeCacheReferences(
int entry, CodeCache* code_cache) {
TagObject(code_cache->default_cache(), "(default code cache)");
@@ -1353,21 +1364,11 @@ void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) {
js_obj, entry,
descs->GetKey(i), descs->GetConstantFunction(i));
break;
- case CALLBACKS: {
- Object* callback_obj = descs->GetValue(i);
- if (callback_obj->IsAccessorPair()) {
- AccessorPair* accessors = AccessorPair::cast(callback_obj);
- if (Object* getter = accessors->getter()) {
- SetPropertyReference(js_obj, entry, descs->GetKey(i),
- getter, "get-%s");
- }
- if (Object* setter = accessors->setter()) {
- SetPropertyReference(js_obj, entry, descs->GetKey(i),
- setter, "set-%s");
- }
- }
+ case CALLBACKS:
+ ExtractAccessorPairProperty(
+ js_obj, entry,
+ descs->GetKey(i), descs->GetValue(i));
break;
- }
case NORMAL: // only in slow mode
case HANDLER: // only in lookup results, not in descriptors
case INTERCEPTOR: // only in lookup results, not in descriptors
@@ -1389,18 +1390,35 @@ void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) {
Object* value = target->IsPropertyCell()
? PropertyCell::cast(target)->value()
: target;
- if (k != heap_->hidden_string()) {
- SetPropertyReference(js_obj, entry, String::cast(k), value);
- } else {
+ if (k == heap_->hidden_string()) {
TagObject(value, "(hidden properties)");
SetInternalReference(js_obj, entry, "hidden_properties", value);
+ continue;
}
+ if (ExtractAccessorPairProperty(js_obj, entry, k, value)) continue;
+ SetPropertyReference(js_obj, entry, String::cast(k), value);
}
}
}
}
+bool V8HeapExplorer::ExtractAccessorPairProperty(
+ JSObject* js_obj, int entry, Object* key, Object* callback_obj) {
+ if (!callback_obj->IsAccessorPair()) return false;
+ AccessorPair* accessors = AccessorPair::cast(callback_obj);
+ Object* getter = accessors->getter();
+ if (!getter->IsOddball()) {
+ SetPropertyReference(js_obj, entry, String::cast(key), getter, "get %s");
+ }
+ Object* setter = accessors->setter();
+ if (!setter->IsOddball()) {
+ SetPropertyReference(js_obj, entry, String::cast(key), setter, "set %s");
+ }
+ return true;
+}
+
+
void V8HeapExplorer::ExtractElementReferences(JSObject* js_obj, int entry) {
if (js_obj->HasFastObjectElements()) {
FixedArray* elements = FixedArray::cast(js_obj->elements());
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698