Chromium Code Reviews| Index: include/v8.h |
| diff --git a/include/v8.h b/include/v8.h |
| index 4eb7614210fd1fb3120428e65f7c9ed97394f3b9..d3619f5b744030bc1283c8f31c71961299f30c26 100644 |
| --- a/include/v8.h |
| +++ b/include/v8.h |
| @@ -2891,7 +2891,9 @@ class V8_EXPORT Object : public Value { |
| * a field, GetAlignedPointerFromInternalField must be used, everything else |
| * leads to undefined behavior. |
| */ |
| - void SetAlignedPointerInInternalField(int index, void* value); |
| + V8_INLINE void SetAlignedPointerInInternalField(int index, void* value); |
| + V8_INLINE void SetAlignedPointerInInternalFields(int argc, int indices[], |
| + void* values[]); |
| // Testers for local properties. |
| V8_DEPRECATED("Use maybe version", bool HasOwnProperty(Local<String> key)); |
| @@ -3031,6 +3033,9 @@ class V8_EXPORT Object : public Value { |
| static void CheckCast(Value* obj); |
| Local<Value> SlowGetInternalField(int index); |
| void* SlowGetAlignedPointerFromInternalField(int index); |
| + void SlowSetAlignedPointerInInternalField(int index, void* value); |
| + void SlowSetAlignedPointerInInternalFields(int argc, int indices[], |
| + void* values[]); |
| }; |
| @@ -7701,6 +7706,12 @@ class Internals { |
| return *reinterpret_cast<const T*>(addr); |
| } |
| + V8_INLINE static void WriteField(internal::Object* ptr, int offset, |
| + void* value) { |
| + uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; |
| + *reinterpret_cast<void**>(addr) = value; |
| + } |
| + |
| template <typename T> |
| V8_INLINE static T ReadEmbedderData(const v8::Context* context, int index) { |
| typedef internal::Object O; |
| @@ -8238,6 +8249,44 @@ void* Object::GetAlignedPointerFromInternalField(int index) { |
| return SlowGetAlignedPointerFromInternalField(index); |
| } |
| +void Object::SetAlignedPointerInInternalField(int index, void* value) { |
| +#ifndef V8_ENABLE_CHECKS |
| + typedef internal::Object O; |
| + typedef internal::Internals I; |
| + O* object = *reinterpret_cast<O**>(this); |
| + // Fast path: If the object is a plain JSObject, which is the common case, we |
| + // know where to find the internal fields and can set the value directly. |
| + auto instance_type = I::GetInstanceType(object); |
| + if (V8_LIKELY(instance_type == I::kJSObjectType || |
| + instance_type == I::kJSApiObjectType)) { |
| + int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); |
| + I::WriteField(object, offset, value); |
|
Michael Starzinger
2016/07/29 09:50:53
Isn't this missing a return? Otherwise the slow ca
|
| + } |
| +#endif |
| + return SlowSetAlignedPointerInInternalField(index, value); |
| +} |
| + |
| +void Object::SetAlignedPointerInInternalFields(int argc, int indices[], |
| + void* values[]) { |
| +#ifndef V8_ENABLE_CHECKS |
| + typedef internal::Object O; |
| + typedef internal::Internals I; |
| + O* object = *reinterpret_cast<O**>(this); |
| + // Fast path: If the object is a plain JSObject, which is the common case, we |
| + // know where to find the internal fields and can set the value directly. |
| + auto instance_type = I::GetInstanceType(object); |
| + if (V8_LIKELY(instance_type == I::kJSObjectType || |
| + instance_type == I::kJSApiObjectType)) { |
| + for (int i = 0; i < argc; i++) { |
| + int index = indices[i]; |
| + void* value = values[i]; |
| + int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); |
| + I::WriteField(object, offset, value); |
|
Michael Starzinger
2016/07/29 09:50:53
Isn't this missing a return? Otherwise the slow ca
|
| + } |
| + } |
| +#endif |
| + return SlowSetAlignedPointerInInternalFields(argc, indices, values); |
| +} |
| String* String::Cast(v8::Value* value) { |
| #ifdef V8_ENABLE_CHECKS |