On Mon, Jul 8, 2013 at 4:23 AM, Dan Carney <[email protected]> wrote:

> I'm afraid that, if you use 3.20, for the cases you've mentioned, you're
> stuck with that performance regression if you use the API correctly.  While
> cutting Chrome over to this API, we had to use a lot of
> reinterpret_casts<Local*> to work around some of these problems.
>

> The weak callback problem we've already discovered and are in the process
> of fixing, but I'm not sure when the new weak callback API will arrive.
>
> For certain API functions, we can create a version that's callable from a
> Persistent directly, but Function::Call unfortunately isn't one of them.
>

Right now the largest pain is needing to Local<T>::New() the Persistent<T>*
passed to the MakeWeak callback so we can access external memory attached
via Object::SetIndexedPropertiesToExternalArrayData().

As for using reinterpret_cast<Local*>, will that be a long-er term solution
for problems like the following:

Persistent<Function> p_call_this_often;
Persistent<Object> p_empty_obj;

template<class T>
inline Local<T> ToLocal(Persistent<T>* p_) {
  return *reinterpret_cast<Local<T>*>(p_);
}

void CallMe(const FunctionCallbackInfo<Value>& args) {
  HandleScope scope(args.GetCurrentIsolate());
  // storing and passing a cached empty object is the fastest way I've found
  // to call a js fn from cc

ToLocal<Function>(&p_call_this_often)->Call(ToLocal<Object>(&p_empty_obj),
argc, argv);
}

Using ::New() in a couple specific cases like this leads to ~15% regression.


> We have a few functions slated to have a Persistent version, like
> GetAlignedPointerFromInternalField,
>

To be honest I stay far away from Object::Set, Object::SetHiddenValue, etc.
wherever I can. Performance tests have shown me that it's usually faster to
set properties by calling out to js first (for non-hidden/readonly, etc).
Here are the specific performance tests I'm referring to:
https://github.com/trevnorris/talks/tree/master/js-vs-cc-set-properties

They've shown me it's ~15x's faster to call out to js from cc to create an
object and set three properties than to do the same from cc. So being able
to call out to js as quickly as possible has been very important to
creating performant code.


> and if there are certain functions causing you pain, we can look at adding
> them if you send me a list.  If there's any path by which a function might
> allocate heap memory, however, we cannot add it.
>

Right now they'd be:
- Object::HasIndexedPropertiesInExternalArrayData()
- Object::GetIndexedPropertiesExternalArrayData()
- Object::GetIndexedPropertiesExternalArrayDataLength()

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to