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