forked from oven-sh/bun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBunProcess.h
81 lines (61 loc) · 2.89 KB
/
BunProcess.h
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
77
78
79
80
81
#pragma once
#include "root.h"
#include "BunBuiltinNames.h"
#include "BunClientData.h"
#include "JSEventEmitter.h"
namespace Bun {
// TODO: find a better place for this
int getRSS(size_t* rss);
using namespace JSC;
class Process : public WebCore::JSEventEmitter {
using Base = WebCore::JSEventEmitter;
LazyProperty<Process, Structure> m_cpuUsageStructure;
LazyProperty<Process, Structure> m_memoryUsageStructure;
LazyProperty<Process, JSObject> m_bindingUV;
LazyProperty<Process, JSObject> m_bindingNatives;
public:
Process(JSC::Structure* structure, WebCore::JSDOMGlobalObject& globalObject, Ref<WebCore::EventEmitter>&& impl)
: Base(structure, globalObject, WTFMove(impl))
{
}
void emitSignalEvent(int signalNumber);
DECLARE_EXPORT_INFO;
static void destroy(JSC::JSCell* cell)
{
static_cast<Process*>(cell)->Process::~Process();
}
~Process();
static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject,
JSC::JSValue prototype)
{
return JSC::Structure::create(vm, globalObject, prototype,
JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
}
static Process* create(WebCore::JSDOMGlobalObject& globalObject, JSC::Structure* structure)
{
auto emitter = WebCore::EventEmitter::create(*globalObject.scriptExecutionContext());
Process* accessor = new (NotNull, JSC::allocateCell<Process>(globalObject.vm())) Process(structure, globalObject, WTFMove(emitter));
accessor->finishCreation(globalObject.vm());
return accessor;
}
DECLARE_VISIT_CHILDREN;
template<typename, SubspaceAccess mode>
static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
{
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
return nullptr;
return WebCore::subspaceForImpl<Process, WebCore::UseCustomHeapCellType::No>(
vm,
[](auto& spaces) { return spaces.m_clientSubspaceForProcessObject.get(); },
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForProcessObject = std::forward<decltype(space)>(space); },
[](auto& spaces) { return spaces.m_subspaceForProcessObject.get(); },
[](auto& spaces, auto&& space) { spaces.m_subspaceForProcessObject = std::forward<decltype(space)>(space); });
}
void finishCreation(JSC::VM& vm);
inline Structure* cpuUsageStructure() { return m_cpuUsageStructure.getInitializedOnMainThread(this); }
inline Structure* memoryUsageStructure() { return m_memoryUsageStructure.getInitializedOnMainThread(this); }
inline JSObject* bindingUV() { return m_bindingUV.getInitializedOnMainThread(this); }
inline JSObject* bindingNatives() { return m_bindingNatives.getInitializedOnMainThread(this); }
};
} // namespace Bun