LCOV - code coverage report
Current view: top level - src - v8.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 52 55 94.5 %
Date: 2017-04-26 Functions: 9 10 90.0 %

          Line data    Source code
       1             : // Copyright 2012 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/v8.h"
       6             : 
       7             : #include "src/api.h"
       8             : #include "src/assembler.h"
       9             : #include "src/base/once.h"
      10             : #include "src/base/platform/platform.h"
      11             : #include "src/bootstrapper.h"
      12             : #include "src/crankshaft/lithium-allocator.h"
      13             : #include "src/debug/debug.h"
      14             : #include "src/deoptimizer.h"
      15             : #include "src/elements.h"
      16             : #include "src/frames.h"
      17             : #include "src/isolate.h"
      18             : #include "src/libsampler/sampler.h"
      19             : #include "src/objects-inl.h"
      20             : #include "src/profiler/heap-profiler.h"
      21             : #include "src/runtime-profiler.h"
      22             : #include "src/snapshot/natives.h"
      23             : #include "src/snapshot/snapshot.h"
      24             : #include "src/tracing/tracing-category-observer.h"
      25             : 
      26             : namespace v8 {
      27             : namespace internal {
      28             : 
      29             : V8_DECLARE_ONCE(init_once);
      30             : 
      31             : #ifdef V8_USE_EXTERNAL_STARTUP_DATA
      32             : V8_DECLARE_ONCE(init_natives_once);
      33             : V8_DECLARE_ONCE(init_snapshot_once);
      34             : #endif
      35             : 
      36             : v8::Platform* V8::platform_ = NULL;
      37             : 
      38             : 
      39       59923 : bool V8::Initialize() {
      40             :   InitializeOncePerProcess();
      41       59923 :   return true;
      42             : }
      43             : 
      44             : 
      45       32496 : void V8::TearDown() {
      46       32496 :   Bootstrapper::TearDownExtensions();
      47       32496 :   ElementsAccessor::TearDown();
      48       32496 :   LOperand::TearDownCaches();
      49       32496 :   RegisteredExtension::UnregisterAll();
      50       32496 :   Isolate::GlobalTearDown();
      51       32496 :   sampler::Sampler::TearDown();
      52       32496 :   FlagList::ResetAllFlags();  // Frees memory held by string arguments.
      53       32496 : }
      54             : 
      55             : 
      56       59461 : void V8::InitializeOncePerProcessImpl() {
      57       59461 :   FlagList::EnforceFlagImplications();
      58             : 
      59       59461 :   if (FLAG_predictable && FLAG_random_seed == 0) {
      60             :     // Avoid random seeds in predictable mode.
      61           0 :     FLAG_random_seed = 12347;
      62             :   }
      63             : 
      64       59461 :   if (FLAG_stress_compaction) {
      65          77 :     FLAG_force_marking_deque_overflows = true;
      66          77 :     FLAG_gc_global = true;
      67          77 :     FLAG_max_semi_space_size = 1;
      68             :   }
      69             : 
      70       59461 :   if (FLAG_opt && FLAG_turbo && strcmp(FLAG_turbo_filter, "~~") == 0) {
      71             :     const char* filter_flag = "--turbo-filter=*";
      72       42969 :     FlagList::SetFlagsFromString(filter_flag, StrLength(filter_flag));
      73             :   }
      74             : 
      75       59461 :   base::OS::Initialize(FLAG_random_seed, FLAG_hard_abort, FLAG_gc_fake_mmap);
      76             : 
      77       59461 :   Isolate::InitializeOncePerProcess();
      78             : 
      79       59461 :   sampler::Sampler::SetUp();
      80             :   CpuFeatures::Probe(false);
      81       59461 :   ElementsAccessor::InitializeOncePerProcess();
      82       59461 :   LOperand::SetUpCaches();
      83       59461 :   SetUpJSCallerSavedCodeData();
      84       59461 :   ExternalReference::SetUp();
      85       59461 :   Bootstrapper::InitializeOncePerProcess();
      86       59461 : }
      87             : 
      88             : 
      89           0 : void V8::InitializeOncePerProcess() {
      90       59923 :   base::CallOnce(&init_once, &InitializeOncePerProcessImpl);
      91           0 : }
      92             : 
      93             : 
      94       59461 : void V8::InitializePlatform(v8::Platform* platform) {
      95       59461 :   CHECK(!platform_);
      96       59461 :   CHECK(platform);
      97       59461 :   platform_ = platform;
      98       59461 :   v8::base::SetPrintStackTrace(platform_->GetStackTracePrinter());
      99       59461 :   v8::tracing::TracingCategoryObserver::SetUp();
     100       59461 : }
     101             : 
     102             : 
     103       58744 : void V8::ShutdownPlatform() {
     104       58744 :   CHECK(platform_);
     105       58744 :   v8::tracing::TracingCategoryObserver::TearDown();
     106       58744 :   v8::base::SetPrintStackTrace(nullptr);
     107       58744 :   platform_ = NULL;
     108       58744 : }
     109             : 
     110             : 
     111     9692931 : v8::Platform* V8::GetCurrentPlatform() {
     112             :   DCHECK(platform_);
     113     9692931 :   return platform_;
     114             : }
     115             : 
     116             : 
     117         194 : void V8::SetPlatformForTesting(v8::Platform* platform) { platform_ = platform; }
     118             : 
     119             : 
     120       59466 : void V8::SetNativesBlob(StartupData* natives_blob) {
     121             : #ifdef V8_USE_EXTERNAL_STARTUP_DATA
     122       59466 :   base::CallOnce(&init_natives_once, &SetNativesFromFile, natives_blob);
     123             : #else
     124             :   CHECK(false);
     125             : #endif
     126       59466 : }
     127             : 
     128             : 
     129       59466 : void V8::SetSnapshotBlob(StartupData* snapshot_blob) {
     130             : #ifdef V8_USE_EXTERNAL_STARTUP_DATA
     131       59466 :   base::CallOnce(&init_snapshot_once, &SetSnapshotFromFile, snapshot_blob);
     132             : #else
     133             :   CHECK(false);
     134             : #endif
     135       59466 : }
     136             : }  // namespace internal
     137             : }  // namespace v8

Generated by: LCOV version 1.10