2 +----------------------------------------------------------------------+
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_RECORD_DATA_H_
18 #define incl_HPHP_RECORD_DATA_H_
20 #include "hphp/runtime/base/countable.h"
21 #include "hphp/runtime/base/record-common.h"
22 #include "hphp/runtime/base/req-vector.h"
23 #include "hphp/runtime/base/tv-val.h"
25 #include "hphp/util/type-scan.h"
28 struct RecordData
: Countable
,
30 type_scan::MarkCollectable
<RecordData
> {
31 explicit RecordData(const RecordDesc
*);
33 RecordData(const RecordData
&) = delete;
34 RecordData
& operator=(const RecordData
&) = delete;
35 ~RecordData() = delete;
37 size_t heapSize() const;
38 bool kindIsValid() const;
40 static size_t sizeWithFields(const RecordDesc
* rec
) {
41 return sizeof(RecordData
) + fieldSize(rec
);
43 static constexpr ptrdiff_t getVMRecordOffset() {
44 return offsetof(RecordData
, m_record
);
48 /* Given a Record type, an array of keys and an array of corresponding
49 * initial values, return a fully initialized instance of that Record.
50 * The initial ref-count will be set to one.
52 static RecordData
* newRecord(const RecordDesc
*,
54 const StringData
* const* keys
,
55 const TypedValue
* values
);
56 RecordData
* copyRecord() const;
57 // Decrement ref-counts of all fields of the record and free the memory.
58 void release() noexcept
;
59 ALWAYS_INLINE
void decRefAndRelease() {
60 assertx(kindIsValid());
61 if (decReleaseCheck()) release();
64 static bool equal(const RecordData
*, const RecordData
*);
65 static bool same(const RecordData
*, const RecordData
*);
67 bool instanceof(const RecordDesc
* rec
) const {
68 return m_record
->recordDescOf(rec
);
71 void scan(type_scan::Scanner
&) const;
75 template<bool (*fieldEq
)(TypedValue
, TypedValue
)>
76 static bool equalImpl(const RecordData
*, const RecordData
*);
80 ALWAYS_INLINE
void decRefRec(RecordData
* rec
) {
81 rec
->decRefAndRelease();
86 #define incl_HPHP_RECORD_DATA_INL_H_
87 #include "hphp/runtime/base/record-data-inl.h"
88 #undef incl_HPHP_RECORD_DATA_INL_H_
90 #endif // incl_HPHP_RECORD_DATA_H_