LCOV - code coverage report
Current view: top level - src/objects - managed.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 10 10 100.0 %
Date: 2019-03-21 Functions: 3 3 100.0 %

          Line data    Source code
       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/objects/managed.h"
       6             : 
       7             : namespace v8 {
       8             : namespace internal {
       9             : 
      10             : namespace {
      11             : // Called by the GC in its second pass when a Managed<CppType> is
      12             : // garbage collected.
      13     2600715 : void ManagedObjectFinalizerSecondPass(const v8::WeakCallbackInfo<void>& data) {
      14             :   auto destructor =
      15             :       reinterpret_cast<ManagedPtrDestructor*>(data.GetParameter());
      16             :   Isolate* isolate = reinterpret_cast<Isolate*>(data.GetIsolate());
      17     2600715 :   isolate->UnregisterManagedPtrDestructor(destructor);
      18     2600715 :   int64_t adjustment = 0 - static_cast<int64_t>(destructor->estimated_size_);
      19     2600715 :   destructor->destructor_(destructor->shared_ptr_ptr_);
      20     2600715 :   delete destructor;
      21             :   data.GetIsolate()->AdjustAmountOfExternalAllocatedMemory(adjustment);
      22     2600715 : }
      23             : }  // namespace
      24             : 
      25             : // Called by the GC in its first pass when a Managed<CppType> is
      26             : // garbage collected.
      27     2600715 : void ManagedObjectFinalizer(const v8::WeakCallbackInfo<void>& data) {
      28             :   auto destructor =
      29             :       reinterpret_cast<ManagedPtrDestructor*>(data.GetParameter());
      30     2600715 :   GlobalHandles::Destroy(destructor->global_handle_location_);
      31             :   // We need to do the main work as a second pass callback because
      32             :   // it can trigger garbage collection. The first pass callbacks
      33             :   // are not allowed to invoke V8 API.
      34             :   data.SetSecondPassCallback(&ManagedObjectFinalizerSecondPass);
      35     2600715 : }
      36             : 
      37             : }  // namespace internal
      38      120216 : }  // namespace v8

Generated by: LCOV version 1.10