Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
76 lines (64 loc) · 2.38 KB

File metadata and controls

76 lines (64 loc) · 2.38 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "hermes/VM/JSGenerator.h"
#include "hermes/VM/BuildMetadata.h"
#include "llvh/Support/Debug.h"
#define DEBUG_TYPE "serialize"
namespace hermes {
namespace vm {
//===----------------------------------------------------------------------===//
// class JSGenerator
const ObjectVTable JSGenerator::vt{
VTable(CellKind::GeneratorKind, cellSize<JSGenerator>()),
JSGenerator::_getOwnIndexedRangeImpl,
JSGenerator::_haveOwnIndexedImpl,
JSGenerator::_getOwnIndexedPropertyFlagsImpl,
JSGenerator::_getOwnIndexedImpl,
JSGenerator::_setOwnIndexedImpl,
JSGenerator::_deleteOwnIndexedImpl,
JSGenerator::_checkAllOwnIndexedImpl,
};
void GeneratorBuildMeta(const GCCell *cell, Metadata::Builder &mb) {
mb.addJSObjectOverlapSlots(JSObject::numOverlapSlots<JSGenerator>());
ObjectBuildMeta(cell, mb);
const auto *self = static_cast<const JSGenerator *>(cell);
mb.addField("innerFunction", &self->innerFunction_);
}
#ifdef HERMESVM_SERIALIZE
JSGenerator::JSGenerator(Deserializer &d) : JSObject(d, &vt.base) {
d.readRelocation(&innerFunction_, RelocationKind::GCPointer);
}
void GeneratorSerialize(Serializer &s, const GCCell *cell) {
auto *self = vmcast<const JSGenerator>(cell);
JSObject::serializeObjectImpl(
s, cell, JSObject::numOverlapSlots<JSGenerator>());
s.writeRelocation(self->innerFunction_.get(s.getRuntime()));
s.endObject(cell);
}
void GeneratorDeserialize(Deserializer &d, CellKind kind) {
assert(kind == CellKind::GeneratorKind && "Expected Generator");
void *mem = d.getRuntime()->alloc(cellSize<JSGenerator>());
auto *cell = new (mem) JSGenerator(d);
d.endObject(cell);
}
#endif
CallResult<PseudoHandle<JSGenerator>> JSGenerator::create(
Runtime *runtime,
Handle<GeneratorInnerFunction> innerFunction,
Handle<JSObject> parentHandle) {
JSObjectAlloc<JSGenerator> mem{runtime};
auto self = new (mem) JSGenerator(
runtime,
*parentHandle,
runtime->getHiddenClassForPrototypeRaw(
*parentHandle,
numOverlapSlots<JSGenerator>() + ANONYMOUS_PROPERTY_SLOTS));
self->innerFunction_.set(runtime, *innerFunction, &runtime->getHeap());
return mem.initToPseudoHandle(self);
}
} // namespace vm
} // namespace hermes
Morty Proxy This is a proxified and sanitized view of the page, visit original site.