OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 CalculateNetworkSize(JSObject::cast(obj)) : obj->Size(); | 62 CalculateNetworkSize(JSObject::cast(obj)) : obj->Size(); |
63 } | 63 } |
64 static void InsertIntoTree(JSObjectsClusterTree* tree, | 64 static void InsertIntoTree(JSObjectsClusterTree* tree, |
65 const JSObjectsCluster& cluster, int size); | 65 const JSObjectsCluster& cluster, int size); |
66 }; | 66 }; |
67 | 67 |
68 | 68 |
69 JSObjectsCluster Clusterizer::Clusterize(HeapObject* obj, bool fine_grain) { | 69 JSObjectsCluster Clusterizer::Clusterize(HeapObject* obj, bool fine_grain) { |
70 if (obj->IsJSObject()) { | 70 if (obj->IsJSObject()) { |
71 JSObject* js_obj = JSObject::cast(obj); | 71 JSObject* js_obj = JSObject::cast(obj); |
72 String* constructor = JSObject::cast(js_obj)->constructor_name(); | 72 String* constructor = GetConstructorNameForHeapProfile( |
| 73 JSObject::cast(js_obj)); |
73 // Differentiate Object and Array instances. | 74 // Differentiate Object and Array instances. |
74 if (fine_grain && (constructor == Heap::Object_symbol() || | 75 if (fine_grain && (constructor == Heap::Object_symbol() || |
75 constructor == Heap::Array_symbol())) { | 76 constructor == Heap::Array_symbol())) { |
76 return JSObjectsCluster(constructor, obj); | 77 return JSObjectsCluster(constructor, obj); |
77 } else { | 78 } else { |
78 return JSObjectsCluster(constructor); | 79 return JSObjectsCluster(constructor); |
79 } | 80 } |
80 } else if (obj->IsString()) { | 81 } else if (obj->IsString()) { |
81 return JSObjectsCluster(Heap::String_symbol()); | 82 return JSObjectsCluster(Heap::String_symbol()); |
82 } else if (obj->IsJSGlobalPropertyCell()) { | 83 } else if (obj->IsJSGlobalPropertyCell()) { |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 // | 708 // |
708 static void StackWeakReferenceCallback(Persistent<Value> object, | 709 static void StackWeakReferenceCallback(Persistent<Value> object, |
709 void* trace) { | 710 void* trace) { |
710 DeleteArray(static_cast<Address*>(trace)); | 711 DeleteArray(static_cast<Address*>(trace)); |
711 object.Dispose(); | 712 object.Dispose(); |
712 } | 713 } |
713 | 714 |
714 | 715 |
715 static void PrintProducerStackTrace(Object* obj, void* trace) { | 716 static void PrintProducerStackTrace(Object* obj, void* trace) { |
716 if (!obj->IsJSObject()) return; | 717 if (!obj->IsJSObject()) return; |
717 String* constructor = JSObject::cast(obj)->constructor_name(); | 718 String* constructor = GetConstructorNameForHeapProfile(JSObject::cast(obj)); |
718 SmartPointer<char> s_name( | 719 SmartPointer<char> s_name( |
719 constructor->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL)); | 720 constructor->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL)); |
720 LOG(HeapSampleJSProducerEvent(GetConstructorName(*s_name), | 721 LOG(HeapSampleJSProducerEvent(GetConstructorName(*s_name), |
721 reinterpret_cast<Address*>(trace))); | 722 reinterpret_cast<Address*>(trace))); |
722 } | 723 } |
723 | 724 |
724 | 725 |
725 void HeapProfiler::WriteSample() { | 726 void HeapProfiler::WriteSample() { |
726 LOG(HeapSampleBeginEvent("Heap", "allocated")); | 727 LOG(HeapSampleBeginEvent("Heap", "allocated")); |
727 LOG(HeapSampleStats( | 728 LOG(HeapSampleStats( |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 return cluster.can_be_coarsed() ? | 880 return cluster.can_be_coarsed() ? |
880 reinterpret_cast<HeapObject*>(cluster.instance()) : cluster.constructor(); | 881 reinterpret_cast<HeapObject*>(cluster.instance()) : cluster.constructor(); |
881 } | 882 } |
882 | 883 |
883 | 884 |
884 static JSObjectsCluster HeapObjectAsCluster(HeapObject* object) { | 885 static JSObjectsCluster HeapObjectAsCluster(HeapObject* object) { |
885 if (object->IsString()) { | 886 if (object->IsString()) { |
886 return JSObjectsCluster(String::cast(object)); | 887 return JSObjectsCluster(String::cast(object)); |
887 } else { | 888 } else { |
888 JSObject* js_obj = JSObject::cast(object); | 889 JSObject* js_obj = JSObject::cast(object); |
889 String* constructor = JSObject::cast(js_obj)->constructor_name(); | 890 String* constructor = GetConstructorNameForHeapProfile( |
| 891 JSObject::cast(js_obj)); |
890 return JSObjectsCluster(constructor, object); | 892 return JSObjectsCluster(constructor, object); |
891 } | 893 } |
892 } | 894 } |
893 | 895 |
894 | 896 |
895 class CountingRetainersIterator { | 897 class CountingRetainersIterator { |
896 public: | 898 public: |
897 CountingRetainersIterator(const JSObjectsCluster& child_cluster, | 899 CountingRetainersIterator(const JSObjectsCluster& child_cluster, |
898 HeapEntriesMap* map) | 900 HeapEntriesMap* map) |
899 : child_(ClusterAsHeapObject(child_cluster)), map_(map) { | 901 : child_(ClusterAsHeapObject(child_cluster)), map_(map) { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 GlobalHandles::MakeWeak(handle.location(), | 1096 GlobalHandles::MakeWeak(handle.location(), |
1095 static_cast<void*>(stack.start()), | 1097 static_cast<void*>(stack.start()), |
1096 StackWeakReferenceCallback); | 1098 StackWeakReferenceCallback); |
1097 } | 1099 } |
1098 | 1100 |
1099 | 1101 |
1100 #endif // ENABLE_LOGGING_AND_PROFILING | 1102 #endif // ENABLE_LOGGING_AND_PROFILING |
1101 | 1103 |
1102 | 1104 |
1103 } } // namespace v8::internal | 1105 } } // namespace v8::internal |
OLD | NEW |