[Webkit-unassigned] [Bug 123955] New: Avoid calling fastRealloc when it returns the same address
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Nov 6 22:20:18 PST 2013
https://bugs.webkit.org/show_bug.cgi?id=123955
Summary: Avoid calling fastRealloc when it returns the same
address
Product: WebKit
Version: 528+ (Nightly build)
Platform: Macintosh
OS/Version: Mac OS X 10.8
Status: NEW
Severity: Enhancement
Priority: P5
Component: Web Template Framework
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: hbono at chromium.org
Created an attachment (id=216259)
--> (https://bugs.webkit.org/attachment.cgi?id=216259&action=review)
A patch that uses fastMallocGoodSize
Greetings,
On OS X, malloc() rounds up the specified size to a multiple of malloc_good_size(). (For example, malloc(1) returns a 16-byte block on OS X.) Also, as listed in the source code <http://www.opensource.apple.com/source/Libc/Libc-594.1.4/gen/malloc.c>, realloc() returns the same address when the specified new size is less than the block size of the given memory, i.e. |p0| is equal to |p1| in the following code snippet.
int main(int argc, char* argv[]) {
void* p0 = malloc(1);
void* p1 = realloc(p0, 10);
printf("p0=%p, p1=%p\n", p0, p1);
return 0;
}
To consider this fact, it may be good for the StringBuilder class to use fastMallocGoodSize(length) instead of length to check if it needs to call StringBuilder<T>::reallocateBuffer() as listed in the attached diff. (For your information, the StringBUilder class tried reallocating memory to the same block size >13000 times when I ran 'run-webkit-tests --no-http' on my Mac.)
Regards,
Hironori Bono
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list