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

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

Issue 8491041: Fix missing fast property accessors in heap snapshots. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments addressed Created 9 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
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 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 SetPropertyReference( 1911 SetPropertyReference(
1912 obj, entry, heap_->Proto_symbol(), js_obj->GetPrototype()); 1912 obj, entry, heap_->Proto_symbol(), js_obj->GetPrototype());
1913 if (obj->IsJSFunction()) { 1913 if (obj->IsJSFunction()) {
1914 JSFunction* js_fun = JSFunction::cast(js_obj); 1914 JSFunction* js_fun = JSFunction::cast(js_obj);
1915 Object* proto_or_map = js_fun->prototype_or_initial_map(); 1915 Object* proto_or_map = js_fun->prototype_or_initial_map();
1916 if (!proto_or_map->IsTheHole()) { 1916 if (!proto_or_map->IsTheHole()) {
1917 if (!proto_or_map->IsMap()) { 1917 if (!proto_or_map->IsMap()) {
1918 SetPropertyReference( 1918 SetPropertyReference(
1919 obj, entry, 1919 obj, entry,
1920 heap_->prototype_symbol(), proto_or_map, 1920 heap_->prototype_symbol(), proto_or_map,
1921 NULL,
1921 JSFunction::kPrototypeOrInitialMapOffset); 1922 JSFunction::kPrototypeOrInitialMapOffset);
1922 } else { 1923 } else {
1923 SetPropertyReference( 1924 SetPropertyReference(
1924 obj, entry, 1925 obj, entry,
1925 heap_->prototype_symbol(), js_fun->prototype()); 1926 heap_->prototype_symbol(), js_fun->prototype());
1926 } 1927 }
1927 } 1928 }
1928 SetInternalReference(js_fun, entry, 1929 SetInternalReference(js_fun, entry,
1929 "shared", js_fun->shared(), 1930 "shared", js_fun->shared(),
1930 JSFunction::kSharedFunctionInfoOffset); 1931 JSFunction::kSharedFunctionInfoOffset);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 if (js_obj->HasFastProperties()) { 2095 if (js_obj->HasFastProperties()) {
2095 DescriptorArray* descs = js_obj->map()->instance_descriptors(); 2096 DescriptorArray* descs = js_obj->map()->instance_descriptors();
2096 for (int i = 0; i < descs->number_of_descriptors(); i++) { 2097 for (int i = 0; i < descs->number_of_descriptors(); i++) {
2097 switch (descs->GetType(i)) { 2098 switch (descs->GetType(i)) {
2098 case FIELD: { 2099 case FIELD: {
2099 int index = descs->GetFieldIndex(i); 2100 int index = descs->GetFieldIndex(i);
2100 if (index < js_obj->map()->inobject_properties()) { 2101 if (index < js_obj->map()->inobject_properties()) {
2101 SetPropertyReference( 2102 SetPropertyReference(
2102 js_obj, entry, 2103 js_obj, entry,
2103 descs->GetKey(i), js_obj->InObjectPropertyAt(index), 2104 descs->GetKey(i), js_obj->InObjectPropertyAt(index),
2105 NULL,
2104 js_obj->GetInObjectPropertyOffset(index)); 2106 js_obj->GetInObjectPropertyOffset(index));
2105 } else { 2107 } else {
2106 SetPropertyReference( 2108 SetPropertyReference(
2107 js_obj, entry, 2109 js_obj, entry,
2108 descs->GetKey(i), js_obj->FastPropertyAt(index)); 2110 descs->GetKey(i), js_obj->FastPropertyAt(index));
2109 } 2111 }
2110 break; 2112 break;
2111 } 2113 }
2112 case CONSTANT_FUNCTION: 2114 case CONSTANT_FUNCTION:
2113 SetPropertyReference( 2115 SetPropertyReference(
2114 js_obj, entry, 2116 js_obj, entry,
2115 descs->GetKey(i), descs->GetConstantFunction(i)); 2117 descs->GetKey(i), descs->GetConstantFunction(i));
2116 break; 2118 break;
2119 case CALLBACKS: {
2120 Object* callback_obj = descs->GetValue(i);
2121 if (callback_obj->IsFixedArray()) {
2122 FixedArray* accessors = FixedArray::cast(callback_obj);
2123 if (Object* getter = accessors->get(JSObject::kGetterIndex)) {
2124 SetPropertyReference(js_obj, entry, descs->GetKey(i),
2125 getter, "get-%s");
2126 }
2127 if (Object* setter = accessors->get(JSObject::kSetterIndex)) {
2128 SetPropertyReference(js_obj, entry, descs->GetKey(i),
2129 setter, "set-%s");
2130 }
2131 }
2132 break;
2133 }
2117 case NORMAL: // only in slow mode 2134 case NORMAL: // only in slow mode
2118 case HANDLER: // only in lookup results, not in descriptors 2135 case HANDLER: // only in lookup results, not in descriptors
2119 case INTERCEPTOR: // only in lookup results, not in descriptors 2136 case INTERCEPTOR: // only in lookup results, not in descriptors
2120 case MAP_TRANSITION: // we do not care about transitions here... 2137 case MAP_TRANSITION: // we do not care about transitions here...
2121 case ELEMENTS_TRANSITION: 2138 case ELEMENTS_TRANSITION:
2122 case CONSTANT_TRANSITION: 2139 case CONSTANT_TRANSITION:
2123 case NULL_DESCRIPTOR: // ... and not about "holes" 2140 case NULL_DESCRIPTOR: // ... and not about "holes"
2124 break; 2141 break;
2125 // TODO(svenpanne): Should we really ignore accessors here?
2126 case CALLBACKS:
2127 break;
2128 } 2142 }
2129 } 2143 }
2130 } else { 2144 } else {
2131 StringDictionary* dictionary = js_obj->property_dictionary(); 2145 StringDictionary* dictionary = js_obj->property_dictionary();
2132 int length = dictionary->Capacity(); 2146 int length = dictionary->Capacity();
2133 for (int i = 0; i < length; ++i) { 2147 for (int i = 0; i < length; ++i) {
2134 Object* k = dictionary->KeyAt(i); 2148 Object* k = dictionary->KeyAt(i);
2135 if (dictionary->IsKey(k)) { 2149 if (dictionary->IsKey(k)) {
2136 Object* target = dictionary->ValueAt(i); 2150 Object* target = dictionary->ValueAt(i);
2137 SetPropertyReference( 2151 SetPropertyReference(
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2342 child_obj, 2356 child_obj,
2343 child_entry); 2357 child_entry);
2344 } 2358 }
2345 } 2359 }
2346 2360
2347 2361
2348 void V8HeapExplorer::SetPropertyReference(HeapObject* parent_obj, 2362 void V8HeapExplorer::SetPropertyReference(HeapObject* parent_obj,
2349 HeapEntry* parent_entry, 2363 HeapEntry* parent_entry,
2350 String* reference_name, 2364 String* reference_name,
2351 Object* child_obj, 2365 Object* child_obj,
2366 const char* name_format_string,
2352 int field_offset) { 2367 int field_offset) {
2353 HeapEntry* child_entry = GetEntry(child_obj); 2368 HeapEntry* child_entry = GetEntry(child_obj);
2354 if (child_entry != NULL) { 2369 if (child_entry != NULL) {
2355 HeapGraphEdge::Type type = reference_name->length() > 0 ? 2370 HeapGraphEdge::Type type = reference_name->length() > 0 ?
2356 HeapGraphEdge::kProperty : HeapGraphEdge::kInternal; 2371 HeapGraphEdge::kProperty : HeapGraphEdge::kInternal;
2372 const char* name = name_format_string != NULL ?
2373 collection_->names()->GetFormatted(
2374 name_format_string,
2375 *reference_name->ToCString(DISALLOW_NULLS,
2376 ROBUST_STRING_TRAVERSAL)) :
2377 collection_->names()->GetName(reference_name);
2378
2357 filler_->SetNamedReference(type, 2379 filler_->SetNamedReference(type,
2358 parent_obj, 2380 parent_obj,
2359 parent_entry, 2381 parent_entry,
2360 collection_->names()->GetName(reference_name), 2382 name,
2361 child_obj, 2383 child_obj,
2362 child_entry); 2384 child_entry);
2363 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); 2385 IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset);
2364 } 2386 }
2365 } 2387 }
2366 2388
2367 2389
2368 void V8HeapExplorer::SetPropertyShortcutReference(HeapObject* parent_obj, 2390 void V8HeapExplorer::SetPropertyShortcutReference(HeapObject* parent_obj,
2369 HeapEntry* parent_entry, 2391 HeapEntry* parent_entry,
2370 String* reference_name, 2392 String* reference_name,
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
3419 3441
3420 3442
3421 void HeapSnapshotJSONSerializer::SortHashMap( 3443 void HeapSnapshotJSONSerializer::SortHashMap(
3422 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 3444 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
3423 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 3445 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
3424 sorted_entries->Add(p); 3446 sorted_entries->Add(p);
3425 sorted_entries->Sort(SortUsingEntryValue); 3447 sorted_entries->Sort(SortUsingEntryValue);
3426 } 3448 }
3427 3449
3428 } } // namespace v8::internal 3450 } } // namespace v8::internal
OLDNEW
« src/objects.cc ('K') | « 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