Title: [201226] trunk/Source/_javascript_Core
- Revision
- 201226
- Author
- [email protected]
- Date
- 2016-05-20 14:47:18 -0700 (Fri, 20 May 2016)
Log Message
Web Inspector: retained size for typed arrays does not count native backing store
https://bugs.webkit.org/show_bug.cgi?id=157945
<rdar://problem/26392238>
Patch by Joseph Pecoraro <[email protected]> on 2016-05-20
Reviewed by Geoffrey Garen.
* runtime/JSArrayBuffer.h:
* runtime/JSArrayBuffer.cpp:
(JSC::JSArrayBuffer::estimatedSize):
Include an estimatedSize implementation for JSArrayBuffer.
ArrayBuffer has a unique path, different from other data
stored in the Heap.
* tests/heapProfiler/typed-array-sizes.js: Added.
Test sizes of TypedArray with and without an ArrayBuffer.
When the TypedArray is a view wrapping an ArrayBuffer, the
ArrayBuffer has the size.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (201225 => 201226)
--- trunk/Source/_javascript_Core/ChangeLog 2016-05-20 21:17:58 UTC (rev 201225)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-05-20 21:47:18 UTC (rev 201226)
@@ -1,3 +1,23 @@
+2016-05-20 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: retained size for typed arrays does not count native backing store
+ https://bugs.webkit.org/show_bug.cgi?id=157945
+ <rdar://problem/26392238>
+
+ Reviewed by Geoffrey Garen.
+
+ * runtime/JSArrayBuffer.h:
+ * runtime/JSArrayBuffer.cpp:
+ (JSC::JSArrayBuffer::estimatedSize):
+ Include an estimatedSize implementation for JSArrayBuffer.
+ ArrayBuffer has a unique path, different from other data
+ stored in the Heap.
+
+ * tests/heapProfiler/typed-array-sizes.js: Added.
+ Test sizes of TypedArray with and without an ArrayBuffer.
+ When the TypedArray is a view wrapping an ArrayBuffer, the
+ ArrayBuffer has the size.
+
2016-05-20 Geoffrey Garen <[email protected]>
reifyAllStaticProperties makes two copies of every string
Modified: trunk/Source/_javascript_Core/runtime/JSArrayBuffer.cpp (201225 => 201226)
--- trunk/Source/_javascript_Core/runtime/JSArrayBuffer.cpp 2016-05-20 21:17:58 UTC (rev 201225)
+++ trunk/Source/_javascript_Core/runtime/JSArrayBuffer.cpp 2016-05-20 21:47:18 UTC (rev 201226)
@@ -66,6 +66,13 @@
NonArray);
}
+size_t JSArrayBuffer::estimatedSize(JSCell* cell)
+{
+ JSArrayBuffer* thisObject = jsCast<JSArrayBuffer*>(cell);
+ size_t bufferEstimatedSize = thisObject->impl()->gcSizeEstimateInBytes();
+ return Base::estimatedSize(cell) + bufferEstimatedSize;
+}
+
bool JSArrayBuffer::getOwnPropertySlot(
JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
Modified: trunk/Source/_javascript_Core/runtime/JSArrayBuffer.h (201225 => 201226)
--- trunk/Source/_javascript_Core/runtime/JSArrayBuffer.h 2016-05-20 21:17:58 UTC (rev 201225)
+++ trunk/Source/_javascript_Core/runtime/JSArrayBuffer.h 2016-05-20 21:47:18 UTC (rev 201226)
@@ -51,6 +51,8 @@
DECLARE_EXPORT_INFO;
protected:
+
+ static size_t estimatedSize(JSCell*);
static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
static bool put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&, bool shouldThrow);
Added: trunk/Source/_javascript_Core/tests/heapProfiler/typed-array-sizes.js (0 => 201226)
--- trunk/Source/_javascript_Core/tests/heapProfiler/typed-array-sizes.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/heapProfiler/typed-array-sizes.js 2016-05-20 21:47:18 UTC (rev 201226)
@@ -0,0 +1,28 @@
+load("./driver/driver.js");
+
+(function() {
+ const bufferBytes = 4 * 2000;
+ const typedArraySize = 1000;
+ const typedArrayBytes = 4 * typedArraySize;
+ assert(typedArrayBytes < bufferBytes, "Sizes should be different");
+
+ let buffer = new ArrayBuffer(bufferBytes);
+ let view = new Float32Array(buffer);
+ let typedArray = new Uint32Array(typedArraySize);
+
+ let snapshot = createCheapHeapSnapshot();
+
+ let arrayBufferNodes = snapshot.nodesWithClassName("ArrayBuffer");
+ let viewNodes = snapshot.nodesWithClassName("Float32Array");
+ let typedArrayNodes = snapshot.nodesWithClassName("Uint32Array");
+ assert(arrayBufferNodes.length === 1, "Snapshot should contain 1 'ArrayBuffer' instance");
+ assert(viewNodes.length === 1, "Snapshot should contain 1 'Float32Array' instance");
+ assert(typedArrayNodes.length === 1, "Snapshot should contain 1 'Uint32Array' instance");
+
+ let arrayBufferNode = arrayBufferNodes[0];
+ let viewNode = viewNodes[0];
+ let typedArrayNode = typedArrayNodes[0];
+ assert(arrayBufferNode.size >= bufferBytes, "ArrayBuffer node should have a large size");
+ assert(viewNode.size <= 100, "Float32Array node should have a very small size, it just wraps the already large ArrayBuffer");
+ assert(typedArrayNode.size >= typedArrayBytes && typedArrayNode.size < bufferBytes, "Uint32Array node should have a large size, but not as large as the ArrayBuffer");
+})();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes