OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
6 * | 6 * |
7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
8 * | 8 * |
9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
(...skipping 2873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2884 V8_INLINE static void* GetAlignedPointerFromInternalField( | 2884 V8_INLINE static void* GetAlignedPointerFromInternalField( |
2885 const PersistentBase<Object>& object, int index) { | 2885 const PersistentBase<Object>& object, int index) { |
2886 return object.val_->GetAlignedPointerFromInternalField(index); | 2886 return object.val_->GetAlignedPointerFromInternalField(index); |
2887 } | 2887 } |
2888 | 2888 |
2889 /** | 2889 /** |
2890 * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such | 2890 * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such |
2891 * a field, GetAlignedPointerFromInternalField must be used, everything else | 2891 * a field, GetAlignedPointerFromInternalField must be used, everything else |
2892 * leads to undefined behavior. | 2892 * leads to undefined behavior. |
2893 */ | 2893 */ |
2894 void SetAlignedPointerInInternalField(int index, void* value); | 2894 V8_INLINE void SetAlignedPointerInInternalField(int index, void* value); |
2895 V8_INLINE void SetAlignedPointerInInternalFields(int argc, int indices[], | |
2896 void* values[]); | |
2895 | 2897 |
2896 // Testers for local properties. | 2898 // Testers for local properties. |
2897 V8_DEPRECATED("Use maybe version", bool HasOwnProperty(Local<String> key)); | 2899 V8_DEPRECATED("Use maybe version", bool HasOwnProperty(Local<String> key)); |
2898 V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context, | 2900 V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context, |
2899 Local<Name> key); | 2901 Local<Name> key); |
2900 V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context, | 2902 V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context, |
2901 uint32_t index); | 2903 uint32_t index); |
2902 V8_DEPRECATE_SOON("Use maybe version", | 2904 V8_DEPRECATE_SOON("Use maybe version", |
2903 bool HasRealNamedProperty(Local<String> key)); | 2905 bool HasRealNamedProperty(Local<String> key)); |
2904 V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedProperty(Local<Context> context, | 2906 V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedProperty(Local<Context> context, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3024 | 3026 |
3025 static Local<Object> New(Isolate* isolate); | 3027 static Local<Object> New(Isolate* isolate); |
3026 | 3028 |
3027 V8_INLINE static Object* Cast(Value* obj); | 3029 V8_INLINE static Object* Cast(Value* obj); |
3028 | 3030 |
3029 private: | 3031 private: |
3030 Object(); | 3032 Object(); |
3031 static void CheckCast(Value* obj); | 3033 static void CheckCast(Value* obj); |
3032 Local<Value> SlowGetInternalField(int index); | 3034 Local<Value> SlowGetInternalField(int index); |
3033 void* SlowGetAlignedPointerFromInternalField(int index); | 3035 void* SlowGetAlignedPointerFromInternalField(int index); |
3036 void SlowSetAlignedPointerInInternalField(int index, void* value); | |
3037 void SlowSetAlignedPointerInInternalFields(int argc, int indices[], | |
3038 void* values[]); | |
3034 }; | 3039 }; |
3035 | 3040 |
3036 | 3041 |
3037 /** | 3042 /** |
3038 * An instance of the built-in array constructor (ECMA-262, 15.4.2). | 3043 * An instance of the built-in array constructor (ECMA-262, 15.4.2). |
3039 */ | 3044 */ |
3040 class V8_EXPORT Array : public Object { | 3045 class V8_EXPORT Array : public Object { |
3041 public: | 3046 public: |
3042 uint32_t Length() const; | 3047 uint32_t Length() const; |
3043 | 3048 |
(...skipping 4650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7694 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); | 7699 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); |
7695 } | 7700 } |
7696 | 7701 |
7697 template <typename T> | 7702 template <typename T> |
7698 V8_INLINE static T ReadField(const internal::Object* ptr, int offset) { | 7703 V8_INLINE static T ReadField(const internal::Object* ptr, int offset) { |
7699 const uint8_t* addr = | 7704 const uint8_t* addr = |
7700 reinterpret_cast<const uint8_t*>(ptr) + offset - kHeapObjectTag; | 7705 reinterpret_cast<const uint8_t*>(ptr) + offset - kHeapObjectTag; |
7701 return *reinterpret_cast<const T*>(addr); | 7706 return *reinterpret_cast<const T*>(addr); |
7702 } | 7707 } |
7703 | 7708 |
7709 V8_INLINE static void WriteField(internal::Object* ptr, int offset, | |
7710 void* value) { | |
7711 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; | |
7712 *reinterpret_cast<void**>(addr) = value; | |
7713 } | |
7714 | |
7704 template <typename T> | 7715 template <typename T> |
7705 V8_INLINE static T ReadEmbedderData(const v8::Context* context, int index) { | 7716 V8_INLINE static T ReadEmbedderData(const v8::Context* context, int index) { |
7706 typedef internal::Object O; | 7717 typedef internal::Object O; |
7707 typedef internal::Internals I; | 7718 typedef internal::Internals I; |
7708 O* ctx = *reinterpret_cast<O* const*>(context); | 7719 O* ctx = *reinterpret_cast<O* const*>(context); |
7709 int embedder_data_offset = I::kContextHeaderSize + | 7720 int embedder_data_offset = I::kContextHeaderSize + |
7710 (internal::kApiPointerSize * I::kContextEmbedderDataIndex); | 7721 (internal::kApiPointerSize * I::kContextEmbedderDataIndex); |
7711 O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset); | 7722 O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset); |
7712 int value_offset = | 7723 int value_offset = |
7713 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); | 7724 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8231 auto instance_type = I::GetInstanceType(obj); | 8242 auto instance_type = I::GetInstanceType(obj); |
8232 if (V8_LIKELY(instance_type == I::kJSObjectType || | 8243 if (V8_LIKELY(instance_type == I::kJSObjectType || |
8233 instance_type == I::kJSApiObjectType)) { | 8244 instance_type == I::kJSApiObjectType)) { |
8234 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); | 8245 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); |
8235 return I::ReadField<void*>(obj, offset); | 8246 return I::ReadField<void*>(obj, offset); |
8236 } | 8247 } |
8237 #endif | 8248 #endif |
8238 return SlowGetAlignedPointerFromInternalField(index); | 8249 return SlowGetAlignedPointerFromInternalField(index); |
8239 } | 8250 } |
8240 | 8251 |
8252 void Object::SetAlignedPointerInInternalField(int index, void* value) { | |
8253 #ifndef V8_ENABLE_CHECKS | |
8254 typedef internal::Object O; | |
8255 typedef internal::Internals I; | |
8256 O* object = *reinterpret_cast<O**>(this); | |
8257 // Fast path: If the object is a plain JSObject, which is the common case, we | |
8258 // know where to find the internal fields and can set the value directly. | |
8259 auto instance_type = I::GetInstanceType(object); | |
8260 if (V8_LIKELY(instance_type == I::kJSObjectType || | |
8261 instance_type == I::kJSApiObjectType)) { | |
8262 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); | |
8263 I::WriteField(object, offset, value); | |
Michael Starzinger
2016/07/29 09:50:53
Isn't this missing a return? Otherwise the slow ca
| |
8264 } | |
8265 #endif | |
8266 return SlowSetAlignedPointerInInternalField(index, value); | |
8267 } | |
8268 | |
8269 void Object::SetAlignedPointerInInternalFields(int argc, int indices[], | |
8270 void* values[]) { | |
8271 #ifndef V8_ENABLE_CHECKS | |
8272 typedef internal::Object O; | |
8273 typedef internal::Internals I; | |
8274 O* object = *reinterpret_cast<O**>(this); | |
8275 // Fast path: If the object is a plain JSObject, which is the common case, we | |
8276 // know where to find the internal fields and can set the value directly. | |
8277 auto instance_type = I::GetInstanceType(object); | |
8278 if (V8_LIKELY(instance_type == I::kJSObjectType || | |
8279 instance_type == I::kJSApiObjectType)) { | |
8280 for (int i = 0; i < argc; i++) { | |
8281 int index = indices[i]; | |
8282 void* value = values[i]; | |
8283 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); | |
8284 I::WriteField(object, offset, value); | |
Michael Starzinger
2016/07/29 09:50:53
Isn't this missing a return? Otherwise the slow ca
| |
8285 } | |
8286 } | |
8287 #endif | |
8288 return SlowSetAlignedPointerInInternalFields(argc, indices, values); | |
8289 } | |
8241 | 8290 |
8242 String* String::Cast(v8::Value* value) { | 8291 String* String::Cast(v8::Value* value) { |
8243 #ifdef V8_ENABLE_CHECKS | 8292 #ifdef V8_ENABLE_CHECKS |
8244 CheckCast(value); | 8293 CheckCast(value); |
8245 #endif | 8294 #endif |
8246 return static_cast<String*>(value); | 8295 return static_cast<String*>(value); |
8247 } | 8296 } |
8248 | 8297 |
8249 | 8298 |
8250 Local<String> String::Empty(Isolate* isolate) { | 8299 Local<String> String::Empty(Isolate* isolate) { |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8955 */ | 9004 */ |
8956 | 9005 |
8957 | 9006 |
8958 } // namespace v8 | 9007 } // namespace v8 |
8959 | 9008 |
8960 | 9009 |
8961 #undef TYPE_CHECK | 9010 #undef TYPE_CHECK |
8962 | 9011 |
8963 | 9012 |
8964 #endif // INCLUDE_V8_H_ | 9013 #endif // INCLUDE_V8_H_ |
OLD | NEW |