⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 api.h.svn-base

📁 Google浏览器V8内核代码
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
  static inline v8::internal::Handle<v8::internal::JSObject>      OpenHandle(Message* message);  static inline v8::internal::Handle<v8::internal::Context>      OpenHandle(v8::Context* context);  static inline v8::internal::Handle<v8::internal::SignatureInfo>      OpenHandle(v8::Signature* sig);  static inline v8::internal::Handle<v8::internal::TypeSwitchInfo>      OpenHandle(v8::TypeSwitch* that);};template <class T>static inline T* ToApi(v8::internal::Handle<v8::internal::Object> obj) {  return reinterpret_cast<T*>(obj.location());}template <class T>v8::internal::Handle<T> v8::internal::Handle<T>::EscapeFrom(    HandleScope* scope) {  return Utils::OpenHandle(*scope->Close(Utils::ToLocal(*this)));}// Implementations of ToLocal#define MAKE_TO_LOCAL(Name, From, To) \  Local<v8::To> Utils::Name(v8::internal::Handle<v8::internal::From> obj) { \    return Local<To>(reinterpret_cast<To*>(obj.location())); \  }MAKE_TO_LOCAL(ToLocal, Context, Context)MAKE_TO_LOCAL(ToLocal, Object, Value)MAKE_TO_LOCAL(ToLocal, JSFunction, Function)MAKE_TO_LOCAL(ToLocal, String, String)MAKE_TO_LOCAL(ToLocal, JSObject, Object)MAKE_TO_LOCAL(ToLocal, JSArray, Array)MAKE_TO_LOCAL(ToLocal, Proxy, External)MAKE_TO_LOCAL(ToLocal, FunctionTemplateInfo, FunctionTemplate)MAKE_TO_LOCAL(ToLocal, ObjectTemplateInfo, ObjectTemplate)MAKE_TO_LOCAL(ToLocal, SignatureInfo, Signature)MAKE_TO_LOCAL(ToLocal, TypeSwitchInfo, TypeSwitch)MAKE_TO_LOCAL(MessageToLocal, Object, Message)MAKE_TO_LOCAL(NumberToLocal, Object, Number)MAKE_TO_LOCAL(IntegerToLocal, Object, Integer)MAKE_TO_LOCAL(Uint32ToLocal, Object, Uint32)#undef MAKE_TO_LOCAL// Implementations of OpenHandle#define MAKE_OPEN_HANDLE(From, To) \  v8::internal::Handle<v8::internal::To> Utils::OpenHandle(v8::From* that) { \    return v8::internal::Handle<v8::internal::To>( \        reinterpret_cast<v8::internal::To**>(that)); \  }MAKE_OPEN_HANDLE(Template, TemplateInfo)MAKE_OPEN_HANDLE(FunctionTemplate, FunctionTemplateInfo)MAKE_OPEN_HANDLE(ObjectTemplate, ObjectTemplateInfo)MAKE_OPEN_HANDLE(Signature, SignatureInfo)MAKE_OPEN_HANDLE(TypeSwitch, TypeSwitchInfo)MAKE_OPEN_HANDLE(Data, Object)MAKE_OPEN_HANDLE(Object, JSObject)MAKE_OPEN_HANDLE(Array, JSArray)MAKE_OPEN_HANDLE(String, String)MAKE_OPEN_HANDLE(Script, JSFunction)MAKE_OPEN_HANDLE(Function, JSFunction)MAKE_OPEN_HANDLE(Message, JSObject)MAKE_OPEN_HANDLE(Context, Context)#undef MAKE_OPEN_HANDLEnamespace internal {// This class is here in order to be able to declare it a friend of// HandleScope.  Moving these methods to be members of HandleScope would be// neat in some ways, but it would expose external implementation details in// our public header file, which is undesirable.//// There is a singleton instance of this class to hold the per-thread data.// For multithreaded V8 programs this data is copied in and out of storage// so that the currently executing thread always has its own copy of this// data.class HandleScopeImplementer { public:  HandleScopeImplementer()      : blocks(0),        entered_contexts_(0),        saved_contexts_(0),        saved_security_contexts_(0) {    Initialize();  }  void Initialize() {    blocks.Initialize(0);    entered_contexts_.Initialize(0);    saved_contexts_.Initialize(0);    saved_security_contexts_.Initialize(0);    spare = NULL;    ignore_out_of_memory = false;    call_depth = 0;  }  static HandleScopeImplementer* instance();  // Threading support for handle data.  static int ArchiveSpacePerThread();  static char* RestoreThread(char* from);  static char* ArchiveThread(char* to);  // Garbage collection support.  static void Iterate(v8::internal::ObjectVisitor* v);  static char* Iterate(v8::internal::ObjectVisitor* v, char* data);  inline void** GetSpareOrNewBlock();  inline void DeleteExtensions(int extensions);  inline void IncrementCallDepth() {call_depth++;}  inline void DecrementCallDepth() {call_depth--;}  inline bool CallDepthIsZero() { return call_depth == 0; }  inline void EnterContext(Handle<Object> context);  inline bool LeaveLastContext();  // Returns the last entered context or an empty handle if no  // contexts have been entered.  inline Handle<Object> LastEnteredContext();  inline void SaveContext(Handle<Object> context);  inline Handle<Object> RestoreContext();  inline bool HasSavedContexts();  inline void SaveSecurityContext(Handle<Object> context);  inline Handle<Object> RestoreSecurityContext();  inline bool HasSavedSecurityContexts();  inline List<void**>* Blocks() { return &blocks; }  inline bool IgnoreOutOfMemory() { return ignore_out_of_memory; }  inline void SetIgnoreOutOfMemory(bool value) { ignore_out_of_memory = value; } private:  List<void**> blocks;  Object** spare;  int call_depth;  // Used as a stack to keep track of entered contexts.  List<Handle<Object> > entered_contexts_;  // Used as a stack to keep track of saved contexts.  List<Handle<Object> > saved_contexts_;  // Used as a stack to keep track of saved security contexts.  List<Handle<Object> > saved_security_contexts_;  bool ignore_out_of_memory;  // This is only used for threading support.  ImplementationUtilities::HandleScopeData handle_scope_data_;  static void Iterate(ObjectVisitor* v,                      List<void**>* blocks,                      ImplementationUtilities::HandleScopeData* handle_data);  char* RestoreThreadHelper(char* from);  char* ArchiveThreadHelper(char* to);  DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer);};static const int kHandleBlockSize = v8::internal::KB - 2;  // fit in one pagevoid HandleScopeImplementer::SaveContext(Handle<Object> context) {  saved_contexts_.Add(context);}Handle<Object> HandleScopeImplementer::RestoreContext() {  return saved_contexts_.RemoveLast();}bool HandleScopeImplementer::HasSavedContexts() {  return !saved_contexts_.is_empty();}void HandleScopeImplementer::SaveSecurityContext(Handle<Object> context) {  saved_security_contexts_.Add(context);}Handle<Object> HandleScopeImplementer::RestoreSecurityContext() {  return saved_security_contexts_.RemoveLast();}bool HandleScopeImplementer::HasSavedSecurityContexts() {  return !saved_security_contexts_.is_empty();}void HandleScopeImplementer::EnterContext(Handle<Object> context) {  entered_contexts_.Add(context);}bool HandleScopeImplementer::LeaveLastContext() {  if (entered_contexts_.is_empty()) return false;  entered_contexts_.RemoveLast();  return true;}Handle<Object> HandleScopeImplementer::LastEnteredContext() {  if (entered_contexts_.is_empty()) return Handle<Object>::null();  return entered_contexts_.last();}// If there's a spare block, use it for growing the current scope.void** HandleScopeImplementer::GetSpareOrNewBlock() {  void** block = (spare != NULL) ?      reinterpret_cast<void**>(spare) :      NewArray<void*>(kHandleBlockSize);  spare = NULL;  return block;}void HandleScopeImplementer::DeleteExtensions(int extensions) {  if (spare != NULL) {    DeleteArray(spare);    spare = NULL;  }  for (int i = extensions; i > 1; --i) {    void** block = blocks.RemoveLast();#ifdef DEBUG    ImplementationUtilities::ZapHandleRange(block, &block[kHandleBlockSize]);#endif    DeleteArray(block);  }  spare = reinterpret_cast<Object**>(blocks.RemoveLast());#ifdef DEBUG  ImplementationUtilities::ZapHandleRange(      reinterpret_cast<void**>(spare),      reinterpret_cast<void**>(&spare[kHandleBlockSize]));#endif}} }  // namespace v8::internal#endif  // V8_API_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -