LCOV - code coverage report
Current view: top level - src - isolate-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 46 50 92.0 %
Date: 2017-10-20 Functions: 112 116 96.6 %

          Line data    Source code
       1             : // Copyright 2015 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             : #ifndef V8_ISOLATE_INL_H_
       6             : #define V8_ISOLATE_INL_H_
       7             : 
       8             : #include "src/isolate.h"
       9             : #include "src/objects-inl.h"
      10             : 
      11             : namespace v8 {
      12             : namespace internal {
      13             : 
      14             : 
      15     1477701 : void Isolate::set_context(Context* context) {
      16             :   DCHECK(context == nullptr || context->IsContext());
      17    53044451 :   thread_local_top_.context_ = context;
      18     1477701 : }
      19             : 
      20    16475250 : Handle<Context> Isolate::native_context() {
      21    16475250 :   return handle(context()->native_context(), this);
      22             : }
      23             : 
      24    32045311 : Context* Isolate::raw_native_context() { return context()->native_context(); }
      25             : 
      26           0 : Object* Isolate::pending_exception() {
      27             :   DCHECK(has_pending_exception());
      28             :   DCHECK(!thread_local_top_.pending_exception_->IsException(this));
      29           0 :   return thread_local_top_.pending_exception_;
      30             : }
      31             : 
      32             : 
      33             : void Isolate::set_pending_exception(Object* exception_obj) {
      34             :   DCHECK(!exception_obj->IsException(this));
      35     1290659 :   thread_local_top_.pending_exception_ = exception_obj;
      36             : }
      37             : 
      38             : 
      39           0 : void Isolate::clear_pending_exception() {
      40             :   DCHECK(!thread_local_top_.pending_exception_->IsException(this));
      41     1431167 :   thread_local_top_.pending_exception_ = heap_.the_hole_value();
      42           0 : }
      43             : 
      44             : 
      45    33141945 : bool Isolate::has_pending_exception() {
      46             :   DCHECK(!thread_local_top_.pending_exception_->IsException(this));
      47    66283890 :   return !thread_local_top_.pending_exception_->IsTheHole(this);
      48             : }
      49             : 
      50        1320 : Object* Isolate::get_wasm_caught_exception() {
      51        1320 :   return thread_local_top_.wasm_caught_exception_;
      52             : }
      53             : 
      54         250 : void Isolate::set_wasm_caught_exception(Object* exception) {
      55         410 :   thread_local_top_.wasm_caught_exception_ = exception;
      56         250 : }
      57             : 
      58         280 : void Isolate::clear_wasm_caught_exception() {
      59         280 :   thread_local_top_.wasm_caught_exception_ = nullptr;
      60         280 : }
      61             : 
      62             : void Isolate::clear_pending_message() {
      63    24932797 :   thread_local_top_.pending_message_obj_ = heap_.the_hole_value();
      64             : }
      65             : 
      66             : 
      67             : Object* Isolate::scheduled_exception() {
      68             :   DCHECK(has_scheduled_exception());
      69             :   DCHECK(!thread_local_top_.scheduled_exception_->IsException(this));
      70             :   return thread_local_top_.scheduled_exception_;
      71             : }
      72             : 
      73             : 
      74     1462529 : bool Isolate::has_scheduled_exception() {
      75             :   DCHECK(!thread_local_top_.scheduled_exception_->IsException(this));
      76   177947666 :   return thread_local_top_.scheduled_exception_ != heap_.the_hole_value();
      77             : }
      78             : 
      79             : 
      80             : void Isolate::clear_scheduled_exception() {
      81             :   DCHECK(!thread_local_top_.scheduled_exception_->IsException(this));
      82      107048 :   thread_local_top_.scheduled_exception_ = heap_.the_hole_value();
      83             : }
      84             : 
      85             : bool Isolate::is_catchable_by_javascript(Object* exception) {
      86     2438859 :   return exception != heap()->termination_exception();
      87             : }
      88             : 
      89             : void Isolate::FireBeforeCallEnteredCallback() {
      90    10717120 :   for (auto& callback : before_call_entered_callbacks_) {
      91          80 :     callback(reinterpret_cast<v8::Isolate*>(this));
      92             :   }
      93             : }
      94             : 
      95             : void Isolate::FireMicrotasksCompletedCallback() {
      96       98348 :   for (auto& callback : microtasks_completed_callbacks_) {
      97          25 :     callback(reinterpret_cast<v8::Isolate*>(this));
      98             :   }
      99             : }
     100             : 
     101     4038791 : Handle<JSGlobalObject> Isolate::global_object() {
     102     8077581 :   return handle(context()->global_object(), this);
     103             : }
     104             : 
     105      235490 : Handle<JSObject> Isolate::global_proxy() {
     106      470980 :   return handle(context()->global_proxy(), this);
     107             : }
     108             : 
     109             : 
     110        9654 : Isolate::ExceptionScope::ExceptionScope(Isolate* isolate)
     111             :     : isolate_(isolate),
     112       19308 :       pending_exception_(isolate_->pending_exception(), isolate_) {}
     113             : 
     114             : 
     115             : Isolate::ExceptionScope::~ExceptionScope() {
     116        9654 :   isolate_->set_pending_exception(*pending_exception_);
     117             : }
     118             : 
     119             : #define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name)     \
     120             :   Handle<type> Isolate::name() {                             \
     121             :     return Handle<type>(raw_native_context()->name(), this); \
     122             :   }                                                          \
     123             :   bool Isolate::is_##name(type* value) {                     \
     124             :     return raw_native_context()->is_##name(value);           \
     125             :   }
     126    44567281 : NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR)
     127             : #undef NATIVE_CONTEXT_FIELD_ACCESSOR
     128             : 
     129        2301 : bool Isolate::IsArrayConstructorIntact() {
     130        2938 :   Cell* array_constructor_cell = heap()->array_constructor_protector();
     131        2938 :   return array_constructor_cell->value() == Smi::FromInt(kProtectorValid);
     132             : }
     133             : 
     134          75 : bool Isolate::IsArraySpeciesLookupChainIntact() {
     135             :   // Note: It would be nice to have debug checks to make sure that the
     136             :   // species protector is accurate, but this would be hard to do for most of
     137             :   // what the protector stands for:
     138             :   // - You'd need to traverse the heap to check that no Array instance has
     139             :   //   a constructor property
     140             :   // - To check that Array[Symbol.species] == Array, JS code has to execute,
     141             :   //   but JS cannot be invoked in callstack overflow situations
     142             :   // All that could be checked reliably is that
     143             :   // Array.prototype.constructor == Array. Given that limitation, no check is
     144             :   // done here. In place, there are mjsunit tests harmony/array-species* which
     145             :   // ensure that behavior is correct in various invalid protector cases.
     146             : 
     147      742914 :   PropertyCell* species_cell = heap()->species_protector();
     148     1485828 :   return species_cell->value()->IsSmi() &&
     149          75 :          Smi::ToInt(species_cell->value()) == kProtectorValid;
     150             : }
     151             : 
     152             : bool Isolate::IsStringLengthOverflowIntact() {
     153        2709 :   Cell* string_length_cell = heap()->string_length_protector();
     154             :   return string_length_cell->value() == Smi::FromInt(kProtectorValid);
     155             : }
     156             : 
     157             : bool Isolate::IsFastArrayIterationIntact() {
     158         661 :   Cell* fast_iteration_cell = heap()->fast_array_iteration_protector();
     159             :   return fast_iteration_cell->value() == Smi::FromInt(kProtectorValid);
     160             : }
     161             : 
     162             : bool Isolate::IsArrayBufferNeuteringIntact() {
     163       11391 :   PropertyCell* buffer_neutering = heap()->array_buffer_neutering_protector();
     164             :   return buffer_neutering->value() == Smi::FromInt(kProtectorValid);
     165             : }
     166             : 
     167             : bool Isolate::IsArrayIteratorLookupChainIntact() {
     168       41202 :   PropertyCell* array_iterator_cell = heap()->array_iterator_protector();
     169             :   return array_iterator_cell->value() == Smi::FromInt(kProtectorValid);
     170             : }
     171             : 
     172             : }  // namespace internal
     173             : }  // namespace v8
     174             : 
     175             : #endif  // V8_ISOLATE_INL_H_

Generated by: LCOV version 1.10