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

Side by Side Diff: src/profile-generator.cc

Issue 4681003: Heap profiler: remove context checks for objects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 10 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/profile-generator.h ('k') | test/cctest/test-heap-profiler.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 return entry; 1841 return entry;
1842 } 1842 }
1843 1843
1844 if (snapshot_->WillAddEntry(object)) entry = filler_->AddEntry(object); 1844 if (snapshot_->WillAddEntry(object)) entry = filler_->AddEntry(object);
1845 } 1845 }
1846 1846
1847 return entry; 1847 return entry;
1848 } 1848 }
1849 1849
1850 1850
1851 int HeapSnapshotGenerator::GetGlobalSecurityToken() {
1852 return collection_->token_enumerator()->GetTokenId(
1853 Top::context()->global()->global_context()->security_token());
1854 }
1855
1856
1857 int HeapSnapshotGenerator::GetObjectSecurityToken(HeapObject* obj) {
1858 if (obj->IsGlobalContext()) {
1859 return collection_->token_enumerator()->GetTokenId(
1860 Context::cast(obj)->security_token());
1861 } else {
1862 return TokenEnumerator::kNoSecurityToken;
1863 }
1864 }
1865
1866
1867 class IndexedReferencesExtractor : public ObjectVisitor { 1851 class IndexedReferencesExtractor : public ObjectVisitor {
1868 public: 1852 public:
1869 IndexedReferencesExtractor(HeapSnapshotGenerator* generator, 1853 IndexedReferencesExtractor(HeapSnapshotGenerator* generator,
1870 HeapObject* parent_obj, 1854 HeapObject* parent_obj,
1871 HeapEntry* parent_entry) 1855 HeapEntry* parent_entry)
1872 : generator_(generator), 1856 : generator_(generator),
1873 parent_obj_(parent_obj), 1857 parent_obj_(parent_obj),
1874 parent_(parent_entry), 1858 parent_(parent_entry),
1875 next_index_(1) { 1859 next_index_(1) {
1876 } 1860 }
1877 1861
1878 void VisitPointer(Object** o) { 1862 void VisitPointer(Object** o) {
1879 generator_->SetElementReference(parent_obj_, parent_, next_index_++, *o); 1863 generator_->SetElementReference(parent_obj_, parent_, next_index_++, *o);
1880 } 1864 }
1881 1865
1882 void VisitPointers(Object** start, Object** end) { 1866 void VisitPointers(Object** start, Object** end) {
1883 for (Object** p = start; p < end; p++) VisitPointer(p); 1867 for (Object** p = start; p < end; p++) VisitPointer(p);
1884 } 1868 }
1885 1869
1886 private: 1870 private:
1887 HeapSnapshotGenerator* generator_; 1871 HeapSnapshotGenerator* generator_;
1888 HeapObject* parent_obj_; 1872 HeapObject* parent_obj_;
1889 HeapEntry* parent_; 1873 HeapEntry* parent_;
1890 int next_index_; 1874 int next_index_;
1891 }; 1875 };
1892 1876
1893 1877
1894 void HeapSnapshotGenerator::ExtractReferences(HeapObject* obj) { 1878 void HeapSnapshotGenerator::ExtractReferences(HeapObject* obj) {
1895 // We need to reference JS global objects from snapshot's root. 1879 // We need to reference JS global objects from snapshot's root.
1896 // We also need to only include global objects from the current 1880 // We use JSGlobalProxy because this is what embedder (e.g. browser)
1897 // security context. And we don't want to add the global proxy, 1881 // uses for the global object.
1898 // as we don't have a special type for it.
1899 if (obj->IsJSGlobalProxy()) { 1882 if (obj->IsJSGlobalProxy()) {
1900 int global_security_token = GetGlobalSecurityToken();
1901 JSGlobalProxy* proxy = JSGlobalProxy::cast(obj); 1883 JSGlobalProxy* proxy = JSGlobalProxy::cast(obj);
1902 int object_security_token = 1884 SetRootReference(proxy->map()->prototype());
1903 collection_->token_enumerator()->GetTokenId(
1904 Context::cast(proxy->context())->security_token());
1905 if (object_security_token == TokenEnumerator::kNoSecurityToken
1906 || object_security_token == global_security_token) {
1907 SetRootReference(proxy->map()->prototype());
1908 }
1909 return; 1885 return;
1910 } 1886 }
1911 1887
1912 HeapEntry* entry = GetEntry(obj); 1888 HeapEntry* entry = GetEntry(obj);
1913 if (entry == NULL) return; // No interest in this object. 1889 if (entry == NULL) return; // No interest in this object.
1914 1890
1915 if (obj->IsJSObject()) { 1891 if (obj->IsJSObject()) {
1916 JSObject* js_obj = JSObject::cast(obj); 1892 JSObject* js_obj = JSObject::cast(obj);
1917 ExtractClosureReferences(js_obj, entry); 1893 ExtractClosureReferences(js_obj, entry);
1918 ExtractPropertyReferences(js_obj, entry); 1894 ExtractPropertyReferences(js_obj, entry);
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
2546 void HeapSnapshotJSONSerializer::SortHashMap( 2522 void HeapSnapshotJSONSerializer::SortHashMap(
2547 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 2523 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2548 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 2524 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2549 sorted_entries->Add(p); 2525 sorted_entries->Add(p);
2550 sorted_entries->Sort(SortUsingEntryValue); 2526 sorted_entries->Sort(SortUsingEntryValue);
2551 } 2527 }
2552 2528
2553 } } // namespace v8::internal 2529 } } // namespace v8::internal
2554 2530
2555 #endif // ENABLE_LOGGING_AND_PROFILING 2531 #endif // ENABLE_LOGGING_AND_PROFILING
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698