| Index: src/api.cc
|
| diff --git a/src/api.cc b/src/api.cc
|
| index 145fa9d9b82760a62072278e3cd643344f37021c..c23efeb72a2966b2c662f49dad5e199a56e12fd7 100644
|
| --- a/src/api.cc
|
| +++ b/src/api.cc
|
| @@ -2465,6 +2465,43 @@ void v8::Object::SetInternalField(int index, v8::Handle<Value> value) {
|
| }
|
|
|
|
|
| +void* v8::Object::GetPointerFromInternalField(int index) {
|
| + i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
|
| + i::Object* pointer = obj->GetInternalField(index);
|
| + if (pointer->IsSmi()) {
|
| + // Fast case, aligned native pointer.
|
| + return pointer;
|
| + }
|
| +
|
| + // Read from uninitialized field.
|
| + if (!pointer->IsProxy()) {
|
| + // Play safe even if it's something unexpected.
|
| + ASSERT(pointer->IsUndefined());
|
| + return NULL;
|
| + }
|
| +
|
| + // Unaligned native pointer
|
| + return reinterpret_cast<void*>(i::Proxy::cast(pointer)->proxy());
|
| +}
|
| +
|
| +
|
| +void v8::Object::SetPointerInInternalField(int index, void* value) {
|
| + i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
|
| + i::Object* as_object = reinterpret_cast<i::Object*>(value);
|
| + if (as_object->IsSmi()) {
|
| + // Aligned pointer, store as is.
|
| + obj->SetInternalField(index, as_object);
|
| + } else {
|
| + // Currently internal fields are used by DOM wrappers which
|
| + // only get GCed by the mark-sweep collector,
|
| + // so let's put proxy into old space.
|
| + i::Proxy* proxy = *i::Factory::NewProxy(reinterpret_cast<i::Address>(value),
|
| + i::TENURED);
|
| + obj->SetInternalField(index, proxy);
|
| + }
|
| +}
|
| +
|
| +
|
| // --- E n v i r o n m e n t ---
|
|
|
| bool v8::V8::Initialize() {
|
|
|