v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
builtins-weak-refs.cc
Go to the documentation of this file.
1
// Copyright 2018 the V8 project authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#include "
src/builtins/builtins-utils-inl.h
"
6
#include "
src/logging/counters.h
"
7
#include "
src/objects/js-weak-refs-inl.h
"
8
9
namespace
v8
{
10
namespace
internal
{
11
12
// https://tc39.es/ecma262/#sec-finalization-registry.prototype.unregister
13
BUILTIN
(FinalizationRegistryUnregister) {
14
HandleScope
scope(isolate);
15
const
char
* method_name =
"FinalizationRegistry.prototype.unregister"
;
16
17
// 1. Let finalizationGroup be the this value.
18
//
19
// 2. Perform ? RequireInternalSlot(finalizationRegistry, [[Cells]]).
20
CHECK_RECEIVER
(
JSFinalizationRegistry
, finalization_registry, method_name);
21
22
Handle<Object>
unregister_token =
args
.atOrUndefined(isolate, 1);
23
24
// 3. If CanBeHeldWeakly(unregisterToken) is false, throw a TypeError
25
// exception.
26
if
(!
Object::CanBeHeldWeakly
(*unregister_token)) {
27
THROW_NEW_ERROR_RETURN_FAILURE
(
28
isolate, NewTypeError(MessageTemplate::kInvalidWeakRefsUnregisterToken,
29
unregister_token));
30
}
31
32
bool
success =
JSFinalizationRegistry::Unregister
(
33
finalization_registry,
Cast<HeapObject>
(unregister_token), isolate);
34
35
return
*isolate->factory()->ToBoolean(success);
36
}
37
38
}
// namespace internal
39
}
// namespace v8
builtins-utils-inl.h
CHECK_RECEIVER
#define CHECK_RECEIVER(Type, name, method)
Definition
builtins-utils.h:156
BUILTIN
#define BUILTIN(name)
Definition
builtins-utils.h:152
v8::internal::HandleScope
Definition
handles.h:262
v8::internal::Handle
Definition
handles.h:149
v8::internal::JSFinalizationRegistry
Definition
js-weak-refs.h:26
v8::internal::JSFinalizationRegistry::Unregister
static bool Unregister(DirectHandle< JSFinalizationRegistry > finalization_registry, DirectHandle< HeapObject > unregister_token, Isolate *isolate)
Definition
js-weak-refs-inl.h:59
v8::internal::Object::CanBeHeldWeakly
static bool CanBeHeldWeakly(Tagged< Object > obj)
Definition
objects-inl.h:1943
counters.h
THROW_NEW_ERROR_RETURN_FAILURE
#define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call)
Definition
isolate.h:294
args
base::Vector< const DirectHandle< Object > > args
Definition
execution.cc:74
js-weak-refs-inl.h
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8::internal::Cast
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition
casting.h:150
v8
Definition
api-arguments-inl.h:19
src
builtins
builtins-weak-refs.cc
Generated on Sun Apr 6 2025 21:08:50 for v8 by
1.12.0