OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/heap-snapshot-generator-inl.h" | 7 #include "src/heap-snapshot-generator-inl.h" |
8 | 8 |
9 #include "src/allocation-tracker.h" | 9 #include "src/allocation-tracker.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 js_obj, entry, i, o, js_obj->GetInternalFieldOffset(i)); | 1779 js_obj, entry, i, o, js_obj->GetInternalFieldOffset(i)); |
1780 } | 1780 } |
1781 } | 1781 } |
1782 | 1782 |
1783 | 1783 |
1784 String* V8HeapExplorer::GetConstructorName(JSObject* object) { | 1784 String* V8HeapExplorer::GetConstructorName(JSObject* object) { |
1785 Heap* heap = object->GetHeap(); | 1785 Heap* heap = object->GetHeap(); |
1786 if (object->IsJSFunction()) return heap->closure_string(); | 1786 if (object->IsJSFunction()) return heap->closure_string(); |
1787 String* constructor_name = object->constructor_name(); | 1787 String* constructor_name = object->constructor_name(); |
1788 if (constructor_name == heap->Object_string()) { | 1788 if (constructor_name == heap->Object_string()) { |
1789 // Look up an immediate "constructor" property, if it is a function, | 1789 // TODO(verwaest): Try to get object.constructor.name in this case. |
1790 // return its name. This is for instances of binding objects, which | 1790 // This requires handlification of the V8HeapExplorer. |
1791 // have prototype constructor type "Object". | |
1792 Object* constructor_prop = NULL; | |
1793 Isolate* isolate = heap->isolate(); | |
1794 LookupResult result(isolate); | |
1795 object->LookupOwnRealNamedProperty( | |
1796 isolate->factory()->constructor_string(), &result); | |
1797 if (!result.IsFound()) return object->constructor_name(); | |
1798 | |
1799 constructor_prop = result.GetLazyValue(); | |
1800 if (constructor_prop->IsJSFunction()) { | |
1801 Object* maybe_name = | |
1802 JSFunction::cast(constructor_prop)->shared()->name(); | |
1803 if (maybe_name->IsString()) { | |
1804 String* name = String::cast(maybe_name); | |
1805 if (name->length() > 0) return name; | |
1806 } | |
1807 } | |
1808 } | 1791 } |
1809 return object->constructor_name(); | 1792 return object->constructor_name(); |
1810 } | 1793 } |
1811 | 1794 |
1812 | 1795 |
1813 HeapEntry* V8HeapExplorer::GetEntry(Object* obj) { | 1796 HeapEntry* V8HeapExplorer::GetEntry(Object* obj) { |
1814 if (!obj->IsHeapObject()) return NULL; | 1797 if (!obj->IsHeapObject()) return NULL; |
1815 return filler_->FindOrAddEntry(obj, this); | 1798 return filler_->FindOrAddEntry(obj, this); |
1816 } | 1799 } |
1817 | 1800 |
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3184 writer_->AddString("\"<dummy>\""); | 3167 writer_->AddString("\"<dummy>\""); |
3185 for (int i = 1; i < sorted_strings.length(); ++i) { | 3168 for (int i = 1; i < sorted_strings.length(); ++i) { |
3186 writer_->AddCharacter(','); | 3169 writer_->AddCharacter(','); |
3187 SerializeString(sorted_strings[i]); | 3170 SerializeString(sorted_strings[i]); |
3188 if (writer_->aborted()) return; | 3171 if (writer_->aborted()) return; |
3189 } | 3172 } |
3190 } | 3173 } |
3191 | 3174 |
3192 | 3175 |
3193 } } // namespace v8::internal | 3176 } } // namespace v8::internal |
OLD | NEW |