2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_JIT_ARRAY_KIND_PROFILE_H_
18 #define incl_HPHP_JIT_ARRAY_KIND_PROFILE_H_
20 #include "hphp/runtime/base/array-data.h"
22 namespace HPHP
{ namespace jit
{
24 ///////////////////////////////////////////////////////////////////////////////
27 * Target profile for the distribution of a value's observed array kinds.
29 * The array kinds currently tracked are Empty, Packed, and Mixed.
31 struct ArrayKindProfile
{
32 static const uint32_t kNumProfiledArrayKinds
= 4;
35 * Register an observed `kind'.
37 void report(ArrayData::ArrayKind kind
);
40 * Return the fraction of the profiled arrays that had the given `kind'.
42 double fraction(ArrayData::ArrayKind kind
) const;
45 * Return the total number of samples profiled so far.
47 uint32_t total() const {
49 for (uint32_t i
= 0; i
< kNumProfiledArrayKinds
; ++i
) {
56 * Combine `l' and `r', summing across the kind counts.
58 static void reduce(ArrayKindProfile
& l
, const ArrayKindProfile
& r
) {
59 for (uint32_t i
= 0; i
< kNumProfiledArrayKinds
; ++i
) {
60 l
.m_count
[i
] += r
.m_count
[i
];
64 std::string
toString() const;
67 uint32_t m_count
[kNumProfiledArrayKinds
];
70 ///////////////////////////////////////////////////////////////////////////////