Properly serialize/deserialize TypeProfiles
[hiphop-php.git] / hphp / runtime / vm / jit / type-profile.h
blob8a5cfdef10c901c0af4544a7cf100243e6364904
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2013 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_TYPE_PROFILE_H_
18 #define incl_HPHP_JIT_TYPE_PROFILE_H_
20 #include "hphp/runtime/vm/jit/type.h"
22 #include "hphp/util/type-scan.h"
24 #include <string>
26 namespace HPHP { namespace jit {
28 ///////////////////////////////////////////////////////////////////////////////
31 * TypeProfile keeps the union of all the types observed during profiling.
33 struct TypeProfile {
34 std::string toString() const { return type.toString(); }
36 void report(TypedValue tv) {
37 type |= typeFromTV(&tv, nullptr);
40 static void reduce(TypeProfile& a, const TypeProfile& b) {
41 a.type |= b.type;
44 void serialize(ProfDataSerializer& ser) const { type.serialize(ser); }
45 void deserialize(ProfDataDeserializer& ser) { type = Type::deserialize(ser); }
47 Type type; // This gets initialized with 0, which is TBottom.
48 static_assert(Type::Bits::kBottom == 0, "Assuming TBottom is 0");
50 // In RDS, but can't contain pointers to request-allocated data.
51 TYPE_SCAN_IGNORE_ALL;
54 ///////////////////////////////////////////////////////////////////////////////
58 #endif