Fix rare crash when calling SetExternalResource

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 <andy.shaw@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>