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

Side by Side Diff: src/heap-snapshot-generator.cc

Issue 166993002: Make a single HeapEntry per single JSArrayBuffer data in heap snapshot. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added a test. Created 6 years, 10 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 AllocationSite::kNestedSiteOffset); 1449 AllocationSite::kNestedSiteOffset);
1450 SetInternalReference(site, entry, "dependent_code", site->dependent_code(), 1450 SetInternalReference(site, entry, "dependent_code", site->dependent_code(),
1451 AllocationSite::kDependentCodeOffset); 1451 AllocationSite::kDependentCodeOffset);
1452 // Do not visit weak_next as it is not visited by the StaticVisitor, 1452 // Do not visit weak_next as it is not visited by the StaticVisitor,
1453 // and we're not very interested in weak_next field here. 1453 // and we're not very interested in weak_next field here.
1454 STATIC_CHECK(AllocationSite::kWeakNextOffset >= 1454 STATIC_CHECK(AllocationSite::kWeakNextOffset >=
1455 AllocationSite::BodyDescriptor::kEndOffset); 1455 AllocationSite::BodyDescriptor::kEndOffset);
1456 } 1456 }
1457 1457
1458 1458
1459 class JSArrayBufferDataEntryAllocator : public HeapEntriesAllocator {
1460 public:
1461 JSArrayBufferDataEntryAllocator(int size, V8HeapExplorer* explorer)
1462 : size_(size)
1463 , explorer_(explorer) {
1464 }
1465 virtual HeapEntry* AllocateEntry(HeapThing ptr) {
1466 return explorer_->AddEntry(
1467 static_cast<Address>(ptr),
1468 HeapEntry::kNative, "system / JSArrayBufferData", size_);
1469 }
1470 private:
1471 int size_;
1472 V8HeapExplorer* explorer_;
1473 };
1474
1475
1459 void V8HeapExplorer::ExtractJSArrayBufferReferences( 1476 void V8HeapExplorer::ExtractJSArrayBufferReferences(
1460 int entry, JSArrayBuffer* buffer) { 1477 int entry, JSArrayBuffer* buffer) {
1461 SetWeakReference(buffer, entry, "weak_next", buffer->weak_next(), 1478 SetWeakReference(buffer, entry, "weak_next", buffer->weak_next(),
1462 JSArrayBuffer::kWeakNextOffset); 1479 JSArrayBuffer::kWeakNextOffset);
1463 SetWeakReference(buffer, entry, 1480 SetWeakReference(buffer, entry,
1464 "weak_first_view", buffer->weak_first_view(), 1481 "weak_first_view", buffer->weak_first_view(),
1465 JSArrayBuffer::kWeakFirstViewOffset); 1482 JSArrayBuffer::kWeakFirstViewOffset);
1466 // Setup a reference to a native memory backing_store object. 1483 // Setup a reference to a native memory backing_store object.
1467 if (!buffer->backing_store()) 1484 if (!buffer->backing_store())
1468 return; 1485 return;
1469 size_t data_size = NumberToSize(heap_->isolate(), buffer->byte_length()); 1486 size_t data_size = NumberToSize(heap_->isolate(), buffer->byte_length());
1470 CHECK(data_size <= static_cast<size_t>(kMaxInt)); 1487 CHECK(data_size <= static_cast<size_t>(kMaxInt));
1471 HeapEntry* data_entry = AddEntry( 1488 JSArrayBufferDataEntryAllocator allocator(static_cast<int>(data_size), this);
1472 static_cast<Address>(buffer->backing_store()), 1489 HeapEntry* data_entry =
1473 HeapEntry::kNative, "system / ArrayBufferData", 1490 filler_->FindOrAddEntry(buffer->backing_store(), &allocator);
1474 static_cast<int>(data_size));
1475 filler_->SetNamedReference(HeapGraphEdge::kInternal, 1491 filler_->SetNamedReference(HeapGraphEdge::kInternal,
1476 entry, "backing_store", data_entry); 1492 entry, "backing_store", data_entry);
1477 } 1493 }
1478 1494
1479 1495
1480 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, int entry) { 1496 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, int entry) {
1481 if (!js_obj->IsJSFunction()) return; 1497 if (!js_obj->IsJSFunction()) return;
1482 1498
1483 JSFunction* func = JSFunction::cast(js_obj); 1499 JSFunction* func = JSFunction::cast(js_obj);
1484 if (func->shared()->bound()) { 1500 if (func->shared()->bound()) {
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
3023 writer_->AddString("\"<dummy>\""); 3039 writer_->AddString("\"<dummy>\"");
3024 for (int i = 1; i < sorted_strings.length(); ++i) { 3040 for (int i = 1; i < sorted_strings.length(); ++i) {
3025 writer_->AddCharacter(','); 3041 writer_->AddCharacter(',');
3026 SerializeString(sorted_strings[i]); 3042 SerializeString(sorted_strings[i]);
3027 if (writer_->aborted()) return; 3043 if (writer_->aborted()) return;
3028 } 3044 }
3029 } 3045 }
3030 3046
3031 3047
3032 } } // namespace v8::internal 3048 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698