LCOV - code coverage report
Current view: top level - src - vm-state-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 18 30 60.0 %
Date: 2019-04-19 Functions: 4 5 80.0 %

          Line data    Source code
       1             : // Copyright 2010 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_VM_STATE_INL_H_
       6             : #define V8_VM_STATE_INL_H_
       7             : 
       8             : #include "src/vm-state.h"
       9             : #include "src/log.h"
      10             : #include "src/simulator.h"
      11             : #include "src/tracing/trace-event.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : //
      17             : // VMState class implementation.  A simple stack of VM states held by the
      18             : // logger and partially threaded through the call stack.  States are pushed by
      19             : // VMState construction and popped by destruction.
      20             : //
      21           0 : inline const char* StateToString(StateTag state) {
      22           0 :   switch (state) {
      23             :     case JS:
      24             :       return "JS";
      25             :     case GC:
      26           0 :       return "GC";
      27             :     case PARSER:
      28           0 :       return "PARSER";
      29             :     case BYTECODE_COMPILER:
      30           0 :       return "BYTECODE_COMPILER";
      31             :     case COMPILER:
      32           0 :       return "COMPILER";
      33             :     case OTHER:
      34           0 :       return "OTHER";
      35             :     case EXTERNAL:
      36           0 :       return "EXTERNAL";
      37             :     case IDLE:
      38           0 :       return "IDLE";
      39             :   }
      40           0 : }
      41             : 
      42             : 
      43             : template <StateTag Tag>
      44     5753680 : VMState<Tag>::VMState(Isolate* isolate)
      45    11507360 :     : isolate_(isolate), previous_tag_(isolate->current_vm_state()) {
      46     5753680 :   if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && Tag == EXTERNAL) {
      47           0 :     LOG(isolate_, TimerEvent(Logger::START, TimerEventExternal::name()));
      48             :   }
      49     5753680 :   isolate_->set_current_vm_state(Tag);
      50     5753680 : }
      51             : 
      52             : 
      53             : template <StateTag Tag>
      54     5753681 : VMState<Tag>::~VMState() {
      55     5753681 :   if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && Tag == EXTERNAL) {
      56           0 :     LOG(isolate_, TimerEvent(Logger::END, TimerEventExternal::name()));
      57             :   }
      58     5753681 :   isolate_->set_current_vm_state(previous_tag_);
      59     5753681 : }
      60             : 
      61     5440348 : ExternalCallbackScope::ExternalCallbackScope(Isolate* isolate, Address callback)
      62             :     : isolate_(isolate),
      63             :       callback_(callback),
      64    10880696 :       previous_scope_(isolate->external_callback_scope()) {
      65             : #ifdef USE_SIMULATOR
      66             :   scope_address_ = Simulator::current(isolate)->get_sp();
      67             : #endif
      68             :   isolate_->set_external_callback_scope(this);
      69    10880696 :   TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"),
      70             :                      "V8.ExternalCallback");
      71     5440348 : }
      72             : 
      73    10880696 : ExternalCallbackScope::~ExternalCallbackScope() {
      74     5440348 :   isolate_->set_external_callback_scope(previous_scope_);
      75    10880696 :   TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"),
      76             :                    "V8.ExternalCallback");
      77     5440348 : }
      78             : 
      79             : Address ExternalCallbackScope::scope_address() {
      80             : #ifdef USE_SIMULATOR
      81             :   return scope_address_;
      82             : #else
      83       35953 :   return reinterpret_cast<Address>(this);
      84             : #endif
      85             : }
      86             : 
      87             : 
      88             : }  // namespace internal
      89             : }  // namespace v8
      90             : 
      91             : #endif  // V8_VM_STATE_INL_H_

Generated by: LCOV version 1.10