Deshim VirtualExecutor in folly
[hiphop-php.git] / hphp / util / rank.h
blobbbf106e4833b12c8b0e1b4560e72a6b2570501e9
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 #pragma once
19 #include <limits.h>
21 namespace HPHP {
24 * The order in which we acquire blocking resources cannot produce
25 * deadlock if paths respect a partial order on the resources.
28 enum Rank {
29 RankUnranked = -1, // Unranked locks can be inserted in any order.
31 * Base rank locks are only ever acquired while no other locks are held.
32 * In a wedding-cake diagram of the system, these are the upper layers of
33 * frosting.
35 RankBase = 0,
38 * Fbml is currently the lowest ranked lock because we reenter the VM while
39 * holding it. This is probably a bad idea and is not intended to be
40 * permanent.
42 RankFbml = RankBase,
44 RankUnitInit,
45 RankEvaledUnits,
46 RankWriteLease,
47 RankCodeCache,
48 RankCodeMetadata,
49 RankInterceptTable,
51 RankStatCache,
53 RankUnitCache,
54 RankStatCacheNode = RankUnitCache,
56 RankUnitHashCache,
58 RankInstanceBitsInit,
60 RankTreadmill,
63 * Leaf-rank locks are the deepest resources in the system; once you've
64 * acquired one, you can acquire no further resources without releasing
65 * one.
67 RankLeaf
70 #ifndef NDEBUG
71 extern Rank currentRank();
72 extern void checkRank(Rank r);
73 extern void pushRank(Rank r);
74 extern void popRank(Rank r);
75 extern void insertRank(Rank r);
76 #else
77 #define currentRank() RankBase
78 #define checkRank(r) do { } while(0)
79 #define pushRank(r) do { } while(0)
80 #define popRank(r) do { } while(0)
81 #define insertRank(r) do { } while(0)
82 #endif