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_EXECUTION_VM_STATE_H_ 6 #define V8_EXECUTION_VM_STATE_H_ 7 8 #include "include/v8.h" 9 #include "src/common/globals.h" 10 11 namespace v8 { 12 namespace internal { 13 14 // Logging and profiling. A StateTag represents a possible state of the VM. The 15 // logger maintains a stack of these. Creating a VMState object enters a state 16 // by pushing on the stack, and destroying a VMState object leaves a state by 17 // popping the current state from the stack. 18 template <StateTag Tag> 19 class VMState { 20 public: 21 explicit inline VMState(Isolate* isolate); 22 inline ~VMState(); 23 24 private: 25 Isolate* isolate_; 26 StateTag previous_tag_; 27 }; 28 29 class ExternalCallbackScope { 30 public: 31 inline ExternalCallbackScope(Isolate* isolate, Address callback); 32 inline ~ExternalCallbackScope(); callback()33 Address callback() { return callback_; } callback_entrypoint_address()34 Address* callback_entrypoint_address() { 35 if (callback_ == kNullAddress) return nullptr; 36 #if USES_FUNCTION_DESCRIPTORS 37 return FUNCTION_ENTRYPOINT_ADDRESS(callback_); 38 #else 39 return &callback_; 40 #endif 41 } previous()42 ExternalCallbackScope* previous() { return previous_scope_; } 43 inline Address scope_address(); 44 45 private: 46 Isolate* isolate_; 47 Address callback_; 48 ExternalCallbackScope* previous_scope_; 49 #ifdef USE_SIMULATOR 50 Address scope_address_; 51 #endif 52 }; 53 54 } // namespace internal 55 } // namespace v8 56 57 #endif // V8_EXECUTION_VM_STATE_H_ 58