track static array in reverse data map
[hiphop-php.git] / hphp / runtime / vm / reverse-data-map.h
blobb10a1753c61f72b4d083769122758aef624df303
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 <folly/DiscriminatedPtr.h>
21 namespace HPHP {
23 struct ArrayData;
24 struct Class;
25 struct Func;
26 struct NamedEntity;
27 struct StringData;
28 struct Unit;
30 namespace data_map {
32 * Logical reverse mapping from memory address ranges to the VM objects
33 * allocated at them.
36 ///////////////////////////////////////////////////////////////////////////////
39 * Register the start address of an object.
41 * The object pointer must be 16-byte aligned.
43 void register_start(const ArrayData*);
44 void register_start(const Class*);
45 void register_start(const Func*);
46 void register_start(const NamedEntity*);
47 void register_start(const StringData*);
48 void register_start(const Unit*);
51 * Deregister an object.
53 * Requires that register_start() was called on the object, and it has not yet
54 * been deregistered.
56 void deregister(const ArrayData*);
57 void deregister(const Class*);
58 void deregister(const Func*);
59 void deregister(const NamedEntity*);
60 void deregister(const StringData*);
61 void deregister(const Unit*);
64 * Look up the object containing `addr' as an internal pointer.
66 * This function is aware of the variable-length allocations of Func, Class,
67 * and StringData, and takes them into consideration for determining
68 * constituency.
70 * Returns an empty result if `addr' is not mapped.
72 using result = folly::DiscriminatedPtr<
73 ArrayData,
74 Class,
75 Func,
76 NamedEntity,
77 StringData,
78 Unit
80 result find_containing(const void* addr);
82 ///////////////////////////////////////////////////////////////////////////////