LCOV - code coverage report
Current view: top level - test/unittests - test-utils.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 21 21 100.0 %
Date: 2019-03-21 Functions: 5 5 100.0 %

          Line data    Source code
       1             : // Copyright 2014 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 "test/unittests/test-utils.h"
       6             : 
       7             : #include "include/libplatform/libplatform.h"
       8             : #include "include/v8.h"
       9             : #include "src/api-inl.h"
      10             : #include "src/base/platform/time.h"
      11             : #include "src/flags.h"
      12             : #include "src/isolate.h"
      13             : #include "src/objects-inl.h"
      14             : #include "src/v8.h"
      15             : 
      16             : namespace v8 {
      17             : 
      18        1258 : IsolateWrapper::IsolateWrapper(bool enforce_pointer_compression)
      19             :     : array_buffer_allocator_(
      20        1258 :           v8::ArrayBuffer::Allocator::NewDefaultAllocator()) {
      21             :   v8::Isolate::CreateParams create_params;
      22        1258 :   create_params.array_buffer_allocator = array_buffer_allocator_;
      23        1258 :   if (enforce_pointer_compression) {
      24             :     isolate_ = reinterpret_cast<v8::Isolate*>(
      25           1 :         i::Isolate::New(i::IsolateAllocationMode::kInV8Heap));
      26           1 :     v8::Isolate::Initialize(isolate_, create_params);
      27             :   } else {
      28        1257 :     isolate_ = v8::Isolate::New(create_params);
      29             :   }
      30        1258 :   CHECK_NOT_NULL(isolate_);
      31        1258 : }
      32             : 
      33        2516 : IsolateWrapper::~IsolateWrapper() {
      34        1258 :   v8::Platform* platform = internal::V8::GetCurrentPlatform();
      35        1258 :   CHECK_NOT_NULL(platform);
      36        1262 :   while (platform::PumpMessageLoop(platform, isolate_)) continue;
      37        1258 :   isolate_->Dispose();
      38        1258 :   delete array_buffer_allocator_;
      39        1258 : }
      40             : 
      41             : // static
      42             : v8::IsolateWrapper* SharedIsolateHolder::isolate_wrapper_ = nullptr;
      43             : 
      44             : namespace internal {
      45             : 
      46          42 : SaveFlags::SaveFlags() {
      47             :   // For each flag, save the current flag value.
      48             : #define FLAG_MODE_APPLY(ftype, ctype, nam, def, cmt) SAVED_##nam = FLAG_##nam;
      49             : #include "src/flag-definitions.h"  // NOLINT
      50             : #undef FLAG_MODE_APPLY
      51          42 : }
      52             : 
      53          84 : SaveFlags::~SaveFlags() {
      54             :   // For each flag, set back the old flag value if it changed (don't write the
      55             :   // flag if it didn't change, to keep TSAN happy).
      56             : #define FLAG_MODE_APPLY(ftype, ctype, nam, def, cmt) \
      57             :   if (SAVED_##nam != FLAG_##nam) {                   \
      58             :     FLAG_##nam = SAVED_##nam;                        \
      59             :   }
      60             : #include "src/flag-definitions.h"  // NOLINT
      61             : #undef FLAG_MODE_APPLY
      62          42 : }
      63             : 
      64             : }  // namespace internal
      65        6148 : }  // namespace v8

Generated by: LCOV version 1.10