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
8
9namespace v8 {
10namespace internal {
11
12// https://tc39.es/ecma262/#sec-finalization-registry.prototype.unregister
13BUILTIN(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)) {
28 isolate, NewTypeError(MessageTemplate::kInvalidWeakRefsUnregisterToken,
29 unregister_token));
30 }
31
33 finalization_registry, Cast<HeapObject>(unregister_token), isolate);
34
35 return *isolate->factory()->ToBoolean(success);
36}
37
38} // namespace internal
39} // namespace v8
#define CHECK_RECEIVER(Type, name, method)
#define BUILTIN(name)
static bool Unregister(DirectHandle< JSFinalizationRegistry > finalization_registry, DirectHandle< HeapObject > unregister_token, Isolate *isolate)
static bool CanBeHeldWeakly(Tagged< Object > obj)
#define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call)
Definition isolate.h:294
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150