Page 1 of 1

Improve cef_v8value_t

PostPosted: Mon Feb 24, 2020 4:34 am
by vmas

An existing C API provides the ability to compare the cef_v8value_t objects only with the cef_v8value_t::is_same. If we want to create a dictionary for wrappers then we need to compare each object, that is very slow. I found one ugly hack for checking the inequality of v8-objects is getting a v8::internal::Address value from the v8::Persistent handle. I read a memory to get a value from the CefV8ValueImpl::handle_->GetPersistentV8Handle().val_ and use it to create a hash code. It seems to work. But this is not a safe way, I'm not sure that this address will not be changed when the JavaScript garbage collector works.

There is another right way to get a hash code of a v8 object is call to the v8::Object::GetIdentityHash.

These are my suggestions:
1) Add to the CefV8ValueImpl a function that will return result of calling the v8::Object::GetIdentityHash for V8-objects; or a function that will return 32-bit hash code for any value type of the CefV8Value object.
2) Is there a reason to have many functions for type checking (cef_v8value_t::is_*)? Perhaps we could reduce the size of the cef_v8value_t structure by replacing the is_object, is_double, is_int, is_uint, is_undefined, is_null, is_bool, is_date, is_string with the get_type function that would return a value of the CefV8ValueImpl::type_ field.

PS: Sorry for my poor English.

Re: Improve cef_v8value_t

PostPosted: Mon Mar 02, 2020 5:48 am
by vmas