Bug 95737 - Extend the coverage of the Custom Allocation Framework in WTF and in JavaScriptCore
Summary: Extend the coverage of the Custom Allocation Framework in WTF and in JavaScri...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Zoltan Horvath
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-04 05:06 PDT by Zoltan Horvath
Modified: 2012-09-04 13:29 PDT (History)
7 users (show)

See Also:


Attachments
proposed patch (7.97 KB, patch)
2012-09-04 05:25 PDT, Zoltan Horvath
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zoltan Horvath 2012-09-04 05:06:49 PDT
Add WTF_MAKE_FAST_ALLOCATED macro to some class declarations in WTF and in JavaScriptCore because these are instantiated by 'new'.
Comment 1 Zoltan Horvath 2012-09-04 05:25:31 PDT
Created attachment 162020 [details]
proposed patch
Comment 2 Eric Seidel (no email) 2012-09-04 08:22:38 PDT
What happens w/o this change?  Are there ports whcih would end up using sytem malloc for these objects by mistake?
Comment 3 Zoltan Horvath 2012-09-04 08:25:46 PDT
(In reply to comment #2)
> What happens w/o this change?  Are there ports whcih would end up using sytem malloc for these objects by mistake?

Ports that don't customize ::new (e.g. qt) use system malloc for these allocations. The macro makes it straightforward for every port.
Comment 4 Eric Seidel (no email) 2012-09-04 08:28:24 PDT
ok
Comment 5 Benjamin Poulain 2012-09-04 12:01:06 PDT
May I suggest to extend the style checker to cover that?

Chances are people will forget it again. I know I am guilty of this.
Comment 6 Zoltan Horvath 2012-09-04 12:17:09 PDT
(In reply to comment #5)
> May I suggest to extend the style checker to cover that?
> 
> Chances are people will forget it again. I know I am guilty of this.

It would be good, but we couldn't do that, since static source code analysis is required to find the places.

For example some JSValue classes don't have allocation operators, but stored on the JSGC's heap with placement new, or e.g. we don't want to customize memory allocation for QObjects.

I'm working on the WebCore's coverage now. I think it's not critical and it's okay if I check it sometimes.
Comment 7 WebKit Review Bot 2012-09-04 12:35:32 PDT
Comment on attachment 162020 [details]
proposed patch

Clearing flags on attachment: 162020

Committed r127484: <http://trac.webkit.org/changeset/127484>
Comment 8 WebKit Review Bot 2012-09-04 12:35:35 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Zoltan Horvath 2012-09-04 12:38:54 PDT
(In reply to comment #6)

> For example some JSValue classes don't have allocation operators, but stored on the JSGC's heap with placement new

Let me correct myself. So it can happen that you customize the operator new of a class and you should have not done it. (e.g. basically it inherits the operator new from its base class what you can't see with a grep)
Comment 10 Benjamin Poulain 2012-09-04 13:14:46 PDT
(In reply to comment #9)
> Let me correct myself. So it can happen that you customize the operator new of a class and you should have not done it. (e.g. basically it inherits the operator new from its base class what you can't see with a grep)

It does not have to be perfect.
You'd be surprised how dumb are some test in webkitpy, and yet they work 99% of the time :)
Comment 11 Zoltan Horvath 2012-09-04 13:29:58 PDT
(In reply to comment #10)
> (In reply to comment #9)
> > Let me correct myself. So it can happen that you customize the operator new of a class and you should have not done it. (e.g. basically it inherits the operator new from its base class what you can't see with a grep)
> 
> It does not have to be perfect.
> You'd be surprised how dumb are some test in webkitpy, and yet they work 99% of the time :)

I see your point, but the incorrect use of this macro can lead to random crashes. Of course if anyone wants to give it a try to implement a checker for this in check-webkit-style I'd gladly support him.