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

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

Issue 17881005: Heap snapshot: Update user roots definition. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix a typo 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 895c0da1e04f1ea8114bb1de00e566d35b88565a..dd8896ebd72a599a740733e1d6f0f0464ce11d9b 100644
--- a/src/heap-snapshot-generator.cc
+++ b/src/heap-snapshot-generator.cc
@@ -961,7 +961,7 @@ void V8HeapExplorer::ExtractReferences(HeapObject* obj) {
bool extract_indexed_refs = true;
if (obj->IsJSGlobalProxy()) {
- ExtractJSGlobalProxyReferences(JSGlobalProxy::cast(obj));
+ ExtractJSGlobalProxyReferences(entry, JSGlobalProxy::cast(obj));
} else if (obj->IsJSObject()) {
ExtractJSObjectReferences(entry, JSObject::cast(obj));
} else if (obj->IsString()) {
@@ -996,19 +996,11 @@ void V8HeapExplorer::ExtractReferences(HeapObject* obj) {
}
-void V8HeapExplorer::ExtractJSGlobalProxyReferences(JSGlobalProxy* proxy) {
- // We need to reference JS global objects from snapshot's root.
- // We use JSGlobalProxy because this is what embedder (e.g. browser)
- // uses for the global object.
- Object* object = proxy->map()->prototype();
- bool is_debug_object = false;
-#ifdef ENABLE_DEBUGGER_SUPPORT
- is_debug_object = object->IsGlobalObject() &&
- Isolate::Current()->debug()->IsDebugGlobal(GlobalObject::cast(object));
-#endif
- if (!is_debug_object) {
- SetUserGlobalReference(object);
- }
+void V8HeapExplorer::ExtractJSGlobalProxyReferences(
+ int entry, JSGlobalProxy* proxy) {
+ SetInternalReference(proxy, entry,
+ "native_context", proxy->native_context(),
+ JSGlobalProxy::kNativeContextOffset);
}
@@ -1778,6 +1770,22 @@ void V8HeapExplorer::SetGcSubrootReference(
snapshot_->gc_subroot(tag)->index(),
child_entry);
}
+
+ // Add a shortcut to JS global object reference at snapshot root.
+ if (child_obj->IsNativeContext()) {
+ Context* context = Context::cast(child_obj);
+ GlobalObject* global = context->global_object();
+ if (global->IsJSGlobalObject()) {
+ bool is_debug_object = false;
+#ifdef ENABLE_DEBUGGER_SUPPORT
+ is_debug_object = heap_->isolate()->debug()->IsDebugGlobal(global);
+#endif
+ if (!is_debug_object && !user_roots_.Contains(global)) {
+ user_roots_.Insert(global);
+ SetUserGlobalReference(global);
+ }
+ }
+ }
}
}
« 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