Optional Two-phase heap tracing
[hiphop-php.git] / hphp / util / rank.h
blob65cb0787208f84a01a81ebebf8d5a0a1224eb738
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
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_RANK_H_
18 #define incl_HPHP_RANK_H_
20 #include <limits.h>
22 namespace HPHP {
25 * The order in which we acquire blocking resources cannot produce
26 * deadlock if paths respect a partial order on the resources.
29 enum Rank {
30 RankUnranked = -1, // Unranked locks can be inserted in any order.
32 * Base rank locks are only ever acquired while no other locks are held.
33 * In a wedding-cake diagram of the system, these are the upper layers of
34 * frosting.
36 RankBase = 0,
39 * Fbml is currently the lowest ranked lock because we reenter the VM while
40 * holding it. This is probably a bad idea and is not intended to be
41 * permanent.
43 RankFbml = RankBase,
45 RankUnitInit,
46 RankEvaledUnits,
47 RankWriteLease,
48 RankCodeCache,
49 RankCodeMetadata,
51 RankStatCache,
53 RankUnitCache,
54 RankStatCacheNode = RankUnitCache,
56 RankInstanceBitsInit,
58 RankTreadmill,
61 * Leaf-rank locks are the deepest resources in the system; once you've
62 * acquired one, you can acquire no further resources without releasing
63 * one.
65 RankLeaf
68 #ifdef DEBUG
69 extern Rank currentRank();
70 extern void checkRank(Rank r);
71 extern void pushRank(Rank r);
72 extern void popRank(Rank r);
73 extern void insertRank(Rank r);
74 #else
75 #define currentRank() RankBase
76 #define checkRank(r) do { } while(0)
77 #define pushRank(r) do { } while(0)
78 #define popRank(r) do { } while(0)
79 #define insertRank(r) do { } while(0)
80 #endif
84 #endif