OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 public: | 818 public: |
819 HandleScope(Isolate* isolate); | 819 HandleScope(Isolate* isolate); |
820 | 820 |
821 ~HandleScope(); | 821 ~HandleScope(); |
822 | 822 |
823 /** | 823 /** |
824 * Counts the number of allocated handles. | 824 * Counts the number of allocated handles. |
825 */ | 825 */ |
826 static int NumberOfHandles(Isolate* isolate); | 826 static int NumberOfHandles(Isolate* isolate); |
827 | 827 |
828 private: | 828 V8_INLINE Isolate* GetIsolate() const { |
829 /** | 829 return reinterpret_cast<Isolate*>(isolate_); |
830 * Creates a new handle with the given value. | 830 } |
831 */ | 831 |
| 832 protected: |
| 833 V8_INLINE HandleScope() {} |
| 834 |
| 835 void Initialize(Isolate* isolate); |
| 836 |
832 static internal::Object** CreateHandle(internal::Isolate* isolate, | 837 static internal::Object** CreateHandle(internal::Isolate* isolate, |
833 internal::Object* value); | 838 internal::Object* value); |
834 // Uses HeapObject to obtain the current Isolate. | 839 |
| 840 private: |
| 841 // Uses heap_object to obtain the current Isolate. |
835 static internal::Object** CreateHandle(internal::HeapObject* heap_object, | 842 static internal::Object** CreateHandle(internal::HeapObject* heap_object, |
836 internal::Object* value); | 843 internal::Object* value); |
837 | 844 |
838 V8_INLINE HandleScope() {} | |
839 void Initialize(Isolate* isolate); | |
840 | |
841 // Make it hard to create heap-allocated or illegal handle scopes by | 845 // Make it hard to create heap-allocated or illegal handle scopes by |
842 // disallowing certain operations. | 846 // disallowing certain operations. |
843 HandleScope(const HandleScope&); | 847 HandleScope(const HandleScope&); |
844 void operator=(const HandleScope&); | 848 void operator=(const HandleScope&); |
845 void* operator new(size_t size); | 849 void* operator new(size_t size); |
846 void operator delete(void*, size_t); | 850 void operator delete(void*, size_t); |
847 | 851 |
848 // This Data class is accessible internally as HandleScopeData through a | |
849 // typedef in the ImplementationUtilities class. | |
850 class V8_EXPORT Data { | |
851 public: | |
852 internal::Object** next; | |
853 internal::Object** limit; | |
854 int level; | |
855 V8_INLINE void Initialize() { | |
856 next = limit = NULL; | |
857 level = 0; | |
858 } | |
859 }; | |
860 | |
861 internal::Isolate* isolate_; | 852 internal::Isolate* isolate_; |
862 internal::Object** prev_next_; | 853 internal::Object** prev_next_; |
863 internal::Object** prev_limit_; | 854 internal::Object** prev_limit_; |
864 | 855 |
865 friend class ImplementationUtilities; | 856 // Local::New uses CreateHandle with an Isolate* parameter. |
866 friend class EscapableHandleScope; | |
867 template<class F> friend class Handle; | |
868 template<class F> friend class Local; | 857 template<class F> friend class Local; |
| 858 |
| 859 // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with |
| 860 // a HeapObject* in their shortcuts. |
869 friend class Object; | 861 friend class Object; |
870 friend class Context; | 862 friend class Context; |
871 }; | 863 }; |
872 | 864 |
873 | 865 |
874 /** | 866 /** |
875 * A HandleScope which first allocates a handle in the current scope | 867 * A HandleScope which first allocates a handle in the current scope |
876 * which will be later filled with the escape value. | 868 * which will be later filled with the escape value. |
877 */ | 869 */ |
878 class V8_EXPORT EscapableHandleScope : public HandleScope { | 870 class V8_EXPORT EscapableHandleScope : public HandleScope { |
(...skipping 4037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4916 bool has_terminated_ : 1; | 4908 bool has_terminated_ : 1; |
4917 | 4909 |
4918 friend class v8::internal::Isolate; | 4910 friend class v8::internal::Isolate; |
4919 }; | 4911 }; |
4920 | 4912 |
4921 | 4913 |
4922 // --- Context --- | 4914 // --- Context --- |
4923 | 4915 |
4924 | 4916 |
4925 /** | 4917 /** |
4926 * Ignore | 4918 * A container for extension names. |
4927 */ | 4919 */ |
4928 class V8_EXPORT ExtensionConfiguration { | 4920 class V8_EXPORT ExtensionConfiguration { |
4929 public: | 4921 public: |
| 4922 ExtensionConfiguration() : name_count_(0), names_(NULL) { } |
4930 ExtensionConfiguration(int name_count, const char* names[]) | 4923 ExtensionConfiguration(int name_count, const char* names[]) |
4931 : name_count_(name_count), names_(names) { } | 4924 : name_count_(name_count), names_(names) { } |
| 4925 |
| 4926 const char** begin() const { return &names_[0]; } |
| 4927 const char** end() const { return &names_[name_count_]; } |
| 4928 |
4932 private: | 4929 private: |
4933 friend class ImplementationUtilities; | 4930 const int name_count_; |
4934 int name_count_; | |
4935 const char** names_; | 4931 const char** names_; |
4936 }; | 4932 }; |
4937 | 4933 |
4938 | 4934 |
4939 /** | 4935 /** |
4940 * A sandboxed execution context with its own set of built-in objects | 4936 * A sandboxed execution context with its own set of built-in objects |
4941 * and functions. | 4937 * and functions. |
4942 */ | 4938 */ |
4943 class V8_EXPORT Context { | 4939 class V8_EXPORT Context { |
4944 public: | 4940 public: |
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6439 */ | 6435 */ |
6440 | 6436 |
6441 | 6437 |
6442 } // namespace v8 | 6438 } // namespace v8 |
6443 | 6439 |
6444 | 6440 |
6445 #undef TYPE_CHECK | 6441 #undef TYPE_CHECK |
6446 | 6442 |
6447 | 6443 |
6448 #endif // V8_H_ | 6444 #endif // V8_H_ |
OLD | NEW |