Make sure we don't crash if NewProxy returns an empty handle (only

happens when out of memory).
Review URL: http://codereview.chromium.org/155685

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
kasperl@chromium.org 2009-07-17 11:16:10 +00:00
parent 3c6c399381
commit 21f44e8fd2

View File

@ -2480,7 +2480,7 @@ void* v8::Object::GetPointerFromInternalField(int index) {
return NULL;
}
// Unaligned native pointer
// Unaligned native pointer.
return reinterpret_cast<void*>(i::Proxy::cast(pointer)->proxy());
}
@ -2492,12 +2492,12 @@ void v8::Object::SetPointerInInternalField(int index, void* value) {
// 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);
// Currently internal fields are used by DOM wrappers which only
// get garbage collected by the mark-sweep collector, so we
// pretenure the proxy.
i::Handle<i::Proxy> proxy =
i::Factory::NewProxy(reinterpret_cast<i::Address>(value), i::TENURED);
if (!proxy.is_null()) obj->SetInternalField(index, *proxy);
}
}