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

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

Issue 9227007: Version 3.8.6 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/profile-generator.h ('k') | src/runtime.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 } 105 }
106 106
107 107
108 const char* StringsStorage::GetCopy(const char* src) { 108 const char* StringsStorage::GetCopy(const char* src) {
109 int len = static_cast<int>(strlen(src)); 109 int len = static_cast<int>(strlen(src));
110 Vector<char> dst = Vector<char>::New(len + 1); 110 Vector<char> dst = Vector<char>::New(len + 1);
111 OS::StrNCpy(dst, src, len); 111 OS::StrNCpy(dst, src, len);
112 dst[len] = '\0'; 112 dst[len] = '\0';
113 uint32_t hash = 113 uint32_t hash =
114 HashSequentialString(dst.start(), len, HEAP->StringHashSeed()); 114 HashSequentialString(dst.start(), len, HEAP->HashSeed());
115 return AddOrDisposeString(dst.start(), hash); 115 return AddOrDisposeString(dst.start(), hash);
116 } 116 }
117 117
118 118
119 const char* StringsStorage::GetFormatted(const char* format, ...) { 119 const char* StringsStorage::GetFormatted(const char* format, ...) {
120 va_list args; 120 va_list args;
121 va_start(args, format); 121 va_start(args, format);
122 const char* result = GetVFormatted(format, args); 122 const char* result = GetVFormatted(format, args);
123 va_end(args); 123 va_end(args);
124 return result; 124 return result;
(...skipping 13 matching lines...) Expand all
138 138
139 139
140 const char* StringsStorage::GetVFormatted(const char* format, va_list args) { 140 const char* StringsStorage::GetVFormatted(const char* format, va_list args) {
141 Vector<char> str = Vector<char>::New(1024); 141 Vector<char> str = Vector<char>::New(1024);
142 int len = OS::VSNPrintF(str, format, args); 142 int len = OS::VSNPrintF(str, format, args);
143 if (len == -1) { 143 if (len == -1) {
144 DeleteArray(str.start()); 144 DeleteArray(str.start());
145 return format; 145 return format;
146 } 146 }
147 uint32_t hash = HashSequentialString( 147 uint32_t hash = HashSequentialString(
148 str.start(), len, HEAP->StringHashSeed()); 148 str.start(), len, HEAP->HashSeed());
149 return AddOrDisposeString(str.start(), hash); 149 return AddOrDisposeString(str.start(), hash);
150 } 150 }
151 151
152 152
153 const char* StringsStorage::GetName(String* name) { 153 const char* StringsStorage::GetName(String* name) {
154 if (name->IsString()) { 154 if (name->IsString()) {
155 int length = Min(kMaxNameSize, name->length()); 155 int length = Min(kMaxNameSize, name->length());
156 SmartArrayPointer<char> data = 156 SmartArrayPointer<char> data =
157 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length); 157 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length);
158 uint32_t hash = 158 uint32_t hash =
159 HashSequentialString(*data, length, name->GetHeap()->StringHashSeed()); 159 HashSequentialString(*data, length, name->GetHeap()->HashSeed());
160 return AddOrDisposeString(data.Detach(), hash); 160 return AddOrDisposeString(data.Detach(), hash);
161 } 161 }
162 return ""; 162 return "";
163 } 163 }
164 164
165 165
166 const char* StringsStorage::GetName(int index) { 166 const char* StringsStorage::GetName(int index) {
167 return GetFormatted("%d", index); 167 return GetFormatted("%d", index);
168 } 168 }
169 169
170 170
171 const char* const CodeEntry::kEmptyNamePrefix = ""; 171 const char* const CodeEntry::kEmptyNamePrefix = "";
172 172
173 173
174 void CodeEntry::CopyData(const CodeEntry& source) { 174 void CodeEntry::CopyData(const CodeEntry& source) {
175 tag_ = source.tag_; 175 tag_ = source.tag_;
176 name_prefix_ = source.name_prefix_; 176 name_prefix_ = source.name_prefix_;
177 name_ = source.name_; 177 name_ = source.name_;
178 resource_name_ = source.resource_name_; 178 resource_name_ = source.resource_name_;
179 line_number_ = source.line_number_; 179 line_number_ = source.line_number_;
180 } 180 }
181 181
182 182
183 uint32_t CodeEntry::GetCallUid() const { 183 uint32_t CodeEntry::GetCallUid() const {
184 uint32_t hash = ComputeIntegerHash(tag_); 184 uint32_t hash = ComputeIntegerHash(tag_, v8::internal::kZeroHashSeed);
185 if (shared_id_ != 0) { 185 if (shared_id_ != 0) {
186 hash ^= ComputeIntegerHash( 186 hash ^= ComputeIntegerHash(static_cast<uint32_t>(shared_id_),
187 static_cast<uint32_t>(shared_id_)); 187 v8::internal::kZeroHashSeed);
188 } else { 188 } else {
189 hash ^= ComputeIntegerHash( 189 hash ^= ComputeIntegerHash(
190 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_prefix_))); 190 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_prefix_)),
191 v8::internal::kZeroHashSeed);
191 hash ^= ComputeIntegerHash( 192 hash ^= ComputeIntegerHash(
192 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_))); 193 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_)),
194 v8::internal::kZeroHashSeed);
193 hash ^= ComputeIntegerHash( 195 hash ^= ComputeIntegerHash(
194 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(resource_name_))); 196 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(resource_name_)),
195 hash ^= ComputeIntegerHash(line_number_); 197 v8::internal::kZeroHashSeed);
198 hash ^= ComputeIntegerHash(line_number_, v8::internal::kZeroHashSeed);
196 } 199 }
197 return hash; 200 return hash;
198 } 201 }
199 202
200 203
201 bool CodeEntry::IsSameAs(CodeEntry* entry) const { 204 bool CodeEntry::IsSameAs(CodeEntry* entry) const {
202 return this == entry 205 return this == entry
203 || (tag_ == entry->tag_ 206 || (tag_ == entry->tag_
204 && shared_id_ == entry->shared_id_ 207 && shared_id_ == entry->shared_id_
205 && (shared_id_ != 0 208 && (shared_id_ != 0
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 } else if (sample.tos != NULL) { 897 } else if (sample.tos != NULL) {
895 // Find out, if top of stack was pointing inside a JS function 898 // Find out, if top of stack was pointing inside a JS function
896 // meaning that we have encountered a frameless invocation. 899 // meaning that we have encountered a frameless invocation.
897 *entry = code_map_.FindEntry(sample.tos); 900 *entry = code_map_.FindEntry(sample.tos);
898 if (*entry != NULL && !(*entry)->is_js_function()) { 901 if (*entry != NULL && !(*entry)->is_js_function()) {
899 *entry = NULL; 902 *entry = NULL;
900 } 903 }
901 entry++; 904 entry++;
902 } 905 }
903 906
904 for (const Address *stack_pos = sample.stack, 907 for (const Address* stack_pos = sample.stack,
905 *stack_end = stack_pos + sample.frames_count; 908 *stack_end = stack_pos + sample.frames_count;
906 stack_pos != stack_end; 909 stack_pos != stack_end;
907 ++stack_pos) { 910 ++stack_pos) {
908 *entry++ = code_map_.FindEntry(*stack_pos); 911 *entry++ = code_map_.FindEntry(*stack_pos);
909 } 912 }
910 } 913 }
911 914
912 if (FLAG_prof_browser_mode) { 915 if (FLAG_prof_browser_mode) {
913 bool no_symbolized_entries = true; 916 bool no_symbolized_entries = true;
914 for (CodeEntry** e = entries.start(); e != entry; ++e) { 917 for (CodeEntry** e = entries.start(); e != entry; ++e) {
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 type_(type), 1224 type_(type),
1222 title_(title), 1225 title_(title),
1223 uid_(uid), 1226 uid_(uid),
1224 root_entry_(NULL), 1227 root_entry_(NULL),
1225 gc_roots_entry_(NULL), 1228 gc_roots_entry_(NULL),
1226 natives_root_entry_(NULL), 1229 natives_root_entry_(NULL),
1227 raw_entries_(NULL), 1230 raw_entries_(NULL),
1228 entries_sorted_(false) { 1231 entries_sorted_(false) {
1229 STATIC_ASSERT( 1232 STATIC_ASSERT(
1230 sizeof(HeapGraphEdge) == 1233 sizeof(HeapGraphEdge) ==
1231 SnapshotSizeConstants<sizeof(void*)>::kExpectedHeapGraphEdgeSize); // NOL INT 1234 SnapshotSizeConstants<kPointerSize>::kExpectedHeapGraphEdgeSize);
1232 STATIC_ASSERT( 1235 STATIC_ASSERT(
1233 sizeof(HeapEntry) == 1236 sizeof(HeapEntry) ==
1234 SnapshotSizeConstants<sizeof(void*)>::kExpectedHeapEntrySize); // NOLINT 1237 SnapshotSizeConstants<kPointerSize>::kExpectedHeapEntrySize);
1235 for (int i = 0; i < VisitorSynchronization::kNumberOfSyncTags; ++i) { 1238 for (int i = 0; i < VisitorSynchronization::kNumberOfSyncTags; ++i) {
1236 gc_subroot_entries_[i] = NULL; 1239 gc_subroot_entries_[i] = NULL;
1237 } 1240 }
1238 } 1241 }
1239 1242
1240 HeapSnapshot::~HeapSnapshot() { 1243 HeapSnapshot::~HeapSnapshot() {
1241 DeleteArray(raw_entries_); 1244 DeleteArray(raw_entries_);
1242 } 1245 }
1243 1246
1244 1247
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 delete entries_; 1502 delete entries_;
1500 entries_ = new_entries; 1503 entries_ = new_entries;
1501 } 1504 }
1502 1505
1503 1506
1504 uint64_t HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { 1507 uint64_t HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) {
1505 uint64_t id = static_cast<uint64_t>(info->GetHash()); 1508 uint64_t id = static_cast<uint64_t>(info->GetHash());
1506 const char* label = info->GetLabel(); 1509 const char* label = info->GetLabel();
1507 id ^= HashSequentialString(label, 1510 id ^= HashSequentialString(label,
1508 static_cast<int>(strlen(label)), 1511 static_cast<int>(strlen(label)),
1509 HEAP->StringHashSeed()); 1512 HEAP->HashSeed());
1510 intptr_t element_count = info->GetElementCount(); 1513 intptr_t element_count = info->GetElementCount();
1511 if (element_count != -1) 1514 if (element_count != -1)
1512 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count)); 1515 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count),
1516 v8::internal::kZeroHashSeed);
1513 return id << 1; 1517 return id << 1;
1514 } 1518 }
1515 1519
1516 1520
1517 HeapSnapshotsCollection::HeapSnapshotsCollection() 1521 HeapSnapshotsCollection::HeapSnapshotsCollection()
1518 : is_tracking_objects_(false), 1522 : is_tracking_objects_(false),
1519 snapshots_uids_(HeapSnapshotsMatch), 1523 snapshots_uids_(HeapSnapshotsMatch),
1520 token_enumerator_(new TokenEnumerator()) { 1524 token_enumerator_(new TokenEnumerator()) {
1521 } 1525 }
1522 1526
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 if (ids_.FindObject(obj->address()) == id) { 1588 if (ids_.FindObject(obj->address()) == id) {
1585 ASSERT(object == NULL); 1589 ASSERT(object == NULL);
1586 object = obj; 1590 object = obj;
1587 // Can't break -- kFilterUnreachable requires full heap traversal. 1591 // Can't break -- kFilterUnreachable requires full heap traversal.
1588 } 1592 }
1589 } 1593 }
1590 return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>(); 1594 return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>();
1591 } 1595 }
1592 1596
1593 1597
1594 HeapEntry *const HeapEntriesMap::kHeapEntryPlaceholder = 1598 HeapEntry* const HeapEntriesMap::kHeapEntryPlaceholder =
1595 reinterpret_cast<HeapEntry*>(1); 1599 reinterpret_cast<HeapEntry*>(1);
1596 1600
1597 HeapEntriesMap::HeapEntriesMap() 1601 HeapEntriesMap::HeapEntriesMap()
1598 : entries_(HeapThingsMatch), 1602 : entries_(HeapThingsMatch),
1599 entries_count_(0), 1603 entries_count_(0),
1600 total_children_count_(0), 1604 total_children_count_(0),
1601 total_retainers_count_(0) { 1605 total_retainers_count_(0) {
1602 } 1606 }
1603 1607
1604 1608
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 1717
1714 void HeapObjectsSet::SetTag(Object* obj, const char* tag) { 1718 void HeapObjectsSet::SetTag(Object* obj, const char* tag) {
1715 if (!obj->IsHeapObject()) return; 1719 if (!obj->IsHeapObject()) return;
1716 HeapObject* object = HeapObject::cast(obj); 1720 HeapObject* object = HeapObject::cast(obj);
1717 HashMap::Entry* cache_entry = 1721 HashMap::Entry* cache_entry =
1718 entries_.Lookup(object, HeapEntriesMap::Hash(object), true); 1722 entries_.Lookup(object, HeapEntriesMap::Hash(object), true);
1719 cache_entry->value = const_cast<char*>(tag); 1723 cache_entry->value = const_cast<char*>(tag);
1720 } 1724 }
1721 1725
1722 1726
1723 HeapObject *const V8HeapExplorer::kInternalRootObject = 1727 HeapObject* const V8HeapExplorer::kInternalRootObject =
1724 reinterpret_cast<HeapObject*>( 1728 reinterpret_cast<HeapObject*>(
1725 static_cast<intptr_t>(HeapObjectsMap::kInternalRootObjectId)); 1729 static_cast<intptr_t>(HeapObjectsMap::kInternalRootObjectId));
1726 HeapObject *const V8HeapExplorer::kGcRootsObject = 1730 HeapObject* const V8HeapExplorer::kGcRootsObject =
1727 reinterpret_cast<HeapObject*>( 1731 reinterpret_cast<HeapObject*>(
1728 static_cast<intptr_t>(HeapObjectsMap::kGcRootsObjectId)); 1732 static_cast<intptr_t>(HeapObjectsMap::kGcRootsObjectId));
1729 HeapObject *const V8HeapExplorer::kFirstGcSubrootObject = 1733 HeapObject* const V8HeapExplorer::kFirstGcSubrootObject =
1730 reinterpret_cast<HeapObject*>( 1734 reinterpret_cast<HeapObject*>(
1731 static_cast<intptr_t>(HeapObjectsMap::kGcRootsFirstSubrootId)); 1735 static_cast<intptr_t>(HeapObjectsMap::kGcRootsFirstSubrootId));
1732 HeapObject *const V8HeapExplorer::kLastGcSubrootObject = 1736 HeapObject* const V8HeapExplorer::kLastGcSubrootObject =
1733 reinterpret_cast<HeapObject*>( 1737 reinterpret_cast<HeapObject*>(
1734 static_cast<intptr_t>(HeapObjectsMap::kFirstAvailableObjectId)); 1738 static_cast<intptr_t>(HeapObjectsMap::kFirstAvailableObjectId));
1735 1739
1736 1740
1737 V8HeapExplorer::V8HeapExplorer( 1741 V8HeapExplorer::V8HeapExplorer(
1738 HeapSnapshot* snapshot, 1742 HeapSnapshot* snapshot,
1739 SnapshottingProgressReportingInterface* progress) 1743 SnapshottingProgressReportingInterface* progress)
1740 : heap_(Isolate::Current()->heap()), 1744 : heap_(Isolate::Current()->heap()),
1741 snapshot_(snapshot), 1745 snapshot_(snapshot),
1742 collection_(snapshot_->collection()), 1746 collection_(snapshot_->collection()),
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
2219 } 2223 }
2220 break; 2224 break;
2221 } 2225 }
2222 case CONSTANT_FUNCTION: 2226 case CONSTANT_FUNCTION:
2223 SetPropertyReference( 2227 SetPropertyReference(
2224 js_obj, entry, 2228 js_obj, entry,
2225 descs->GetKey(i), descs->GetConstantFunction(i)); 2229 descs->GetKey(i), descs->GetConstantFunction(i));
2226 break; 2230 break;
2227 case CALLBACKS: { 2231 case CALLBACKS: {
2228 Object* callback_obj = descs->GetValue(i); 2232 Object* callback_obj = descs->GetValue(i);
2229 if (callback_obj->IsFixedArray()) { 2233 if (callback_obj->IsAccessorPair()) {
2230 FixedArray* accessors = FixedArray::cast(callback_obj); 2234 AccessorPair* accessors = AccessorPair::cast(callback_obj);
2231 if (Object* getter = accessors->get(JSObject::kGetterIndex)) { 2235 if (Object* getter = accessors->getter()) {
2232 SetPropertyReference(js_obj, entry, descs->GetKey(i), 2236 SetPropertyReference(js_obj, entry, descs->GetKey(i),
2233 getter, "get-%s"); 2237 getter, "get-%s");
2234 } 2238 }
2235 if (Object* setter = accessors->get(JSObject::kSetterIndex)) { 2239 if (Object* setter = accessors->setter()) {
2236 SetPropertyReference(js_obj, entry, descs->GetKey(i), 2240 SetPropertyReference(js_obj, entry, descs->GetKey(i),
2237 setter, "set-%s"); 2241 setter, "set-%s");
2238 } 2242 }
2239 } 2243 }
2240 break; 2244 break;
2241 } 2245 }
2242 case NORMAL: // only in slow mode 2246 case NORMAL: // only in slow mode
2243 case HANDLER: // only in lookup results, not in descriptors 2247 case HANDLER: // only in lookup results, not in descriptors
2244 case INTERCEPTOR: // only in lookup results, not in descriptors 2248 case INTERCEPTOR: // only in lookup results, not in descriptors
2245 case MAP_TRANSITION: // we do not care about transitions here... 2249 case MAP_TRANSITION: // we do not care about transitions here...
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 FixedArray* elements = FixedArray::cast(js_obj->elements()); 2282 FixedArray* elements = FixedArray::cast(js_obj->elements());
2279 int length = js_obj->IsJSArray() ? 2283 int length = js_obj->IsJSArray() ?
2280 Smi::cast(JSArray::cast(js_obj)->length())->value() : 2284 Smi::cast(JSArray::cast(js_obj)->length())->value() :
2281 elements->length(); 2285 elements->length();
2282 for (int i = 0; i < length; ++i) { 2286 for (int i = 0; i < length; ++i) {
2283 if (!elements->get(i)->IsTheHole()) { 2287 if (!elements->get(i)->IsTheHole()) {
2284 SetElementReference(js_obj, entry, i, elements->get(i)); 2288 SetElementReference(js_obj, entry, i, elements->get(i));
2285 } 2289 }
2286 } 2290 }
2287 } else if (js_obj->HasDictionaryElements()) { 2291 } else if (js_obj->HasDictionaryElements()) {
2288 NumberDictionary* dictionary = js_obj->element_dictionary(); 2292 SeededNumberDictionary* dictionary = js_obj->element_dictionary();
2289 int length = dictionary->Capacity(); 2293 int length = dictionary->Capacity();
2290 for (int i = 0; i < length; ++i) { 2294 for (int i = 0; i < length; ++i) {
2291 Object* k = dictionary->KeyAt(i); 2295 Object* k = dictionary->KeyAt(i);
2292 if (dictionary->IsKey(k)) { 2296 if (dictionary->IsKey(k)) {
2293 ASSERT(k->IsNumber()); 2297 ASSERT(k->IsNumber());
2294 uint32_t index = static_cast<uint32_t>(k->Number()); 2298 uint32_t index = static_cast<uint32_t>(k->Number());
2295 SetElementReference(js_obj, entry, index, dictionary->ValueAt(i)); 2299 SetElementReference(js_obj, entry, index, dictionary->ValueAt(i));
2296 } 2300 }
2297 } 2301 }
2298 } 2302 }
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after
3634 3638
3635 3639
3636 void HeapSnapshotJSONSerializer::SortHashMap( 3640 void HeapSnapshotJSONSerializer::SortHashMap(
3637 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 3641 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
3638 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 3642 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
3639 sorted_entries->Add(p); 3643 sorted_entries->Add(p);
3640 sorted_entries->Sort(SortUsingEntryValue); 3644 sorted_entries->Sort(SortUsingEntryValue);
3641 } 3645 }
3642 3646
3643 } } // namespace v8::internal 3647 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698