diff options
author | Simon Hausmann <[email protected]> | 2013-09-11 09:14:33 +0200 |
---|---|---|
committer | The Qt Project <[email protected]> | 2013-09-11 18:48:08 +0200 |
commit | a48ae1d629f4c7939f3421db969f43db6bab8e11 (patch) | |
tree | 0d286fbf47f68a01705bf2b29d486e807436eeb9 | |
parent | 0a8af38cf0add7592bf8f491e45a5de8b125a190 (diff) |
This is a patch on top of the original patch that adds support for
external resources to v8::Object.
When the provided external resource pointer cannot be encoded in SMI, then we
need to allocate an object on the heap to hold it. That in turn may trigger a
garbage collection, which in turn may end up collecting the object itself.
Similarly to other methods dealing with the allocation of i::Foreign, the
insertion of a HandleScope is required.
Done-with: Lars
Task-Number: QTBUG-29127
Change-Id: I9a99998e2fbfcb8a4c1e31595344680123072c6b
Reviewed-by: Andy Shaw <[email protected]>
Reviewed-by: Lars Knoll <[email protected]>
-rw-r--r-- | src/3rdparty/v8/src/api.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/3rdparty/v8/src/api.cc b/src/3rdparty/v8/src/api.cc index cbb3a04..baa5b0a 100644 --- a/src/3rdparty/v8/src/api.cc +++ b/src/3rdparty/v8/src/api.cc @@ -4421,11 +4421,13 @@ void v8::Object::SetPointerInInternalField(int index, void* value) { void v8::Object::SetExternalResource(v8::Object::ExternalResource *resource) { i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); ENTER_V8(isolate); + HandleScope scope; i::Handle<i::JSObject> obj = Utils::OpenHandle(this); if (CanBeEncodedAsSmi(resource)) { obj->SetExternalResourceObject(EncodeAsSmi(resource)); } else { - obj->SetExternalResourceObject(*isolate->factory()->NewForeign(static_cast<i::Address>((void *)resource))); + i::Handle<i::Foreign> foreign = isolate->factory()->NewForeign(static_cast<i::Address>((void *)resource)); + obj->SetExternalResourceObject(*foreign); } if (!obj->IsSymbol()) { isolate->heap()->external_string_table()->AddObject(*obj); |