/src/hermes/lib/VM/JSMapImpl.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) Meta Platforms, Inc. and affiliates. |
3 | | * |
4 | | * This source code is licensed under the MIT license found in the |
5 | | * LICENSE file in the root directory of this source tree. |
6 | | */ |
7 | | |
8 | | #include "hermes/VM/JSMapImpl.h" |
9 | | |
10 | | #include "hermes/VM/BuildMetadata.h" |
11 | | #include "hermes/VM/Operations.h" |
12 | | |
13 | | namespace hermes { |
14 | | namespace vm { |
15 | | |
16 | | //===----------------------------------------------------------------------===// |
17 | | // class JSMapImpl |
18 | | |
19 | | template <CellKind C> |
20 | | void JSMapImpl<C>::MapOrSetBuildMeta( |
21 | | const GCCell *cell, |
22 | 2 | Metadata::Builder &mb) { |
23 | 2 | mb.addJSObjectOverlapSlots(JSObject::numOverlapSlots<JSMapImpl<C>>()); |
24 | 2 | JSObjectBuildMeta(cell, mb); |
25 | 2 | const auto *self = static_cast<const JSMapImpl<C> *>(cell); |
26 | 2 | mb.addField("storage", &self->storage_); |
27 | 2 | } hermes::vm::JSMapImpl<(hermes::vm::CellKind)47>::MapOrSetBuildMeta(hermes::vm::GCCell const*, hermes::vm::Metadata::Builder&) Line | Count | Source | 22 | 1 | Metadata::Builder &mb) { | 23 | 1 | mb.addJSObjectOverlapSlots(JSObject::numOverlapSlots<JSMapImpl<C>>()); | 24 | 1 | JSObjectBuildMeta(cell, mb); | 25 | 1 | const auto *self = static_cast<const JSMapImpl<C> *>(cell); | 26 | 1 | mb.addField("storage", &self->storage_); | 27 | 1 | } |
hermes::vm::JSMapImpl<(hermes::vm::CellKind)48>::MapOrSetBuildMeta(hermes::vm::GCCell const*, hermes::vm::Metadata::Builder&) Line | Count | Source | 22 | 1 | Metadata::Builder &mb) { | 23 | 1 | mb.addJSObjectOverlapSlots(JSObject::numOverlapSlots<JSMapImpl<C>>()); | 24 | 1 | JSObjectBuildMeta(cell, mb); | 25 | 1 | const auto *self = static_cast<const JSMapImpl<C> *>(cell); | 26 | 1 | mb.addField("storage", &self->storage_); | 27 | 1 | } |
|
28 | | |
29 | 1 | void JSMapBuildMeta(const GCCell *cell, Metadata::Builder &mb) { |
30 | 1 | JSMap::MapOrSetBuildMeta(cell, mb); |
31 | 1 | mb.setVTable(&JSMap::vt); |
32 | 1 | } |
33 | | |
34 | 1 | void JSSetBuildMeta(const GCCell *cell, Metadata::Builder &mb) { |
35 | 1 | JSSet::MapOrSetBuildMeta(cell, mb); |
36 | 1 | mb.setVTable(&JSSet::vt); |
37 | 1 | } |
38 | | |
39 | | template <CellKind C> |
40 | | const ObjectVTable JSMapImpl<C>::vt{ |
41 | | VTable(C, cellSize<JSMapImpl<C>>()), |
42 | | JSMapImpl::_getOwnIndexedRangeImpl, |
43 | | JSMapImpl::_haveOwnIndexedImpl, |
44 | | JSMapImpl::_getOwnIndexedPropertyFlagsImpl, |
45 | | JSMapImpl::_getOwnIndexedImpl, |
46 | | JSMapImpl::_setOwnIndexedImpl, |
47 | | JSMapImpl::_deleteOwnIndexedImpl, |
48 | | JSMapImpl::_checkAllOwnIndexedImpl, |
49 | | }; |
50 | | |
51 | | template <CellKind C> |
52 | | PseudoHandle<JSMapImpl<C>> JSMapImpl<C>::create( |
53 | | Runtime &runtime, |
54 | 0 | Handle<JSObject> parentHandle) { |
55 | 0 | auto *cell = runtime.makeAFixed<JSMapImpl>( |
56 | 0 | runtime, |
57 | 0 | parentHandle, |
58 | 0 | runtime.getHiddenClassForPrototype( |
59 | 0 | *parentHandle, numOverlapSlots<JSMapImpl>())); |
60 | 0 | return JSObjectInit::initToPseudoHandle(runtime, cell); |
61 | 0 | } Unexecuted instantiation: hermes::vm::JSMapImpl<(hermes::vm::CellKind)47>::create(hermes::vm::Runtime&, hermes::vm::Handle<hermes::vm::JSObject>) Unexecuted instantiation: hermes::vm::JSMapImpl<(hermes::vm::CellKind)48>::create(hermes::vm::Runtime&, hermes::vm::Handle<hermes::vm::JSObject>) |
62 | | |
63 | | template class JSMapImpl<CellKind::JSSetKind>; |
64 | | template class JSMapImpl<CellKind::JSMapKind>; |
65 | | |
66 | | //===----------------------------------------------------------------------===// |
67 | | // class JSSetIterator |
68 | | |
69 | | template <CellKind C> |
70 | | void JSMapIteratorImpl<C>::MapOrSetIteratorBuildMeta( |
71 | | const GCCell *cell, |
72 | 2 | Metadata::Builder &mb) { |
73 | 2 | mb.addJSObjectOverlapSlots(JSObject::numOverlapSlots<JSMapIteratorImpl<C>>()); |
74 | 2 | JSObjectBuildMeta(cell, mb); |
75 | 2 | const auto *self = static_cast<const JSMapIteratorImpl<C> *>(cell); |
76 | 2 | mb.addField("data", &self->data_); |
77 | 2 | mb.addField("itr", &self->itr_); |
78 | 2 | } hermes::vm::JSMapIteratorImpl<(hermes::vm::CellKind)50>::MapOrSetIteratorBuildMeta(hermes::vm::GCCell const*, hermes::vm::Metadata::Builder&) Line | Count | Source | 72 | 1 | Metadata::Builder &mb) { | 73 | 1 | mb.addJSObjectOverlapSlots(JSObject::numOverlapSlots<JSMapIteratorImpl<C>>()); | 74 | 1 | JSObjectBuildMeta(cell, mb); | 75 | 1 | const auto *self = static_cast<const JSMapIteratorImpl<C> *>(cell); | 76 | 1 | mb.addField("data", &self->data_); | 77 | 1 | mb.addField("itr", &self->itr_); | 78 | 1 | } |
hermes::vm::JSMapIteratorImpl<(hermes::vm::CellKind)49>::MapOrSetIteratorBuildMeta(hermes::vm::GCCell const*, hermes::vm::Metadata::Builder&) Line | Count | Source | 72 | 1 | Metadata::Builder &mb) { | 73 | 1 | mb.addJSObjectOverlapSlots(JSObject::numOverlapSlots<JSMapIteratorImpl<C>>()); | 74 | 1 | JSObjectBuildMeta(cell, mb); | 75 | 1 | const auto *self = static_cast<const JSMapIteratorImpl<C> *>(cell); | 76 | 1 | mb.addField("data", &self->data_); | 77 | 1 | mb.addField("itr", &self->itr_); | 78 | 1 | } |
|
79 | | |
80 | 1 | void JSMapIteratorBuildMeta(const GCCell *cell, Metadata::Builder &mb) { |
81 | 1 | JSMapIterator::MapOrSetIteratorBuildMeta(cell, mb); |
82 | 1 | mb.setVTable(&JSMapIterator::vt); |
83 | 1 | } |
84 | | |
85 | 1 | void JSSetIteratorBuildMeta(const GCCell *cell, Metadata::Builder &mb) { |
86 | 1 | JSSetIterator::MapOrSetIteratorBuildMeta(cell, mb); |
87 | 1 | mb.setVTable(&JSSetIterator::vt); |
88 | 1 | } |
89 | | |
90 | | template <CellKind C> |
91 | | const ObjectVTable JSMapIteratorImpl<C>::vt = { |
92 | | VTable(C, cellSize<JSMapIteratorImpl<C>>()), |
93 | | JSMapIteratorImpl::_getOwnIndexedRangeImpl, |
94 | | JSMapIteratorImpl::_haveOwnIndexedImpl, |
95 | | JSMapIteratorImpl::_getOwnIndexedPropertyFlagsImpl, |
96 | | JSMapIteratorImpl::_getOwnIndexedImpl, |
97 | | JSMapIteratorImpl::_setOwnIndexedImpl, |
98 | | JSMapIteratorImpl::_deleteOwnIndexedImpl, |
99 | | JSMapIteratorImpl::_checkAllOwnIndexedImpl, |
100 | | }; |
101 | | |
102 | | template <CellKind C> |
103 | | PseudoHandle<JSMapIteratorImpl<C>> JSMapIteratorImpl<C>::create( |
104 | | Runtime &runtime, |
105 | 0 | Handle<JSObject> prototype) { |
106 | 0 | auto *cell = runtime.makeAFixed<JSMapIteratorImpl<C>>( |
107 | 0 | runtime, |
108 | 0 | prototype, |
109 | 0 | runtime.getHiddenClassForPrototype( |
110 | 0 | *prototype, numOverlapSlots<JSMapIteratorImpl>())); |
111 | 0 | return JSObjectInit::initToPseudoHandle(runtime, cell); |
112 | 0 | } Unexecuted instantiation: hermes::vm::JSMapIteratorImpl<(hermes::vm::CellKind)50>::create(hermes::vm::Runtime&, hermes::vm::Handle<hermes::vm::JSObject>) Unexecuted instantiation: hermes::vm::JSMapIteratorImpl<(hermes::vm::CellKind)49>::create(hermes::vm::Runtime&, hermes::vm::Handle<hermes::vm::JSObject>) |
113 | | |
114 | | template class JSMapIteratorImpl<CellKind::JSMapIteratorKind>; |
115 | | template class JSMapIteratorImpl<CellKind::JSSetIteratorKind>; |
116 | | |
117 | | } // namespace vm |
118 | | } // namespace hermes |