Reland D23318594 and D23318592 add recordbasenativesp instr
[hiphop-php.git] / hphp / runtime / vm / reverse-data-map.h
blobe54835cf3de60301136c2b6d2306867c9eca7ca2
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_REVERSE_DATA_MAP_H_
18 #define incl_HPHP_REVERSE_DATA_MAP_H_
20 #include <folly/DiscriminatedPtr.h>
22 namespace HPHP {
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 Class*);
44 void register_start(const Func*);
45 void register_start(const NamedEntity*);
46 void register_start(const StringData*);
47 void register_start(const Unit*);
50 * Deregister an object.
52 * Requires that register_start() was called on the object, and it has not yet
53 * been deregistered.
55 void deregister(const Class*);
56 void deregister(const Func*);
57 void deregister(const NamedEntity*);
58 void deregister(const StringData*);
59 void deregister(const Unit*);
62 * Look up the object containing `addr' as an internal pointer.
64 * This function is aware of the variable-length allocations of Func, Class,
65 * and StringData, and takes them into consideration for determining
66 * constituency.
68 * Returns an empty result if `addr' is not mapped.
70 using result = folly::DiscriminatedPtr<
71 Class,
72 Func,
73 NamedEntity,
74 StringData,
75 Unit
77 result find_containing(const void* addr);
79 ///////////////////////////////////////////////////////////////////////////////
83 #endif