v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
managed.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
6
9
10namespace v8 {
11namespace internal {
12
13namespace {
14// Called by the GC in its second pass when a Managed<CppType> is
15// garbage collected.
16void ManagedObjectFinalizerSecondPass(const v8::WeakCallbackInfo<void>& data) {
17 auto destructor =
18 reinterpret_cast<ManagedPtrDestructor*>(data.GetParameter());
19 Isolate* isolate = reinterpret_cast<Isolate*>(data.GetIsolate());
20 isolate->UnregisterManagedPtrDestructor(destructor);
21 destructor->destructor_(destructor->shared_ptr_ptr_);
22 destructor->external_memory_accounter_.Decrease(
23 reinterpret_cast<v8::Isolate*>(isolate), destructor->estimated_size_);
24#ifdef V8_ENABLE_SANDBOX
25 destructor->ZapExternalPointerTableEntry();
26#endif // V8_ENABLE_SANDBOX
27 delete destructor;
28}
29} // namespace
30
31// Called by the GC in its first pass when a Managed<CppType> is
32// garbage collected.
34 auto destructor =
35 reinterpret_cast<ManagedPtrDestructor*>(data.GetParameter());
36 GlobalHandles::Destroy(destructor->global_handle_location_);
37 // We need to do the main work as a second pass callback because
38 // it can trigger garbage collection. The first pass callbacks
39 // are not allowed to invoke V8 API.
40 data.SetSecondPassCallback(&ManagedObjectFinalizerSecondPass);
41}
42
43} // namespace internal
44} // namespace v8
static void Destroy(Address *location)
void ManagedObjectFinalizer(const v8::WeakCallbackInfo< void > &data)
Definition managed.cc:33