Improve cef_v8value_t

Think CEF could benefit from a new feature or capability? Discuss CEF feature requests here.

Improve cef_v8value_t

Postby vmas » Mon Feb 24, 2020 4:34 am

Hello,

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.
Maintainer of the CefNet project.
vmas
Techie
 
Posts: 13
Joined: Mon Feb 24, 2020 4:03 am

Re: Improve cef_v8value_t

Postby vmas » Mon Mar 02, 2020 5:48 am

Maintainer of the CefNet project.
vmas
Techie
 
Posts: 13
Joined: Mon Feb 24, 2020 4:03 am


Return to Feature Request Forum

Who is online

Users browsing this forum: No registered users and 15 guests