| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 class HeapProfiler; | 98 class HeapProfiler; |
| 99 class ImplementationUtilities; | 99 class ImplementationUtilities; |
| 100 class Int32; | 100 class Int32; |
| 101 class Integer; | 101 class Integer; |
| 102 class Isolate; | 102 class Isolate; |
| 103 class Number; | 103 class Number; |
| 104 class NumberObject; | 104 class NumberObject; |
| 105 class Object; | 105 class Object; |
| 106 class ObjectOperationDescriptor; | 106 class ObjectOperationDescriptor; |
| 107 class ObjectTemplate; | 107 class ObjectTemplate; |
| 108 class Platform; |
| 108 class Primitive; | 109 class Primitive; |
| 109 class RawOperationDescriptor; | 110 class RawOperationDescriptor; |
| 110 class Signature; | 111 class Signature; |
| 111 class StackFrame; | 112 class StackFrame; |
| 112 class StackTrace; | 113 class StackTrace; |
| 113 class String; | 114 class String; |
| 114 class StringObject; | 115 class StringObject; |
| 115 class Symbol; | 116 class Symbol; |
| 116 class SymbolObject; | 117 class SymbolObject; |
| 117 class Private; | 118 class Private; |
| (...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; | 1729 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; |
| 1729 | 1730 |
| 1730 V8_INLINE static String* Cast(v8::Value* obj); | 1731 V8_INLINE static String* Cast(v8::Value* obj); |
| 1731 | 1732 |
| 1732 /** | 1733 /** |
| 1733 * Allocates a new string from either UTF-8 encoded or ASCII data. | 1734 * Allocates a new string from either UTF-8 encoded or ASCII data. |
| 1734 * The second parameter 'length' gives the buffer length. If omitted, | 1735 * The second parameter 'length' gives the buffer length. If omitted, |
| 1735 * the function calls 'strlen' to determine the buffer length. | 1736 * the function calls 'strlen' to determine the buffer length. |
| 1736 */ | 1737 */ |
| 1737 V8_DEPRECATED( | 1738 V8_DEPRECATED( |
| 1738 "Use NewFromOneByte instead", | 1739 "Use NewFromUtf8 instead", |
| 1739 V8_INLINE static Local<String> New(const char* data, int length = -1)); | 1740 V8_INLINE static Local<String> New(const char* data, int length = -1)); |
| 1740 | 1741 |
| 1741 /** Allocates a new string from 16-bit character codes.*/ | 1742 /** Allocates a new string from 16-bit character codes.*/ |
| 1742 V8_DEPRECATED( | 1743 V8_DEPRECATED( |
| 1743 "Use NewFromTwoByte instead", | 1744 "Use NewFromTwoByte instead", |
| 1744 V8_INLINE static Local<String> New( | 1745 V8_INLINE static Local<String> New( |
| 1745 const uint16_t* data, int length = -1)); | 1746 const uint16_t* data, int length = -1)); |
| 1746 | 1747 |
| 1747 /** | 1748 /** |
| 1748 * Creates an internalized string (historically called a "symbol", | 1749 * Creates an internalized string (historically called a "symbol", |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2527 int GetScriptColumnNumber() const; | 2528 int GetScriptColumnNumber() const; |
| 2528 | 2529 |
| 2529 /** | 2530 /** |
| 2530 * Tells whether this function is builtin. | 2531 * Tells whether this function is builtin. |
| 2531 */ | 2532 */ |
| 2532 bool IsBuiltin() const; | 2533 bool IsBuiltin() const; |
| 2533 | 2534 |
| 2534 /** | 2535 /** |
| 2535 * Returns scriptId object. | 2536 * Returns scriptId object. |
| 2536 */ | 2537 */ |
| 2537 V8_DEPRECATED("Use ScriptId instead", Handle<Value> GetScriptId()) const; | 2538 V8_DEPRECATED("Use ScriptId instead", Handle<Value> GetScriptId() const); |
| 2538 | 2539 |
| 2539 /** | 2540 /** |
| 2540 * Returns scriptId. | 2541 * Returns scriptId. |
| 2541 */ | 2542 */ |
| 2542 int ScriptId() const; | 2543 int ScriptId() const; |
| 2543 | 2544 |
| 2544 ScriptOrigin GetScriptOrigin() const; | 2545 ScriptOrigin GetScriptOrigin() const; |
| 2545 V8_INLINE static Function* Cast(Value* obj); | 2546 V8_INLINE static Function* Cast(Value* obj); |
| 2546 static const int kLineOffsetNotFound; | 2547 static const int kLineOffsetNotFound; |
| 2547 | 2548 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2891 | 2892 |
| 2892 /** | 2893 /** |
| 2893 * An instance of the built-in Date constructor (ECMA-262, 15.9). | 2894 * An instance of the built-in Date constructor (ECMA-262, 15.9). |
| 2894 */ | 2895 */ |
| 2895 class V8_EXPORT Date : public Object { | 2896 class V8_EXPORT Date : public Object { |
| 2896 public: | 2897 public: |
| 2897 static Local<Value> New(double time); | 2898 static Local<Value> New(double time); |
| 2898 | 2899 |
| 2899 V8_DEPRECATED( | 2900 V8_DEPRECATED( |
| 2900 "Use ValueOf instead", | 2901 "Use ValueOf instead", |
| 2901 double NumberValue()) const { return ValueOf(); } | 2902 double NumberValue() const) { return ValueOf(); } |
| 2902 | 2903 |
| 2903 /** | 2904 /** |
| 2904 * A specialization of Value::NumberValue that is more efficient | 2905 * A specialization of Value::NumberValue that is more efficient |
| 2905 * because we know the structure of this object. | 2906 * because we know the structure of this object. |
| 2906 */ | 2907 */ |
| 2907 double ValueOf() const; | 2908 double ValueOf() const; |
| 2908 | 2909 |
| 2909 V8_INLINE static Date* Cast(v8::Value* obj); | 2910 V8_INLINE static Date* Cast(v8::Value* obj); |
| 2910 | 2911 |
| 2911 /** | 2912 /** |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2929 | 2930 |
| 2930 /** | 2931 /** |
| 2931 * A Number object (ECMA-262, 4.3.21). | 2932 * A Number object (ECMA-262, 4.3.21). |
| 2932 */ | 2933 */ |
| 2933 class V8_EXPORT NumberObject : public Object { | 2934 class V8_EXPORT NumberObject : public Object { |
| 2934 public: | 2935 public: |
| 2935 static Local<Value> New(double value); | 2936 static Local<Value> New(double value); |
| 2936 | 2937 |
| 2937 V8_DEPRECATED( | 2938 V8_DEPRECATED( |
| 2938 "Use ValueOf instead", | 2939 "Use ValueOf instead", |
| 2939 double NumberValue()) const { return ValueOf(); } | 2940 double NumberValue() const) { return ValueOf(); } |
| 2940 | 2941 |
| 2941 /** | 2942 /** |
| 2942 * Returns the Number held by the object. | 2943 * Returns the Number held by the object. |
| 2943 */ | 2944 */ |
| 2944 double ValueOf() const; | 2945 double ValueOf() const; |
| 2945 | 2946 |
| 2946 V8_INLINE static NumberObject* Cast(v8::Value* obj); | 2947 V8_INLINE static NumberObject* Cast(v8::Value* obj); |
| 2947 | 2948 |
| 2948 private: | 2949 private: |
| 2949 static void CheckCast(v8::Value* obj); | 2950 static void CheckCast(v8::Value* obj); |
| 2950 }; | 2951 }; |
| 2951 | 2952 |
| 2952 | 2953 |
| 2953 /** | 2954 /** |
| 2954 * A Boolean object (ECMA-262, 4.3.15). | 2955 * A Boolean object (ECMA-262, 4.3.15). |
| 2955 */ | 2956 */ |
| 2956 class V8_EXPORT BooleanObject : public Object { | 2957 class V8_EXPORT BooleanObject : public Object { |
| 2957 public: | 2958 public: |
| 2958 static Local<Value> New(bool value); | 2959 static Local<Value> New(bool value); |
| 2959 | 2960 |
| 2960 V8_DEPRECATED( | 2961 V8_DEPRECATED( |
| 2961 "Use ValueOf instead", | 2962 "Use ValueOf instead", |
| 2962 bool BooleanValue()) const { return ValueOf(); } | 2963 bool BooleanValue() const) { return ValueOf(); } |
| 2963 | 2964 |
| 2964 /** | 2965 /** |
| 2965 * Returns the Boolean held by the object. | 2966 * Returns the Boolean held by the object. |
| 2966 */ | 2967 */ |
| 2967 bool ValueOf() const; | 2968 bool ValueOf() const; |
| 2968 | 2969 |
| 2969 V8_INLINE static BooleanObject* Cast(v8::Value* obj); | 2970 V8_INLINE static BooleanObject* Cast(v8::Value* obj); |
| 2970 | 2971 |
| 2971 private: | 2972 private: |
| 2972 static void CheckCast(v8::Value* obj); | 2973 static void CheckCast(v8::Value* obj); |
| 2973 }; | 2974 }; |
| 2974 | 2975 |
| 2975 | 2976 |
| 2976 /** | 2977 /** |
| 2977 * A String object (ECMA-262, 4.3.18). | 2978 * A String object (ECMA-262, 4.3.18). |
| 2978 */ | 2979 */ |
| 2979 class V8_EXPORT StringObject : public Object { | 2980 class V8_EXPORT StringObject : public Object { |
| 2980 public: | 2981 public: |
| 2981 static Local<Value> New(Handle<String> value); | 2982 static Local<Value> New(Handle<String> value); |
| 2982 | 2983 |
| 2983 V8_DEPRECATED( | 2984 V8_DEPRECATED( |
| 2984 "Use ValueOf instead", | 2985 "Use ValueOf instead", |
| 2985 Local<String> StringValue()) const { return ValueOf(); } | 2986 Local<String> StringValue() const) { return ValueOf(); } |
| 2986 | 2987 |
| 2987 /** | 2988 /** |
| 2988 * Returns the String held by the object. | 2989 * Returns the String held by the object. |
| 2989 */ | 2990 */ |
| 2990 Local<String> ValueOf() const; | 2991 Local<String> ValueOf() const; |
| 2991 | 2992 |
| 2992 V8_INLINE static StringObject* Cast(v8::Value* obj); | 2993 V8_INLINE static StringObject* Cast(v8::Value* obj); |
| 2993 | 2994 |
| 2994 private: | 2995 private: |
| 2995 static void CheckCast(v8::Value* obj); | 2996 static void CheckCast(v8::Value* obj); |
| 2996 }; | 2997 }; |
| 2997 | 2998 |
| 2998 | 2999 |
| 2999 /** | 3000 /** |
| 3000 * A Symbol object (ECMA-262 edition 6). | 3001 * A Symbol object (ECMA-262 edition 6). |
| 3001 * | 3002 * |
| 3002 * This is an experimental feature. Use at your own risk. | 3003 * This is an experimental feature. Use at your own risk. |
| 3003 */ | 3004 */ |
| 3004 class V8_EXPORT SymbolObject : public Object { | 3005 class V8_EXPORT SymbolObject : public Object { |
| 3005 public: | 3006 public: |
| 3006 static Local<Value> New(Isolate* isolate, Handle<Symbol> value); | 3007 static Local<Value> New(Isolate* isolate, Handle<Symbol> value); |
| 3007 | 3008 |
| 3008 V8_DEPRECATED( | 3009 V8_DEPRECATED( |
| 3009 "Use ValueOf instead", | 3010 "Use ValueOf instead", |
| 3010 Local<Symbol> SymbolValue()) const { return ValueOf(); } | 3011 Local<Symbol> SymbolValue() const) { return ValueOf(); } |
| 3011 | 3012 |
| 3012 /** | 3013 /** |
| 3013 * Returns the Symbol held by the object. | 3014 * Returns the Symbol held by the object. |
| 3014 */ | 3015 */ |
| 3015 Local<Symbol> ValueOf() const; | 3016 Local<Symbol> ValueOf() const; |
| 3016 | 3017 |
| 3017 V8_INLINE static SymbolObject* Cast(v8::Value* obj); | 3018 V8_INLINE static SymbolObject* Cast(v8::Value* obj); |
| 3018 | 3019 |
| 3019 private: | 3020 private: |
| 3020 static void CheckCast(v8::Value* obj); | 3021 static void CheckCast(v8::Value* obj); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3067 }; | 3068 }; |
| 3068 | 3069 |
| 3069 | 3070 |
| 3070 /** | 3071 /** |
| 3071 * A JavaScript value that wraps a C++ void*. This type of value is mainly used | 3072 * A JavaScript value that wraps a C++ void*. This type of value is mainly used |
| 3072 * to associate C++ data structures with JavaScript objects. | 3073 * to associate C++ data structures with JavaScript objects. |
| 3073 */ | 3074 */ |
| 3074 class V8_EXPORT External : public Value { | 3075 class V8_EXPORT External : public Value { |
| 3075 public: | 3076 public: |
| 3076 static Local<External> New(Isolate* isolate, void* value); | 3077 static Local<External> New(Isolate* isolate, void* value); |
| 3077 // Deprecated, do not use. | 3078 V8_DEPRECATED("Will be removed", static Local<External> New(void *value)); |
| 3078 static Local<External> New(void* value); | |
| 3079 V8_INLINE static External* Cast(Value* obj); | 3079 V8_INLINE static External* Cast(Value* obj); |
| 3080 void* Value() const; | 3080 void* Value() const; |
| 3081 private: | 3081 private: |
| 3082 static void CheckCast(v8::Value* obj); | 3082 static void CheckCast(v8::Value* obj); |
| 3083 }; | 3083 }; |
| 3084 | 3084 |
| 3085 | 3085 |
| 3086 // --- Templates --- | 3086 // --- Templates --- |
| 3087 | 3087 |
| 3088 | 3088 |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3796 * You must set the heap size before initializing the VM - the size cannot be | 3796 * You must set the heap size before initializing the VM - the size cannot be |
| 3797 * adjusted after the VM is initialized. | 3797 * adjusted after the VM is initialized. |
| 3798 * | 3798 * |
| 3799 * If you are using threads then you should hold the V8::Locker lock while | 3799 * If you are using threads then you should hold the V8::Locker lock while |
| 3800 * setting the stack limit and you must set a non-default stack limit separately | 3800 * setting the stack limit and you must set a non-default stack limit separately |
| 3801 * for each thread. | 3801 * for each thread. |
| 3802 */ | 3802 */ |
| 3803 class V8_EXPORT ResourceConstraints { | 3803 class V8_EXPORT ResourceConstraints { |
| 3804 public: | 3804 public: |
| 3805 ResourceConstraints(); | 3805 ResourceConstraints(); |
| 3806 |
| 3807 /** |
| 3808 * Configures the constraints with reasonable default values based on the |
| 3809 * capabilities of the current device the VM is running on. |
| 3810 * |
| 3811 * \param physical_memory The total amount of physical memory on the current |
| 3812 * device, in bytes. |
| 3813 * \param number_of_processors The number of CPUs available on the current |
| 3814 * device. |
| 3815 */ |
| 3816 void ConfigureDefaults(uint64_t physical_memory, |
| 3817 uint32_t number_of_processors); |
| 3818 V8_DEPRECATED("Will be removed", |
| 3819 void ConfigureDefaults(uint64_t physical_memory)); |
| 3820 |
| 3806 int max_young_space_size() const { return max_young_space_size_; } | 3821 int max_young_space_size() const { return max_young_space_size_; } |
| 3807 void set_max_young_space_size(int value) { max_young_space_size_ = value; } | 3822 void set_max_young_space_size(int value) { max_young_space_size_ = value; } |
| 3808 int max_old_space_size() const { return max_old_space_size_; } | 3823 int max_old_space_size() const { return max_old_space_size_; } |
| 3809 void set_max_old_space_size(int value) { max_old_space_size_ = value; } | 3824 void set_max_old_space_size(int value) { max_old_space_size_ = value; } |
| 3810 int max_executable_size() { return max_executable_size_; } | 3825 int max_executable_size() const { return max_executable_size_; } |
| 3811 void set_max_executable_size(int value) { max_executable_size_ = value; } | 3826 void set_max_executable_size(int value) { max_executable_size_ = value; } |
| 3812 uint32_t* stack_limit() const { return stack_limit_; } | 3827 uint32_t* stack_limit() const { return stack_limit_; } |
| 3813 // Sets an address beyond which the VM's stack may not grow. | 3828 // Sets an address beyond which the VM's stack may not grow. |
| 3814 void set_stack_limit(uint32_t* value) { stack_limit_ = value; } | 3829 void set_stack_limit(uint32_t* value) { stack_limit_ = value; } |
| 3830 int max_available_threads() const { return max_available_threads_; } |
| 3831 // Set the number of threads available to V8, assuming at least 1. |
| 3832 void set_max_available_threads(int value) { |
| 3833 max_available_threads_ = value; |
| 3834 } |
| 3815 | 3835 |
| 3816 private: | 3836 private: |
| 3817 int max_young_space_size_; | 3837 int max_young_space_size_; |
| 3818 int max_old_space_size_; | 3838 int max_old_space_size_; |
| 3819 int max_executable_size_; | 3839 int max_executable_size_; |
| 3820 uint32_t* stack_limit_; | 3840 uint32_t* stack_limit_; |
| 3841 int max_available_threads_; |
| 3821 }; | 3842 }; |
| 3822 | 3843 |
| 3823 | 3844 |
| 3824 V8_DEPRECATED( | |
| 3825 "Use SetResourceConstraints(isolate, constraints) instead", | |
| 3826 bool V8_EXPORT SetResourceConstraints(ResourceConstraints* constraints)); | |
| 3827 | |
| 3828 | |
| 3829 /** | 3845 /** |
| 3830 * Sets the given ResourceConstraints on the given Isolate. | 3846 * Sets the given ResourceConstraints on the given Isolate. |
| 3831 */ | 3847 */ |
| 3832 bool V8_EXPORT SetResourceConstraints(Isolate* isolate, | 3848 bool V8_EXPORT SetResourceConstraints(Isolate* isolate, |
| 3833 ResourceConstraints* constraints); | 3849 ResourceConstraints* constraints); |
| 3834 | 3850 |
| 3835 | 3851 |
| 3836 // --- Exceptions --- | 3852 // --- Exceptions --- |
| 3837 | 3853 |
| 3838 | 3854 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4032 */ | 4048 */ |
| 4033 void Exit(); | 4049 void Exit(); |
| 4034 | 4050 |
| 4035 /** | 4051 /** |
| 4036 * Disposes the isolate. The isolate must not be entered by any | 4052 * Disposes the isolate. The isolate must not be entered by any |
| 4037 * thread to be disposable. | 4053 * thread to be disposable. |
| 4038 */ | 4054 */ |
| 4039 void Dispose(); | 4055 void Dispose(); |
| 4040 | 4056 |
| 4041 /** | 4057 /** |
| 4042 * Associate embedder-specific data with the isolate | 4058 * Associate embedder-specific data with the isolate. This legacy method |
| 4059 * puts the data in the 0th slot. It will be deprecated soon. |
| 4043 */ | 4060 */ |
| 4044 V8_INLINE void SetData(void* data); | 4061 V8_INLINE void SetData(void* data); |
| 4045 | 4062 |
| 4046 /** | 4063 /** |
| 4047 * Retrieve embedder-specific data from the isolate. | 4064 * Associate embedder-specific data with the isolate. |slot| has to be |
| 4065 * between 0 and GetNumberOfDataSlots() - 1. |
| 4066 */ |
| 4067 V8_INLINE void SetData(uint32_t slot, void* data); |
| 4068 |
| 4069 /** |
| 4070 * Retrieve embedder-specific data from the isolate. This legacy method |
| 4071 * retrieves the data from slot 0. It will be deprecated soon. |
| 4048 * Returns NULL if SetData has never been called. | 4072 * Returns NULL if SetData has never been called. |
| 4049 */ | 4073 */ |
| 4050 V8_INLINE void* GetData(); | 4074 V8_INLINE void* GetData(); |
| 4051 | 4075 |
| 4052 /** | 4076 /** |
| 4077 * Retrieve embedder-specific data from the isolate. |
| 4078 * Returns NULL if SetData has never been called for the given |slot|. |
| 4079 */ |
| 4080 V8_INLINE void* GetData(uint32_t slot); |
| 4081 |
| 4082 /** |
| 4083 * Returns the maximum number of available embedder data slots. Valid slots |
| 4084 * are in the range of 0 - GetNumberOfDataSlots() - 1. |
| 4085 */ |
| 4086 V8_INLINE static uint32_t GetNumberOfDataSlots(); |
| 4087 |
| 4088 /** |
| 4053 * Get statistics about the heap memory usage. | 4089 * Get statistics about the heap memory usage. |
| 4054 */ | 4090 */ |
| 4055 void GetHeapStatistics(HeapStatistics* heap_statistics); | 4091 void GetHeapStatistics(HeapStatistics* heap_statistics); |
| 4056 | 4092 |
| 4057 /** | 4093 /** |
| 4058 * Adjusts the amount of registered external memory. Used to give V8 an | 4094 * Adjusts the amount of registered external memory. Used to give V8 an |
| 4059 * indication of the amount of externally allocated memory that is kept alive | 4095 * indication of the amount of externally allocated memory that is kept alive |
| 4060 * by JavaScript objects. V8 uses this to decide when to perform global | 4096 * by JavaScript objects. V8 uses this to decide when to perform global |
| 4061 * garbage collections. Registering externally allocated memory will trigger | 4097 * garbage collections. Registering externally allocated memory will trigger |
| 4062 * global garbage collections more often than it would otherwise in an attempt | 4098 * global garbage collections more often than it would otherwise in an attempt |
| 4063 * to garbage collect the JavaScript objects that keep the externally | 4099 * to garbage collect the JavaScript objects that keep the externally |
| 4064 * allocated memory alive. | 4100 * allocated memory alive. |
| 4065 * | 4101 * |
| 4066 * \param change_in_bytes the change in externally allocated memory that is | 4102 * \param change_in_bytes the change in externally allocated memory that is |
| 4067 * kept alive by JavaScript objects. | 4103 * kept alive by JavaScript objects. |
| 4068 * \returns the adjusted value. | 4104 * \returns the adjusted value. |
| 4069 */ | 4105 */ |
| 4070 intptr_t AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes); | 4106 int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes); |
| 4071 | 4107 |
| 4072 /** | 4108 /** |
| 4073 * Returns heap profiler for this isolate. Will return NULL until the isolate | 4109 * Returns heap profiler for this isolate. Will return NULL until the isolate |
| 4074 * is initialized. | 4110 * is initialized. |
| 4075 */ | 4111 */ |
| 4076 HeapProfiler* GetHeapProfiler(); | 4112 HeapProfiler* GetHeapProfiler(); |
| 4077 | 4113 |
| 4078 /** | 4114 /** |
| 4079 * Returns CPU profiler for this isolate. Will return NULL unless the isolate | 4115 * Returns CPU profiler for this isolate. Will return NULL unless the isolate |
| 4080 * is initialized. It is the embedder's responsibility to stop all CPU | 4116 * is initialized. It is the embedder's responsibility to stop all CPU |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4643 * \note the set of events declared in JitCodeEvent::EventType is expected to | 4679 * \note the set of events declared in JitCodeEvent::EventType is expected to |
| 4644 * grow over time, and the JitCodeEvent structure is expected to accrue | 4680 * grow over time, and the JitCodeEvent structure is expected to accrue |
| 4645 * new members. The \p event_handler function must ignore event codes | 4681 * new members. The \p event_handler function must ignore event codes |
| 4646 * it does not recognize to maintain future compatibility. | 4682 * it does not recognize to maintain future compatibility. |
| 4647 */ | 4683 */ |
| 4648 static void SetJitCodeEventHandler(JitCodeEventOptions options, | 4684 static void SetJitCodeEventHandler(JitCodeEventOptions options, |
| 4649 JitCodeEventHandler event_handler); | 4685 JitCodeEventHandler event_handler); |
| 4650 | 4686 |
| 4651 V8_DEPRECATED( | 4687 V8_DEPRECATED( |
| 4652 "Use Isolate::AdjustAmountOfExternalAllocatedMemory instead", | 4688 "Use Isolate::AdjustAmountOfExternalAllocatedMemory instead", |
| 4653 static intptr_t AdjustAmountOfExternalAllocatedMemory( | 4689 static int64_t AdjustAmountOfExternalAllocatedMemory( |
| 4654 intptr_t change_in_bytes)); | 4690 int64_t change_in_bytes)); |
| 4655 | 4691 |
| 4656 /** | 4692 /** |
| 4657 * Forcefully terminate the current thread of JavaScript execution | 4693 * Forcefully terminate the current thread of JavaScript execution |
| 4658 * in the given isolate. If no isolate is provided, the default | 4694 * in the given isolate. If no isolate is provided, the default |
| 4659 * isolate is used. | 4695 * isolate is used. |
| 4660 * | 4696 * |
| 4661 * This method can be used by any thread even if that thread has not | 4697 * This method can be used by any thread even if that thread has not |
| 4662 * acquired the V8 lock with a Locker object. | 4698 * acquired the V8 lock with a Locker object. |
| 4663 * | 4699 * |
| 4664 * \param isolate The isolate in which to terminate the current JS execution. | 4700 * \param isolate The isolate in which to terminate the current JS execution. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4756 * V8 had a chance to clean up. | 4792 * V8 had a chance to clean up. |
| 4757 */ | 4793 */ |
| 4758 static int ContextDisposedNotification(); | 4794 static int ContextDisposedNotification(); |
| 4759 | 4795 |
| 4760 /** | 4796 /** |
| 4761 * Initialize the ICU library bundled with V8. The embedder should only | 4797 * Initialize the ICU library bundled with V8. The embedder should only |
| 4762 * invoke this method when using the bundled ICU. Returns true on success. | 4798 * invoke this method when using the bundled ICU. Returns true on success. |
| 4763 */ | 4799 */ |
| 4764 static bool InitializeICU(); | 4800 static bool InitializeICU(); |
| 4765 | 4801 |
| 4802 /** |
| 4803 * Sets the v8::Platform to use. This should be invoked before V8 is |
| 4804 * initialized. |
| 4805 */ |
| 4806 static void InitializePlatform(Platform* platform); |
| 4807 |
| 4808 /** |
| 4809 * Clears all references to the v8::Platform. This should be invoked after |
| 4810 * V8 was disposed. |
| 4811 */ |
| 4812 static void ShutdownPlatform(); |
| 4813 |
| 4766 private: | 4814 private: |
| 4767 V8(); | 4815 V8(); |
| 4768 | 4816 |
| 4769 static internal::Object** GlobalizeReference(internal::Isolate* isolate, | 4817 static internal::Object** GlobalizeReference(internal::Isolate* isolate, |
| 4770 internal::Object** handle); | 4818 internal::Object** handle); |
| 4771 static internal::Object** CopyPersistent(internal::Object** handle); | 4819 static internal::Object** CopyPersistent(internal::Object** handle); |
| 4772 static void DisposeGlobal(internal::Object** global_handle); | 4820 static void DisposeGlobal(internal::Object** global_handle); |
| 4773 typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback; | 4821 typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback; |
| 4774 typedef WeakCallbackData<Value, void>::Callback WeakCallback; | 4822 typedef WeakCallbackData<Value, void>::Callback WeakCallback; |
| 4775 static void MakeWeak(internal::Object** global_handle, | 4823 static void MakeWeak(internal::Object** global_handle, |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5230 class V8_EXPORT Locker { | 5278 class V8_EXPORT Locker { |
| 5231 public: | 5279 public: |
| 5232 /** | 5280 /** |
| 5233 * Initialize Locker for a given Isolate. | 5281 * Initialize Locker for a given Isolate. |
| 5234 */ | 5282 */ |
| 5235 V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); } | 5283 V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); } |
| 5236 | 5284 |
| 5237 ~Locker(); | 5285 ~Locker(); |
| 5238 | 5286 |
| 5239 /** | 5287 /** |
| 5240 * Start preemption. | |
| 5241 * | |
| 5242 * When preemption is started, a timer is fired every n milliseconds | |
| 5243 * that will switch between multiple threads that are in contention | |
| 5244 * for the V8 lock. | |
| 5245 */ | |
| 5246 static void StartPreemption(Isolate* isolate, int every_n_ms); | |
| 5247 | |
| 5248 /** | |
| 5249 * Stop preemption. | |
| 5250 */ | |
| 5251 static void StopPreemption(Isolate* isolate); | |
| 5252 | |
| 5253 /** | |
| 5254 * Returns whether or not the locker for a given isolate, is locked by the | 5288 * Returns whether or not the locker for a given isolate, is locked by the |
| 5255 * current thread. | 5289 * current thread. |
| 5256 */ | 5290 */ |
| 5257 static bool IsLocked(Isolate* isolate); | 5291 static bool IsLocked(Isolate* isolate); |
| 5258 | 5292 |
| 5259 /** | 5293 /** |
| 5260 * Returns whether v8::Locker is being used by this V8 instance. | 5294 * Returns whether v8::Locker is being used by this V8 instance. |
| 5261 */ | 5295 */ |
| 5262 static bool IsActive(); | 5296 static bool IsActive(); |
| 5263 | 5297 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5434 static const int kForeignAddressOffset = kApiPointerSize; | 5468 static const int kForeignAddressOffset = kApiPointerSize; |
| 5435 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | 5469 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; |
| 5436 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; | 5470 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; |
| 5437 static const int kContextHeaderSize = 2 * kApiPointerSize; | 5471 static const int kContextHeaderSize = 2 * kApiPointerSize; |
| 5438 static const int kContextEmbedderDataIndex = 65; | 5472 static const int kContextEmbedderDataIndex = 65; |
| 5439 static const int kFullStringRepresentationMask = 0x07; | 5473 static const int kFullStringRepresentationMask = 0x07; |
| 5440 static const int kStringEncodingMask = 0x4; | 5474 static const int kStringEncodingMask = 0x4; |
| 5441 static const int kExternalTwoByteRepresentationTag = 0x02; | 5475 static const int kExternalTwoByteRepresentationTag = 0x02; |
| 5442 static const int kExternalAsciiRepresentationTag = 0x06; | 5476 static const int kExternalAsciiRepresentationTag = 0x06; |
| 5443 | 5477 |
| 5444 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; | 5478 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize; |
| 5445 static const int kIsolateRootsOffset = 3 * kApiPointerSize; | 5479 static const int kIsolateRootsOffset = 5 * kApiPointerSize; |
| 5446 static const int kUndefinedValueRootIndex = 5; | 5480 static const int kUndefinedValueRootIndex = 5; |
| 5447 static const int kNullValueRootIndex = 7; | 5481 static const int kNullValueRootIndex = 7; |
| 5448 static const int kTrueValueRootIndex = 8; | 5482 static const int kTrueValueRootIndex = 8; |
| 5449 static const int kFalseValueRootIndex = 9; | 5483 static const int kFalseValueRootIndex = 9; |
| 5450 static const int kEmptyStringRootIndex = 134; | 5484 static const int kEmptyStringRootIndex = 134; |
| 5451 | 5485 |
| 5452 static const int kNodeClassIdOffset = 1 * kApiPointerSize; | 5486 static const int kNodeClassIdOffset = 1 * kApiPointerSize; |
| 5453 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; | 5487 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; |
| 5454 static const int kNodeStateMask = 0xf; | 5488 static const int kNodeStateMask = 0xf; |
| 5455 static const int kNodeStateIsWeakValue = 2; | 5489 static const int kNodeStateIsWeakValue = 2; |
| 5456 static const int kNodeStateIsPendingValue = 3; | 5490 static const int kNodeStateIsPendingValue = 3; |
| 5457 static const int kNodeStateIsNearDeathValue = 4; | 5491 static const int kNodeStateIsNearDeathValue = 4; |
| 5458 static const int kNodeIsIndependentShift = 4; | 5492 static const int kNodeIsIndependentShift = 4; |
| 5459 static const int kNodeIsPartiallyDependentShift = 5; | 5493 static const int kNodeIsPartiallyDependentShift = 5; |
| 5460 | 5494 |
| 5461 static const int kJSObjectType = 0xb2; | 5495 static const int kJSObjectType = 0xb2; |
| 5462 static const int kFirstNonstringType = 0x80; | 5496 static const int kFirstNonstringType = 0x80; |
| 5463 static const int kOddballType = 0x83; | 5497 static const int kOddballType = 0x83; |
| 5464 static const int kForeignType = 0x87; | 5498 static const int kForeignType = 0x87; |
| 5465 | 5499 |
| 5466 static const int kUndefinedOddballKind = 5; | 5500 static const int kUndefinedOddballKind = 5; |
| 5467 static const int kNullOddballKind = 3; | 5501 static const int kNullOddballKind = 3; |
| 5468 | 5502 |
| 5503 static const uint32_t kNumIsolateDataSlots = 4; |
| 5504 |
| 5469 V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate); | 5505 V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate); |
| 5470 V8_INLINE static void CheckInitialized(v8::Isolate* isolate) { | 5506 V8_INLINE static void CheckInitialized(v8::Isolate* isolate) { |
| 5471 #ifdef V8_ENABLE_CHECKS | 5507 #ifdef V8_ENABLE_CHECKS |
| 5472 CheckInitializedImpl(isolate); | 5508 CheckInitializedImpl(isolate); |
| 5473 #endif | 5509 #endif |
| 5474 } | 5510 } |
| 5475 | 5511 |
| 5476 V8_INLINE static bool HasHeapObjectTag(internal::Object* value) { | 5512 V8_INLINE static bool HasHeapObjectTag(internal::Object* value) { |
| 5477 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == | 5513 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == |
| 5478 kHeapObjectTag); | 5514 kHeapObjectTag); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5522 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | 5558 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
| 5523 return *addr & kNodeStateMask; | 5559 return *addr & kNodeStateMask; |
| 5524 } | 5560 } |
| 5525 | 5561 |
| 5526 V8_INLINE static void UpdateNodeState(internal::Object** obj, | 5562 V8_INLINE static void UpdateNodeState(internal::Object** obj, |
| 5527 uint8_t value) { | 5563 uint8_t value) { |
| 5528 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | 5564 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; |
| 5529 *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value); | 5565 *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value); |
| 5530 } | 5566 } |
| 5531 | 5567 |
| 5532 V8_INLINE static void SetEmbedderData(v8::Isolate* isolate, void* data) { | 5568 V8_INLINE static void SetEmbedderData(v8::Isolate *isolate, |
| 5533 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | 5569 uint32_t slot, |
| 5534 kIsolateEmbedderDataOffset; | 5570 void *data) { |
| 5571 uint8_t *addr = reinterpret_cast<uint8_t *>(isolate) + |
| 5572 kIsolateEmbedderDataOffset + slot * kApiPointerSize; |
| 5535 *reinterpret_cast<void**>(addr) = data; | 5573 *reinterpret_cast<void**>(addr) = data; |
| 5536 } | 5574 } |
| 5537 | 5575 |
| 5538 V8_INLINE static void* GetEmbedderData(v8::Isolate* isolate) { | 5576 V8_INLINE static void* GetEmbedderData(v8::Isolate* isolate, uint32_t slot) { |
| 5539 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | 5577 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + |
| 5540 kIsolateEmbedderDataOffset; | 5578 kIsolateEmbedderDataOffset + slot * kApiPointerSize; |
| 5541 return *reinterpret_cast<void**>(addr); | 5579 return *reinterpret_cast<void**>(addr); |
| 5542 } | 5580 } |
| 5543 | 5581 |
| 5544 V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate, | 5582 V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate, |
| 5545 int index) { | 5583 int index) { |
| 5546 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset; | 5584 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset; |
| 5547 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); | 5585 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); |
| 5548 } | 5586 } |
| 5549 | 5587 |
| 5550 template <typename T> V8_INLINE static T ReadField(Object* ptr, int offset) { | 5588 template <typename T> V8_INLINE static T ReadField(Object* ptr, int offset) { |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6002 } | 6040 } |
| 6003 | 6041 |
| 6004 | 6042 |
| 6005 Handle<Boolean> Boolean::New(bool value) { | 6043 Handle<Boolean> Boolean::New(bool value) { |
| 6006 Isolate* isolate = Isolate::GetCurrent(); | 6044 Isolate* isolate = Isolate::GetCurrent(); |
| 6007 return value ? True(isolate) : False(isolate); | 6045 return value ? True(isolate) : False(isolate); |
| 6008 } | 6046 } |
| 6009 | 6047 |
| 6010 | 6048 |
| 6011 void Template::Set(const char* name, v8::Handle<Data> value) { | 6049 void Template::Set(const char* name, v8::Handle<Data> value) { |
| 6012 Set(v8::String::New(name), value); | 6050 Set(v8::String::NewFromUtf8(Isolate::GetCurrent(), name), value); |
| 6013 } | 6051 } |
| 6014 | 6052 |
| 6015 | 6053 |
| 6016 Local<Value> Object::GetInternalField(int index) { | 6054 Local<Value> Object::GetInternalField(int index) { |
| 6017 #ifndef V8_ENABLE_CHECKS | 6055 #ifndef V8_ENABLE_CHECKS |
| 6018 typedef internal::Object O; | 6056 typedef internal::Object O; |
| 6019 typedef internal::HeapObject HO; | 6057 typedef internal::HeapObject HO; |
| 6020 typedef internal::Internals I; | 6058 typedef internal::Internals I; |
| 6021 O* obj = *reinterpret_cast<O**>(this); | 6059 O* obj = *reinterpret_cast<O**>(this); |
| 6022 // Fast path: If the object is a plain JSObject, which is the common case, we | 6060 // Fast path: If the object is a plain JSObject, which is the common case, we |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6456 typedef internal::Object* S; | 6494 typedef internal::Object* S; |
| 6457 typedef internal::Internals I; | 6495 typedef internal::Internals I; |
| 6458 I::CheckInitialized(isolate); | 6496 I::CheckInitialized(isolate); |
| 6459 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); | 6497 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); |
| 6460 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); | 6498 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); |
| 6461 } | 6499 } |
| 6462 | 6500 |
| 6463 | 6501 |
| 6464 void Isolate::SetData(void* data) { | 6502 void Isolate::SetData(void* data) { |
| 6465 typedef internal::Internals I; | 6503 typedef internal::Internals I; |
| 6466 I::SetEmbedderData(this, data); | 6504 I::SetEmbedderData(this, 0, data); |
| 6467 } | 6505 } |
| 6468 | 6506 |
| 6469 | 6507 |
| 6470 void* Isolate::GetData() { | 6508 void* Isolate::GetData() { |
| 6471 typedef internal::Internals I; | 6509 typedef internal::Internals I; |
| 6472 return I::GetEmbedderData(this); | 6510 return I::GetEmbedderData(this, 0); |
| 6473 } | 6511 } |
| 6474 | 6512 |
| 6475 | 6513 |
| 6514 void Isolate::SetData(uint32_t slot, void* data) { |
| 6515 typedef internal::Internals I; |
| 6516 I::SetEmbedderData(this, slot, data); |
| 6517 } |
| 6518 |
| 6519 |
| 6520 void* Isolate::GetData(uint32_t slot) { |
| 6521 typedef internal::Internals I; |
| 6522 return I::GetEmbedderData(this, slot); |
| 6523 } |
| 6524 |
| 6525 |
| 6526 uint32_t Isolate::GetNumberOfDataSlots() { |
| 6527 typedef internal::Internals I; |
| 6528 return I::kNumIsolateDataSlots; |
| 6529 } |
| 6530 |
| 6531 |
| 6476 template<typename T> | 6532 template<typename T> |
| 6477 void Isolate::SetObjectGroupId(const Persistent<T>& object, | 6533 void Isolate::SetObjectGroupId(const Persistent<T>& object, |
| 6478 UniqueId id) { | 6534 UniqueId id) { |
| 6479 TYPE_CHECK(Value, T); | 6535 TYPE_CHECK(Value, T); |
| 6480 SetObjectGroupId(reinterpret_cast<v8::internal::Object**>(object.val_), id); | 6536 SetObjectGroupId(reinterpret_cast<v8::internal::Object**>(object.val_), id); |
| 6481 } | 6537 } |
| 6482 | 6538 |
| 6483 | 6539 |
| 6484 template<typename T> | 6540 template<typename T> |
| 6485 void Isolate::SetReferenceFromGroup(UniqueId id, | 6541 void Isolate::SetReferenceFromGroup(UniqueId id, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6537 */ | 6593 */ |
| 6538 | 6594 |
| 6539 | 6595 |
| 6540 } // namespace v8 | 6596 } // namespace v8 |
| 6541 | 6597 |
| 6542 | 6598 |
| 6543 #undef TYPE_CHECK | 6599 #undef TYPE_CHECK |
| 6544 | 6600 |
| 6545 | 6601 |
| 6546 #endif // V8_H_ | 6602 #endif // V8_H_ |
| OLD | NEW |