forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime-weak-refs.cc
More file actions
38 lines (29 loc) · 1.15 KB
/
Copy pathruntime-weak-refs.cc
File metadata and controls
38 lines (29 loc) · 1.15 KB
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
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/execution/arguments-inl.h"
#include "src/objects/js-weak-refs-inl.h"
#include "src/runtime/runtime-utils.h"
namespace v8 {
namespace internal {
RUNTIME_FUNCTION(
Runtime_JSFinalizationRegistryRegisterWeakCellWithUnregisterToken) {
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
DirectHandle<JSFinalizationRegistry> finalization_registry =
args.at<JSFinalizationRegistry>(0);
DirectHandle<WeakCell> weak_cell = args.at<WeakCell>(1);
JSFinalizationRegistry::RegisterWeakCellWithUnregisterToken(
finalization_registry, weak_cell, isolate);
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_JSWeakRefAddToKeptObjects) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
DirectHandle<HeapObject> object = args.at<HeapObject>(0);
DCHECK(Object::CanBeHeldWeakly(*object));
isolate->heap()->KeepDuringJob(object);
return ReadOnlyRoots(isolate).undefined_value();
}
} // namespace internal
} // namespace v8