Give purity hints to compiler to avoid penalizing repeated calls to some functions.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Sep 2013 12:49:59 +0000 (12:49 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Sep 2013 12:49:59 +0000 (12:49 +0000)
commit0423f6a31e314bade0492955538500e9bea2a4c2
treea6fa49943b81e6c3d81564c4e22df92f5ee999c0
parent4fe63db0dc485df5ffd277f881a6feb4fcb4bec7
Give purity hints to compiler to avoid penalizing repeated calls to some functions.
<https://webkit.org/b/121744>

Reviewed by Darin Adler.

Source/WebCore:

Mark the following functions pure:

    - gcController()
    - cssValuePool()
    - threadGlobalData()

I had this idea when I saw Darin's patch to cache cssValuePool() in a local.
We know that this function will always return the same value, so we should just
share this knowledge with the compiler and let it do the cleverness instead.

Source/WTF:

Added a PURE_FUNCTION macro. This is supported on GCC and Clang for now.
Marking a function pure means that the compiler's CSE pass is free to coalesce
multiple calls to this function because it has no globally observable side
effects beyond the first call.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156246 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/Compiler.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/GCController.h
Source/WebCore/css/CSSValuePool.h
Source/WebCore/platform/ThreadGlobalData.h